mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-02-22 17:42:00 +00:00
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 1m24s
- 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.
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
"use server";
|
|
import type { TNationalPerson } from "@/lib/types";
|
|
import type { User } from "@prisma/client";
|
|
|
|
export async function getNationalPerson({
|
|
idCard,
|
|
}: { idCard: string }): Promise<TNationalPerson> {
|
|
const nationalInformation = await fetch(
|
|
`${process.env.PERSON_VERIFY_API_BASE}/api/person/${idCard}`,
|
|
{
|
|
next: {
|
|
revalidate: 60,
|
|
},
|
|
},
|
|
);
|
|
const nationalData = (await nationalInformation.json()) as TNationalPerson;
|
|
return nationalData;
|
|
}
|
|
|
|
export async function VerifyUserDetails({ user }: { user: User }) {
|
|
const phoneNumber = String(user.phoneNumber).slice(4);
|
|
console.log({ phoneNumber });
|
|
const nationalData = await getNationalPerson({ idCard: user.id_card ?? "" });
|
|
const dob = new Date(nationalData.dob);
|
|
const age = new Date().getFullYear() - dob.getFullYear();
|
|
|
|
console.log("ID card", user.id_card === nationalData.nic);
|
|
console.log("name", user.name === nationalData.name_en);
|
|
console.log("house", user.address === nationalData.house_name_en);
|
|
console.log("phone", phoneNumber === nationalData.primary_contact);
|
|
console.log("db phone", phoneNumber);
|
|
console.log("national phone", nationalData.primary_contact);
|
|
|
|
if (
|
|
user.id_card === nationalData.nic &&
|
|
user.name === nationalData.name_en &&
|
|
user.address === nationalData.house_name_en &&
|
|
phoneNumber === nationalData.primary_contact &&
|
|
age >= 18
|
|
) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|