mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-23 07:59:59 -04:00
* added more translation keys * added more keys * added a lot of additional translation for every language available * more translations * fixed keys spelling
57 lines
1.3 KiB
TypeScript
57 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')}
|
|
closeLabel={t('close')}
|
|
description={t('delete_library_description')}
|
|
ctaDanger
|
|
ctaLabel={t('delete')}
|
|
/>
|
|
);
|
|
}
|