mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-03 19:08:23 +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:
89
actions/ninja/client.ts
Normal file
89
actions/ninja/client.ts
Normal file
@ -0,0 +1,89 @@
|
||||
"use server";
|
||||
// const raw = {
|
||||
// group_settings_id: "",
|
||||
// address1: "",
|
||||
// city: "F",
|
||||
// state: "Dharanboodhoo",
|
||||
// postal_code: "12040",
|
||||
// country_id: "462",
|
||||
// address2: "Skyvilla",
|
||||
// contacts: [
|
||||
// {
|
||||
// first_name: "Abdulla",
|
||||
// last_name: "Aidhaan",
|
||||
// email: "",
|
||||
// phone: "778-0588",
|
||||
// send_email: false,
|
||||
// custom_value1: "1971-02-24",
|
||||
// custom_value2: "A265117",
|
||||
// custom_value3: "",
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
|
||||
type CreateClientProps = {
|
||||
group_settings_id: string;
|
||||
address1: string;
|
||||
city: string;
|
||||
state: string;
|
||||
postal_code: string;
|
||||
country_id: string;
|
||||
address2: string;
|
||||
contacts: Contact;
|
||||
};
|
||||
|
||||
type Contact = {
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
send_email: boolean;
|
||||
custom_value1: string;
|
||||
custom_value2: string;
|
||||
custom_value3: string;
|
||||
};
|
||||
export async function CreateClient({
|
||||
group_settings_id = "",
|
||||
address1 = "",
|
||||
city,
|
||||
state,
|
||||
postal_code = "",
|
||||
country_id = "462",
|
||||
address2,
|
||||
contacts,
|
||||
}: CreateClientProps) {
|
||||
const response = await fetch(
|
||||
"https://finance-staging.baraveli.dev/api/v1/clients",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-api-token": `${process.env.NINJA_API_KEY}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
group_settings_id,
|
||||
address1,
|
||||
city,
|
||||
state,
|
||||
postal_code,
|
||||
country_id,
|
||||
address2,
|
||||
contacts: [
|
||||
{
|
||||
first_name: contacts.first_name,
|
||||
last_name: contacts.last_name,
|
||||
email: contacts.email || "",
|
||||
phone: contacts.phone,
|
||||
send_email: contacts.send_email,
|
||||
custom_value1: contacts.custom_value1,
|
||||
custom_value2: contacts.custom_value2,
|
||||
custom_value3: contacts.custom_value3 || "",
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
);
|
||||
const data = await response.json();
|
||||
console.log(data.data.contacts);
|
||||
return data;
|
||||
}
|
Reference in New Issue
Block a user