refactor: enhance authentication and signup flow with new providers, update middleware matcher, and improve type safety for API responses

This commit is contained in:
2025-03-26 22:48:14 +05:00
parent 32bb01b656
commit 99c5fef748
14 changed files with 222 additions and 78 deletions

View File

@ -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;
}