add jwtToken to epe short path
This commit is contained in:
parent
d40cc37f76
commit
1ecd01b518
@ -1,4 +1,11 @@
|
|||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import {
|
||||||
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
useLayoutEffect,
|
||||||
|
useMemo,
|
||||||
|
useRef,
|
||||||
|
useState,
|
||||||
|
} from "react";
|
||||||
import {
|
import {
|
||||||
Routes,
|
Routes,
|
||||||
Route,
|
Route,
|
||||||
@ -127,7 +134,7 @@ function App(): JSX.Element {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const api = useApi();
|
const api = useApi();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { token, user, signUp } = useAuth();
|
const { token, user, signUp, logout } = useAuth();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const jwtToken = searchParams.get("token");
|
const jwtToken = searchParams.get("token");
|
||||||
|
|
||||||
@ -164,16 +171,17 @@ function App(): JSX.Element {
|
|||||||
const { data } = useApiCall<Asset[]>(assetsData);
|
const { data } = useApiCall<Asset[]>(assetsData);
|
||||||
|
|
||||||
// jwt auth
|
// jwt auth
|
||||||
useEffect(() => {
|
useLayoutEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
if (!jwtToken) return;
|
if (!jwtToken) return;
|
||||||
|
logout();
|
||||||
const auth = await api.auth({ jwt: jwtToken });
|
const auth = await api.auth({ jwt: jwtToken });
|
||||||
const {
|
const {
|
||||||
auth: { token, user },
|
auth: { token, user },
|
||||||
} = auth;
|
} = auth;
|
||||||
signUp(token, user);
|
signUp(token, user);
|
||||||
})();
|
})();
|
||||||
}, [api, jwtToken, signUp]);
|
}, [api, jwtToken, logout, signUp]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
@ -256,8 +264,22 @@ function App(): JSX.Element {
|
|||||||
<Route element={<Layout setIsSpecialOfferOpen={setIsSpecialOfferOpen} />}>
|
<Route element={<Layout setIsSpecialOfferOpen={setIsSpecialOfferOpen} />}>
|
||||||
<Route path={routes.client.loadingPage()} element={<LoadingPage />} />
|
<Route path={routes.client.loadingPage()} element={<LoadingPage />} />
|
||||||
{/* Email - Pay - Email */}
|
{/* Email - Pay - Email */}
|
||||||
<Route path={routes.client.epeGender()} element={<GenderPage />} />
|
<Route
|
||||||
<Route path={routes.client.epeBirthdate()} element={<BirthdayPage />} />
|
element={
|
||||||
|
<CheckIsAuthOutlet
|
||||||
|
redirectUrl={routes.client.singlePaymentShortPath(
|
||||||
|
"moons.pdf.aura"
|
||||||
|
)}
|
||||||
|
pageType={EIsAuthPageType.public}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Route path={routes.client.epeGender()} element={<GenderPage />} />
|
||||||
|
<Route
|
||||||
|
path={routes.client.epeBirthdate()}
|
||||||
|
element={<BirthdayPage />}
|
||||||
|
/>
|
||||||
|
</Route>
|
||||||
{/* <Route
|
{/* <Route
|
||||||
path={routes.client.epePayment()}
|
path={routes.client.epePayment()}
|
||||||
element={<PaymentWithEmailPage />}
|
element={<PaymentWithEmailPage />}
|
||||||
@ -288,7 +310,7 @@ function App(): JSX.Element {
|
|||||||
element={
|
element={
|
||||||
<CheckIsAuthOutlet
|
<CheckIsAuthOutlet
|
||||||
redirectUrl={routes.client.singlePaymentShortPath("chat.aura")}
|
redirectUrl={routes.client.singlePaymentShortPath("chat.aura")}
|
||||||
pageType={EIsAuthPageType.private}
|
pageType={EIsAuthPageType.public}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -147,7 +147,6 @@ function PaymentWithEmailPage() {
|
|||||||
if (!tokenFromStore.length || !userFromStore) {
|
if (!tokenFromStore.length || !userFromStore) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await createSinglePayment({
|
await createSinglePayment({
|
||||||
user: userFromStore,
|
user: userFromStore,
|
||||||
token: tokenFromStore,
|
token: tokenFromStore,
|
||||||
@ -187,9 +186,8 @@ function PaymentWithEmailPage() {
|
|||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{(!tokenFromStore ||
|
{(!tokenFromStore || !paymentIntent) &&
|
||||||
!paymentIntent ||
|
// || (productId !== "chat.aura" && !name.length)
|
||||||
(productId !== "chat.aura" && !name.length)) &&
|
|
||||||
!isLoadingSinglePayment &&
|
!isLoadingSinglePayment &&
|
||||||
!isLoadingAuth && (
|
!isLoadingAuth && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@ -8,6 +8,7 @@ export const productUrls: IProductUrls = {
|
|||||||
"chat.aura": routes.client.advisorChatPrivate(
|
"chat.aura": routes.client.advisorChatPrivate(
|
||||||
"asst_WWkAlT4Ovs6gKRy6VEn9LqNS"
|
"asst_WWkAlT4Ovs6gKRy6VEn9LqNS"
|
||||||
),
|
),
|
||||||
|
"moons.pdf.aura": routes.client.epeSuccessPayment(),
|
||||||
};
|
};
|
||||||
|
|
||||||
interface IPaymentResultPathsOfProducts {
|
interface IPaymentResultPathsOfProducts {
|
||||||
|
|||||||
@ -101,7 +101,7 @@ export const useSinglePayment = () => {
|
|||||||
targetProductKey,
|
targetProductKey,
|
||||||
token
|
token
|
||||||
);
|
);
|
||||||
if (isPurchased && productUrls[targetProductKey].length) {
|
if (isPurchased && productUrls[targetProductKey]?.length) {
|
||||||
return navigate(productUrls[targetProductKey]);
|
return navigate(productUrls[targetProductKey]);
|
||||||
}
|
}
|
||||||
const paymentIntent = await api.createSinglePayment({
|
const paymentIntent = await api.createSinglePayment({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user