Merge branch 'develop' into 'main'

Develop

See merge request witapp/aura-webapp!486
This commit is contained in:
Daniil Chemerkin 2024-11-22 16:31:24 +00:00
commit 107cc80154
25 changed files with 264 additions and 45 deletions

View File

@ -20,11 +20,11 @@ export interface PayloadUpdate {
profile?: Partial<ICreateAuthorizeUser>;
partner?: Partial<Exclude<ICreateAuthorizeUser, "relationship_status">>;
answers?: Partial<IAnswersSession>;
answers?: Partial<IAnswersSessionPalmistry | IAnswersSessionChats>;
}
}
export interface IAnswersSession {
export interface IAnswersSessionPalmistry {
what_aspects: 'love_relationships' | 'health_vitality' | 'career_destiny', // Type: string, optional - 'love_relationships' | 'health_vitality' | 'career_destiny';
relationship_status: 'single' | 'in_relationship', // Type: string, optional - 'single' | 'in_relationship';
element_resonates: 'water' | 'fire' | 'air' | 'earth', // Type: string, optional - 'water' | 'fire' | 'air' | 'earth';
@ -37,6 +37,37 @@ export interface IAnswersSession {
activities_independently: 1 | 2 | 3 | 4 | 5 // Type: number, optional - 1 | 2 | 3 | 4 | 5;
}
export interface IAnswersSessionChats {
psychicReading: string;
goal: string;
relationshipStatus: string;
satisfiedWithLife: string;
parentStatus: string;
whatEmotion: string;
whatYouWant: string;
missingInLife: string;
yourGoal: string;
somethingWorrying: string;
proneToOverthinking: string;
worriesImpact: string;
sensitiveToCriticism: string;
headOrHeart: string;
howConfident: string;
needGuidance: string;
decisionGuidance: string;
resonateLove: string;
resonateLife: string;
resonateFuture: string;
believeInSpirituality: string;
readingExperience: string;
interestedHowLong: string;
mainReason: string;
whatToExpect: string;
guidanceArea: string[];
psychicComfortable: string[];
userName: string;
}
export interface ResponseCreate {
status: "success" | string,
sessionId: string

View File

@ -20,6 +20,10 @@ export function createMethod<P, R>(createRequest: (payload: P) => Request) {
source = ESourceAuthorization["aura.palmistry.new"];
}
if (location.pathname.includes("/chats")) {
source = ESourceAuthorization["aura.chats"];
}
const sessionId = localStorage.getItem(`${source}_sessionId`);
if (sessionId?.length) {

View File

@ -2,6 +2,9 @@ import { useDispatch } from "react-redux";
import { IAnswer } from "../../data";
import styles from "./styles.module.scss";
import { actions } from "@/store";
import { useSession } from "@/hooks/session/useSession";
import { ESourceAuthorization } from "@/api/resources/User";
import routes from "@/routes";
interface IAnswerProps {
answer: IAnswer;
@ -10,6 +13,14 @@ interface IAnswerProps {
onClick?: () => void;
}
const notUpdateSessionRoutes = [
routes.client.chatsQuizSatisfiedWithLife(),
routes.client.chatsQuizProneToOverthinking(),
routes.client.chatsQuizHeadOrHeart(),
routes.client.chatsQuizDecisionGuidance(),
routes.client.chatsQuizReadingExperience(),
];
function Answer({
answer,
classNameContainer = "",
@ -17,8 +28,19 @@ function Answer({
onClick,
}: IAnswerProps) {
const dispatch = useDispatch();
const { updateSession } = useSession();
const handleClick = () => {
const handleClick = async () => {
if (!notUpdateSessionRoutes.includes(window.location.pathname)) {
await updateSession(
{
answers: {
[answer.questionId]: answer.name,
},
},
ESourceAuthorization["aura.chats"]
);
}
dispatch(
actions.chats.updateAnswers({
[answer.questionId]: answer.value,

View File

@ -8,15 +8,26 @@ import { useState } from "react";
import Button from "@/components/ChatsPath/ui/Button";
import ZodiacWheel from "@/components/ChatsPath/components/ZodiacWheel";
import { useUpdateStep } from "@/components/ChatsPath/hooks/useUpdateStep";
import { useSession } from "@/hooks/session/useSession";
import { ESourceAuthorization } from "@/api/resources/User";
function Date() {
const { updateSession } = useSession();
const dispatch = useDispatch();
useUpdateStep(4);
const navigate = useNavigate();
const birthdate = useSelector(selectors.selectBirthdate);
const [isDisabled, setIsDisabled] = useState(true);
const handleNext = () => {
const handleNext = async () => {
await updateSession(
{
profile: {
birthdate: `${birthdate} 00:00`,
},
},
ESourceAuthorization["aura.chats"]
);
navigate(routes.client.chatsQuizParentStatus());
};

View File

@ -10,13 +10,27 @@ import 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 DecisionGuidance() {
const { updateSession } = useSession();
useUpdateStep(18);
const navigate = useNavigate();
const answer = useSelector(selectors.selectAnswers)?.decisionGuidance;
const handleNext = () => {
const handleNext = async () => {
const _answer = answers.find((item) => item.value === answer);
if (_answer) {
await updateSession(
{
answers: {
decisionGuidance: _answer.name as string,
},
},
ESourceAuthorization["aura.chats"]
);
}
navigate(routes.client.chatsQuizResonateLove());
};

View File

@ -7,14 +7,25 @@ import MultiplyAnswers from "@/components/ChatsPath/components/MultiplyAnswers";
import Button from "@/components/ChatsPath/ui/Button";
import { useSelector } from "react-redux";
import { selectors } from "@/store";
import { useSession } from "@/hooks/session/useSession";
import { ESourceAuthorization } from "@/api/resources/User";
function GuidanceArea() {
const { updateSession } = useSession();
useUpdateStep(27);
const navigate = useNavigate();
const answer = useSelector(selectors.selectAnswers)?.guidanceArea;
const handleNext = () => {
const handleNext = async () => {
if (!answer?.length) return;
await updateSession(
{
answers: {
guidanceArea: answer,
},
},
ESourceAuthorization["aura.chats"]
);
navigate(routes.client.chatsQuizPsychicComfortable());
};

View File

@ -10,13 +10,27 @@ import 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 HeadOrHeart() {
const { updateSession } = useSession();
useUpdateStep(15);
const navigate = useNavigate();
const answer = useSelector(selectors.selectAnswers)?.headOrHeart;
const handleNext = () => {
const handleNext = async () => {
const _answer = answers.find((item) => item.value === answer);
if (_answer) {
await updateSession(
{
answers: {
headOrHeart: _answer.name as string,
},
},
ESourceAuthorization["aura.chats"]
);
}
navigate(routes.client.chatsQuizHowConfident());
};

View File

@ -10,16 +10,15 @@ import 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 handleNext = () => {
navigate(routes.client.chatsQuizWorriesImpact());
};
const answers: IAnswer[] = [
{
id: 1,
@ -59,6 +58,21 @@ function ProneToOverthinking() {
},
};
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>

View File

@ -8,14 +8,25 @@ import Button from "@/components/ChatsPath/ui/Button";
import { useSelector } from "react-redux";
import { selectors } from "@/store";
import Tip from "@/components/ChatsPath/components/Tip";
import { ESourceAuthorization } from "@/api/resources/User";
import { useSession } from "@/hooks/session/useSession";
function PsychicComfortable() {
const { updateSession } = useSession();
useUpdateStep(28);
const navigate = useNavigate();
const answer = useSelector(selectors.selectAnswers)?.psychicComfortable;
const handleNext = () => {
const handleNext = async () => {
if (!answer?.length) return;
await updateSession(
{
answers: {
psychicComfortable: answer,
},
},
ESourceAuthorization["aura.chats"]
);
navigate(routes.client.chatsQuizUserName());
};

View File

@ -10,13 +10,27 @@ import AnswerDescription, {
import { useSelector } from "react-redux";
import { selectors } from "@/store";
import Button from "@/components/ChatsPath/ui/Button";
import { ESourceAuthorization } from "@/api/resources/User";
import { useSession } from "@/hooks/session/useSession";
function ReadingExperience() {
const { updateSession } = useSession();
useUpdateStep(23);
const navigate = useNavigate();
const answer = useSelector(selectors.selectAnswers)?.readingExperience;
const handleNext = () => {
const handleNext = async () => {
const _answer = answers.find((item) => item.value === answer);
if (_answer) {
await updateSession(
{
answers: {
readingExperience: _answer.name as string,
},
},
ESourceAuthorization["aura.chats"]
);
}
navigate(routes.client.chatsQuizInterestedHowLong());
};

View File

@ -6,13 +6,24 @@ import { useDispatch } from "react-redux";
import { actions } from "@/store";
import YesNoButtons from "@/components/ChatsPath/components/YesNoButtons";
import { images } from "@/components/ChatsPath/data";
import { ESourceAuthorization } from "@/api/resources/User";
import { useSession } from "@/hooks/session/useSession";
function ResonateFuture() {
const { updateSession } = useSession();
const dispatch = useDispatch();
useUpdateStep(21);
const navigate = useNavigate();
const handleNext = (answer: "yes" | "no") => {
const handleNext = async (answer: "yes" | "no") => {
await updateSession(
{
answers: {
resonateFuture: answer,
},
},
ESourceAuthorization["aura.chats"]
);
dispatch(actions.chats.updateAnswers({ resonateFuture: answer }));
navigate(routes.client.chatsPreferencesIntro());
};

View File

@ -6,13 +6,24 @@ import { useDispatch } from "react-redux";
import { actions } from "@/store";
import YesNoButtons from "@/components/ChatsPath/components/YesNoButtons";
import { images } from "@/components/ChatsPath/data";
import { useSession } from "@/hooks/session/useSession";
import { ESourceAuthorization } from "@/api/resources/User";
function ResonateLife() {
const { updateSession } = useSession();
const dispatch = useDispatch();
useUpdateStep(20);
const navigate = useNavigate();
const handleNext = (answer: "yes" | "no") => {
const handleNext = async (answer: "yes" | "no") => {
await updateSession(
{
answers: {
resonateLife: answer,
},
},
ESourceAuthorization["aura.chats"]
);
dispatch(actions.chats.updateAnswers({ resonateLife: answer }));
navigate(routes.client.chatsQuizResonateFuture());
};

View File

@ -6,13 +6,24 @@ import { useDispatch } from "react-redux";
import { actions } from "@/store";
import YesNoButtons from "@/components/ChatsPath/components/YesNoButtons";
import { images } from "@/components/ChatsPath/data";
import { useSession } from "@/hooks/session/useSession";
import { ESourceAuthorization } from "@/api/resources/User";
function ResonateLove() {
const { updateSession } = useSession();
const dispatch = useDispatch();
useUpdateStep(19);
const navigate = useNavigate();
const handleNext = (answer: "yes" | "no") => {
const handleNext = async (answer: "yes" | "no") => {
await updateSession(
{
answers: {
resonateLove: answer,
},
},
ESourceAuthorization["aura.chats"]
);
dispatch(actions.chats.updateAnswers({ resonateLove: answer }));
navigate(routes.client.chatsQuizResonateLife());
};

View File

@ -10,16 +10,15 @@ import 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 SatisfiedWithLife() {
const { updateSession } = useSession();
useUpdateStep(6);
const navigate = useNavigate();
const answer = useSelector(selectors.selectAnswers)?.satisfiedWithLife;
const handleNext = () => {
navigate(routes.client.chatsQuizWhatEmotion());
};
const answers: IAnswer[] = [
{
id: 1,
@ -59,6 +58,21 @@ function SatisfiedWithLife() {
},
};
const handleNext = async () => {
const _answer = answers.find((item) => item.value === answer);
if (_answer) {
await updateSession(
{
answers: {
satisfiedWithLife: _answer.name as string,
},
},
ESourceAuthorization["aura.chats"]
);
}
navigate(routes.client.chatsQuizWhatEmotion());
};
return (
<>
<h2 className={`chats-answers-title ${styles.title}`}>

View File

@ -8,8 +8,11 @@ import { actions, selectors } from "@/store";
import Tip from "@/components/ChatsPath/components/Tip";
import NameInput from "@/components/pages/ABDesign/v1/pages/EmailEnterPage/NameInput";
import { useState } from "react";
import { ESourceAuthorization } from "@/api/resources/User";
import { useSession } from "@/hooks/session/useSession";
function UserName() {
const { updateSession } = useSession();
useUpdateStep(29);
const navigate = useNavigate();
const dispatch = useDispatch();
@ -17,8 +20,16 @@ function UserName() {
const [name, setName] = useState("");
const [isValidName, setIsValidName] = useState(false);
const handleNext = () => {
const handleNext = async () => {
if (!answer?.length) return;
await updateSession(
{
profile: {
name,
},
},
ESourceAuthorization["aura.chats"]
);
navigate(routes.client.chatsQuizProcessing());
};

View File

@ -12,12 +12,27 @@ import Address from "../../components/Address";
import { useNavigate } from "react-router-dom";
import routes from "@/routes";
import { useRef } from "react";
import { useSession } from "@/hooks/session/useSession";
import { EGender, ESourceAuthorization } from "@/api/resources/User";
function Welcome() {
const { createSession, updateSession } = useSession();
const navigate = useNavigate();
const genderScrollRef = useRef<HTMLDivElement>(null);
const handleNext = () => {
const handleNext = async (gender: string) => {
const session = await createSession(ESourceAuthorization["aura.chats"]);
if (session?.sessionId?.length) {
await updateSession(
{
profile: {
gender: EGender[gender as keyof typeof EGender],
},
},
ESourceAuthorization["aura.chats"],
session.sessionId
);
}
navigate(routes.client.chatsQuizPsychicReading());
};

View File

@ -15,7 +15,7 @@ import FireSVG from "../../images/SVG/Fire";
import AirSVG from "../../images/SVG/Air";
import EarthSVG from "../../images/SVG/Earth";
import { ELottieKeys, useLottie } from "@/hooks/lottie/useLottie";
import { IAnswersSession } from "@/api/resources/Session";
import { IAnswersSessionPalmistry } from "@/api/resources/Session";
import { useSession } from "@/hooks/session/useSession";
import { ESourceAuthorization } from "@/api/resources/User";
@ -30,7 +30,7 @@ function ElementResonates() {
});
const answers: {
id: IAnswersSession["element_resonates"];
id: IAnswersSessionPalmistry["element_resonates"];
title: string;
Icon: JSX.Element;
}[] = useMemo(
@ -59,7 +59,7 @@ function ElementResonates() {
[translate]
);
const handleClick = async (id: IAnswersSession["element_resonates"]) => {
const handleClick = async (id: IAnswersSessionPalmistry["element_resonates"]) => {
dispatch(actions.palmistryV1Answers.update({ elementResonates: id }));
await updateSession({
answers: {

View File

@ -12,7 +12,7 @@ import { ELocalesPlacement } from "@/locales";
import { useMemo } from "react";
import TabSVG from "../../images/SVG/Tab";
import { usePreloadImages } from "@/hooks/preload/images";
import { IAnswersSession } from "@/api/resources/Session";
import { IAnswersSessionPalmistry } from "@/api/resources/Session";
import { useSession } from "@/hooks/session/useSession";
import { ESourceAuthorization } from "@/api/resources/User";
@ -32,7 +32,7 @@ function FavoriteColor() {
]);
const answers: {
id: IAnswersSession["favorite_color"];
id: IAnswersSessionPalmistry["favorite_color"];
title: string;
color?: string;
}[] = useMemo(
@ -70,7 +70,7 @@ function FavoriteColor() {
[translate]
);
const handleClick = async (id: IAnswersSession["favorite_color"]) => {
const handleClick = async (id: IAnswersSessionPalmistry["favorite_color"]) => {
dispatch(actions.palmistryV1Answers.update({ favoriteColor: id }));
await updateSession({
answers: {

View File

@ -12,7 +12,7 @@ import { ELocalesPlacement } from "@/locales";
import { useMemo } from "react";
import { usePreloadImages } from "@/hooks/preload/images";
import { useSession } from "@/hooks/session/useSession";
import { IAnswersSession } from "@/api/resources/Session";
import { IAnswersSessionPalmistry } from "@/api/resources/Session";
import { ESourceAuthorization } from "@/api/resources/User";
function HeadOrHeart() {
@ -34,7 +34,7 @@ function HeadOrHeart() {
"/v1/palmistry/partners.png",
]);
const answers: { id: IAnswersSession["head_or_heart"]; title: string }[] =
const answers: { id: IAnswersSessionPalmistry["head_or_heart"]; title: string }[] =
useMemo(
() => [
{
@ -53,7 +53,7 @@ function HeadOrHeart() {
[translate]
);
const handleClick = async (id: IAnswersSession["head_or_heart"]) => {
const handleClick = async (id: IAnswersSessionPalmistry["head_or_heart"]) => {
dispatch(actions.palmistryV1Answers.update({ headOrHeart: id }));
await updateSession(
{

View File

@ -12,7 +12,7 @@ import { ELocalesPlacement } from "@/locales";
import { useMemo } from "react";
import { ELottieKeys, useLottie } from "@/hooks/lottie/useLottie";
import { useSession } from "@/hooks/session/useSession";
import { IAnswersSession } from "@/api/resources/Session";
import { IAnswersSessionPalmistry } from "@/api/resources/Session";
import { ESourceAuthorization } from "@/api/resources/User";
function RelationshipStatus() {
@ -28,7 +28,7 @@ function RelationshipStatus() {
});
const answers: {
id: IAnswersSession["relationship_status"];
id: IAnswersSessionPalmistry["relationship_status"];
title: string;
}[] = useMemo(
() => [
@ -44,7 +44,7 @@ function RelationshipStatus() {
[translate]
);
const handleClick = async (id: IAnswersSession["relationship_status"]) => {
const handleClick = async (id: IAnswersSessionPalmistry["relationship_status"]) => {
dispatch(actions.palmistryV1Answers.update({ relationshipStatus: id }));
await updateSession({
answers: {

View File

@ -12,7 +12,7 @@ import { useTranslations } from "@/hooks/translations";
import { useMemo } from "react";
import { ELottieKeys, useLottie } from "@/hooks/lottie/useLottie";
import { useSession } from "@/hooks/session/useSession";
import { IAnswersSession } from "@/api/resources/Session";
import { IAnswersSessionPalmistry } from "@/api/resources/Session";
import { ESourceAuthorization } from "@/api/resources/User";
function WhatAspects() {
@ -25,7 +25,7 @@ function WhatAspects() {
preloadKey: ELottieKeys.scalesHeartPalmistry,
});
const aspects: { id: IAnswersSession["what_aspects"]; title: string }[] =
const aspects: { id: IAnswersSessionPalmistry["what_aspects"]; title: string }[] =
useMemo(
() => [
{
@ -44,7 +44,7 @@ function WhatAspects() {
[translate]
);
const handleClick = async (id: IAnswersSession["what_aspects"]) => {
const handleClick = async (id: IAnswersSessionPalmistry["what_aspects"]) => {
dispatch(actions.palmistryV1Answers.update({ whatAspects: id }));
await updateSession(
{

View File

@ -4,7 +4,7 @@ import useSteps, {
ColorYouLikeChoice,
} from "../../../hooks/palmistry/use-steps";
import { useSession } from "@/hooks/session/useSession";
import { IAnswersSession } from "@/api/resources/Session";
import { IAnswersSessionPalmistry } from "@/api/resources/Session";
import { ESourceAuthorization } from "@/api/resources/User";
import { useTranslations } from "@/hooks/translations";
import { ELocalesPlacement } from "@/locales";
@ -19,7 +19,7 @@ export default function StepColorYouLike() {
{
answers: {
favorite_color:
choice.toLowerCase() as IAnswersSession["favorite_color"],
choice.toLowerCase() as IAnswersSessionPalmistry["favorite_color"],
},
},
ESourceAuthorization["aura.palmistry"]

View File

@ -1,7 +1,7 @@
import Button from "../button/button";
import useSteps, { DecisionsChoice } from "../../../hooks/palmistry/use-steps";
import { useSession } from "@/hooks/session/useSession";
import { IAnswersSession } from "@/api/resources/Session";
import { IAnswersSessionPalmistry } from "@/api/resources/Session";
import { ESourceAuthorization } from "@/api/resources/User";
import { ELocalesPlacement } from "@/locales";
import { useTranslations } from "@/hooks/translations";
@ -17,7 +17,7 @@ export default function StepDecisions() {
{
answers: {
head_or_heart:
choice.toLowerCase() as IAnswersSession["head_or_heart"],
choice.toLowerCase() as IAnswersSessionPalmistry["head_or_heart"],
},
},
ESourceAuthorization["aura.palmistry"]

View File

@ -3,7 +3,7 @@ import useSteps, {
ResonatedElementChoice,
} from "../../../hooks/palmistry/use-steps";
import { useSession } from "@/hooks/session/useSession";
import { IAnswersSession } from "@/api/resources/Session";
import { IAnswersSessionPalmistry } from "@/api/resources/Session";
import { ESourceAuthorization } from "@/api/resources/User";
import { useTranslations } from "@/hooks/translations";
import { ELocalesPlacement } from "@/locales";
@ -19,7 +19,7 @@ export default function StepResonatedElement() {
{
answers: {
element_resonates:
choice.toLowerCase() as IAnswersSession["element_resonates"],
choice.toLowerCase() as IAnswersSessionPalmistry["element_resonates"],
},
},
ESourceAuthorization["aura.palmistry"]

View File

@ -1,13 +1,13 @@
import Button from "../button/button";
import useSteps, { WishChoice } from "../../../hooks/palmistry/use-steps";
import { useSession } from "@/hooks/session/useSession";
import { IAnswersSession } from "@/api/resources/Session";
import { IAnswersSessionPalmistry } from "@/api/resources/Session";
import { ESourceAuthorization } from "@/api/resources/User";
import { useTranslations } from "@/hooks/translations";
import { ELocalesPlacement } from "@/locales";
const choiceForSession: {
[key in WishChoice]: IAnswersSession["what_aspects"];
[key in WishChoice]: IAnswersSessionPalmistry["what_aspects"];
} = {
[WishChoice.Love]: "love_relationships",
[WishChoice.Health]: "health_vitality",