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