Clone
This commit is contained in:
parent
7d5d53b901
commit
71d1be6416
@ -49,30 +49,28 @@ function SubscriptionPage(): JSX.Element {
|
|||||||
const [apiError, setApiError] = useState<ApiError | null>(null);
|
const [apiError, setApiError] = useState<ApiError | null>(null);
|
||||||
const [error, setError] = useState<boolean>(false);
|
const [error, setError] = useState<boolean>(false);
|
||||||
const [subPlans, setSubPlans] = useState<ISubscriptionPlan[]>([]);
|
const [subPlans, setSubPlans] = useState<ISubscriptionPlan[]>([]);
|
||||||
|
const activeSubPlanFromStore = useSelector(selectors.selectActiveSubPlan);
|
||||||
|
const [activeSubPlan, setActiveSubPlan] = useState<ISubscriptionPlan | null>(
|
||||||
|
activeSubPlanFromStore
|
||||||
|
);
|
||||||
|
const { subPlan } = useParams();
|
||||||
const birthday = useSelector(selectors.selectBirthday);
|
const birthday = useSelector(selectors.selectBirthday);
|
||||||
|
|
||||||
// const queryParameters = new URLSearchParams(window.location.search);
|
useEffect(() => {
|
||||||
// const sub_plan = queryParameters.get("sub_plan") || "";
|
if (subPlan) {
|
||||||
const { subPlan } = useParams();
|
const targetSubPlan = subPlans.find(
|
||||||
|
(sub_plan) =>
|
||||||
const activeSubPlanFromStore = useSelector(selectors.selectActiveSubPlan);
|
String(
|
||||||
let activeSubPlan;
|
sub_plan.trial?.price_cents
|
||||||
|
? Math.floor(sub_plan.trial?.price_cents / 100)
|
||||||
if (subPlan) {
|
: sub_plan.id.replace(".", "")
|
||||||
const targetSubPlan = subPlans.find(
|
) === subPlan
|
||||||
(sub_plan) =>
|
);
|
||||||
String(
|
if (targetSubPlan) {
|
||||||
sub_plan.trial?.price_cents
|
setActiveSubPlan(targetSubPlan);
|
||||||
? Math.floor(sub_plan.trial?.price_cents / 100)
|
}
|
||||||
: sub_plan.id.replace(".", "")
|
|
||||||
) === subPlan
|
|
||||||
);
|
|
||||||
if (targetSubPlan) {
|
|
||||||
activeSubPlan = targetSubPlan;
|
|
||||||
}
|
}
|
||||||
} else {
|
}, [subPlan, subPlans]);
|
||||||
activeSubPlan = activeSubPlanFromStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
const paymentItems = [
|
const paymentItems = [
|
||||||
{
|
{
|
||||||
@ -103,6 +101,11 @@ function SubscriptionPage(): JSX.Element {
|
|||||||
dispatch(actions.user.update(updatedUser.user));
|
dispatch(actions.user.update(updatedUser.user));
|
||||||
}
|
}
|
||||||
dispatch(actions.status.update("registred"));
|
dispatch(actions.status.update("registred"));
|
||||||
|
dispatch(
|
||||||
|
actions.payment.update({
|
||||||
|
activeSubPlan,
|
||||||
|
})
|
||||||
|
);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
setIsAuth(true);
|
setIsAuth(true);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user