Files
outline/app/scenes/Trash/components/DeleteDocumentsInTrash.tsx
Hemachandar ef0fb74308 feat: Add button to empty trash (#6772)
Co-authored-by: Tom Moor <tom.moor@gmail.com>
2024-04-16 06:04:56 -07:00

44 lines
1.2 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { observer } from "mobx-react";
import * as React from "react";
import { useTranslation, Trans } from "react-i18next";
import { useHistory } from "react-router-dom";
import { toast } from "sonner";
import ConfirmationDialog from "~/components/ConfirmationDialog";
import Flex from "~/components/Flex";
import useStores from "~/hooks/useStores";
type Props = {
onSubmit: () => void;
shouldRedirect: boolean;
};
function DeleteDocumentsInTrash({ onSubmit, shouldRedirect }: Props) {
const { t } = useTranslation();
const { documents } = useStores();
const history = useHistory();
const handleSubmit = async () => {
await documents.emptyTrash();
toast.success(t("Trash emptied"));
onSubmit();
if (shouldRedirect) {
history.push("/home");
}
};
return (
<Flex column>
<ConfirmationDialog
submitText={t("Im sure Delete")}
savingText={`${t("Deleting")}`}
onSubmit={handleSubmit}
danger
>
<Trans defaults="Are you sure you want to permanently delete all the documents in Trash? This action is immediate and cannot be undone." />
</ConfirmationDialog>
</Flex>
);
}
export default observer(DeleteDocumentsInTrash);