omni-tools/src/components/ToolLayout.tsx

51 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-06-22 20:38:03 +01:00
import { Box } from '@mui/material';
import React, { ReactNode } from 'react';
import { Helmet } from 'react-helmet';
import ToolHeader from './ToolHeader';
2024-06-25 08:39:29 +01:00
import Separator from '@tools/Separator';
import AllTools from './allTools/AllTools';
import { getToolsByCategory } from '@tools/index';
2024-06-19 21:18:35 +01:00
2024-06-22 20:38:03 +01:00
export default function ToolLayout({
children,
title,
2024-06-23 01:26:04 +01:00
description,
2024-06-25 08:39:29 +01:00
image,
type
2024-06-22 20:38:03 +01:00
}: {
title: string;
description: string;
2024-06-23 01:26:04 +01:00
image?: string;
2024-06-22 20:38:03 +01:00
children: ReactNode;
2024-06-25 08:39:29 +01:00
type: string;
2024-06-22 20:38:03 +01:00
}) {
2024-06-25 08:39:29 +01:00
const otherCategoryTools =
getToolsByCategory()
.find((category) => category.type === type)
?.tools.filter((tool) => tool.name !== title)
.map((tool) => ({
title: tool.name,
description: tool.shortDescription,
link: '/' + tool.path
})) ?? [];
2024-06-22 20:38:03 +01:00
return (
<Box
width={'100%'}
display={'flex'}
flexDirection={'column'}
alignItems={'center'}
>
<Helmet>
<title>{`${title} - Omni Tools`}</title>
</Helmet>
<Box width={'85%'}>
2024-06-23 01:26:04 +01:00
<ToolHeader title={title} description={description} image={image} />
2024-06-22 20:38:03 +01:00
{children}
2024-06-25 08:39:29 +01:00
<Separator backgroundColor="#5581b5" margin="50px" />
<AllTools title="All Text Tools" toolCards={otherCategoryTools} />
2024-06-22 20:38:03 +01:00
</Box>
</Box>
);
2024-06-19 21:18:35 +01:00
}