42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { cache } from "react";
|
|
|
|
import { getFunnel } from "./api";
|
|
import type { FunnelRequest } from "./types";
|
|
|
|
export const loadFunnel = cache((payload: FunnelRequest) => getFunnel(payload));
|
|
|
|
export const loadFunnelData = cache((payload: FunnelRequest) =>
|
|
loadFunnel(payload).then(d => d.data)
|
|
);
|
|
|
|
export const loadFunnelStatus = cache((payload: FunnelRequest) =>
|
|
loadFunnel(payload).then(d => d.status)
|
|
);
|
|
|
|
export const loadFunnelCurrency = cache((payload: FunnelRequest) =>
|
|
loadFunnelData(payload).then(d => d.currency)
|
|
);
|
|
|
|
export const loadFunnelLocale = cache((payload: FunnelRequest) =>
|
|
loadFunnelData(payload).then(d => d.locale)
|
|
);
|
|
|
|
export const loadFunnelPayment = cache((payload: FunnelRequest) =>
|
|
loadFunnelData(payload).then(d => d.payment)
|
|
);
|
|
|
|
export const loadFunnelPaymentById = cache(
|
|
(payload: FunnelRequest, paymentId: string) =>
|
|
loadFunnelData(payload).then(d => d.payment[paymentId])
|
|
);
|
|
|
|
// export const loadFunnelProducts = cache(
|
|
// (payload: FunnelRequest, paymentId: string) =>
|
|
// loadFunnelPaymentById(payload, paymentId).then(d => d?.variants ?? [])
|
|
// );
|
|
|
|
// export const loadFunnelProperties = cache(
|
|
// (payload: FunnelRequest, paymentId: string) =>
|
|
// loadFunnelPaymentById(payload, paymentId).then(d => d?.properties ?? [])
|
|
// );
|