refactor: use tabs instead of spaces

This commit is contained in:
Sonny
2024-10-07 01:33:59 +02:00
parent f425decf2c
commit eea9732100
197 changed files with 5206 additions and 5209 deletions

View File

@@ -9,110 +9,110 @@ import useSearchParam from '~/hooks/use_search_param';
import { Collection } from '~/types/app';
export type FormLinkData = {
name: string;
description: string | null;
url: string;
favorite: boolean;
collectionId: Collection['id'];
name: string;
description: string | null;
url: string;
favorite: boolean;
collectionId: Collection['id'];
};
interface FormLinkProps {
title: string;
canSubmit: boolean;
disableHomeLink?: boolean;
data: FormLinkData;
errors?: Record<string, Array<string>>;
collections: Collection[];
disableInputs?: boolean;
submitBtnDanger?: boolean;
title: string;
canSubmit: boolean;
disableHomeLink?: boolean;
data: FormLinkData;
errors?: Record<string, Array<string>>;
collections: Collection[];
disableInputs?: boolean;
submitBtnDanger?: boolean;
setData: (name: string, value: any) => void;
handleSubmit: () => void;
setData: (name: string, value: any) => void;
handleSubmit: () => void;
}
export default function FormLink({
title,
canSubmit,
disableHomeLink,
data,
errors,
collections,
disableInputs = false,
submitBtnDanger = false,
title,
canSubmit,
disableHomeLink,
data,
errors,
collections,
disableInputs = false,
submitBtnDanger = false,
setData,
handleSubmit,
setData,
handleSubmit,
}: FormLinkProps) {
const { t } = useTranslation('common');
const collectionId =
Number(useSearchParam('collectionId')) ?? collections?.[0].id;
const { t } = useTranslation('common');
const collectionId =
Number(useSearchParam('collectionId')) ?? collections?.[0].id;
const onSubmit = (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
handleSubmit();
};
const onSubmit = (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
handleSubmit();
};
return (
<FormLayout
title={title}
handleSubmit={onSubmit}
canSubmit={canSubmit}
disableHomeLink={disableHomeLink}
collectionId={collectionId}
submitBtnDanger={submitBtnDanger}
>
<BackToDashboard>
<TextBox
label={t('link.name')}
placeholder={t('link.name')}
name="name"
onChange={setData}
value={data.name}
errors={errors?.name}
disabled={disableInputs}
required
autoFocus
/>
<TextBox
label={t('link.link')}
placeholder={t('link.link')}
name="url"
onChange={setData}
value={data.url}
errors={errors?.url}
disabled={disableInputs}
required
/>
<TextBox
label={t('link.description')}
placeholder={t('link.description')}
name="description"
onChange={setData}
value={data.description ?? undefined}
errors={errors?.description}
disabled={disableInputs}
/>
<Selector
label={t('collection.collections')}
name="collection"
placeholder={t('collection.collections')}
value={data.collectionId}
onChangeCallback={(value) => setData('collectionId', value)}
options={collections.map(({ id, name }) => ({
label: name,
value: id,
}))}
required
/>
<Checkbox
label={t('favorite')}
name="favorite"
onChange={setData}
checked={data.favorite}
errors={errors?.favorite}
disabled={disableInputs}
/>
</BackToDashboard>
</FormLayout>
);
return (
<FormLayout
title={title}
handleSubmit={onSubmit}
canSubmit={canSubmit}
disableHomeLink={disableHomeLink}
collectionId={collectionId}
submitBtnDanger={submitBtnDanger}
>
<BackToDashboard>
<TextBox
label={t('link.name')}
placeholder={t('link.name')}
name="name"
onChange={setData}
value={data.name}
errors={errors?.name}
disabled={disableInputs}
required
autoFocus
/>
<TextBox
label={t('link.link')}
placeholder={t('link.link')}
name="url"
onChange={setData}
value={data.url}
errors={errors?.url}
disabled={disableInputs}
required
/>
<TextBox
label={t('link.description')}
placeholder={t('link.description')}
name="description"
onChange={setData}
value={data.description ?? undefined}
errors={errors?.description}
disabled={disableInputs}
/>
<Selector
label={t('collection.collections')}
name="collection"
placeholder={t('collection.collections')}
value={data.collectionId}
onChangeCallback={(value) => setData('collectionId', value)}
options={collections.map(({ id, name }) => ({
label: name,
value: id,
}))}
required
/>
<Checkbox
label={t('favorite')}
name="favorite"
onChange={setData}
checked={data.favorite}
errors={errors?.favorite}
disabled={disableInputs}
/>
</BackToDashboard>
</FormLayout>
);
}