From 2c67848618227040f379faf2d911549e967d2be7 Mon Sep 17 00:00:00 2001 From: i701 Date: Fri, 10 Jan 2025 23:34:53 +0500 Subject: [PATCH] Enhance user verification and UI components - Updated `auth-actions.ts` to improve user verification notification formatting and date handling. - Modified `layout.tsx` to support dark mode styling for better user experience. - Refactored `signup/page.tsx` to enhance layout and responsiveness. - Introduced a new API route in `route.ts` for sending user verification notifications. - Improved user feedback in `user-payments-table.tsx` by updating the no payment message. - Made minor adjustments in `application-layout.tsx` for consistent padding. - Enhanced `signup-form.tsx` to display error messages for invalid user validation. These changes improve the user verification process, enhance UI consistency, and provide better feedback to users. --- actions/auth-actions.ts | 19 +++++++++++-------- app/(auth)/signup/page.tsx | 12 +++--------- app/api/test/route.ts | 16 ++++++++++++++++ app/layout.tsx | 2 +- components/admin/user-payments-table.tsx | 2 +- components/auth/application-layout.tsx | 2 +- components/auth/signup-form.tsx | 13 +++++++++++++ lib/person.ts | 10 +++++++++- 8 files changed, 55 insertions(+), 21 deletions(-) create mode 100644 app/api/test/route.ts diff --git a/actions/auth-actions.ts b/actions/auth-actions.ts index d5519cb..6ecea87 100644 --- a/actions/auth-actions.ts +++ b/actions/auth-actions.ts @@ -136,14 +136,17 @@ export async function signup(_actionState: ActionState, formData: FormData) { if (!isValidPerson) { await SendUserRejectionDetailSMS({ details: ` - A new user has requested for verification. - USER DETAILS: - Name: ${parsedData.data.name} - Address: ${parsedData.data.address} - ID Card: ${parsedData.data.id_card} - DOB: ${parsedData.data.dob} - ACC No: ${parsedData.data.accNo} - Verify the user with the folloiwing link: ${process.env.BETTER_AUTH_URL}/users/${newUser.id}/verify + A new user has requested for verification. \n +USER DETAILS: + Name: ${parsedData.data.name} + Address: ${parsedData.data.address} + ID Card: ${parsedData.data.id_card} + DOB: ${parsedData.data.dob.toLocaleDateString("en-US", { + month: "short", + day: "2-digit", + year: "numeric", + })} + ACC No: ${parsedData.data.accNo}\n\nVerify the user with the folloiwing link: ${process.env.BETTER_AUTH_URL}/users/${newUser.id}/verify `, phoneNumber: process.env.ADMIN_PHONENUMBER ?? "", }); diff --git a/app/(auth)/signup/page.tsx b/app/(auth)/signup/page.tsx index a377acd..d27e3d4 100644 --- a/app/(auth)/signup/page.tsx +++ b/app/(auth)/signup/page.tsx @@ -29,15 +29,9 @@ export default async function SignupPage({ }); return ( -
-
- Sar Link Logo +
+
+ Sar Link Logo

SAR Link Portal

diff --git a/app/api/test/route.ts b/app/api/test/route.ts new file mode 100644 index 0000000..f214724 --- /dev/null +++ b/app/api/test/route.ts @@ -0,0 +1,16 @@ +import { SendUserRejectionDetailSMS } from "@/actions/user-actions"; + +export async function POST(request: Request) { + await SendUserRejectionDetailSMS({ + details: ` + A new user has requested for verification. \n +USER DETAILS: + Name: Jacob + Address: Jacob House + ID Card: A222111 + DOB: 24-08-1997 + ACC No: 7770000010629 \n\nVerify the user with the folloiwing link: ${process.env.BETTER_AUTH_URL}/users/verify + `, + phoneNumber: process.env.ADMIN_PHONENUMBER ?? "", + }); +} diff --git a/app/layout.tsx b/app/layout.tsx index 5c26fe4..2a489b7 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -25,7 +25,7 @@ export default function RootLayout({ }>) { return ( - + diff --git a/components/admin/user-payments-table.tsx b/components/admin/user-payments-table.tsx index f590540..7d0ae08 100644 --- a/components/admin/user-payments-table.tsx +++ b/components/admin/user-payments-table.tsx @@ -131,7 +131,7 @@ export async function UsersPaymentsTable({

{payments.length === 0 ? (
-

No Users yet.

+

No user payments yet.

) : ( <> diff --git a/components/auth/application-layout.tsx b/components/auth/application-layout.tsx index cc38a95..8040a86 100644 --- a/components/auth/application-layout.tsx +++ b/components/auth/application-layout.tsx @@ -49,7 +49,7 @@ export async function ApplicationLayout({
-
{children}
+
{children}
); diff --git a/components/auth/signup-form.tsx b/components/auth/signup-form.tsx index 357cecb..b9dd15f 100644 --- a/components/auth/signup-form.tsx +++ b/components/auth/signup-form.tsx @@ -45,6 +45,19 @@ export default function SignUpForm({ atolls }: { atolls: AtollWithIslands[] }) { const NUMBER_WITHOUT_DASH = phoneNumberFromUrl?.split("-").join(""); + if (actionState.db_error === "invalidPersonValidation") { + return ( + <> +
{actionState.message}
+
+ Go to {" "} + + login + +
+ + ) + } return (