first init

This commit is contained in:
ISMAIL MASSERAN
2026-06-08 11:37:14 +08:00
commit 94ecbe5887
1058 changed files with 87732 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
import axios from 'axios'
export const api = axios.create({
baseURL: import.meta.env.VITE_API_BASE_URL,
withCredentials: true,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
})
+16
View File
@@ -0,0 +1,16 @@
export type ApiPagination = {
current_page: number;
per_page: number;
total: number;
last_page: number;
from: number | null;
to: number | null;
has_more_pages: boolean;
};
export type PaginatedApiResponse<T> = {
success: boolean;
data: T[];
pagination: ApiPagination;
message?: string;
};
+10
View File
@@ -0,0 +1,10 @@
import { type Icon } from '@/components/ui/lucide'
export interface Menu {
icon?: Icon
title?: string
route_name?: string
params?: Record<string, unknown>
badge?: number
sub_menu?: Menu[]
}
+30
View File
@@ -0,0 +1,30 @@
import axios from 'axios'
type ApiErrorBody = {
message?: string
errors?: Record<string, string[]>
}
export function getApiErrorMessage(
error: unknown,
fallback = 'Something went wrong. Please try again.',
): string {
if (axios.isAxiosError(error)) {
const data = error.response?.data as ApiErrorBody | undefined
if (data?.errors) {
const firstError = Object.values(data.errors).flat()[0]
if (firstError) return firstError
}
if (data?.message) return data.message
if (error.message) return error.message
}
if (error instanceof Error) {
return error.message
}
return fallback
}