feishin/src/renderer/features/settings/components/settings-header.tsx

49 lines
1.6 KiB
TypeScript
Raw Normal View History

2023-03-31 05:56:32 -07:00
import { Flex, Group } from '@mantine/core';
import { closeAllModals, openModal } from '@mantine/modals';
import { RiSettings2Fill } from 'react-icons/ri';
2023-03-31 05:56:32 -07:00
import { Button, ConfirmModal, PageHeader } from '/@/renderer/components';
import { LibraryHeaderBar } from '/@/renderer/features/shared';
2023-03-31 05:56:32 -07:00
import { useSettingsStoreActions } from '../../../store/settings.store';
export const SettingsHeader = () => {
2023-07-01 19:10:05 -07:00
const { reset } = useSettingsStoreActions();
2023-03-31 05:56:32 -07:00
2023-07-01 19:10:05 -07:00
const handleResetToDefault = () => {
reset();
closeAllModals();
};
2023-03-31 05:56:32 -07:00
2023-07-01 19:10:05 -07:00
const openResetConfirmModal = () => {
openModal({
children: <ConfirmModal onConfirm={handleResetToDefault}>Are you sure?</ConfirmModal>,
title: 'Reset settings to default',
});
};
2023-03-31 05:56:32 -07:00
2023-07-01 19:10:05 -07:00
return (
<Flex>
<PageHeader>
<LibraryHeaderBar>
<Flex
align="center"
justify="space-between"
w="100%"
>
<Group noWrap>
<RiSettings2Fill size="2rem" />
<LibraryHeaderBar.Title>Settings</LibraryHeaderBar.Title>
</Group>
<Button
compact
variant="default"
onClick={openResetConfirmModal}
>
Reset to default
</Button>
</Flex>
</LibraryHeaderBar>
</PageHeader>
</Flex>
);
};