From 406733b3601ec0071dbf7ee1c0ab7bf42a2da7f1 Mon Sep 17 00:00:00 2001 From: i701 Date: Mon, 9 Jun 2025 01:12:16 +0500 Subject: [PATCH] feat: update authentication layout and forms for improved user experience; add new dependencies and enhance styling --- app/(auth)/auth/layout.tsx | 14 +- .../auth/verify-otp-registration/page.tsx | 7 + components/auth/login-form.tsx | 2 +- components/auth/signup-form.tsx | 578 +++++++++--------- components/ui/phone-input.tsx | 2 +- components/ui/sheet.tsx | 8 +- components/ui/sidebar.tsx | 6 +- components/welcome-banner.tsx | 25 +- package-lock.json | 6 + package.json | 1 + tailwind.config.ts | 184 +++--- 11 files changed, 419 insertions(+), 414 deletions(-) diff --git a/app/(auth)/auth/layout.tsx b/app/(auth)/auth/layout.tsx index 458aa5a..90f6a9f 100644 --- a/app/(auth)/auth/layout.tsx +++ b/app/(auth)/auth/layout.tsx @@ -1,22 +1,10 @@ -import Image from "next/image"; export default function AuthLayout({ children, }: { children: React.ReactNode }) { return (
-
- Sar Link Logo -
-

- SAR Link Portal -

-

- Pay for your devices and track your bills. -

-
- {children} -
+ {children}
); } diff --git a/app/(auth)/auth/verify-otp-registration/page.tsx b/app/(auth)/auth/verify-otp-registration/page.tsx index 49d8b05..42e8857 100644 --- a/app/(auth)/auth/verify-otp-registration/page.tsx +++ b/app/(auth)/auth/verify-otp-registration/page.tsx @@ -1,7 +1,9 @@ +import { authOptions } from "@/app/auth"; import VerifyRegistrationOTPForm from "@/components/auth/verify-registration-otp-form"; import ClientErrorMessage from "@/components/client-error-message"; import { checkTempIdOrPhone } from "@/queries/authentication"; import { tryCatch } from "@/utils/tryCatch"; +import { getServerSession } from "next-auth"; import { redirect } from "next/navigation"; export default async function VerifyRegistrationOTP({ @@ -9,6 +11,11 @@ export default async function VerifyRegistrationOTP({ }: { searchParams: Promise<{ phone_number: string }>; }) { + const session = await getServerSession(authOptions) + if (session) { + // If the user is already logged in, redirect them to the home page + return redirect("/"); + } const phone_number = (await searchParams).phone_number; if (!phone_number) { return redirect("/login"); diff --git a/components/auth/login-form.tsx b/components/auth/login-form.tsx index d3cd64b..4ed6312 100644 --- a/components/auth/login-form.tsx +++ b/components/auth/login-form.tsx @@ -15,7 +15,7 @@ export default function LoginForm() { return (
diff --git a/components/auth/signup-form.tsx b/components/auth/signup-form.tsx index 64b67e7..43476dd 100644 --- a/components/auth/signup-form.tsx +++ b/components/auth/signup-form.tsx @@ -21,6 +21,7 @@ import { import type { ApiResponse, Atoll } from "@/lib/backend-types"; import { getAtolls } from "@/queries/islands"; import { keepPreviousData, useQuery } from "@tanstack/react-query"; +import Image from "next/image"; export default function SignUpForm() { const { data: atolls } = useQuery>({ @@ -58,297 +59,322 @@ export default function SignUpForm() { login -
+ - ); } return ( - -
-
- +
+
+
+
+
+ {/* Logo */} +
+
+ Company Logo +
+

SAR Link Portal

+
- - {actionState?.errors?.fieldErrors.name && ( - - {actionState?.errors?.fieldErrors.name} - - )} +

Welcome to Our Platform

+

+ Pay for your devices and track your bills. +

+
-
- - - {actionState?.errors?.fieldErrors?.id_card?.[0] && ( - - {actionState?.errors.fieldErrors.id_card[0]} - - )} - {actionState?.db_error === "id_card" && ( - - {actionState?.message} - - )} -
-
-
- - + {actionState?.errors?.fieldErrors.name && ( - {actionState?.errors?.fieldErrors?.atoll_id} + {actionState?.errors?.fieldErrors.name} )} - -
-
- - + {actionState?.errors?.fieldErrors?.id_card?.[0] && ( - {actionState?.errors?.fieldErrors?.island_id} + {actionState?.errors.fieldErrors.id_card[0]} )} - + {actionState?.db_error === "id_card" && ( + + {actionState?.message} + + )} +
+
+
+ + +
+
+ + +
+
+ +
+ + + {actionState?.errors?.fieldErrors?.address && ( + + {actionState?.errors?.fieldErrors?.address} + + )} +
+ +
+ + + {actionState?.errors?.fieldErrors?.dob && ( + + {actionState?.errors?.fieldErrors?.dob} + + )} + {actionState?.db_error === "dob" && ( + + {actionState?.message} + + )} +
+
+ + + + {actionState?.errors?.fieldErrors.accNo && ( + + {actionState?.errors?.fieldErrors.accNo} + + )} +
+
+ + +
+ {actionState?.errors?.fieldErrors?.phone_number?.[0] && ( + + {actionState?.errors.fieldErrors.phone_number[0]} + + )} + {actionState?.db_error === "phone_number" && ( + + {actionState?.message} + + )} +
+
+ + +
+ {actionState?.errors?.fieldErrors?.terms && ( + + {actionState?.errors?.fieldErrors?.terms} + + )} +
+ + +
+ {actionState?.errors?.fieldErrors?.policy && ( + + {actionState?.errors?.fieldErrors?.policy} + + )} +
+ +
+
+ Already have an account?{" "} + + login +
-
- - - {actionState?.errors?.fieldErrors?.address && ( - - {actionState?.errors?.fieldErrors?.address} - - )} -
+ +
-
- - - {actionState?.errors?.fieldErrors?.dob && ( - - {actionState?.errors?.fieldErrors?.dob} - - )} - {actionState?.db_error === "dob" && ( - - {actionState?.message} - - )} -
-
- - - - {actionState?.errors?.fieldErrors.accNo && ( - - {actionState?.errors?.fieldErrors.accNo} - - )} -
-
- - -
- {actionState?.errors?.fieldErrors?.phone_number?.[0] && ( - - {actionState?.errors.fieldErrors.phone_number[0]} - - )} - {actionState?.db_error === "phone_number" && ( - - {actionState?.message} - - )} -
-
- - -
- {actionState?.errors?.fieldErrors?.terms && ( - - {actionState?.errors?.fieldErrors?.terms} - - )} -
- - -
- {actionState?.errors?.fieldErrors?.policy && ( - - {actionState?.errors?.fieldErrors?.policy} - - )} -
- -
- -
- Already have an account?{" "} - - login - -
- ); } diff --git a/components/ui/phone-input.tsx b/components/ui/phone-input.tsx index 7863041..70d9d66 100644 --- a/components/ui/phone-input.tsx +++ b/components/ui/phone-input.tsx @@ -61,7 +61,7 @@ const InputComponent = React.forwardRef< HTMLInputElement, React.ComponentProps<"input"> >(({ className, ...props }, ref) => ( - + )); InputComponent.displayName = "InputComponent"; diff --git a/components/ui/sheet.tsx b/components/ui/sheet.tsx index 272cb72..7909505 100644 --- a/components/ui/sheet.tsx +++ b/components/ui/sheet.tsx @@ -1,9 +1,9 @@ "use client" -import * as React from "react" import * as SheetPrimitive from "@radix-ui/react-dialog" -import { cva, type VariantProps } from "class-variance-authority" +import { type VariantProps, cva } from "class-variance-authority" import { X } from "lucide-react" +import * as React from "react" import { cn } from "@/lib/utils" @@ -31,7 +31,7 @@ const SheetOverlay = React.forwardRef< SheetOverlay.displayName = SheetPrimitive.Overlay.displayName const sheetVariants = cva( - "fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out", + "fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-150 data-[state=open]:duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out", { variants: { side: { @@ -51,7 +51,7 @@ const sheetVariants = cva( interface SheetContentProps extends React.ComponentPropsWithoutRef, - VariantProps {} + VariantProps { } const SheetContent = React.forwardRef< React.ElementRef, diff --git a/components/ui/sidebar.tsx b/components/ui/sidebar.tsx index 32263c0..870ee1c 100644 --- a/components/ui/sidebar.tsx +++ b/components/ui/sidebar.tsx @@ -242,7 +242,7 @@ const Sidebar = React.forwardRef< {/* This is what handles the sidebar gap on desktop */}