mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-02 09:48:22 +00:00
feat: implement user registration and OTP verification flow with backend integration
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 4m29s
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 4m29s
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
"use server";
|
||||
import type { TAuthUser } from "@/lib/types/user";
|
||||
import type { TAuthUser, User } from "@/lib/types/user";
|
||||
import axiosInstance from "@/utils/axiosInstance";
|
||||
import { handleApiResponse } from "@/utils/tryCatch";
|
||||
|
||||
export async function login({
|
||||
password,
|
||||
@ -51,7 +52,6 @@ export async function checkIdOrPhone({
|
||||
id_card,
|
||||
phone_number,
|
||||
}: { id_card?: string; phone_number?: string }) {
|
||||
console.log("id_card and phone_number", { id_card, phone_number });
|
||||
const response = await fetch(
|
||||
`${process.env.SARLINK_API_BASE_URL}/api/auth/users/filter/?id_card=${id_card}&mobile=${phone_number}`,
|
||||
{
|
||||
@ -64,3 +64,31 @@ export async function checkIdOrPhone({
|
||||
const data = await response.json();
|
||||
return data;
|
||||
}
|
||||
|
||||
type TSignupUser = Pick<
|
||||
User,
|
||||
"username" | "address" | "mobile" | "id_card" | "dob"
|
||||
> & {
|
||||
firstname: string;
|
||||
lastname: string;
|
||||
atoll: number;
|
||||
island: number;
|
||||
acc_no: string;
|
||||
terms_accepted: boolean;
|
||||
policy_accepted: boolean;
|
||||
};
|
||||
export async function backendRegister({ payload }: { payload: TSignupUser }) {
|
||||
console.log("backendRegister payload", payload);
|
||||
const response = await fetch(
|
||||
`${process.env.SARLINK_API_BASE_URL}/api/auth/register/`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
},
|
||||
);
|
||||
console.log("backendRegister response", response);
|
||||
return handleApiResponse<{ t_username: string }>(response, "backendRegister");
|
||||
}
|
||||
|
Reference in New Issue
Block a user