mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 07:03:25 +00:00
feat: use new form layout for link/delete
This commit is contained in:
@@ -98,7 +98,7 @@ export default class LinksController {
|
||||
|
||||
const link = await this.getLinkById(linkId, auth.user!.id);
|
||||
await link.load('collection');
|
||||
return inertia.render('links/delete', { link });
|
||||
return inertia.render('mantine/links/delete', { link });
|
||||
}
|
||||
|
||||
async delete({ request, auth, response }: HttpContext) {
|
||||
|
||||
@@ -91,6 +91,7 @@ export default function MantineFormLink({
|
||||
}))}
|
||||
onChange={(value) => setData('collectionId', value)}
|
||||
value={data.collectionId.toString()}
|
||||
readOnly={disableInputs}
|
||||
mt="md"
|
||||
searchable
|
||||
required
|
||||
@@ -100,7 +101,7 @@ export default function MantineFormLink({
|
||||
onChange={({ target }) => setData('favorite', target.checked)}
|
||||
checked={data.favorite}
|
||||
error={errors?.favorite}
|
||||
disabled={disableInputs}
|
||||
disabled={disableInputs} // readonly not working
|
||||
mt="md"
|
||||
/>
|
||||
</BackToDashboard>
|
||||
|
||||
37
inertia/pages/mantine/links/delete.tsx
Normal file
37
inertia/pages/mantine/links/delete.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import { useForm } from '@inertiajs/react';
|
||||
import { route } from '@izzyjs/route/client';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import MantineFormLink from '~/mantine/components/form/mantine_form_link';
|
||||
import { LinkWithCollection } from '~/types/app';
|
||||
|
||||
export default function DeleteLinkPage({ link }: { link: LinkWithCollection }) {
|
||||
const { t } = useTranslation('common');
|
||||
const { data, setData, submit, processing } = useForm({
|
||||
name: link.name,
|
||||
description: link.description,
|
||||
url: link.url,
|
||||
favorite: link.favorite,
|
||||
collectionId: link.collectionId,
|
||||
});
|
||||
|
||||
const handleSubmit = () => {
|
||||
const { method, url } = route('link.delete', {
|
||||
params: { id: link.id.toString() },
|
||||
});
|
||||
submit(method, url);
|
||||
};
|
||||
|
||||
return (
|
||||
<MantineFormLink
|
||||
title={t('link.delete')}
|
||||
textSubmitButton={t('form.delete')}
|
||||
canSubmit={!processing}
|
||||
data={data}
|
||||
setData={setData}
|
||||
handleSubmit={handleSubmit}
|
||||
collections={[link.collection]}
|
||||
disableInputs
|
||||
submitBtnDanger
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -47,8 +47,8 @@ export default function EditLinkPage({
|
||||
|
||||
return (
|
||||
<MantineFormLink
|
||||
title={t('link.create')}
|
||||
textSubmitButton={t('form.create')}
|
||||
title={t('link.edit')}
|
||||
textSubmitButton={t('form.update')}
|
||||
canSubmit={canSubmit}
|
||||
data={data}
|
||||
setData={setData}
|
||||
|
||||
Reference in New Issue
Block a user