2022-12-04 17:36:30 +01:00
|
|
|
import { Group, Stack } from '@mantine/core';
|
|
|
|
|
import { useMemo } from 'react';
|
|
|
|
|
import { useConfigContext } from '../../../config/provider';
|
2022-12-10 22:14:31 +01:00
|
|
|
import { CategoryType } from '../../../types/category';
|
|
|
|
|
import { WrapperType } from '../../../types/wrapper';
|
|
|
|
|
import { DashboardCategory } from '../Wrappers/Category/Category';
|
2022-12-04 17:36:30 +01:00
|
|
|
import { DashboardSidebar } from '../Wrappers/Sidebar/Sidebar';
|
2022-12-10 22:14:31 +01:00
|
|
|
import { DashboardWrapper } from '../Wrappers/Wrapper/Wrapper';
|
2022-12-04 17:36:30 +01:00
|
|
|
|
|
|
|
|
export const DashboardView = () => {
|
|
|
|
|
const wrappers = useWrapperItems();
|
2022-12-10 22:14:31 +01:00
|
|
|
const clockModule = useConfigContext().config?.integrations.clock;
|
2022-12-04 17:36:30 +01:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Group align="top" h="100%">
|
2022-12-10 22:14:31 +01:00
|
|
|
<DashboardSidebar location="left" />
|
2022-12-04 17:36:30 +01:00
|
|
|
<Stack mx={-10} style={{ flexGrow: 1 }}>
|
2022-12-10 22:14:31 +01:00
|
|
|
{wrappers.map((item) =>
|
|
|
|
|
item.type === 'category' ? (
|
|
|
|
|
<DashboardCategory key={item.id} category={item as unknown as CategoryType} />
|
|
|
|
|
) : (
|
|
|
|
|
<DashboardWrapper key={item.id} wrapper={item as WrapperType} />
|
|
|
|
|
)
|
2022-12-04 17:36:30 +01:00
|
|
|
)}
|
|
|
|
|
</Stack>
|
2022-12-10 22:14:31 +01:00
|
|
|
<DashboardSidebar location="right" />
|
2022-12-04 17:36:30 +01:00
|
|
|
</Group>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const useWrapperItems = () => {
|
|
|
|
|
const { config } = useConfigContext();
|
|
|
|
|
|
|
|
|
|
return useMemo(
|
|
|
|
|
() =>
|
|
|
|
|
config
|
|
|
|
|
? [
|
|
|
|
|
...config.categories.map((c) => ({ ...c, type: 'category' })),
|
|
|
|
|
...config.wrappers.map((w) => ({ ...w, type: 'wrapper' })),
|
|
|
|
|
].sort((a, b) => a.position - b.position)
|
|
|
|
|
: [],
|
|
|
|
|
[config?.categories, config?.wrappers]
|
|
|
|
|
);
|
|
|
|
|
};
|