- Implemented TemplateCheckpointEditDialog for creating and editing inspection checkpoints. - Added VendorActions component for managing vendor actions including edit, activate/deactivate, and delete. - Created VendorContext for managing vendor state across components. - Developed VendorGeneralInfo component to display detailed vendor information. - Introduced AedSymbol and Money components for consistent currency representation. - Added PromptDialog for user input prompts throughout the application. - Implemented RelationLink component for unified related-data display in CRUD tables. - Created InspectionTemplatesClient for API interactions related to inspection templates.
22 lines
728 B
TypeScript
22 lines
728 B
TypeScript
import { useMemo } from "react";
|
|
import { createApi } from "@garage/api";
|
|
import { useAuthStore } from "./stores/auth-store";
|
|
|
|
// The dashboard UI is in English. Tell the backend explicitly so error messages
|
|
// don't default to Arabic when no Accept-Language is sent / saved preference
|
|
// matches. The backend `SetApiLocale` middleware honors this header.
|
|
const UI_LANG = "en"
|
|
|
|
export const useAuthApi = () => {
|
|
const token = useAuthStore(s => s.token)
|
|
return useMemo(
|
|
() => createApi({
|
|
headers: {
|
|
"X-Lang": UI_LANG,
|
|
"Accept-Language": UI_LANG,
|
|
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
|
},
|
|
}),
|
|
[token],
|
|
)
|
|
} |