2024-02-21 02:11:03 +03:00
|
|
|
import { useEffect } from "react";
|
2023-11-14 12:56:22 +03:00
|
|
|
import { FormProvider, useForm } from "react-hook-form";
|
2024-02-15 03:37:33 +03:00
|
|
|
import { useTranslation } from "react-i18next";
|
2023-09-20 10:35:09 +03:00
|
|
|
|
2024-02-15 03:37:33 +03:00
|
|
|
import { Modal } from "@/lib/components/ui/Modal/Modal";
|
2023-11-15 14:42:19 +03:00
|
|
|
import { addBrainDefaultValues } from "@/lib/config/defaultBrainConfig";
|
2023-07-25 13:08:08 +03:00
|
|
|
|
2024-02-15 03:37:33 +03:00
|
|
|
import styles from "./AddBrainModal.module.scss";
|
|
|
|
import { useBrainCreationContext } from "./brainCreation-provider";
|
|
|
|
import { BrainMainInfosStep } from "./components/BrainMainInfosStep/BrainMainInfosStep";
|
|
|
|
import { BrainTypeSelectionStep } from "./components/BrainTypeSelectionStep/BrainTypeSelectionStep";
|
2024-02-21 02:11:03 +03:00
|
|
|
import { CreateBrainStep } from "./components/CreateBrainStep/CreateBrainStep";
|
2024-02-15 03:37:33 +03:00
|
|
|
import { Stepper } from "./components/Stepper/Stepper";
|
|
|
|
import { CreateBrainProps } from "./types/types";
|
2023-07-25 13:08:08 +03:00
|
|
|
|
2024-02-07 03:05:07 +03:00
|
|
|
export const AddBrainModal = (): JSX.Element => {
|
2024-02-15 03:37:33 +03:00
|
|
|
const { t } = useTranslation(["translation", "brain", "config"]);
|
|
|
|
|
2024-02-21 02:11:03 +03:00
|
|
|
const {
|
|
|
|
isBrainCreationModalOpened,
|
|
|
|
setIsBrainCreationModalOpened,
|
|
|
|
setCurrentIntegrationBrain,
|
|
|
|
} = useBrainCreationContext();
|
2024-02-15 03:37:33 +03:00
|
|
|
|
2023-11-15 14:42:19 +03:00
|
|
|
const defaultValues: CreateBrainProps = {
|
|
|
|
...addBrainDefaultValues,
|
|
|
|
setDefault: true,
|
2023-12-05 13:52:56 +03:00
|
|
|
brainCreationStep: "BRAIN_TYPE",
|
2023-11-15 14:42:19 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
const methods = useForm<CreateBrainProps>({
|
|
|
|
defaultValues,
|
2023-11-14 12:56:22 +03:00
|
|
|
});
|
2023-07-25 13:08:08 +03:00
|
|
|
|
2024-02-21 02:11:03 +03:00
|
|
|
useEffect(() => {
|
|
|
|
setCurrentIntegrationBrain(undefined);
|
|
|
|
}, [isBrainCreationModalOpened]);
|
|
|
|
|
2023-07-25 13:08:08 +03:00
|
|
|
return (
|
2023-11-14 12:56:22 +03:00
|
|
|
<FormProvider {...methods}>
|
2024-02-15 03:37:33 +03:00
|
|
|
<Modal
|
|
|
|
title={t("newBrainTitle", { ns: "brain" })}
|
|
|
|
desc={t("newBrainSubtitle", { ns: "brain" })}
|
|
|
|
isOpen={isBrainCreationModalOpened}
|
|
|
|
setOpen={setIsBrainCreationModalOpened}
|
|
|
|
bigModal={true}
|
|
|
|
CloseTrigger={<div />}
|
|
|
|
>
|
|
|
|
<div className={styles.add_brain_modal_container}>
|
|
|
|
<div className={styles.stepper_container}>
|
|
|
|
<Stepper />
|
|
|
|
</div>
|
|
|
|
<div className={styles.content_wrapper}>
|
|
|
|
<BrainTypeSelectionStep />
|
|
|
|
<BrainMainInfosStep />
|
2024-02-21 02:11:03 +03:00
|
|
|
<CreateBrainStep />
|
2024-02-15 03:37:33 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Modal>
|
2023-11-14 12:56:22 +03:00
|
|
|
</FormProvider>
|
2023-07-25 13:08:08 +03:00
|
|
|
);
|
|
|
|
};
|