mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 15:35:35 +00:00
feat: use new form layout for collection/delete
This commit is contained in:
@@ -31,6 +31,7 @@ export default function CreateCollectionPage({
|
||||
return (
|
||||
<MantineFormCollection
|
||||
title={t('collection.create')}
|
||||
textSubmitButton={t('form.create')}
|
||||
canSubmit={!isFormDisabled}
|
||||
disableHomeLink={disableHomeLink}
|
||||
data={data}
|
||||
|
||||
42
inertia/pages/mantine/collections/delete.tsx
Normal file
42
inertia/pages/mantine/collections/delete.tsx
Normal file
@@ -0,0 +1,42 @@
|
||||
import { useForm } from '@inertiajs/react';
|
||||
import { route } from '@izzyjs/route/client';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import MantineFormCollection, {
|
||||
FormCollectionData,
|
||||
} from '~/mantine/components/form/mantine_form_collection';
|
||||
import { Collection } from '~/types/app';
|
||||
|
||||
export default function DeleteCollectionPage({
|
||||
collection,
|
||||
}: {
|
||||
collection: Collection;
|
||||
}) {
|
||||
const { t } = useTranslation('common');
|
||||
const { data, setData, submit, processing, errors } =
|
||||
useForm<FormCollectionData>({
|
||||
name: collection.name,
|
||||
description: collection.description,
|
||||
visibility: collection.visibility,
|
||||
});
|
||||
|
||||
const handleSubmit = () => {
|
||||
const { method, url } = route('collection.delete', {
|
||||
params: { id: collection.id.toString() },
|
||||
});
|
||||
submit(method, url);
|
||||
};
|
||||
|
||||
return (
|
||||
<MantineFormCollection
|
||||
title={t('collection.delete')}
|
||||
textSubmitButton={t('form.delete')}
|
||||
canSubmit={!processing}
|
||||
data={data}
|
||||
setData={setData}
|
||||
handleSubmit={handleSubmit}
|
||||
errors={errors as any}
|
||||
disableInputs
|
||||
submitBtnDanger
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -39,6 +39,7 @@ export default function EditCollectionPage({
|
||||
return (
|
||||
<MantineFormCollection
|
||||
title={t('collection.edit')}
|
||||
textSubmitButton={t('form.update')}
|
||||
canSubmit={canSubmit}
|
||||
data={data}
|
||||
setData={setData}
|
||||
|
||||
Reference in New Issue
Block a user