mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-21 23:18:06 -04:00
* you know, you could just work on first try * fix extension * configure plugin and fix few translation issues * more * more keys * and more * more keys and sort * commit msg * we like keys here * end my suffering * jk i just love keys * key fix * add turkish * add german * Entendido * Demnächst * Mettre une étoile sur GitHub * 成功 * pnpm-lock * vite plugin * remove i18next backends --------- Co-authored-by: Brendan Allan <brendonovich@outlook.com>
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import { useQueryClient } from '@tanstack/react-query';
|
|
import { useNavigate } from 'react-router';
|
|
import { useBridgeMutation, usePlausibleEvent, useZodForm } from '@sd/client';
|
|
import { Dialog, useDialog, UseDialogProps } from '@sd/ui';
|
|
import { useLocale } from '~/hooks';
|
|
import { usePlatform } from '~/util/Platform';
|
|
|
|
interface Props extends UseDialogProps {
|
|
libraryUuid: string;
|
|
}
|
|
|
|
export default function DeleteLibraryDialog(props: Props) {
|
|
const { t } = useLocale();
|
|
|
|
const submitPlausibleEvent = usePlausibleEvent();
|
|
const queryClient = useQueryClient();
|
|
const platform = usePlatform();
|
|
const navigate = useNavigate();
|
|
|
|
const deleteLib = useBridgeMutation('library.delete');
|
|
|
|
const form = useZodForm();
|
|
|
|
const onSubmit = form.handleSubmit(async () => {
|
|
try {
|
|
await deleteLib.mutateAsync(props.libraryUuid);
|
|
|
|
queryClient.invalidateQueries(['library.list']);
|
|
|
|
platform.refreshMenuBar && platform.refreshMenuBar();
|
|
|
|
submitPlausibleEvent({
|
|
event: {
|
|
type: 'libraryDelete'
|
|
}
|
|
});
|
|
|
|
navigate('/');
|
|
} catch (e) {
|
|
alert(`Failed to delete library: ${e}`);
|
|
}
|
|
});
|
|
|
|
return (
|
|
<Dialog
|
|
form={form}
|
|
onSubmit={onSubmit}
|
|
dialog={useDialog(props)}
|
|
title={t('delete_library')}
|
|
description={t('delete_library_description')}
|
|
ctaDanger
|
|
ctaLabel={t('delete')}
|
|
/>
|
|
);
|
|
}
|