mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:56:28 +00:00
78f48d783f
Introduce client and assignment detail pages and client-side components for the Task dashboard. Adds interactive ClientDetailComponent, AssignmentDetailComponent, page entries (server + dummy variants), project-assignment form, various UI components (AssignmentTable, ClientGrid, ManageEmployee, FormUpdateStatus, ConfirmDelete, LazyImage helper), types and a dummy data hook. Update app/(dashboard)/task/page.tsx to use the new components. Update .env.development to point to dev API endpoints, bump NEXT_PUBLIC_APP_VERSION to v1.2.0 and add NEXT_PUBLIC_S3_IMAGE_URL.
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { IClient, INITIAL_CLIENTS, IProjectAssignment } from '@/app/(dashboard)/task/types';
|
|
import { useState, useEffect } from 'react';
|
|
|
|
export function useAppState() {
|
|
const [clients, setClients] = useState<IClient[]>(() => {
|
|
const saved = localStorage.getItem('clients');
|
|
return saved ? JSON.parse(saved) : INITIAL_CLIENTS;
|
|
});
|
|
|
|
const [assignments, setAssignments] = useState<IProjectAssignment[]>(() => {
|
|
const saved = localStorage.getItem('assignments');
|
|
return saved ? JSON.parse(saved) : [];
|
|
});
|
|
|
|
useEffect(() => {
|
|
localStorage.setItem('clients', JSON.stringify(clients));
|
|
}, [clients]);
|
|
|
|
useEffect(() => {
|
|
localStorage.setItem('assignments', JSON.stringify(assignments));
|
|
}, [assignments]);
|
|
|
|
const addClient = (client: IClient) => {
|
|
setClients((prev) => [...prev, client]);
|
|
};
|
|
|
|
const addAssignment = (assignment: IProjectAssignment) => {
|
|
setAssignments((prev) => [...prev, assignment]);
|
|
};
|
|
|
|
const updateAssignment = (id: string, updates: Partial<IProjectAssignment>) => {
|
|
setAssignments((prev) =>
|
|
prev.map((a) => (a.id === id ? { ...a, ...updates } : a))
|
|
);
|
|
};
|
|
|
|
return {
|
|
clients,
|
|
assignments,
|
|
addClient,
|
|
addAssignment,
|
|
updateAssignment,
|
|
};
|
|
}
|