Skip to content

Conversation

@Patrickodrat
Copy link
Contributor

@Patrickodrat Patrickodrat commented Jan 3, 2026

Change Summary

Create the login page for admin. Use cookie to store JWT token.

Related issue

Copy link
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 creates an admin login page that authenticates users via JWT tokens. The implementation posts credentials to a backend endpoint, stores the access token in memory, and sets a refresh token via HTTP-only cookies.

Key changes:

  • New login page with username/email and password fields
  • JWT token management using in-memory storage for access tokens
  • UI component updates including input field styling changes and new input-field component with date/time support

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
client/src/app/login/page.tsx New login page with form handling, authentication logic, and error management
client/src/components/ui/input.tsx Updated input styling to use standardized border and height properties
client/src/components/ui/input-field.tsx New comprehensive input field component supporting text, number, select, badge, date, and time inputs
client/src/components/ui/input_old.tsx Previous version of input-field component preserved for reference

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

<div className="mt-1 flex justify-end">
<button
type="button"
className="text-xs text-slate-500 underline-offset-2 hover:underline"
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

The "Forgot Password?" button doesn't have any functionality or navigation. It should either be removed if not implemented yet, or implement the forgot password functionality, or at least provide a disabled state or proper link to indicate it's not yet available.

Suggested change
className="text-xs text-slate-500 underline-offset-2 hover:underline"
disabled
aria-disabled="true"
title="Forgot password functionality is not available yet"
className="text-xs text-slate-400 cursor-not-allowed"

Copilot uses AI. Check for mistakes.
Comment on lines 93 to 94
value={email}
onChange={(e) => setEmail(e.target.value)}
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

The state variable is named 'username' (line 21) but the input is using an undefined variable 'email'. This will cause a runtime error. The value and onChange handler should reference 'username' instead of 'email', or the state variable should be renamed to 'email'.

Suggested change
value={email}
onChange={(e) => setEmail(e.target.value)}
value={username}
onChange={(e) => setUsername(e.target.value)}

Copilot uses AI. Check for mistakes.
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="Enter Username/ Email"
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

There's an inconsistency in spacing. The placeholder should either be "Enter Username/Email" (no space before slash) or "Enter Username / Email" (spaces around slash) for consistency.

Suggested change
placeholder="Enter Username/ Email"
placeholder="Enter Username / Email"

Copilot uses AI. Check for mistakes.
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import api, { setAccessToken } from "@/lib/api";
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

The function 'setAccessToken' is imported from '@/lib/api' but doesn't appear to be exported from that module. This will cause an import error and the login functionality will not work. You need to implement and export this function in the api module.

Copilot uses AI. Check for mistakes.
htmlFor="email"
className="text-sm font-medium text-slate-800"
>
Username / Email
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

The label says "Username / Email" (with spaces around the slash) but the placeholder says "Enter Username/ Email" (with inconsistent spacing). These should be consistent for better user experience.

Copilot uses AI. Check for mistakes.
Comment on lines 21 to 30
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");

const [isSubmitting, setIsSubmitting] = useState(false);
const [error, setError] = useState<string | null>(null);

async function handleSubmit(e: FormEvent) {
e.preventDefault();
setError(null);

Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

Unused variable setUsername.

Suggested change
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [isSubmitting, setIsSubmitting] = useState(false);
const [error, setError] = useState<string | null>(null);
async function handleSubmit(e: FormEvent) {
e.preventDefault();
setError(null);
const [password, setPassword] = useState("");
const [isSubmitting, setIsSubmitting] = useState(false);
const [error, setError] = useState<string | null>(null);
async function handleSubmit(e: FormEvent<HTMLFormElement>) {
e.preventDefault();
setError(null);
const form = e.currentTarget;
const formData = new FormData(form);
const username =
String(
formData.get("username") ??
formData.get("email") ??
""
).trim();

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@ErikaKK ErikaKK left a comment

Choose a reason for hiding this comment

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

you have added two input field file. The old input file has been moved to components/. Pls update that one instead of adding in components/ui/

const router = useRouter();

const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
Copy link
Contributor

Choose a reason for hiding this comment

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

please use zod and react-hook-form library instead of useState for the form field

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create admin login page

3 participants