mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:56:28 +00:00
ffcf3c6e58
This commit reorganizes client and project-assignment screens into dedicated grid/list components, adds a shared layout toggle via the URL query string, and updates task pages to render the selected view consistently. It also moves shared client form logic into a client folder, improves status badge formatting, extends LazyImage with custom image classes, and updates the illustration assets and Lucide dependency used in the task UI.
77 lines
3.2 KiB
TypeScript
77 lines
3.2 KiB
TypeScript
"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 FormClient from './client/FormClient';
|
|
import FilterComponent from './FilterComponent';
|
|
import {
|
|
Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue,
|
|
} from '@/components/ui/select';
|
|
import Link from 'next/link';
|
|
|
|
interface ShellProps {
|
|
currentView: 'clients' | 'assignments';
|
|
}
|
|
|
|
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">
|
|
<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="clients">Clients</SelectItem>
|
|
<SelectItem value="assignments">Project Assignment</SelectItem>
|
|
</SelectGroup>
|
|
</SelectContent>
|
|
</Select>
|
|
{currentView === 'clients' ?
|
|
<Button className="gap-2" onClick={() => setShowForm(true)}>
|
|
<Plus className="w-4 h-4" /> Add Client
|
|
</Button>
|
|
:
|
|
<Link href='task/project-assignment'>
|
|
<Button className="gap-2">
|
|
<Plus className="w-4 h-4" /> Create Project Assignment
|
|
</Button>
|
|
</Link>
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
<FilterComponent
|
|
hideFilterModal={currentView === 'clients'}
|
|
showLayoutToggle={true}
|
|
/>
|
|
|
|
{showForm && <FormClient isRedirectToDetail onCancel={() => setShowForm(false)} onSuccess={() => { setShowForm(false); router.refresh() }} />}
|
|
</>
|
|
);
|
|
} |