import { useDeleteBackups, useRestoreBackups } from "@/apis/hooks"; import { Action, PageTable } from "@/components"; import { useModals } from "@/modules/modals"; import { useTableStyles } from "@/styles"; import { Environment } from "@/utilities"; import { faClock, faHistory, faTrash } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Anchor, Group, Text } from "@mantine/core"; import { FunctionComponent, useMemo } from "react"; import { Column } from "react-table"; interface Props { backups: readonly System.Backups[]; } const Table: FunctionComponent = ({ backups }) => { const columns: Column[] = useMemo[]>( () => [ { accessor: "type", Cell: , }, { Header: "Name", accessor: "filename", Cell: ({ value }) => { return ( {value} ); }, }, { Header: "Size", accessor: "size", Cell: ({ value }) => { const { classes } = useTableStyles(); return {value}; }, }, { Header: "Time", accessor: "date", Cell: ({ value }) => { const { classes } = useTableStyles(); return {value}; }, }, { id: "actions", accessor: "filename", Cell: ({ value }) => { const modals = useModals(); const restore = useRestoreBackups(); const remove = useDeleteBackups(); return ( modals.openConfirmModal({ title: "Restore Backup", children: ( Are you sure you want to restore the backup ({value})? Bazarr will automatically restart and reload the UI during the restore process. ), labels: { confirm: "Restore", cancel: "Cancel" }, confirmProps: { color: "red" }, onConfirm: () => restore.mutate(value), }) } icon={faHistory} > modals.openConfirmModal({ title: "Delete Backup", children: ( Are you sure you want to delete the backup ({value})? ), labels: { confirm: "Delete", cancel: "Cancel" }, confirmProps: { color: "red" }, onConfirm: () => remove.mutate(value), }) } icon={faTrash} > ); }, }, ], [] ); return ; }; export default Table;