feat(tickets): show pending repair review count in ticket details
This commit is contained in:
@@ -28,7 +28,11 @@ export function TicketDetailHeader({
|
|||||||
|
|
||||||
<div className="flex shrink-0 items-center gap-2">
|
<div className="flex shrink-0 items-center gap-2">
|
||||||
<PermissionGuard permissions={PERMISSIONS.TICKET.REVIEW}>
|
<PermissionGuard permissions={PERMISSIONS.TICKET.REVIEW}>
|
||||||
<OpenRepairReviewAction ticketId={ticket.id} />
|
<OpenRepairReviewAction
|
||||||
|
ticketId={ticket.id}
|
||||||
|
hasPendingReview={ticket.has_pending_review}
|
||||||
|
pendingReviewCount={ticket.pending_review_count}
|
||||||
|
/>
|
||||||
</PermissionGuard>
|
</PermissionGuard>
|
||||||
<PermissionGuard permissions={PERMISSIONS.TICKET.ASSIGN}>
|
<PermissionGuard permissions={PERMISSIONS.TICKET.ASSIGN}>
|
||||||
<AssignTicketAction ticketId={ticket.id} />
|
<AssignTicketAction ticketId={ticket.id} />
|
||||||
|
|||||||
@@ -3,19 +3,43 @@
|
|||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import { ClipboardCheck } from 'lucide-react';
|
import { ClipboardCheck } from 'lucide-react';
|
||||||
|
|
||||||
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { ROUTES } from '@/utils/routes';
|
import { ROUTES } from '@/utils/routes';
|
||||||
|
|
||||||
export function OpenRepairReviewAction({ ticketId }: { ticketId: string }) {
|
interface OpenRepairReviewActionProps {
|
||||||
|
ticketId: string;
|
||||||
|
hasPendingReview: boolean;
|
||||||
|
pendingReviewCount: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function OpenRepairReviewAction({
|
||||||
|
ticketId,
|
||||||
|
hasPendingReview,
|
||||||
|
pendingReviewCount,
|
||||||
|
}: OpenRepairReviewActionProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const count = Math.max(0, pendingReviewCount ?? 0);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
|
disabled={!hasPendingReview}
|
||||||
|
title={
|
||||||
|
hasPendingReview
|
||||||
|
? `${count} ${count === 1 ? 'repair is' : 'repairs are'} awaiting review`
|
||||||
|
: 'No repairs are awaiting review'
|
||||||
|
}
|
||||||
onClick={() => router.push(ROUTES.TICKET_REVIEW(ticketId))}
|
onClick={() => router.push(ROUTES.TICKET_REVIEW(ticketId))}
|
||||||
>
|
>
|
||||||
<ClipboardCheck />
|
<ClipboardCheck />
|
||||||
Review Repairs
|
Review Repairs
|
||||||
|
<Badge
|
||||||
|
variant="secondary"
|
||||||
|
className="h-5 min-w-5 rounded-full px-1.5 font-semibold tabular-nums"
|
||||||
|
>
|
||||||
|
{count}
|
||||||
|
</Badge>
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ export interface TicketAssignmentsResponse {
|
|||||||
export interface TicketOverviewDetail {
|
export interface TicketOverviewDetail {
|
||||||
id: string;
|
id: string;
|
||||||
ticket_name?: string | null;
|
ticket_name?: string | null;
|
||||||
|
has_pending_review: boolean;
|
||||||
|
pending_review_count: number;
|
||||||
video_id?: string | null;
|
video_id?: string | null;
|
||||||
video?: TicketVideo | null;
|
video?: TicketVideo | null;
|
||||||
chainage_id?: string | null;
|
chainage_id?: string | null;
|
||||||
|
|||||||
Reference in New Issue
Block a user