The frontend is a Single Page Application (SPA) built with React 19, Vite, and TypeScript. It utilizes Apollo Client for GraphQL state management and TailwindCSS + Radix UI for styling.
Project Structure
The project follows a feature-based structure for pages (app/) and a shared structure for utilities.
// ... importsconsterrorLink=onError(({graphQLErrors,operation,forward})=>{consthasExpiredToken=graphQLErrors?.some((err)=>err.message==="Signature has expired");if(hasExpiredToken){console.log("Access token expired. Attempting to refresh...");// Logic to refresh token and retry requestreturnnewObservable(observer=>{/* ... */});}});exportconstclient=newApolloClient({link:ApolloLink.from([errorLink,httpLink]),cache:newInMemoryCache(),});
Usage in Components
Components use standard Apollo hooks like useQuery. Queries are defined in src/graphql/queries.ts.
import{useQuery}from"@apollo/client/react";import{GET_KPI_CLOCK}from"@/graphql/queries";exportdefaultfunctionDashboard(){const{user}=useAuth();const{data,loading,error}=useQuery(GET_KPI_CLOCK,{variables:{period:7,userId:user?.id,},skip:!user,// Skip query if user not loadedfetchPolicy:"cache-and-network",});if(loading)return<div>Loading...</div>;// ... render UI}
Routing
Routing is managed via react-router in src/routes.tsx. It supports protected routes based on authentication and roles.