Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Refactor support contact buttons in AgentAuthLayout and UserAuthLayou…#91

Open
DinithEdirisinghe wants to merge 1 commit intoDevfrom
dinithNew
Open

Refactor support contact buttons in AgentAuthLayout and UserAuthLayou…#91
DinithEdirisinghe wants to merge 1 commit intoDevfrom
dinithNew

Conversation

@DinithEdirisinghe
Copy link
Copy Markdown
Contributor

@DinithEdirisinghe DinithEdirisinghe commented Aug 16, 2025

…t to use Link component for navigation

Pull Request

Summary

  • What does this PR change and why?
  • Any relevant context or background?

Area of change

  • Frontend
  • Backend
  • Database
  • DevOps
  • Documentation
  • Other (describe below)

Type of change

  • Feature
  • Bug fix
  • Refactor
  • Performance
  • Accessibility
  • Documentation
  • CI/CD / Chore
  • Other (describe below)

If Other, describe:

Screenshots or recordings (UI changes)

  • Add before/after images or a short clip. Note light/dark mode where relevant, if applicable.

How to test

  • Prereqs: Node LTS
  • Steps to validate locally:
    1. npm ci
    2. npm run lint
    3. npm run build
    4. npm start
    5. Navigate to affected pages and verify behavior
  • Include any mock data, flags, or URLs.

Acceptance criteria checklist

  • Lint passes locally (npm run lint)
  • Production build succeeds (npm run build)
  • No console errors or TypeScript errors in dev
  • UX reviewed (if UI changes)
  • i18n/text reviewed (if user-facing text)
  • Docs updated where needed (README.md / DEPLOYMENT.md)

Accessibility checklist (if UI)

  • Keyboard navigation and focus order make sense
  • Sufficient color contrast
  • ARIA roles/labels where appropriate
  • Images/icons have accessible names or alt text

Security & privacy

  • No secrets committed; uses environment variables
  • No introduction of new PII collection/storage
  • Input validated/sanitized where applicable
  • Third-party deps reviewed (scope minimal)

Breaking changes

  • Yes (describe migration/rollback)
  • No

If breaking, describe migration steps and rollback plan:

Deployment notes

  • Any special steps or config? Reference DEPLOYMENT.md if needed.
  • Service/restart impacts? (see deploy/govlink.service and scripts)

Additional notes

  • Risks, follow-ups, or related issues/PRs.

Summary by CodeRabbit

  • New Features

    • Admin login now shows a loading state (“Signing In...”) with a spinner during submission.
    • Per-field validation errors are displayed directly under email and password inputs.
    • Direct “Contact Support” links on Agent and User auth screens open the in-app support chat.
  • Refactor

    • Admin login form structure overhauled for clearer layout and more consistent error handling.
  • Style

    • Minor UI polish, including subtle animation timing and input/icon alignment improvements.

Copilot AI review requested due to automatic review settings August 16, 2025 17:35
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 16, 2025

Walkthrough

Admin login page form is refactored to controlled inputs with per-field error rendering and a loading-state submit label. Agent and User auth layouts replace “Contact Support” buttons with Next.js Links to /user/chat/bot. No exported API changes.

Changes

Cohort / File(s) Summary
Admin login form refactor
src/app/admin/login/page.tsx
Refactored form to controlled inputs with handleInputChange, per-field error messages, loading spinner/label on submit, minor structural/styling adjustments, no export changes.
Support link navigation update
src/components/agent/auth/AgentAuthLayout.tsx, src/components/user/auth/UserAuthLayout.tsx
Replaced “Contact Support” buttons with Next.js Links to /user/chat/bot; no logic or export changes, preserves text and styling with inline-block class.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant C as AdminLogin Component
  participant A as Auth API

  U->>C: Type email/password (controlled inputs)
  C-->>C: setState(values), setState(errors per-field)
  U->>C: Click "Sign In" (isLoading=true)
  C->>A: POST credentials
  A-->>C: Success or errors
  alt Success
    C-->>C: isLoading=false, clear errors, navigate
  else Validation/Auth Error
    C-->>C: isLoading=false, setErrors(field-level)
    C->>U: Show errors under fields
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • AdeepaK2
  • AdithaBuwaneka
  • mehara-rothila

