Merge branch 'preview/advisor-short-path' into 'develop'
Preview/advisor short path See merge request witapp/aura-webapp!78
This commit is contained in:
commit
d40cc37f76
@ -285,30 +285,39 @@ function App(): JSX.Element {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Route
|
<Route
|
||||||
path={routes.client.advisorChatGender()}
|
element={
|
||||||
element={<GenderPage />}
|
<CheckIsAuthOutlet
|
||||||
/>
|
redirectUrl={routes.client.singlePaymentShortPath("chat.aura")}
|
||||||
<Route
|
pageType={EIsAuthPageType.private}
|
||||||
path={routes.client.advisorChatBirthdate()}
|
/>
|
||||||
element={<BirthdayPage />}
|
}
|
||||||
/>
|
>
|
||||||
<Route
|
<Route
|
||||||
path={routes.client.advisorChatBirthtime()}
|
path={routes.client.advisorChatGender()}
|
||||||
element={<BirthtimePage />}
|
element={<GenderPage />}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path={routes.client.advisorChatBirthPlace()}
|
path={routes.client.advisorChatBirthdate()}
|
||||||
element={<BirthPlacePage />}
|
element={<BirthdayPage />}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path={routes.client.advisorChatSuccessPayment()}
|
path={routes.client.advisorChatBirthtime()}
|
||||||
element={<SuccessPaymentPage />}
|
element={<BirthtimePage />}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path={routes.client.advisorChatFailPayment()}
|
path={routes.client.advisorChatBirthPlace()}
|
||||||
element={<FailPaymentPage />}
|
element={<BirthPlacePage />}
|
||||||
/>
|
/>
|
||||||
|
</Route>
|
||||||
</Route>
|
</Route>
|
||||||
|
<Route
|
||||||
|
path={routes.client.advisorChatSuccessPayment()}
|
||||||
|
element={<SuccessPaymentPage />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path={routes.client.advisorChatFailPayment()}
|
||||||
|
element={<FailPaymentPage />}
|
||||||
|
/>
|
||||||
|
|
||||||
<Route
|
<Route
|
||||||
element={
|
element={
|
||||||
@ -757,6 +766,30 @@ function Layout({ setIsSpecialOfferOpen }: LayoutProps): JSX.Element {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum EIsAuthPageType {
|
||||||
|
private,
|
||||||
|
public,
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ICheckIsAuthOutletProps {
|
||||||
|
redirectUrl: string;
|
||||||
|
pageType: EIsAuthPageType;
|
||||||
|
}
|
||||||
|
|
||||||
|
function CheckIsAuthOutlet({
|
||||||
|
redirectUrl,
|
||||||
|
pageType,
|
||||||
|
}: ICheckIsAuthOutletProps): JSX.Element {
|
||||||
|
const { user } = useAuth();
|
||||||
|
if (user && pageType === EIsAuthPageType.public) {
|
||||||
|
return <Navigate to={redirectUrl} replace={true} />;
|
||||||
|
}
|
||||||
|
if (!user && pageType === EIsAuthPageType.private) {
|
||||||
|
return <Navigate to={redirectUrl} replace={true} />;
|
||||||
|
}
|
||||||
|
return <Outlet />;
|
||||||
|
}
|
||||||
|
|
||||||
interface ICheckPurchasedSingleProductOutletProps {
|
interface ICheckPurchasedSingleProductOutletProps {
|
||||||
productKey: string;
|
productKey: string;
|
||||||
isProductPage: boolean;
|
isProductPage: boolean;
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import Message from "./components/Message";
|
|||||||
import LoaderDots from "./components/LoaderDots";
|
import LoaderDots from "./components/LoaderDots";
|
||||||
import useDetectScroll from "@smakss/react-scroll-direction";
|
import useDetectScroll from "@smakss/react-scroll-direction";
|
||||||
import { getZodiacSignByDate } from "@/services/zodiac-sign";
|
import { getZodiacSignByDate } from "@/services/zodiac-sign";
|
||||||
|
import { useAuth } from "@/auth";
|
||||||
|
|
||||||
function AdvisorChatPage() {
|
function AdvisorChatPage() {
|
||||||
const isPrivateChat = window.location.href.includes("/advisor-chat-private/");
|
const isPrivateChat = window.location.href.includes("/advisor-chat-private/");
|
||||||
@ -29,6 +30,7 @@ function AdvisorChatPage() {
|
|||||||
const { gender, birthtime, birthPlace } = useSelector(
|
const { gender, birthtime, birthPlace } = useSelector(
|
||||||
selectors.selectQuestionnaire
|
selectors.selectQuestionnaire
|
||||||
);
|
);
|
||||||
|
const { user } = useAuth();
|
||||||
const [assistant, setAssistant] = useState<IAssistant>();
|
const [assistant, setAssistant] = useState<IAssistant>();
|
||||||
const [messageText, setMessageText] = useState("");
|
const [messageText, setMessageText] = useState("");
|
||||||
const [textareaRows, setTextareaRows] = useState(1);
|
const [textareaRows, setTextareaRows] = useState(1);
|
||||||
@ -200,11 +202,13 @@ function AdvisorChatPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getContentMessage = (messageText: string) => {
|
const getContentMessage = (messageText: string) => {
|
||||||
const content = `#USER INFO: zodiac sign - ${zodiacSign}; gender - ${gender}; birthdate - ${birthdate}; name - ${
|
const sign = zodiacSign || user?.profile?.sign || "unknown";
|
||||||
username || "unknown"
|
const _gender = gender || user?.profile?.gender || "unknown";
|
||||||
}; birthtime - ${birthtime || "unknown"}; birthPlace - ${
|
const _birthDate = birthdate || user?.profile?.birthday || "unknown";
|
||||||
birthPlace || "unknown"
|
const _birthtime = birthtime || "unknown";
|
||||||
}# ${messageText}`;
|
const _birthPlace = birthPlace || user?.profile?.birthplace || "unknown";
|
||||||
|
const name = username || user?.profile?.full_name || "unknown";
|
||||||
|
const content = `#USER INFO: zodiac sign - ${sign}; gender - ${_gender}; birthdate - ${_birthDate}; name - ${name}; birthtime - ${_birthtime}; birthPlace - ${_birthPlace}# ${messageText}`;
|
||||||
return content;
|
return content;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -21,8 +21,8 @@ import { useSinglePayment } from "@/hooks/payment/useSinglePayment";
|
|||||||
function PaymentWithEmailPage() {
|
function PaymentWithEmailPage() {
|
||||||
const { productId } = useParams();
|
const { productId } = useParams();
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
const tokenFromStore = useSelector(selectors.selectToken);
|
// const tokenFromStore = useSelector(selectors.selectToken);
|
||||||
const { signUp, user: userFromStore } = useAuth();
|
const { signUp, user: userFromStore, token: tokenFromStore } = useAuth();
|
||||||
const api = useApi();
|
const api = useApi();
|
||||||
const timezone = getClientTimezone();
|
const timezone = getClientTimezone();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@ -164,8 +164,7 @@ function PaymentWithEmailPage() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
handleAuthUser();
|
handleAuthUser();
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
}, [handleAuthUser]);
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`${styles.page} page`}>
|
<div className={`${styles.page} page`}>
|
||||||
|
|||||||
@ -69,18 +69,16 @@ export const useSinglePayment = () => {
|
|||||||
token,
|
token,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (
|
if ("active" in purchased && purchased.active) {
|
||||||
"active" in purchased &&
|
return true;
|
||||||
purchased.active &&
|
|
||||||
productUrls[productKey].length
|
|
||||||
) {
|
|
||||||
return navigate(productUrls[productKey]);
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
return false;
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[api, navigate]
|
[api]
|
||||||
);
|
);
|
||||||
|
|
||||||
const createSinglePayment = useCallback(
|
const createSinglePayment = useCallback(
|
||||||
@ -98,7 +96,14 @@ export const useSinglePayment = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setProduct(product);
|
setProduct(product);
|
||||||
await checkProductPurchased(user?.email || "", targetProductKey, token);
|
const isPurchased = await checkProductPurchased(
|
||||||
|
user?.email || "",
|
||||||
|
targetProductKey,
|
||||||
|
token
|
||||||
|
);
|
||||||
|
if (isPurchased && productUrls[targetProductKey].length) {
|
||||||
|
return navigate(productUrls[targetProductKey]);
|
||||||
|
}
|
||||||
const paymentIntent = await api.createSinglePayment({
|
const paymentIntent = await api.createSinglePayment({
|
||||||
token,
|
token,
|
||||||
data: {
|
data: {
|
||||||
@ -140,6 +145,7 @@ export const useSinglePayment = () => {
|
|||||||
gender,
|
gender,
|
||||||
getCurrentProduct,
|
getCurrentProduct,
|
||||||
handlerPaymentIntentResult,
|
handlerPaymentIntentResult,
|
||||||
|
navigate,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user