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

This commit is contained in:
2025-04-08 21:37:51 +05:00
parent daab793592
commit 7e49bf119a
14 changed files with 270 additions and 178 deletions

View File

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

View File

@ -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/");