2022-06-07 00:07:56 +00:00
|
|
|
import { TextInput, Group, Button } from '@mantine/core';
|
2022-06-07 01:35:50 +00:00
|
|
|
import { useForm } from '@mantine/form';
|
2022-06-07 00:07:56 +00:00
|
|
|
import { useConfig } from '../../tools/state';
|
|
|
|
|
|
|
|
|
|
export default function TitleChanger() {
|
2022-06-07 08:21:03 +02:00
|
|
|
const { config, setConfig } = useConfig();
|
2022-06-07 00:07:56 +00:00
|
|
|
|
2022-06-07 01:35:50 +00:00
|
|
|
const form = useForm({
|
|
|
|
|
initialValues: {
|
|
|
|
|
title: config.settings.title,
|
|
|
|
|
logo: config.settings.logo,
|
|
|
|
|
favicon: config.settings.favicon,
|
2022-06-07 17:36:05 +00:00
|
|
|
background: config.settings.background,
|
2022-06-07 01:35:50 +00:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2022-06-07 17:36:05 +00:00
|
|
|
const saveChanges = (values: {
|
|
|
|
|
title?: string;
|
|
|
|
|
logo?: string;
|
|
|
|
|
favicon?: string;
|
|
|
|
|
background?: string;
|
|
|
|
|
}) => {
|
2022-06-07 00:07:56 +00:00
|
|
|
setConfig({
|
|
|
|
|
...config,
|
2022-06-07 01:35:50 +00:00
|
|
|
settings: {
|
|
|
|
|
...config.settings,
|
|
|
|
|
title: values.title,
|
|
|
|
|
logo: values.logo,
|
|
|
|
|
favicon: values.favicon,
|
2022-06-07 17:36:05 +00:00
|
|
|
background: values.background,
|
2022-06-07 01:35:50 +00:00
|
|
|
},
|
2022-06-07 00:07:56 +00:00
|
|
|
});
|
2022-06-07 01:35:50 +00:00
|
|
|
};
|
2022-06-07 00:07:56 +00:00
|
|
|
|
|
|
|
|
return (
|
2022-06-07 08:21:03 +02:00
|
|
|
<Group direction="column" grow>
|
|
|
|
|
<form onSubmit={form.onSubmit((values) => saveChanges(values))}>
|
|
|
|
|
<Group grow direction="column">
|
2022-06-07 12:12:23 +02:00
|
|
|
<TextInput label="Page title" placeholder="Homarr 🦞" {...form.getInputProps('title')} />
|
2022-06-07 08:21:03 +02:00
|
|
|
<TextInput label="Logo" placeholder="/img/logo.png" {...form.getInputProps('logo')} />
|
|
|
|
|
<TextInput
|
|
|
|
|
label="Favicon"
|
|
|
|
|
placeholder="/favicon.svg"
|
|
|
|
|
{...form.getInputProps('favicon')}
|
|
|
|
|
/>
|
2022-06-07 17:36:05 +00:00
|
|
|
<TextInput label="Background" placeholder="" {...form.getInputProps('background')} />
|
2022-06-07 16:53:51 +00:00
|
|
|
<Button type="submit" color={config.settings.primary_color || 'red'}>
|
|
|
|
|
Save
|
|
|
|
|
</Button>
|
2022-06-07 08:21:03 +02:00
|
|
|
</Group>
|
|
|
|
|
</form>
|
|
|
|
|
</Group>
|
2022-06-07 00:07:56 +00:00
|
|
|
);
|
|
|
|
|
}
|