Files
hats-app/app/(dashboard)/task/page.tsx
T
Ichsan Kurniawan 80cb73f7fa Add FilterModal and DatePickerMultiMode; UI fixes
Introduce a FilterModal component and a DatePickerMultiMode UI component; refactor FilterComponent to use the modal and expose new hide* props for finer control. Update HomeTask to use a Select for view switching and remove unused props. Improve client and assignment UIs: ClientGrid empty state, client card actions, AssignmentTable empty state, and various text/label adjustments. Fix PieChart null-safety with optional chaining and remove a stray console.log in ClientDetailComponent. Update assignment field mappings to prefer wo_* values where appropriate and pass hideCategory to project detail page. Also update .env.development API/IMG URLs.
2026-04-23 21:01:12 +07:00

47 lines
1.7 KiB
TypeScript

// app/clients/page.tsx
import { Suspense } from 'react';
import HomeTask from './component/HomeTask';
import ClientGrid from './component/ClientGrid';
import AssignmentTable from './component/AssignmentTable';
import fetchData from '@/lib/fetchData';
import { getFilteredAssignments, getFilteredClients } from './data';
type Props = {
searchParams: Promise<{ view?: string; q?: string, status?: string, sort?: string }>
};
export default async function ClientsPage({ searchParams }: Props) {
const params = await searchParams;
const view = params.view === 'table' ? 'table' : 'grid';
const query = (params.q || '').toLowerCase();
const status = (params.status || '').toLowerCase();
const sort = (params.sort || '').toLowerCase();
const sortBy = sort || 'default';
const getClient = fetchData('/client')
const getAssignment = fetchData('/project-assignment')
const [allClients, allAssignments] = await Promise.all([getClient, getAssignment]);
const filteredClients = getFilteredClients(allClients, query, sortBy)
const filterAssignments = getFilteredAssignments(allAssignments, query, status, sortBy)
return (
<div className="flex-1 space-y-8 p-6 sm:p-8 pt-6">
{/* The Shell manages the Search Input, Tabs, and "Add Client" Modal */}
<HomeTask currentView={view} />
{/* Render the correct view based on the URL */}
<Suspense fallback={<div className="animate-pulse h-96 bg-accent rounded-xl" />}>
{view === 'grid' ?
<ClientGrid clients={filteredClients} />
:
<AssignmentTable data={filterAssignments} />
}
</Suspense>
</div>
);
}