mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:56:28 +00:00
80cb73f7fa
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.
73 lines
3.2 KiB
TypeScript
73 lines
3.2 KiB
TypeScript
// app/clients/components/dashboard-shell.tsx
|
|
"use client"
|
|
|
|
import { useState } from 'react';
|
|
import { useRouter, usePathname, useSearchParams } from 'next/navigation';
|
|
import { Plus } from 'lucide-react';
|
|
import { Button } from '@/components/ui/button';
|
|
// import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
|
import FormClient from './FormClient';
|
|
import FilterComponent from './FilterComponent';
|
|
import {
|
|
Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue,
|
|
} from '@/components/ui/select';
|
|
|
|
interface ShellProps {
|
|
currentView: 'grid' | 'table';
|
|
}
|
|
|
|
export default function HomeTask({ currentView }: ShellProps) {
|
|
const router = useRouter();
|
|
const pathname = usePathname();
|
|
const searchParams = useSearchParams();
|
|
|
|
const [showForm, setShowForm] = useState(false);
|
|
|
|
// Update URL when Tabs change
|
|
const handleTabChange = (view: string) => {
|
|
const params = new URLSearchParams(searchParams!);
|
|
params.set('view', view);
|
|
params.delete('status');
|
|
router.push(`${pathname}?${params.toString()}`);
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<div className="flex flex-col md:flex-row md:items-center justify-between gap-4">
|
|
<div>
|
|
<h1 className="text-lg sm:text-3xl font-medium tracking-tight capitalize">My Task & Projects</h1>
|
|
<p className="text-xs md:text-base text-muted-foreground w-full lg:w-1/2 xl:w-3/4 mt-2">
|
|
Something that can be done at any time is often done at no time.
|
|
</p>
|
|
</div>
|
|
<div className="flex items-center gap-3">
|
|
{/* <Tabs value={currentView} onValueChange={handleTabChange} className="w-auto">
|
|
<TabsList>
|
|
<TabsTrigger value="grid" className="gap-2"><LayoutGrid className="w-4 h-4" /> Clients</TabsTrigger>
|
|
<TabsTrigger value="table" className="gap-2"><List className="w-4 h-4" /> Assignments</TabsTrigger>
|
|
</TabsList>
|
|
</Tabs> */}
|
|
<Select value={currentView} onValueChange={handleTabChange}>
|
|
<SelectTrigger className="w-full md:w-max bg-white dark:bg-zinc-900">
|
|
<SelectValue placeholder="Show by" />
|
|
</SelectTrigger>
|
|
<SelectContent>
|
|
<SelectGroup>
|
|
<SelectLabel>Show by</SelectLabel>
|
|
<SelectItem value="grid">Clients</SelectItem>
|
|
<SelectItem value="table">Project Assignment</SelectItem>
|
|
</SelectGroup>
|
|
</SelectContent>
|
|
</Select>
|
|
<Button className="gap-2" onClick={() => setShowForm(true)}>
|
|
<Plus className="w-4 h-4" /> Add Client
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
|
|
<FilterComponent hideDateFilters={currentView === 'grid'} />
|
|
|
|
{showForm && <FormClient onCancel={() => setShowForm(false)} onSuccess={() => { setShowForm(false); router.refresh() }} />}
|
|
</>
|
|
);
|
|
} |