w-aura/src/components/ChatsPath/pages/Answers/ProneToOverthinking/index.tsx
Daniil Chemerkin c0d0533235 Develop
2024-11-22 16:31:24 +00:00

96 lines
2.8 KiB
TypeScript

import styles from "./styles.module.scss";
import { useNavigate } from "react-router-dom";
import { useUpdateStep } from "@/components/ChatsPath/hooks/useUpdateStep";
import routes from "@/routes";
import { IAnswer } from "@/components/ChatsPath/data";
import Answers from "@/components/ChatsPath/components/Answers";
import AnswerDescription, {
IAnswerDescriptionProps,
} from "@/components/ChatsPath/components/AnswerDescription";
import { useSelector } from "react-redux";
import { selectors } from "@/store";
import Button from "@/components/ChatsPath/ui/Button";
import { useSession } from "@/hooks/session/useSession";
import { ESourceAuthorization } from "@/api/resources/User";
function ProneToOverthinking() {
const { updateSession } = useSession();
useUpdateStep(12);
const navigate = useNavigate();
const answer = useSelector(selectors.selectAnswers)?.proneToOverthinking;
const answers: IAnswer[] = [
{
id: 1,
value: "yes",
name: "Yes",
questionId: "proneToOverthinking",
},
{
id: 2,
value: "sometimes",
name: "Sometimes",
questionId: "proneToOverthinking",
},
{
id: 3,
value: "no",
name: "No",
questionId: "proneToOverthinking",
},
];
const descriptions: Record<string, IAnswerDescriptionProps> = {
yes: {
title: "🙌 Overthinking can be overwhelming",
description:
"We understand your concerns and will focus your first reading on bringing you clarity and easing your doubts",
},
sometimes: {
title: "🙌 We all need clarity at times",
description:
"Based on your responses, we will tailor your reading to provide certainty and ease your doubts",
},
no: {
title: "👍 You seem confident in your decisions",
description:
"Our psychics will help confirm that your intuition is leading you in the right direction",
},
};
const handleNext = async () => {
const _answer = answers.find((item) => item.value === answer);
if (_answer) {
await updateSession(
{
answers: {
proneToOverthinking: _answer.name as string,
},
},
ESourceAuthorization["aura.chats"]
);
}
navigate(routes.client.chatsQuizWorriesImpact());
};
return (
<>
<h2 className={`chats-answers-title`}>Are you prone to overthinking?</h2>
<Answers answers={answers} activeAnswer={answer} />
{!!answer && (
<AnswerDescription
title={descriptions[answer]?.title}
description={descriptions[answer]?.description}
/>
)}
{!!answer && (
<Button classNameContainer={styles.button} onClick={handleNext}>
Continue
</Button>
)}
</>
);
}
export default ProneToOverthinking;