mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-03 06:48:21 +00:00
Refactor user actions and authentication components
- Updated user verification logic to include atoll and island relationships. - Introduced CreateClient function for integrating with external client API. - Replaced 'house_name' with 'address' in user signup data handling. - Added new Checkbox component for improved UI interactions. - Migrated database provider from SQLite to PostgreSQL and redefined user schema. - Removed obsolete migration files and ensured database integrity with new structure.
This commit is contained in:
@ -2,17 +2,21 @@
|
||||
|
||||
import prisma from "@/lib/db";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { CreateClient } from "./ninja/client";
|
||||
|
||||
export async function VerifyUser(userId: string) {
|
||||
const user = await prisma.user.findUnique({
|
||||
where: {
|
||||
id: userId,
|
||||
},
|
||||
include: {
|
||||
atoll: true,
|
||||
island: true,
|
||||
},
|
||||
});
|
||||
if (!user) {
|
||||
throw new Error("User not found");
|
||||
}
|
||||
user.verified = true;
|
||||
await prisma.user.update({
|
||||
where: {
|
||||
id: userId,
|
||||
@ -21,5 +25,24 @@ export async function VerifyUser(userId: string) {
|
||||
verified: true,
|
||||
},
|
||||
});
|
||||
await CreateClient({
|
||||
group_settings_id: "",
|
||||
address1: "",
|
||||
city: user.atoll?.name || "",
|
||||
state: user.island?.name || "",
|
||||
postal_code: "",
|
||||
country_id: "462",
|
||||
address2: user.address || "",
|
||||
contacts: {
|
||||
first_name: user.name?.split(" ")[0] || "",
|
||||
last_name: user.name?.split(" ")[1] || "",
|
||||
email: user.email || "",
|
||||
phone: user.phoneNumber || "",
|
||||
send_email: false,
|
||||
custom_value1: user.dob?.toISOString().split("T")[0] || "",
|
||||
custom_value2: user.id_card || "",
|
||||
custom_value3: "",
|
||||
},
|
||||
});
|
||||
revalidatePath("/users");
|
||||
}
|
||||
|
Reference in New Issue
Block a user