import { useQueryClient } from '@tanstack/react-query' import dayjs from 'dayjs' import { MoreVertical, X } from 'lucide-react' import { useRouter } from 'next/router' import { toast } from 'sonner' import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from 'ui' import { useBranchUpdateMutation } from '@/data/branches/branch-update-mutation' import type { Branch } from '@/data/branches/branches-query' import { branchKeys } from '@/data/branches/keys' interface ReviewRowProps { branch: Branch } export const ReviewRow = ({ branch }: ReviewRowProps) => { const router = useRouter() const queryClient = useQueryClient() const { project_ref: branchRef, parent_project_ref: projectRef } = branch const { mutate: updateBranch, isPending: isUpdating } = useBranchUpdateMutation({ onSuccess: () => { toast.success('Branch marked as not ready for review') queryClient.invalidateQueries({ queryKey: branchKeys.list(projectRef), }) }, onError: (error) => { toast.error(`Failed to update branch: ${error.message}`) }, }) const handleRowClick = () => { router.push(`/project/${branchRef}/merge`) } const handleNotReadyForReview = (e?: Event) => { e?.preventDefault() e?.stopPropagation() updateBranch({ branchRef, projectRef, requestReview: false, }) } const formattedReviewDate = branch.review_requested_at ? dayjs(branch.review_requested_at).format('MMM DD, YYYY HH:mm') : '' return (

{branch.name}

{formattedReviewDate}

) }