Files
hats-app/app/(dashboard)/task/component/HomeTask.tsx
T
Ichsan Kurniawan 78f48d783f 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.
2026-04-16 22:38:26 +07:00

78 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, Search, LayoutGrid, List } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
import FormClient from './FormClient';
interface ShellProps {
currentView: 'grid' | 'table';
currentQuery: string;
}
export default function HomeTask({ currentView, currentQuery }: 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);
router.push(`${pathname}?${params.toString()}`);
};
// Update URL when typing (Debouncing recommended for production)
const handleSearch = (term: string) => {
const params = new URLSearchParams(searchParams!);
if (term) {
params.set('q', term);
} else {
params.delete('q');
}
// Use replace so we don't clutter the browser history with every keystroke
router.replace(`${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>
<Button className="gap-2" onClick={() => setShowForm(true)}>
<Plus className="w-4 h-4" /> Add Client
</Button>
</div>
</div>
<div className="relative">
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground" />
<Input
placeholder="Search clients, projects, or work orders..."
className="pl-10"
defaultValue={currentQuery}
onChange={(e) => handleSearch(e.target.value)}
/>
</div>
{showForm && <FormClient onCancel={() => setShowForm(false)} onSuccess={() => { setShowForm(false); router.refresh() }} />}
</>
);
}