mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 07:25:35 +00:00
refactor: use tabs instead of spaces
This commit is contained in:
@@ -4,38 +4,38 @@ import { route } from '@izzyjs/route/client';
|
||||
import { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import FormCollection, {
|
||||
FormCollectionData,
|
||||
FormCollectionData,
|
||||
} from '~/components/form/form_collection';
|
||||
|
||||
export default function CreateCollectionPage({
|
||||
disableHomeLink,
|
||||
disableHomeLink,
|
||||
}: {
|
||||
disableHomeLink: boolean;
|
||||
disableHomeLink: boolean;
|
||||
}) {
|
||||
const { t } = useTranslation('common');
|
||||
const { data, setData, submit, processing } = useForm<FormCollectionData>({
|
||||
name: '',
|
||||
description: '',
|
||||
visibility: Visibility.PRIVATE,
|
||||
});
|
||||
const isFormDisabled = useMemo(
|
||||
() => processing || data.name.length === 0,
|
||||
[processing, data]
|
||||
);
|
||||
const { t } = useTranslation('common');
|
||||
const { data, setData, submit, processing } = useForm<FormCollectionData>({
|
||||
name: '',
|
||||
description: '',
|
||||
visibility: Visibility.PRIVATE,
|
||||
});
|
||||
const isFormDisabled = useMemo(
|
||||
() => processing || data.name.length === 0,
|
||||
[processing, data]
|
||||
);
|
||||
|
||||
const handleSubmit = () => {
|
||||
const { method, url } = route('collection.create');
|
||||
submit(method, url);
|
||||
};
|
||||
const handleSubmit = () => {
|
||||
const { method, url } = route('collection.create');
|
||||
submit(method, url);
|
||||
};
|
||||
|
||||
return (
|
||||
<FormCollection
|
||||
title={t('collection.create')}
|
||||
canSubmit={!isFormDisabled}
|
||||
disableHomeLink={disableHomeLink}
|
||||
data={data}
|
||||
setData={setData}
|
||||
handleSubmit={handleSubmit}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<FormCollection
|
||||
title={t('collection.create')}
|
||||
canSubmit={!isFormDisabled}
|
||||
disableHomeLink={disableHomeLink}
|
||||
data={data}
|
||||
setData={setData}
|
||||
handleSubmit={handleSubmit}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,40 +2,40 @@ import { useForm } from '@inertiajs/react';
|
||||
import { route } from '@izzyjs/route/client';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import FormCollection, {
|
||||
FormCollectionData,
|
||||
FormCollectionData,
|
||||
} from '~/components/form/form_collection';
|
||||
import { Collection } from '~/types/app';
|
||||
|
||||
export default function DeleteCollectionPage({
|
||||
collection,
|
||||
collection,
|
||||
}: {
|
||||
collection: 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 { 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);
|
||||
};
|
||||
const handleSubmit = () => {
|
||||
const { method, url } = route('collection.delete', {
|
||||
params: { id: collection.id.toString() },
|
||||
});
|
||||
submit(method, url);
|
||||
};
|
||||
|
||||
return (
|
||||
<FormCollection
|
||||
title={t('collection.delete')}
|
||||
canSubmit={!processing}
|
||||
data={data}
|
||||
setData={setData}
|
||||
handleSubmit={handleSubmit}
|
||||
errors={errors as any}
|
||||
disableInputs
|
||||
submitBtnDanger
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<FormCollection
|
||||
title={t('collection.delete')}
|
||||
canSubmit={!processing}
|
||||
data={data}
|
||||
setData={setData}
|
||||
handleSubmit={handleSubmit}
|
||||
errors={errors as any}
|
||||
disableInputs
|
||||
submitBtnDanger
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,48 +3,48 @@ import { route } from '@izzyjs/route/client';
|
||||
import { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import FormCollection, {
|
||||
FormCollectionData,
|
||||
FormCollectionData,
|
||||
} from '~/components/form/form_collection';
|
||||
import { Collection } from '~/types/app';
|
||||
|
||||
export default function EditCollectionPage({
|
||||
collection,
|
||||
collection,
|
||||
}: {
|
||||
collection: Collection;
|
||||
collection: Collection;
|
||||
}) {
|
||||
const { t } = useTranslation('common');
|
||||
const { data, setData, submit, processing, errors } =
|
||||
useForm<FormCollectionData>({
|
||||
name: collection.name,
|
||||
description: collection.description,
|
||||
visibility: collection.visibility,
|
||||
nextId: collection.nextId,
|
||||
});
|
||||
const canSubmit = useMemo<boolean>(() => {
|
||||
const isFormEdited =
|
||||
data.name !== collection.name ||
|
||||
data.description !== collection.description ||
|
||||
data.visibility !== collection.visibility;
|
||||
const isFormValid = data.name !== '';
|
||||
return isFormEdited && isFormValid && !processing;
|
||||
}, [data, collection]);
|
||||
const { t } = useTranslation('common');
|
||||
const { data, setData, submit, processing, errors } =
|
||||
useForm<FormCollectionData>({
|
||||
name: collection.name,
|
||||
description: collection.description,
|
||||
visibility: collection.visibility,
|
||||
nextId: collection.nextId,
|
||||
});
|
||||
const canSubmit = useMemo<boolean>(() => {
|
||||
const isFormEdited =
|
||||
data.name !== collection.name ||
|
||||
data.description !== collection.description ||
|
||||
data.visibility !== collection.visibility;
|
||||
const isFormValid = data.name !== '';
|
||||
return isFormEdited && isFormValid && !processing;
|
||||
}, [data, collection]);
|
||||
|
||||
const handleSubmit = () => {
|
||||
const { method, url } = route('collection.edit', {
|
||||
params: { id: collection.id.toString() },
|
||||
});
|
||||
submit(method, url);
|
||||
};
|
||||
const handleSubmit = () => {
|
||||
const { method, url } = route('collection.edit', {
|
||||
params: { id: collection.id.toString() },
|
||||
});
|
||||
submit(method, url);
|
||||
};
|
||||
|
||||
return (
|
||||
<FormCollection
|
||||
title={t('collection.edit')}
|
||||
canSubmit={canSubmit}
|
||||
data={data}
|
||||
setData={setData}
|
||||
handleSubmit={handleSubmit}
|
||||
// TODO: fix this, type mistmatch (Record<string, string[]> sent by the backend, but useForm expects a Record<string, string>)
|
||||
errors={errors as any}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<FormCollection
|
||||
title={t('collection.edit')}
|
||||
canSubmit={canSubmit}
|
||||
data={data}
|
||||
setData={setData}
|
||||
handleSubmit={handleSubmit}
|
||||
// TODO: fix this, type mistmatch (Record<string, string[]> sent by the backend, but useForm expects a Record<string, string>)
|
||||
errors={errors as any}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user