@zuplo/zudoku-plugin-monetization 0.0.18 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +10 -8
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -81,8 +81,13 @@ const useDeploymentName = () => {
|
|
|
81
81
|
|
|
82
82
|
//#endregion
|
|
83
83
|
//#region src/hooks/usePlans.ts
|
|
84
|
-
const usePlans = (
|
|
85
|
-
|
|
84
|
+
const usePlans = () => {
|
|
85
|
+
const zudoku = useZudoku();
|
|
86
|
+
const auth = useAuth();
|
|
87
|
+
return useSuspenseQuery({
|
|
88
|
+
queryKey: [`/v3/zudoku-metering/${useDeploymentName()}/pricing-page`],
|
|
89
|
+
meta: { context: auth.isAuthenticated ? zudoku : void 0 }
|
|
90
|
+
});
|
|
86
91
|
};
|
|
87
92
|
|
|
88
93
|
//#endregion
|
|
@@ -271,7 +276,7 @@ const CheckoutConfirmPage = () => {
|
|
|
271
276
|
const zudoku = useZudoku();
|
|
272
277
|
const deploymentName = useDeploymentName();
|
|
273
278
|
const navigate = useNavigate();
|
|
274
|
-
const { data: plans } = usePlans(
|
|
279
|
+
const { data: plans } = usePlans();
|
|
275
280
|
const selectedPlan = plans?.items?.find((plan) => plan.id === planId);
|
|
276
281
|
if (!planId) throw new Error("Parameter `planId` missing");
|
|
277
282
|
const rateCards = selectedPlan?.phases.at(-1)?.rateCards;
|
|
@@ -651,10 +656,7 @@ const PricingPage = ({ subtitle = "See our pricing options and choose the one th
|
|
|
651
656
|
const zudoku = useZudoku();
|
|
652
657
|
const deploymentName = useDeploymentName();
|
|
653
658
|
const auth = useAuth();
|
|
654
|
-
const { data: pricingTable } =
|
|
655
|
-
queryKey: [`/v3/zudoku-metering/${deploymentName}/pricing-page`],
|
|
656
|
-
meta: { context: auth.isAuthenticated ? zudoku : void 0 }
|
|
657
|
-
});
|
|
659
|
+
const { data: pricingTable } = usePlans();
|
|
658
660
|
const { data: subscriptions = { items: [] } } = useQuery({
|
|
659
661
|
meta: { context: zudoku },
|
|
660
662
|
queryKey: [`/v3/zudoku-metering/${deploymentName}/subscriptions`],
|
|
@@ -1370,7 +1372,7 @@ const ConfirmSwitchAlert = ({ switchTo, onRequestClose }) => {
|
|
|
1370
1372
|
};
|
|
1371
1373
|
const SwitchPlanModal = ({ subscription, children }) => {
|
|
1372
1374
|
const [open, setOpen] = useState(false);
|
|
1373
|
-
const { data: plansData } = usePlans(
|
|
1375
|
+
const { data: plansData } = usePlans();
|
|
1374
1376
|
const [switchTo, setSwitchTo] = useState(null);
|
|
1375
1377
|
const currentPlan = plansData?.items.find((p) => p.id === subscription.plan.id);
|
|
1376
1378
|
const { upgrades, downgrades } = useMemo(() => {
|