mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-02 03:38:22 +00:00
refactor: enhance authentication and signup flow with new providers, update middleware matcher, and improve type safety for API responses
This commit is contained in:
@ -46,3 +46,21 @@ export async function logout({ token }: { token: string }) {
|
||||
// Since the API endpoint returns 204 No Content on success, we don't need to parse JSON
|
||||
return null; // Return null to indicate a successful logout with no content
|
||||
}
|
||||
|
||||
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}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
);
|
||||
const data = await response.json();
|
||||
return data;
|
||||
}
|
||||
|
@ -1,12 +1,47 @@
|
||||
"use server";
|
||||
|
||||
import { AxiosClient } from "@/utils/AxiosClient";
|
||||
|
||||
export async function getIslands() {
|
||||
const res = await fetch(`${process.env.SARLINK_API_BASE_URL}/islands/`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
const data = await res.json();
|
||||
const response = await AxiosClient.get("/islands/");
|
||||
const data = response.data;
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function getAtolls() {
|
||||
const response = await fetch(
|
||||
`${process.env.SARLINK_API_BASE_URL}/api/auth/atolls/`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
);
|
||||
const data = response.json();
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function getAllItems({
|
||||
limit = 10,
|
||||
offset = 0,
|
||||
...otherParams
|
||||
}: {
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
} & Record<string, unknown>) {
|
||||
const params = new URLSearchParams();
|
||||
// Add default params
|
||||
params.append("limit", limit.toString());
|
||||
params.append("offset", offset.toString());
|
||||
|
||||
// Add any additional params dynamically
|
||||
Object.entries(otherParams).map(([key, value]) => {
|
||||
if (value !== undefined) {
|
||||
params.append(key, String(value || ""));
|
||||
}
|
||||
});
|
||||
|
||||
const response = await AxiosClient.get(`/inventory/?${params.toString()}`);
|
||||
return response.data;
|
||||
}
|
||||
|
Reference in New Issue
Block a user