();
const [messageText, setMessageText] = useState("");
const [textareaRows, setTextareaRows] = useState(1);
@@ -200,11 +202,13 @@ function AdvisorChatPage() {
};
const getContentMessage = (messageText: string) => {
- const content = `#USER INFO: zodiac sign - ${zodiacSign}; gender - ${gender}; birthdate - ${birthdate}; name - ${
- username || "unknown"
- }; birthtime - ${birthtime || "unknown"}; birthPlace - ${
- birthPlace || "unknown"
- }# ${messageText}`;
+ const sign = zodiacSign || user?.profile?.sign || "unknown";
+ const _gender = gender || user?.profile?.gender || "unknown";
+ const _birthDate = birthdate || user?.profile?.birthday || "unknown";
+ const _birthtime = birthtime || "unknown";
+ 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;
};
diff --git a/src/components/pages/PaymentWithEmailPage/index.tsx b/src/components/pages/PaymentWithEmailPage/index.tsx
index 83e5cd5..d72afa8 100644
--- a/src/components/pages/PaymentWithEmailPage/index.tsx
+++ b/src/components/pages/PaymentWithEmailPage/index.tsx
@@ -21,8 +21,8 @@ import { useSinglePayment } from "@/hooks/payment/useSinglePayment";
function PaymentWithEmailPage() {
const { productId } = useParams();
const { t, i18n } = useTranslation();
- const tokenFromStore = useSelector(selectors.selectToken);
- const { signUp, user: userFromStore } = useAuth();
+ // const tokenFromStore = useSelector(selectors.selectToken);
+ const { signUp, user: userFromStore, token: tokenFromStore } = useAuth();
const api = useApi();
const timezone = getClientTimezone();
const dispatch = useDispatch();
@@ -164,8 +164,7 @@ function PaymentWithEmailPage() {
useEffect(() => {
handleAuthUser();
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, []);
+ }, [handleAuthUser]);
return (
diff --git a/src/hooks/payment/useSinglePayment.ts b/src/hooks/payment/useSinglePayment.ts
index cb6d133..8b82e48 100644
--- a/src/hooks/payment/useSinglePayment.ts
+++ b/src/hooks/payment/useSinglePayment.ts
@@ -69,18 +69,16 @@ export const useSinglePayment = () => {
token,
});
- if (
- "active" in purchased &&
- purchased.active &&
- productUrls[productKey].length
- ) {
- return navigate(productUrls[productKey]);
+ if ("active" in purchased && purchased.active) {
+ return true;
}
+ return false;
} catch (error) {
+ return false;
console.error(error);
}
},
- [api, navigate]
+ [api]
);
const createSinglePayment = useCallback(
@@ -98,7 +96,14 @@ export const useSinglePayment = () => {
return;
}
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({
token,
data: {
@@ -140,6 +145,7 @@ export const useSinglePayment = () => {
gender,
getCurrentProduct,
handlerPaymentIntentResult,
+ navigate,
]
);