mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:56:28 +00:00
Simplify task dashboard to client view
This change removes the assignment-view toggle from the task dashboard and keeps the page focused on clients, while preserving layout selection behavior with an explicit grid/list state. It also updates the shared Manage Team and Timeline Status modals to use the Dialog component, fixes their close handling, and adds a # prefix to assignment codes for clearer labeling.
This commit is contained in:
+1
-1
@@ -125,7 +125,7 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
{assignmentStatus ? <BadgeStatus status={assignmentStatus} /> : null}
|
||||
{assignmentCode ? (
|
||||
<span className="rounded-lg border border-border bg-muted/50 px-2 py-0.5 font-mono text-xs text-muted-foreground">
|
||||
{assignmentCode}
|
||||
# {assignmentCode}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
@@ -45,7 +45,7 @@ const FilterComponent: FC<Props> = ({
|
||||
|
||||
const currentQuery = searchParams?.get('q') || '';
|
||||
const currentSort = searchParams?.get('sort') || '';
|
||||
const currentLayout = searchParams?.get('layout') === 'list' ? 'list' : 'grid';
|
||||
const currentLayout = searchParams?.get('layout') === 'grid' ? 'grid' : 'list';
|
||||
|
||||
const [searchText, setSearchText] = useState(currentQuery);
|
||||
|
||||
@@ -78,8 +78,8 @@ const FilterComponent: FC<Props> = ({
|
||||
const handleLayoutChange = (val: 'grid' | 'list') => {
|
||||
const params = new URLSearchParams(searchParams?.toString() || '');
|
||||
|
||||
if (val === 'list') {
|
||||
params.set('layout', 'list');
|
||||
if (val === 'grid') {
|
||||
params.set('layout', 'grid');
|
||||
} else {
|
||||
params.delete('layout');
|
||||
}
|
||||
|
||||
@@ -1,34 +1,28 @@
|
||||
"use client"
|
||||
|
||||
import { useState } from 'react';
|
||||
import { useRouter, usePathname, useSearchParams } from 'next/navigation';
|
||||
import { useRouter } 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';
|
||||
}
|
||||
// interface ShellProps {
|
||||
// currentView: 'clients' | 'assignments';
|
||||
// }
|
||||
|
||||
export default function HomeTask({ currentView }: ShellProps) {
|
||||
export default function HomeTask() {
|
||||
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()}`);
|
||||
};
|
||||
// const handleTabChange = (view: string) => {
|
||||
// const params = new URLSearchParams(searchParams!);
|
||||
// params.set('view', view);
|
||||
// params.delete('status');
|
||||
// router.push(`${pathname}?${params.toString()}`);
|
||||
// };
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -40,7 +34,7 @@ export default function HomeTask({ currentView }: ShellProps) {
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-col sm:flex-row items-stretch sm:items-center gap-2.5 sm:gap-3 w-full md:w-auto">
|
||||
<Select value={currentView} onValueChange={handleTabChange}>
|
||||
{/* <Select value={currentView} onValueChange={handleTabChange}>
|
||||
<SelectTrigger className="w-full sm:w-44 md:w-max bg-white dark:bg-zinc-900">
|
||||
<SelectValue placeholder="Show by" />
|
||||
</SelectTrigger>
|
||||
@@ -51,8 +45,11 @@ export default function HomeTask({ currentView }: ShellProps) {
|
||||
<SelectItem value="assignments">Project Assignment</SelectItem>
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
{currentView === 'clients' ?
|
||||
</Select> */}
|
||||
<Button className="gap-2 w-full sm:w-auto shrink-0" onClick={() => setShowForm(true)}>
|
||||
<Plus className="w-4 h-4" /> Add Client
|
||||
</Button>
|
||||
{/* {currentView === 'clients' ?
|
||||
<Button className="gap-2 w-full sm:w-auto shrink-0" onClick={() => setShowForm(true)}>
|
||||
<Plus className="w-4 h-4" /> Add Client
|
||||
</Button>
|
||||
@@ -62,12 +59,12 @@ export default function HomeTask({ currentView }: ShellProps) {
|
||||
<Plus className="w-4 h-4" /> Create Project Assignment
|
||||
</Button>
|
||||
</Link>
|
||||
}
|
||||
} */}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<FilterComponent
|
||||
hideFilterModal={currentView === 'clients'}
|
||||
hideFilterModal
|
||||
showLayoutToggle={true}
|
||||
/>
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ import {
|
||||
} from "@/components/ui/select";
|
||||
import { DatePicker } from "@/components/ui/datepicker";
|
||||
import {
|
||||
AlertDialog, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle
|
||||
} from "@/components/ui/alert-dialog"
|
||||
Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle
|
||||
} from "@/components/ui/dialog"
|
||||
import AddTeam from "./AddTeam";
|
||||
import { useFetchWithAxios } from "@/lib/axios/useFetch";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
@@ -113,16 +113,16 @@ export function ManageTeam({ assignmentId, onClose, startDate, endDate }: { assi
|
||||
|
||||
return (
|
||||
<>
|
||||
<AlertDialog open={true} >
|
||||
<AlertDialogContent className="min-w-full md:min-w-max py-7">
|
||||
<div className="flex flex-col sm:flex-row justify-between gap-3">
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Manage Team</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
<Dialog open={true} onOpenChange={(open) => { if (!open) onClose(); }}>
|
||||
<DialogContent className="min-w-full md:min-w-max max-h-[90vh] overflow-y-auto py-7">
|
||||
<div className="flex flex-col sm:flex-row justify-between gap-3 pr-6">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Manage Team</DialogTitle>
|
||||
<DialogDescription>
|
||||
Add team members and manage who is working on each project assignment.
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<Button size='sm' variant='outline' onClick={() => setShowAddTeamDialog(true)}><UserPlus /> Add Team</Button>
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<Button size='sm' variant='outline' onClick={() => setShowAddTeamDialog(true)}><UserPlus className="h-4 w-4" /> Add Team</Button>
|
||||
</div>
|
||||
<div className="rounded-md border bg-card overflow-x-auto my-5">
|
||||
<Table>
|
||||
@@ -287,11 +287,11 @@ export function ManageTeam({ assignmentId, onClose, startDate, endDate }: { assi
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel onClick={onClose} disabled={isSaving}>Close</AlertDialogCancel>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={onClose} disabled={isSaving}>Close</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{showAddTeamDialog ?
|
||||
<AddTeam assignmentId={assignmentId} existingTeam={existUserAssign} onCancel={() => setShowAddTeamDialog(false)} onSuccess={handleSuccess} />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState, type FC } from 'react';
|
||||
import {
|
||||
AlertDialog, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle
|
||||
} from "@/components/ui/alert-dialog"
|
||||
Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle
|
||||
} from "@/components/ui/dialog"
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { DatePicker } from '@/components/ui/datepicker';
|
||||
import { Edit2, Loader2, Save, X } from 'lucide-react';
|
||||
@@ -97,14 +97,14 @@ const UpdateTimelineStatus: FC<Props> = ({ assignmentId, onClose }) => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<AlertDialog open={true} >
|
||||
<AlertDialogContent className="min-w-full md:min-w-max max-h-[90vh] overflow-y-auto">
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Update Status</AlertDialogTitle>
|
||||
<AlertDialogDescription className='w-full sm:max-w-140'>
|
||||
<Dialog open={true} onOpenChange={(open) => { if (!open && onClose) onClose(); }}>
|
||||
<DialogContent className="min-w-full md:min-w-max max-h-[90vh] overflow-y-auto">
|
||||
<DialogHeader className="pr-6">
|
||||
<DialogTitle>Update Status</DialogTitle>
|
||||
<DialogDescription className='w-full sm:max-w-140'>
|
||||
Update the timeline status for this assignment. You can also add a note or remark regarding this status change. This will help to keep track of the progress.
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="rounded-md border bg-card overflow-x-auto my-3">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
@@ -187,11 +187,11 @@ const UpdateTimelineStatus: FC<Props> = ({ assignmentId, onClose }) => {
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel onClick={onClose} disabled={isSaving}>Close</AlertDialogCancel>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={onClose} disabled={isSaving}>Close</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
"use client";
|
||||
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { BookOpenCheck } from 'lucide-react';
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
import { IProjectAssignment } from '../../type.assignment';
|
||||
import AssignmentGrid from './AssignmentGrid';
|
||||
import AssignmentList from './AssignmentList';
|
||||
|
||||
interface AssignmentTableProps {
|
||||
data: IProjectAssignment[];
|
||||
layout?: 'grid' | 'list';
|
||||
initialLayout?: 'grid' | 'list';
|
||||
}
|
||||
|
||||
export default function AssignmentTable({
|
||||
data,
|
||||
layout,
|
||||
initialLayout = 'grid',
|
||||
}: AssignmentTableProps) {
|
||||
const searchParams = useSearchParams();
|
||||
const layout = searchParams?.get('layout') === 'list' ? 'list' : initialLayout;
|
||||
const currentLayout = layout || initialLayout;
|
||||
|
||||
if (data.length === 0) {
|
||||
return (
|
||||
@@ -33,7 +31,7 @@ export default function AssignmentTable({
|
||||
);
|
||||
}
|
||||
|
||||
if (layout === 'list') {
|
||||
if (currentLayout === 'list') {
|
||||
return <AssignmentList assignments={data} />;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { lazy, Suspense } from 'react';
|
||||
import fetchData, { getQueryStringFilteredAssignments } from '@/lib/fetchData';
|
||||
import { getFilteredAssignments, getFilteredClients } from './data';
|
||||
import fetchData from '@/lib/fetchData';
|
||||
import { getFilteredClients } from './data';
|
||||
import { Loader2 } from 'lucide-react';
|
||||
|
||||
const HomeTask = lazy(() => import('./component/HomeTask'));
|
||||
const ProjectAssignment = lazy(() => import('./component/project-assignment/ProjectAssignment'));
|
||||
const Client = lazy(() => import('./component/client/Client'));
|
||||
|
||||
type Props = {
|
||||
@@ -14,37 +13,37 @@ type Props = {
|
||||
export default async function ClientsPage({ searchParams }: Props) {
|
||||
const searchParams_ = await searchParams;
|
||||
|
||||
const view = searchParams_.view === 'assignments' ? 'assignments' : 'clients';
|
||||
// const view = searchParams_.view === 'assignments' ? 'assignments' : 'clients';
|
||||
const query = (searchParams_.q || '').toLowerCase();
|
||||
const sort = (searchParams_.sort || '').toLowerCase();
|
||||
const sortBy = sort || 'default';
|
||||
const layout = searchParams_.layout === 'list' ? 'list' : 'grid';
|
||||
const layout = searchParams_.layout === 'grid' ? 'grid' : 'list';
|
||||
|
||||
const queryString = getQueryStringFilteredAssignments(searchParams_)
|
||||
// const queryString = getQueryStringFilteredAssignments(searchParams_)
|
||||
|
||||
const getClient = fetchData('/client')
|
||||
const getAssignment = fetchData(queryString ? `/project-assignment?${queryString}` : '/project-assignment')
|
||||
const allClients = await fetchData('/client')
|
||||
// const getAssignment = fetchData(queryString ? `/project-assignment?${queryString}` : '/project-assignment')
|
||||
|
||||
const [allClients, allAssignments] = await Promise.all([getClient, getAssignment]);
|
||||
// const [allClients, allAssignments] = await Promise.all([getClient, getAssignment]);
|
||||
|
||||
const filteredClients = getFilteredClients(allClients, query, sortBy)
|
||||
const filterAssignments = getFilteredAssignments(allAssignments, query, sortBy)
|
||||
// const filterAssignments = getFilteredAssignments(allAssignments, query, sortBy)
|
||||
|
||||
return (
|
||||
<div className="flex-1 space-y-8 p-4 sm:p-8 pt-4 sm:pt-6">
|
||||
|
||||
<Suspense fallback={<div className='flex justify-center items-center h-48 gap-2'><Loader2 className="animate-spin" />Loading...</div>}>
|
||||
<HomeTask currentView={view} />
|
||||
<HomeTask />
|
||||
</Suspense>
|
||||
|
||||
{/* Render the correct view based on the URL */}
|
||||
<Suspense fallback={<div className="animate-pulse h-96 bg-accent rounded-xl" />}>
|
||||
<Client clients={filteredClients} initialLayout={layout} />
|
||||
{/* <Suspense fallback={<div className="animate-pulse h-96 bg-accent rounded-xl" />}>
|
||||
{view === 'clients' ?
|
||||
<Client clients={filteredClients} initialLayout={layout} />
|
||||
:
|
||||
<ProjectAssignment data={filterAssignments} />
|
||||
<ProjectAssignment data={filterAssignments} layout={layout} />
|
||||
}
|
||||
</Suspense>
|
||||
</Suspense> */}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user