import { ColumnDef } from '@tanstack/react-table'; import DateTime from '@/components/date-time'; import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from '@/components/ui/dialog'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'; import { Button } from '@/components/ui/button'; import { useForm } from '@inertiajs/react'; import { LoaderCircleIcon, MoreVerticalIcon } from 'lucide-react'; import FormSuccessful from '@/components/form-successful'; import { useState } from 'react'; import { Badge } from '@/components/ui/badge'; import { Backup } from '@/types/backup'; import BackupFiles from '@/pages/backups/components/files'; import EditBackup from '@/pages/backups/components/edit-backup'; function Delete({ backup }: { backup: Backup }) { const [open, setOpen] = useState(false); const form = useForm(); const submit = () => { form.delete(route('backups.destroy', { server: backup.server_id, backup: backup.id }), { onSuccess: () => { setOpen(false); }, }); }; return ( e.preventDefault()}> Delete Delete backup [{backup.database.name}] Delete backup Are you sure you want to this backup: {backup.database.name}? All backup files will be deleted and this action cannot be undone. Cancel {form.processing && } Delete ); } export const columns: ColumnDef[] = [ { accessorKey: 'database_id', header: 'Database', enableColumnFilter: true, enableSorting: true, cell: ({ row }) => { return {row.original.database.name}; }, }, { accessorKey: 'storage_id', header: 'Storage', enableColumnFilter: true, enableSorting: true, cell: ({ row }) => { return {row.original.storage.name}; }, }, { accessorKey: 'created_at', header: 'Created at', enableColumnFilter: true, enableSorting: true, cell: ({ row }) => { return ; }, }, { accessorKey: 'status', header: 'Status', enableColumnFilter: true, enableSorting: true, cell: ({ row }) => { return {row.original.status}; }, }, { accessorKey: 'last_file', header: 'Last file status', enableColumnFilter: true, enableSorting: true, cell: ({ row }) => { return row.original.last_file && {row.original.last_file.status}; }, }, { id: 'actions', enableColumnFilter: false, enableSorting: false, cell: ({ row }) => { return ( Open menu e.preventDefault()}>Edit e.preventDefault()}>Files ); }, }, ];
Are you sure you want to this backup: {backup.database.name}? All backup files will be deleted and this action cannot be undone.