mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-06 21:06:29 +00:00
6f0d8481a1
Normalize project-assignment status handling and improve assignment creation flow. - Use project_assignment_status / project_assignment_status_detail fields throughout (ClientDetail, AssignmentDetail, WorkOrderCard, StatusTimeline, UpdateTimelineStatus, ProjectDetail filters) and prefer start_date/end_date for timeline ranges. - Filter timeline lists to only include entries with start_date and format dates using dayjs. - Update UpdateTimelineStatus to submit detail/master IDs and call PUT /project-assignment/status/:assignmentId; adjust table and editing state types. - Rework ManageTeam and related types to match API shape (user object nested) and update UI/behaviors. - Add a dedicated "Clients" step to ProjectAssignmentForm with client & end-user comboboxes, client creation modal, client/end-user fetching, validation, and navigation; fix payload mapping, default values, and post-submit routing. - Add new project-assignment page entry (app/(dashboard)/task/project-assignment/page.tsx). - Wrap ClientGrid cards in links and tidy card actions; adjust HomeTask view options and create-button behavior to route to project assignment flow. - Add optional redirect behavior to FormClient and small UI spacing/structure tweaks. These changes align front-end data structures with backend fields, improve timeline accuracy, and streamline the project assignment creation UX.
81 lines
3.6 KiB
TypeScript
81 lines
3.6 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 { 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';
|
|
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">
|
|
{/* <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="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 hideCategory />
|
|
|
|
{showForm && <FormClient isRedirectToDetail onCancel={() => setShowForm(false)} onSuccess={() => { setShowForm(false); router.refresh() }} />}
|
|
</>
|
|
);
|
|
} |