♻️ refactor: all codebase

Completely refactoring the entire old codebase with a new codebase. This change also altered most of the core UI from the old codebase, replacing it with Shadcn with some customizations.
This commit is contained in:
2026-01-07 08:44:48 +07:00
parent fbcb575a36
commit a82e7a7424
95 changed files with 1143 additions and 3303 deletions

View File

@ -1,21 +0,0 @@
export const API_BASE_URL =
process.env.MAIN_BACKEND_API_URL ?? "http://localhost";
const apiFetch = async <T = unknown>(
path: string,
init?: RequestInit
): Promise<T> => {
const res = await fetch(`${API_BASE_URL}${path}`, {
...init,
headers: {
"Content-Type": "application/json",
...init?.headers,
},
cache: "no-store",
});
if (!res.ok) throw new Error(await res.text());
return res.json();
};
export default apiFetch;

View File

@ -1,15 +0,0 @@
"use server";
import { cookies } from "next/headers";
export const setCookie = async (name: string, value: string, sec?: number) => {
(await cookies()).set({
name,
value,
httpOnly: true,
secure: process.env.NODE_ENV === "production",
path: "/",
sameSite: "lax",
maxAge: sec || Number(process.env.SESSION_EXPIRE),
});
};

View File

@ -1,11 +0,0 @@
import { useRouter } from "next/navigation";
export const delayButtonClick = (
router: ReturnType<typeof useRouter>,
href: string,
timeout: number = 300
) => {
setTimeout(() => {
router.push(href);
}, timeout);
};

View File

@ -1,7 +0,0 @@
import { customAlphabet } from "nanoid";
export const generateRandomString = (length: number = 10): string => {
const characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
return customAlphabet(characters, length)();
};