mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-04-20 03:50:20 +00:00
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 6m28s
48 lines
1.0 KiB
TypeScript
48 lines
1.0 KiB
TypeScript
"use server";
|
|
|
|
import { AxiosClient } from "@/utils/axios-client";
|
|
|
|
export async function getIslands() {
|
|
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;
|
|
}
|