Files
spacedrive/interface/app/$libraryId/Explorer/FilePath/EraseDialog.tsx
Brendan Allan a1ed97b702 [ENG-816, ENG-821] Re-implement reveal in finder + ContextMenu overhaul (#1029)
* mostly there

* native opening working

* more

* cleanup

* reorganise

* remove unnecessary import

* uncomment some stuff

* spacing

* store quickview ref inside provider

* fix linting

* clippy

---------

Co-authored-by: Utku <74243531+utkubakir@users.noreply.github.com>
Co-authored-by: Jamie Pine <32987599+jamiepine@users.noreply.github.com>
2023-06-27 15:34:53 +00:00

68 lines
1.5 KiB
TypeScript

import { useState } from 'react';
import { useLibraryMutation } from '@sd/client';
import { Dialog, Slider, UseDialogProps, useDialog } from '@sd/ui';
import { useZodForm, z } from '@sd/ui/src/forms';
interface Props extends UseDialogProps {
location_id: number;
path_id: number;
}
const schema = z.object({
passes: z.number()
});
export default (props: Props) => {
const eraseFile = useLibraryMutation('files.eraseFiles');
const form = useZodForm({
schema,
defaultValues: {
passes: 4
}
});
const [passes, setPasses] = useState([4]);
return (
<Dialog
form={form}
onSubmit={form.handleSubmit((data) =>
eraseFile.mutateAsync({
location_id: props.location_id,
file_path_ids: [props.path_id],
passes: data.passes.toString()
})
)}
dialog={useDialog(props)}
title="Erase a file"
description="Configure your erasure settings."
loading={eraseFile.isLoading}
ctaLabel="Erase"
>
<div className="mt-2 flex flex-col">
<span className="text-xs font-bold"># of passes</span>
<div className="flex flex-row space-x-2">
<div className="relative mt-2 flex grow">
<Slider
value={passes}
max={16}
min={1}
step={1}
defaultValue={[4]}
onValueChange={(val) => {
setPasses(val);
form.setValue('passes', val[0] ?? 1);
}}
/>
</div>
<span className="mt-2.5 text-sm font-medium">{passes}</span>
</div>
</div>
<p>TODO: checkbox for "erase all matching files" (only if a file is selected)</p>
</Dialog>
);
};