mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 11:06:29 +00:00
Add client & assignment detail UI; update dev env
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.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
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,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user