mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-06 12:46:29 +00:00
60 lines
2.5 KiB
TypeScript
60 lines
2.5 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';
|
|
import FilterComponent from './FilterComponent';
|
|
|
|
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);
|
|
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>
|
|
<Button className="gap-2" onClick={() => setShowForm(true)}>
|
|
<Plus className="w-4 h-4" /> Add Client
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
|
|
<FilterComponent hideStatus={currentView === 'grid'} />
|
|
|
|
{showForm && <FormClient onCancel={() => setShowForm(false)} onSuccess={() => { setShowForm(false); router.refresh() }} />}
|
|
</>
|
|
);
|
|
} |