'use client'; import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'; import { Button } from '@/components/ui/button'; import { Widget, WidgetBody, WidgetHead } from '@/components/widget'; import { handleError, useTRPC } from '@/integrations/trpc/react'; import { showConfirm } from '@/modals'; import type { IServiceProjectWithClients } from '@openpanel/db'; import { useMutation } from '@tanstack/react-query'; import { useRouter } from '@tanstack/react-router'; import { addHours, format, startOfHour } from 'date-fns'; import { TrashIcon } from 'lucide-react'; import { toast } from 'sonner'; type Props = { project: IServiceProjectWithClients }; export default function DeleteProject({ project }: Props) { const router = useRouter(); const trpc = useTRPC(); const mutation = useMutation( trpc.project.delete.mutationOptions({ onError: handleError, onSuccess: () => { toast.success('Project updated'); router.invalidate(); }, }), ); const cancelDeletionMutation = useMutation( trpc.project.cancelDeletion.mutationOptions({ onError: handleError, onSuccess: () => { toast.success('Project updated'); router.invalidate(); }, }), ); return ( Delete Project

Deleting your project will remove it from your organization and all of its data. It'll be permanently deleted after 24 hours.

{project?.deleteAt && ( Project scheduled for deletion This project will be deleted on{' '} { // add 1 hour and round to the nearest hour // Since we run cron once an hour format( startOfHour(addHours(project.deleteAt, 1)), 'yyyy-MM-dd HH:mm:ss', ) } . Any event associated with this project will be deleted. )}
{project?.deleteAt && ( )}
); }