mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-02 03:38:22 +00:00
refactor: update axios client import, enhance device and payment handling, and add cancel payment button component
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 6m28s
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 6m28s
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
import { authOptions } from "@/app/auth";
|
||||
import type { Api400Error, ApiResponse, Device } from "@/lib/backend-types";
|
||||
import { AxiosClient } from "@/utils/axios-client";
|
||||
import { checkSession } from "@/utils/session";
|
||||
import { getServerSession } from "next-auth";
|
||||
import { revalidatePath } from "next/cache";
|
||||
@ -14,7 +15,7 @@ type GetDevicesProps = {
|
||||
};
|
||||
export async function getDevices({ query }: GetDevicesProps) {
|
||||
const session = await checkSession();
|
||||
const respose = await fetch(
|
||||
const response = await fetch(
|
||||
`${process.env.SARLINK_API_BASE_URL}/api/devices/?name=${query}`,
|
||||
{
|
||||
method: "GET",
|
||||
@ -24,7 +25,10 @@ export async function getDevices({ query }: GetDevicesProps) {
|
||||
},
|
||||
},
|
||||
);
|
||||
const data = (await respose.json()) as ApiResponse<Device>;
|
||||
if (response.status === 401) {
|
||||
throw new Error("Unauthorized; redirect to /auth/signin");
|
||||
}
|
||||
const data = (await response.json()) as ApiResponse<Device>;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
"use server";
|
||||
|
||||
import { AxiosClient } from "@/utils/AxiosClient";
|
||||
import { AxiosClient } from "@/utils/axios-client";
|
||||
|
||||
export async function getIslands() {
|
||||
const response = await AxiosClient.get("/islands/");
|
||||
|
Reference in New Issue
Block a user