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';
|
|
|
|
|
import { ServiceType } from '../../../../../../types/service';
|
2022-12-11 00:17:34 +01:00
|
|
|
import { DebouncedServiceIcon } from '../Shared/DebouncedServiceIcon';
|
2022-12-05 21:43:47 +01:00
|
|
|
import { IconSelector } from './IconSelector/IconSelector';
|
2022-12-04 21:19:40 +01:00
|
|
|
|
|
|
|
|
interface AppearanceTabProps {
|
|
|
|
|
form: UseFormReturnType<ServiceType, (values: ServiceType) => ServiceType>;
|
2022-12-11 19:32:51 +01:00
|
|
|
disallowServiceNameProgagation: () => void;
|
|
|
|
|
allowServiceNamePropagation: boolean;
|
2022-12-04 21:19:40 +01:00
|
|
|
}
|
|
|
|
|
|
2022-12-11 19:32:51 +01:00
|
|
|
export const AppearanceTab = ({
|
|
|
|
|
form,
|
|
|
|
|
disallowServiceNameProgagation,
|
|
|
|
|
allowServiceNamePropagation,
|
|
|
|
|
}: AppearanceTabProps) => {
|
2022-12-04 21:19:40 +01:00
|
|
|
const { t } = useTranslation('');
|
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
|
|
|
|
|
defaultValue={form.values.appearance.iconUrl}
|
|
|
|
|
className={classes.textInput}
|
2022-12-11 00:17:34 +01:00
|
|
|
icon={<DebouncedServiceIcon form={form} width={20} height={20} />}
|
2022-12-05 21:43:47 +01:00
|
|
|
label="Service Icon"
|
2022-12-06 20:48:35 +01:00
|
|
|
description="Logo of your service displayed in your dashboard. Must return a body content containg an image"
|
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
|
|
|
});
|
|
|
|
|
disallowServiceNameProgagation();
|
|
|
|
|
}}
|
|
|
|
|
allowServiceNamePropagation={allowServiceNamePropagation}
|
|
|
|
|
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
|
|
|
}));
|