2022-12-05 21:43:47 +01:00
|
|
|
import { createStyles, Flex, Tabs, TextInput } from '@mantine/core';
|
2022-12-04 21:19:40 +01:00
|
|
|
import { UseFormReturnType } from '@mantine/form';
|
|
|
|
|
import { useTranslation } from 'next-i18next';
|
2022-12-18 22:27:01 +01:00
|
|
|
import { AppType } from '../../../../../../types/app';
|
|
|
|
|
import { DebouncedAppIcon } from '../Shared/DebouncedAppIcon';
|
2022-12-05 21:43:47 +01:00
|
|
|
import { IconSelector } from './IconSelector/IconSelector';
|
2022-12-04 21:19:40 +01:00
|
|
|
|
|
|
|
|
interface AppearanceTabProps {
|
2022-12-18 22:27:01 +01:00
|
|
|
form: UseFormReturnType<AppType, (values: AppType) => AppType>;
|
|
|
|
|
disallowAppNameProgagation: () => void;
|
|
|
|
|
allowAppNamePropagation: boolean;
|
2022-12-04 21:19:40 +01:00
|
|
|
}
|
|
|
|
|
|
2022-12-11 19:32:51 +01:00
|
|
|
export const AppearanceTab = ({
|
|
|
|
|
form,
|
2022-12-18 22:27:01 +01:00
|
|
|
disallowAppNameProgagation,
|
|
|
|
|
allowAppNamePropagation,
|
2022-12-11 19:32:51 +01:00
|
|
|
}: AppearanceTabProps) => {
|
2022-12-20 11:34:07 +09:00
|
|
|
const { t } = useTranslation('layout/modals/add-app');
|
2022-12-05 20:04:08 +01:00
|
|
|
const { classes } = useStyles();
|
|
|
|
|
|
2022-12-04 21:19:40 +01:00
|
|
|
return (
|
|
|
|
|
<Tabs.Panel value="appearance" pt="lg">
|
2022-12-05 21:43:47 +01:00
|
|
|
<Flex gap={5}>
|
|
|
|
|
<TextInput
|
|
|
|
|
className={classes.textInput}
|
2022-12-18 22:27:01 +01:00
|
|
|
icon={<DebouncedAppIcon form={form} width={20} height={20} />}
|
2022-12-20 11:34:07 +09:00
|
|
|
label={t('appearance.icon.label')}
|
|
|
|
|
description={t('appearance.icon.description')}
|
2022-12-05 21:43:47 +01:00
|
|
|
variant="default"
|
|
|
|
|
withAsterisk
|
|
|
|
|
required
|
|
|
|
|
{...form.getInputProps('appearance.iconUrl')}
|
|
|
|
|
/>
|
|
|
|
|
<IconSelector
|
2022-12-11 19:32:51 +01:00
|
|
|
onChange={(item) => {
|
2022-12-05 21:43:47 +01:00
|
|
|
form.setValues({
|
|
|
|
|
appearance: {
|
|
|
|
|
iconUrl: item.url,
|
|
|
|
|
},
|
2022-12-11 19:32:51 +01:00
|
|
|
});
|
2022-12-18 22:27:01 +01:00
|
|
|
disallowAppNameProgagation();
|
2022-12-11 19:32:51 +01:00
|
|
|
}}
|
2022-12-18 22:27:01 +01:00
|
|
|
allowAppNamePropagation={allowAppNamePropagation}
|
2022-12-11 19:32:51 +01:00
|
|
|
form={form}
|
2022-12-05 21:43:47 +01:00
|
|
|
/>
|
|
|
|
|
</Flex>
|
2022-12-04 21:19:40 +01:00
|
|
|
</Tabs.Panel>
|
|
|
|
|
);
|
|
|
|
|
};
|
2022-12-05 20:04:08 +01:00
|
|
|
|
|
|
|
|
const useStyles = createStyles(() => ({
|
2022-12-05 21:43:47 +01:00
|
|
|
textInput: {
|
|
|
|
|
flexGrow: 1,
|
|
|
|
|
},
|
2022-12-05 20:04:08 +01:00
|
|
|
}));
|