2023-07-18 12:26:57 +00:00
|
|
|
"use client";
|
|
|
|
|
|
2023-05-24 20:27:57 +00:00
|
|
|
import { FC, useEffect } from "react";
|
2023-02-13 13:46:56 +00:00
|
|
|
import { useTranslate } from "react-polyglot";
|
2023-07-18 12:26:57 +00:00
|
|
|
import { useRouter, usePathname } from "next/navigation";
|
2023-02-13 13:46:56 +00:00
|
|
|
import { Box, Grid } from "@mui/material";
|
|
|
|
|
import { useCookies } from "react-cookie";
|
2023-07-18 12:26:57 +00:00
|
|
|
import { useAppContext } from "app/_components/AppProvider";
|
|
|
|
|
import { PageHeader } from "app/_components/PageHeader";
|
|
|
|
|
import { VisualizationBuilder } from "app/_components/VisualizationBuilder";
|
2023-02-13 13:46:56 +00:00
|
|
|
|
2023-05-24 20:27:57 +00:00
|
|
|
type CreateProps = {
|
|
|
|
|
templates: any;
|
|
|
|
|
};
|
|
|
|
|
|
2023-07-18 12:26:57 +00:00
|
|
|
export const Create: FC<CreateProps> = ({ templates }) => {
|
2023-02-13 13:46:56 +00:00
|
|
|
const t = useTranslate();
|
|
|
|
|
const {
|
|
|
|
|
colors: { cdrLinkOrange },
|
|
|
|
|
typography: { h1, h4 },
|
|
|
|
|
} = useAppContext();
|
|
|
|
|
const router = useRouter();
|
2023-07-18 12:26:57 +00:00
|
|
|
const pathname = usePathname();
|
2023-02-13 13:46:56 +00:00
|
|
|
const cookieName = "searchIntroComplete";
|
|
|
|
|
const [cookies, setCookie] = useCookies([cookieName]);
|
|
|
|
|
const searchIntroComplete = parseInt(cookies[cookieName], 10) || 0;
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (searchIntroComplete === 0) {
|
|
|
|
|
setCookie(cookieName, `${1}`, { path: "/" });
|
2023-07-18 12:26:57 +00:00
|
|
|
router.push(`${pathname}?group=search&tooltip=1&checklist=1`);
|
2023-02-13 13:46:56 +00:00
|
|
|
}
|
|
|
|
|
}, [searchIntroComplete, router, setCookie]);
|
|
|
|
|
|
|
|
|
|
return (
|
2023-07-18 12:26:57 +00:00
|
|
|
<>
|
2023-02-13 13:46:56 +00:00
|
|
|
<PageHeader backgroundColor={cdrLinkOrange}>
|
|
|
|
|
<Grid container direction="row" spacing={2} alignItems="center">
|
|
|
|
|
{/* <Grid item xs={2} sx={{ textAlign: "center" }}>
|
|
|
|
|
<Image src={SearchCreateHeader} width={100} height={100} alt="" />
|
|
|
|
|
</Grid> */}
|
|
|
|
|
<Grid container direction="column" item xs={10}>
|
|
|
|
|
<Grid item>
|
|
|
|
|
<Box component="h1" sx={{ ...h1 }}>
|
|
|
|
|
{t("searchAndCreateTitle")}
|
|
|
|
|
</Box>
|
|
|
|
|
</Grid>
|
|
|
|
|
<Grid item>
|
|
|
|
|
<Box component="h4" sx={{ ...h4, mt: 1, mb: 1 }}>
|
|
|
|
|
{t("searchAndCreateSubtitle")}
|
|
|
|
|
</Box>
|
|
|
|
|
</Grid>
|
|
|
|
|
{/* <Grid>
|
|
|
|
|
<Box component="p" sx={{ ...p }}>
|
|
|
|
|
{t("searchAndCreateDescription")}
|
|
|
|
|
</Box>
|
|
|
|
|
</Grid> */}
|
|
|
|
|
</Grid>
|
|
|
|
|
</Grid>
|
|
|
|
|
</PageHeader>
|
|
|
|
|
<VisualizationBuilder templates={templates} />
|
2023-07-18 12:26:57 +00:00
|
|
|
</>
|
2023-02-13 13:46:56 +00:00
|
|
|
);
|
|
|
|
|
};
|