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 ( eraseFile.mutateAsync({ location_id: props.location_id, path_id: props.path_id, passes: data.passes.toString() }) } dialog={useDialog(props)} title="Erase a file" description="Configure your erasure settings." loading={eraseFile.isLoading} ctaLabel="Erase" >
# of passes
{ setPasses(val); form.setValue('passes', val[0] ?? 1); }} />
{passes}

TODO: checkbox for "erase all matching files" (only if a file is selected)

); };