Poem

A whisker twitch, a tap-tap key—
I hop through forms, error-free.
Links now leap to chatbot burrows,
While spinners twirl like lunar furrows.
Sign-in stars align just so—
Onward, admin portals glow!
(o^.^o) 🥕

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dinithNew

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors support contact buttons in authentication layouts to use proper navigation components instead of non-functional button elements. The main change replaces static button elements with Link components that provide actual navigation functionality to the support chat bot.

  • Replace non-functional button elements with Next.js Link components for support contact
  • Add proper navigation to "/user/chat/bot" route for both user and agent authentication layouts
  • Update styling to maintain visual consistency with inline-block display

Reviewed Changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 1 comment.

File Description
src/components/user/auth/UserAuthLayout.tsx Replace contact support button with Link component for navigation
src/components/agent/auth/AgentAuthLayout.tsx Replace contact IT support button with Link component for navigation
src/app/admin/login/page.tsx Code formatting changes from single quotes to double quotes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

{t.technicalAssistance}{' '}
<button className="text-[#FFC72C] hover:text-[#FF5722] transition-all duration-300 underline font-medium hover:scale-105">
<Link
href="/user/chat/bot"
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Link href points to '/user/chat/bot' in the Agent authentication layout, but this should likely point to an agent-specific support route like '/agent/chat/bot' to maintain consistency with the agent context.

Suggested change
href="/user/chat/bot"
href="/agent/chat/bot"

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (5)
src/components/user/auth/UserAuthLayout.tsx (1)

218-224: Deduplicate the support URL via a shared constant

This path is now duplicated here and in AgentAuthLayout. Centralizing it reduces drift and eases future changes.

Apply this diff within this block:

-              <Link 
-                href="/user/chat/bot" 
+              <Link 
+                href={SUPPORT_CHAT_PATH} 
                 className="text-[#FFC72C] hover:text-[#FF5722] transition-all duration-300 underline font-medium hover:scale-105 inline-block"
               >

Then add a routes constant and import it:

Create src/constants/routes.ts:

export const SUPPORT_CHAT_PATH = "/user/chat/bot";

Import at the top of this file:

import { SUPPORT_CHAT_PATH } from "@/constants/routes";
src/components/agent/auth/AgentAuthLayout.tsx (1)

218-224: Use a shared constant for the support path

Reduce duplication across auth layouts by centralizing the support URL.

Apply this diff within this block:

-              <Link 
-                href="/user/chat/bot" 
+              <Link 
+                href={SUPPORT_CHAT_PATH} 
                 className="text-[#FFC72C] hover:text-[#FF5722] transition-all duration-300 underline font-medium hover:scale-105 inline-block"
               >

Add the shared constant (if not already added for the user layout):

Create src/constants/routes.ts:

export const SUPPORT_CHAT_PATH = "/user/chat/bot";

Import at the top of this file:

import { SUPPORT_CHAT_PATH } from "@/constants/routes";
src/app/admin/login/page.tsx (3)

230-241: Accessibility: add autocomplete and associate error messaging for Email

  • Improve UX with correct browser autofill hints.
  • Convey validation state to assistive tech.

Apply this diff:

                   <input
                     id="email"
                     name="email"
                     type="email"
                     value={formData.email}
                     onChange={handleInputChange}
                     className={`w-full pl-10 pr-4 py-3 bg-card/60 dark:bg-card/40 backdrop-blur-sm border rounded-xl focus:ring-2 focus:ring-[#8D153A]/20 focus:border-[#8D153A]/50 transition-all duration-300 modern-card ${
                       errors.email ? "border-destructive" : "border-border/50"
                     }`}
                     placeholder="Enter your email address"
                     disabled={isLoading}
+                    autoComplete="username"
+                    inputMode="email"
+                    autoCapitalize="none"
+                    aria-invalid={!!errors.email}
+                    aria-describedby={errors.email ? "email-error" : undefined}
                   />
                 </div>
