Merge branch 'clone' into 'main'
fix: fix double request See merge request witapp/aura-webapp!13
This commit is contained in:
commit
818aa2341e
@ -14,6 +14,7 @@ import SubPlanInformation from "../SubPlanInformation";
|
||||
import Title from "../Title";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ISubscriptionPlan } from "@/api/resources/SubscriptionPlans";
|
||||
import ApplePayButton from "./ApplePayButton";
|
||||
|
||||
export function StripePage(): JSX.Element {
|
||||
const { i18n } = useTranslation();
|
||||
@ -31,7 +32,7 @@ export function StripePage(): JSX.Element {
|
||||
if (!activeSubPlan) {
|
||||
navigate(routes.client.priceList());
|
||||
}
|
||||
const timeoutRef = useRef<NodeJS.Timeout>();
|
||||
// const timeoutRef = useRef<NodeJS.Timeout>();
|
||||
|
||||
// const appleReceipt = async () => {
|
||||
// const { subscription_receipt } = await api.createSubscriptionReceipt({
|
||||
@ -58,6 +59,26 @@ export function StripePage(): JSX.Element {
|
||||
})();
|
||||
}, [activeSubPlan, api, locale, navigate]);
|
||||
|
||||
// useEffect(() => {
|
||||
// timeoutRef.current = setTimeout(async () => {
|
||||
// const { subscription_receipt } = await api.createSubscriptionReceipt({
|
||||
// token,
|
||||
// way: "stripe",
|
||||
// subscription_receipt: {
|
||||
// sub_plan_id: activeSubPlan?.id || "stripe.7",
|
||||
// },
|
||||
// });
|
||||
// const { client_secret } = subscription_receipt.data;
|
||||
// setClientSecret(client_secret);
|
||||
// setIsLoading(false);
|
||||
// }, 4000);
|
||||
// return () => {
|
||||
// if (timeoutRef.current) {
|
||||
// clearTimeout(timeoutRef.current);
|
||||
// }
|
||||
// };
|
||||
// }, [api, token]);
|
||||
|
||||
useEffect(() => {
|
||||
timeoutRef.current = setTimeout(async () => {
|
||||
const { subscription_receipt } = await api.createSubscriptionReceipt({
|
||||
@ -95,15 +116,11 @@ export function StripePage(): JSX.Element {
|
||||
)}
|
||||
{stripePromise && clientSecret && (
|
||||
<Elements stripe={stripePromise} options={{ clientSecret }}>
|
||||
<ApplePayButton activeSubPlan={activeSubPlan} />
|
||||
<CheckoutForm>
|
||||
<>
|
||||
{activeSubPlan && (
|
||||
<SubPlanInformation
|
||||
subPlan={activeSubPlan}
|
||||
subPlans={subPlans}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
{activeSubPlan && (
|
||||
<SubPlanInformation subPlan={activeSubPlan} subPlans={subPlans} />
|
||||
)}
|
||||
</CheckoutForm>
|
||||
</Elements>
|
||||
)}
|
||||
|
||||
@ -2,7 +2,7 @@ import { useTranslation } from "react-i18next";
|
||||
import styles from "./styles.module.css";
|
||||
import { ISubscriptionPlan } from "@/api/resources/SubscriptionPlans";
|
||||
import TotalToday from "./TotalToday";
|
||||
import ApplePayButton from "../StripePage/ApplePayButton";
|
||||
// import ApplePayButton from "../StripePage/ApplePayButton";
|
||||
import MainButton from "../MainButton";
|
||||
import { useApi } from "@/api";
|
||||
import { useAuth } from "@/auth";
|
||||
@ -87,7 +87,7 @@ function SubPlanInformation({
|
||||
{isLoading && <Loader />}
|
||||
</MainButton>
|
||||
)}
|
||||
<ApplePayButton activeSubPlan={subPlan} />
|
||||
{/* <ApplePayButton activeSubPlan={subPlan} /> */}
|
||||
<p className={styles.description}>
|
||||
{t("auweb.pay.information").replaceAll("%@", getPrice(subPlan))}
|
||||
</p>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user