@hook-sdk/template 0.17.0 → 0.18.1
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.cjs +17 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +17 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -267,7 +267,16 @@ var MAP = {
|
|
|
267
267
|
pix_expired: "QR Code do PIX expirou. Gere um novo.",
|
|
268
268
|
pix_not_paid_yet: "PIX ainda n\xE3o foi pago. Aguardando confirma\xE7\xE3o."
|
|
269
269
|
};
|
|
270
|
-
function asaasErrorMessage(code) {
|
|
270
|
+
function asaasErrorMessage(code, description) {
|
|
271
|
+
if (description) {
|
|
272
|
+
const lower = description.toLowerCase();
|
|
273
|
+
if (lower.includes("cep")) {
|
|
274
|
+
return "Nosso processador de pagamentos n\xE3o reconheceu esse CEP \u2014 a base deles pode estar desatualizada. Tente outro CEP.";
|
|
275
|
+
}
|
|
276
|
+
if (lower.includes("telefone") || lower.includes("contato com ddd")) {
|
|
277
|
+
return "Telefone inv\xE1lido. Confira o n\xFAmero com DDD e tente novamente.";
|
|
278
|
+
}
|
|
279
|
+
}
|
|
271
280
|
return MAP[code] ?? "Ocorreu um erro inesperado. Tente novamente em instantes.";
|
|
272
281
|
}
|
|
273
282
|
|
|
@@ -353,6 +362,7 @@ function usePaywallState() {
|
|
|
353
362
|
const status = subscription.status();
|
|
354
363
|
const daysLeftInTrial = subscription.daysLeftInTrial();
|
|
355
364
|
const initialLoadComplete = subscription.initialLoadComplete;
|
|
365
|
+
const hasAccess = subscription.hasAccess;
|
|
356
366
|
const pixPending = (0, import_react6.useMemo)(() => {
|
|
357
367
|
const sdkPix = subscription.pixPending;
|
|
358
368
|
if (!sdkPix) return null;
|
|
@@ -395,7 +405,9 @@ function usePaywallState() {
|
|
|
395
405
|
(code, fallbackMessage) => ({
|
|
396
406
|
code,
|
|
397
407
|
message: fallbackMessage,
|
|
398
|
-
|
|
408
|
+
// fallbackMessage carries Asaas's PT-BR description ("O CEP informado é inválido.")
|
|
409
|
+
// that distinguishes invalid_holderInfo sub-cases (CEP vs phone vs name).
|
|
410
|
+
userMessage: useDefaultMessages ? asaasErrorMessage(code, fallbackMessage) : fallbackMessage
|
|
399
411
|
}),
|
|
400
412
|
[useDefaultMessages]
|
|
401
413
|
);
|
|
@@ -556,6 +568,7 @@ function usePaywallState() {
|
|
|
556
568
|
return {
|
|
557
569
|
// Subscription status (reactive, proxied from SDK)
|
|
558
570
|
status,
|
|
571
|
+
hasAccess,
|
|
559
572
|
daysLeftInTrial,
|
|
560
573
|
initialLoadComplete,
|
|
561
574
|
// Plan derivation from config (sync, no fetch)
|
|
@@ -599,9 +612,10 @@ var BLOCKING = /* @__PURE__ */ new Set([
|
|
|
599
612
|
]);
|
|
600
613
|
function SubscriptionGate({ Paywall, children }) {
|
|
601
614
|
const { mode } = useTemplateConfig();
|
|
602
|
-
const { status, initialLoadComplete } = usePaywallState();
|
|
615
|
+
const { status, hasAccess, initialLoadComplete } = usePaywallState();
|
|
603
616
|
if (mode === "free") return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children });
|
|
604
617
|
if (!initialLoadComplete && status === "none") return null;
|
|
618
|
+
if (hasAccess === true && status !== "none") return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children });
|
|
605
619
|
if (BLOCKING.has(status)) return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Paywall, {});
|
|
606
620
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children });
|
|
607
621
|
}
|