-                {errors.email && (
-                  <p className="mt-2 text-sm text-destructive">
+                {errors.email && (
+                  <p id="email-error" role="alert" className="mt-2 text-sm text-destructive">
                     {errors.email}
                   </p>
                 )}

Also applies to: 243-247


263-275: Accessibility: add autocomplete + ARIA for Password and toggle control

  • Add autocomplete for password managers.
  • Expose invalid state and tie it to the error element.
  • Give the visibility toggle an accessible name and pressed state.

Apply this diff:

                   <input
                     id="password"
                     name="password"
                     type={showPassword ? "text" : "password"}
                     value={formData.password}
                     onChange={handleInputChange}
                     className={`w-full pl-10 pr-12 py-3 bg-card/60 dark:bg-card/40 backdrop-blur-sm border rounded-xl focus:ring-2 focus:ring-[#8D153A]/20 focus:border-[#8D153A]/50 transition-all duration-300 modern-card ${
                       errors.password
                         ? "border-destructive"
                         : "border-border/50"
                     }`}
                     placeholder="Enter your password"
                     disabled={isLoading}
+                    autoComplete="current-password"
+                    aria-invalid={!!errors.password}
+                    aria-describedby={errors.password ? "password-error" : undefined}
                   />
                   <button
                     type="button"
                     onClick={() => setShowPassword(!showPassword)}
                     className="absolute inset-y-0 right-0 pr-3 flex items-center hover:text-[#8D153A] transition-colors duration-300 z-10"
                     disabled={isLoading}
+                    aria-label={showPassword ? "Hide password" : "Show password"}
+                    aria-pressed={showPassword}
                   >
                 ...
                 </button>
               </div>
-                {errors.password && (
-                  <p className="mt-2 text-sm text-destructive">
+                {errors.password && (
+                  <p id="password-error" role="alert" className="mt-2 text-sm text-destructive">
                     {errors.password}
                   </p>
                 )}

Also applies to: 276-288, 289-293


49-51: Tailwind class names: non-standard fractions may not resolve

Classes like top-1/6 and left-1/5 aren’t in Tailwind’s default spacing scale. Unless you’ve extended your config, they’ll be dropped. Prefer arbitrary values to be safe.

Apply this diff:

-        <div
-          className="absolute top-1/6 left-1/5 w-56 h-56 bg-[#8D153A]/5 dark:bg-[#8D153A]/2 rounded-full blur-3xl animate-pulse"
+        <div
+          className="absolute top-[16%] left-[20%] w-56 h-56 bg-[#8D153A]/5 dark:bg-[#8D153A]/2 rounded-full blur-3xl animate-pulse"

If you’ve customized Tailwind to include those fractions, you can ignore this.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 81ff20c and b2bca72.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • src/app/admin/login/page.tsx (10 hunks)
  • src/components/agent/auth/AgentAuthLayout.tsx (1 hunks)
  • src/components/user/auth/UserAuthLayout.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/app/admin/login/page.tsx (1)
src/lib/auth/AdminAuthContext.tsx (1)
  • useAdminAuth (36-42)
🔇 Additional comments (3)
src/components/user/auth/UserAuthLayout.tsx (1)

218-224: Using Next.js Link here is the right semantic for navigation

Good refactor from a button to a Link for client-side routing to the support chat.

src/components/agent/auth/AgentAuthLayout.tsx (2)

218-224: Nice swap to Next.js Link for support

This aligns with the PR objective and keeps styling intact.


218-224: Confirm /user/chat/bot support route for agents

  • The route exists at src/app/user/chat/bot/page.tsx.
  • Both AgentAuthLayout and User layout link to /user/chat/bot.

Please verify that this unified support chat path is intended for agent users as well. If agents require a dedicated endpoint or different access control, consider adding an agent‐specific route or redirect.

Comment on lines 59 to +67
const [formData, setFormData] = useState({
email: '',
password: ''
email: "",
password: "",
});
const [showPassword, setShowPassword] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [errors, setErrors] = useState<{email?: string; password?: string}>({});

const [errors, setErrors] = useState<{ email?: string; password?: string }>(
{}
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix TypeScript index typing: computed key from string ‘name’ breaks state updates

The current setFormData and setErrors use a string key (name) that isn’t constrained to "email" | "password". This typically causes TS errors like “Type '{ [x: string]: string; ... }' is not assignable to ...”. Constrain the key to the union of known fields to satisfy TS and prevent accidental keys.

Apply these diffs:

  1. Make state types explicit so we can safely use computed keys:
-  const [formData, setFormData] = useState({
-    email: "",
-    password: "",
-  });
+  const [formData, setFormData] = useState<Record<"email" | "password", string>>({
+    email: "",
+    password: "",
+  });
   const [showPassword, setShowPassword] = useState(false);
   const [isLoading, setIsLoading] = useState(false);
-  const [errors, setErrors] = useState<{ email?: string; password?: string }>(
-    {}
-  );
+  const [errors, setErrors] = useState<Partial<Record<"email" | "password", string>>>({});
  1. Use the constrained key when updating state:
   const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
     const { name, value } = e.target;
-    setFormData((prev) => ({
-      ...prev,
-      [name]: value,
-    }));
+    const key = name as keyof typeof formData;
+    setFormData((prev) => ({
+      ...prev,
+      [key]: value,
+    }));
 
     // Clear errors when user starts typing
-    if (errors[name as keyof typeof errors]) {
-      setErrors((prev) => ({
-        ...prev,
-        [name]: undefined,
-      }));
+    if (errors[key]) {
+      setErrors((prev) => ({
+        ...prev,
+        [key]: undefined,
+      }));
     }
   };

Also applies to: 127-141

Comment on lines +348 to +352
<span className="text-xs text-muted-foreground">
Need technical assistance?
</span>
<Link
href="/contact"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Consistency: align Admin footer support link with the new support chat Link

The other auth layouts now use /user/chat/bot. If that’s the canonical support entrypoint, mirror it here and centralize via a constant to avoid drift.

Apply this diff:

-              <Link
-                href="/contact"
+              <Link
+                href={SUPPORT_CHAT_PATH}
                 className="text-xs text-[#8D153A] hover:text-[#8D153A]/80 transition-colors font-medium"
               >
                 Contact IT Support
               </Link>

And import the shared constant (if added):

import { SUPPORT_CHAT_PATH } from "@/constants/routes";

Optionally verify the routes exist:


🏁 Script executed:

#!/bin/bash
set -euo pipefail
for d in "src/app/user/chat/bot" "src/app/contact"; do
  if [ -d "$d" ]; then
    echo "✓ Found $d"
  else
    echo "✗ MISSING: $d"
  fi
done

Length of output: 321


Fix broken admin support link and centralize the support chat route

The /contact route is missing (src/app/contact not found), so the current footer link 404s. Replace it with the canonical support chat entrypoint (/user/chat/bot) and centralize the path in a shared constant to prevent future drift.

  • In src/app/admin/login/page.tsx (lines 348–352), update the <Link>:
     <span className="text-xs text-muted-foreground">
       Need technical assistance?
     </span>
  • href="/contact"
  • href={SUPPORT_CHAT_PATH}
    className="text-xs text-[#8D153A] hover:text-[#8D153A]/80 transition-colors font-medium"
 Contact IT Support
``` - Create or update `src/constants/routes.ts`: ```ts // src/constants/routes.ts export const SUPPORT_CHAT_PATH = '/user/chat/bot'; ``` - Import the constant in the admin login page: ```ts import { SUPPORT_CHAT_PATH } from '@/constants/routes'; ```
🤖 Prompt for AI Agents
In src/app/admin/login/page.tsx around lines 348 to 352 the footer Link points
to a non-existent /contact route causing 404s; replace the href with a shared
constant SUPPORT_CHAT_PATH imported from src/constants/routes. Create or update
src/constants/routes.ts to export SUPPORT_CHAT_PATH = '/user/chat/bot', add the
import in the admin login page (import { SUPPORT_CHAT_PATH } from
'@/constants/routes') and update the Link href to use SUPPORT_CHAT_PATH instead
of the hard-coded string.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants