mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 15:05:35 +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);
|
const link = await this.getLinkById(linkId, auth.user!.id);
|
||||||
await link.load('collection');
|
await link.load('collection');
|
||||||
return inertia.render('links/delete', { link });
|
return inertia.render('mantine/links/delete', { link });
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete({ request, auth, response }: HttpContext) {
|
async delete({ request, auth, response }: HttpContext) {
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ export default function MantineFormLink({
|
|||||||
}))}
|
}))}
|
||||||
onChange={(value) => setData('collectionId', value)}
|
onChange={(value) => setData('collectionId', value)}
|
||||||
value={data.collectionId.toString()}
|
value={data.collectionId.toString()}
|
||||||
|
readOnly={disableInputs}
|
||||||
mt="md"
|
mt="md"
|
||||||
searchable
|
searchable
|
||||||
required
|
required
|
||||||
@@ -100,7 +101,7 @@ export default function MantineFormLink({
|
|||||||
onChange={({ target }) => setData('favorite', target.checked)}
|
onChange={({ target }) => setData('favorite', target.checked)}
|
||||||
checked={data.favorite}
|
checked={data.favorite}
|
||||||
error={errors?.favorite}
|
error={errors?.favorite}
|
||||||
disabled={disableInputs}
|
disabled={disableInputs} // readonly not working
|
||||||
mt="md"
|
mt="md"
|
||||||
/>
|
/>
|
||||||
</BackToDashboard>
|
</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 (
|
return (
|
||||||
<MantineFormLink
|
<MantineFormLink
|
||||||
title={t('link.create')}
|
title={t('link.edit')}
|
||||||
textSubmitButton={t('form.create')}
|
textSubmitButton={t('form.update')}
|
||||||
canSubmit={canSubmit}
|
canSubmit={canSubmit}
|
||||||
data={data}
|
data={data}
|
||||||
setData={setData}
|
setData={setData}
|
||||||
|
|||||||
Reference in New Issue
Block a user