@hook-sdk/template 0.27.0 → 0.28.0
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 +357 -146
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +404 -193
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2726,7 +2726,7 @@ function EmptyState({ title, description, action }) {
|
|
|
2726
2726
|
}
|
|
2727
2727
|
|
|
2728
2728
|
// src/defaults/CheckoutPageDefault.tsx
|
|
2729
|
-
import { useEffect as useEffect11, useMemo as useMemo5 } from "react";
|
|
2729
|
+
import { useEffect as useEffect11, useMemo as useMemo5, useState as useState9 } from "react";
|
|
2730
2730
|
import { useNavigate as useNavigate2 } from "react-router-dom";
|
|
2731
2731
|
|
|
2732
2732
|
// src/hooks/useCheckoutForm.ts
|
|
@@ -2851,7 +2851,7 @@ function useCheckoutForm(args) {
|
|
|
2851
2851
|
const emailConfirmError = touchedEmailConfirm || formSubmitAttempted ? validateEmailConfirm : null;
|
|
2852
2852
|
const phoneError = touchedPhone || formSubmitAttempted ? validatePhone : null;
|
|
2853
2853
|
const cpfError = touchedCpf || formSubmitAttempted ? validateCpf : null;
|
|
2854
|
-
const canSubmit = name.trim().length >= 2 && EMAIL_RE.test(email) && emailConfirm === email && PHONE_RE.test(phone) && validateCpf === null && cpf.replace(/\D/g, "").length === 11 && emailStatus !== "exists" && !submitting && (method !== "card" || card.number.length >= 12 && card.ccv.length >= 3 && card.expiryMonth.length >= 1 && card.expiryYear.length >= 2 && card.holderName.length >= 1);
|
|
2854
|
+
const canSubmit = name.trim().length >= 2 && EMAIL_RE.test(email) && (emailConfirm === "" || emailConfirm === email) && (phone === "" || PHONE_RE.test(phone)) && validateCpf === null && cpf.replace(/\D/g, "").length === 11 && emailStatus !== "exists" && !submitting && (method !== "card" || card.number.length >= 12 && card.ccv.length >= 3 && card.expiryMonth.length >= 1 && card.expiryYear.length >= 2 && card.holderName.length >= 1);
|
|
2855
2855
|
const submit = useCallback6(async () => {
|
|
2856
2856
|
setFormSubmitAttempted(true);
|
|
2857
2857
|
setError(null);
|
|
@@ -2866,7 +2866,7 @@ function useCheckoutForm(args) {
|
|
|
2866
2866
|
method: "card",
|
|
2867
2867
|
name: name.trim(),
|
|
2868
2868
|
email,
|
|
2869
|
-
emailConfirm,
|
|
2869
|
+
emailConfirm: emailConfirm || email,
|
|
2870
2870
|
phone,
|
|
2871
2871
|
cpf: cpf.replace(/\D/g, ""),
|
|
2872
2872
|
cycle,
|
|
@@ -2893,7 +2893,7 @@ function useCheckoutForm(args) {
|
|
|
2893
2893
|
method: "pix-auto",
|
|
2894
2894
|
name: name.trim(),
|
|
2895
2895
|
email,
|
|
2896
|
-
emailConfirm,
|
|
2896
|
+
emailConfirm: emailConfirm || email,
|
|
2897
2897
|
phone,
|
|
2898
2898
|
cpf: cpf.replace(/\D/g, ""),
|
|
2899
2899
|
cycle
|
|
@@ -2966,7 +2966,7 @@ function usePlan() {
|
|
|
2966
2966
|
}
|
|
2967
2967
|
|
|
2968
2968
|
// src/defaults/CheckoutPageDefault.tsx
|
|
2969
|
-
import { jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2969
|
+
import { Fragment as Fragment7, jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2970
2970
|
var INTENT_KEY = "hook:paywall:intent";
|
|
2971
2971
|
var PIX_PAYLOAD_KEY = "hook:paywall:pix-pending";
|
|
2972
2972
|
function readIntent() {
|
|
@@ -2982,13 +2982,49 @@ function readIntent() {
|
|
|
2982
2982
|
function formatBrl(cents) {
|
|
2983
2983
|
return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(cents / 100);
|
|
2984
2984
|
}
|
|
2985
|
+
function formatCardNumber(v) {
|
|
2986
|
+
const digits = v.replace(/\D/g, "").slice(0, 16);
|
|
2987
|
+
return digits.replace(/(.{4})/g, "$1 ").trim();
|
|
2988
|
+
}
|
|
2989
|
+
function formatExpiryMmAa(v) {
|
|
2990
|
+
const d = v.replace(/\D/g, "").slice(0, 4);
|
|
2991
|
+
if (d.length < 3) return d;
|
|
2992
|
+
return d.slice(0, 2) + "/" + d.slice(2);
|
|
2993
|
+
}
|
|
2994
|
+
function parseExpiryMmAa(v) {
|
|
2995
|
+
const d = v.replace(/\D/g, "");
|
|
2996
|
+
return { month: d.slice(0, 2), year: d.slice(2, 4) };
|
|
2997
|
+
}
|
|
2998
|
+
function formatCpf(v) {
|
|
2999
|
+
const d = v.replace(/\D/g, "").slice(0, 11);
|
|
3000
|
+
if (d.length <= 3) return d;
|
|
3001
|
+
if (d.length <= 6) return d.slice(0, 3) + "." + d.slice(3);
|
|
3002
|
+
if (d.length <= 9) return d.slice(0, 3) + "." + d.slice(3, 6) + "." + d.slice(6);
|
|
3003
|
+
return d.slice(0, 3) + "." + d.slice(3, 6) + "." + d.slice(6, 9) + "-" + d.slice(9);
|
|
3004
|
+
}
|
|
3005
|
+
function detectCardBrand(num) {
|
|
3006
|
+
const n = num.replace(/\s/g, "");
|
|
3007
|
+
if (/^4/.test(n)) return "VISA";
|
|
3008
|
+
if (/^(5[1-5]|2[2-7])/.test(n)) return "MASTER";
|
|
3009
|
+
if (/^3[47]/.test(n)) return "AMEX";
|
|
3010
|
+
if (/^(4011|4312|4389|4514|6011|6362|6363)/.test(n)) return "ELO";
|
|
3011
|
+
if (/^(606282|3841)/.test(n)) return "HIPER";
|
|
3012
|
+
return "";
|
|
3013
|
+
}
|
|
2985
3014
|
function CheckoutPageDefault() {
|
|
2986
3015
|
const navigate = useNavigate2();
|
|
2987
3016
|
const plan = usePlan();
|
|
2988
3017
|
const intent = useMemo5(readIntent, []);
|
|
2989
3018
|
const defaultMethod = intent.method === "pix-auto" ? "pix-auto" : "card";
|
|
2990
|
-
const defaultCycle = intent.cycle === "
|
|
3019
|
+
const defaultCycle = intent.cycle === "MONTHLY" ? "MONTHLY" : "YEARLY";
|
|
2991
3020
|
const form = useCheckoutForm({ defaultMethod, defaultCycle });
|
|
3021
|
+
const [expiryMmAa, setExpiryMmAa] = useState9("");
|
|
3022
|
+
useEffect11(() => {
|
|
3023
|
+
const { month, year } = parseExpiryMmAa(expiryMmAa);
|
|
3024
|
+
if (month !== form.card.expiryMonth || year !== form.card.expiryYear) {
|
|
3025
|
+
form.setCard({ expiryMonth: month, expiryYear: year });
|
|
3026
|
+
}
|
|
3027
|
+
}, [expiryMmAa]);
|
|
2992
3028
|
useEffect11(() => {
|
|
2993
3029
|
if (form.emailTaken && form.loginUrl) {
|
|
2994
3030
|
const t = setTimeout(() => navigate(form.loginUrl), 1200);
|
|
@@ -3000,21 +3036,30 @@ function CheckoutPageDefault() {
|
|
|
3000
3036
|
yearlyPriceCents: plan.data.yearlyPriceCents,
|
|
3001
3037
|
trialDays: plan.data.trialDays
|
|
3002
3038
|
} : null;
|
|
3039
|
+
const annual = form.cycle === "YEARLY";
|
|
3003
3040
|
const cyclePrice = useMemo5(() => {
|
|
3004
3041
|
if (!planInfo) return null;
|
|
3005
|
-
return
|
|
3006
|
-
}, [planInfo,
|
|
3007
|
-
const
|
|
3008
|
-
if (
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
return cyclePrice
|
|
3017
|
-
}, [form.method,
|
|
3042
|
+
return annual ? planInfo.yearlyPriceCents ?? planInfo.priceCents * 12 : planInfo.priceCents;
|
|
3043
|
+
}, [planInfo, annual]);
|
|
3044
|
+
const monthlyText = useMemo5(() => {
|
|
3045
|
+
if (!planInfo) return "";
|
|
3046
|
+
const monthly = annual && planInfo.yearlyPriceCents ? Math.round(planInfo.yearlyPriceCents / 12) : planInfo.priceCents;
|
|
3047
|
+
return formatBrl(monthly);
|
|
3048
|
+
}, [planInfo, annual]);
|
|
3049
|
+
const todayCents = useMemo5(() => {
|
|
3050
|
+
if (form.method === "pix-auto") return cyclePrice ?? 0;
|
|
3051
|
+
const trialDays2 = planInfo?.trialDays ?? 0;
|
|
3052
|
+
if (trialDays2 > 0) return 0;
|
|
3053
|
+
return cyclePrice ?? 0;
|
|
3054
|
+
}, [form.method, cyclePrice, planInfo]);
|
|
3055
|
+
const todayAmount = formatBrl(todayCents);
|
|
3056
|
+
const cyclePriceText = cyclePrice !== null ? formatBrl(cyclePrice) : "";
|
|
3057
|
+
const annualSavingsCents = useMemo5(() => {
|
|
3058
|
+
if (!planInfo || !planInfo.yearlyPriceCents) return 0;
|
|
3059
|
+
return planInfo.priceCents * 12 - planInfo.yearlyPriceCents;
|
|
3060
|
+
}, [planInfo]);
|
|
3061
|
+
const trialDays = planInfo?.trialDays ?? 7;
|
|
3062
|
+
const cardBrand = detectCardBrand(form.card.number);
|
|
3018
3063
|
async function onSubmit(e) {
|
|
3019
3064
|
e.preventDefault();
|
|
3020
3065
|
const result = await form.submit();
|
|
@@ -3037,207 +3082,373 @@ function CheckoutPageDefault() {
|
|
|
3037
3082
|
}
|
|
3038
3083
|
navigate(result.redirect.replace(/^.*\/app\/[^/]+/, "") || "/");
|
|
3039
3084
|
}
|
|
3040
|
-
return /* @__PURE__ */ jsx27("div", { className: "flex-1 flex flex-col bg-background min-h-0", children: /* @__PURE__ */ jsxs18("form", { onSubmit, className: "flex-1 overflow-y-auto
|
|
3041
|
-
/* @__PURE__ */ jsxs18("
|
|
3042
|
-
/* @__PURE__ */ jsx27("h1", { className: "font-display text-2xl text-foreground", children: "Finalizar assinatura" }),
|
|
3043
|
-
/* @__PURE__ */ jsx27("p", { className: "text-sm text-muted-foreground", children: "Preencha seus dados pra liberar o app. Voc\xEA j\xE1 entra com acesso na hora." })
|
|
3044
|
-
] }),
|
|
3045
|
-
form.emailTaken ? /* @__PURE__ */ jsxs18("div", { role: "alert", className: "rounded-xl bg-destructive/10 p-4 text-sm text-destructive border border-destructive/20", children: [
|
|
3085
|
+
return /* @__PURE__ */ jsx27("div", { className: "flex-1 flex flex-col bg-background min-h-0", children: /* @__PURE__ */ jsxs18("form", { onSubmit, className: "flex-1 overflow-y-auto", children: [
|
|
3086
|
+
form.emailTaken ? /* @__PURE__ */ jsx27("div", { className: "px-5 pt-4", children: /* @__PURE__ */ jsxs18("div", { role: "alert", className: "rounded-2xl bg-destructive/10 p-4 text-sm text-destructive border border-destructive/20", children: [
|
|
3046
3087
|
"Esse e-mail j\xE1 tem conta nesse app.",
|
|
3047
3088
|
" ",
|
|
3048
|
-
/* @__PURE__ */ jsx27("a", { href: form.loginUrl ?? "/signin", className: "underline font-
|
|
3049
|
-
] }) : null,
|
|
3050
|
-
form.error ? /* @__PURE__ */ jsx27("div", { role: "alert", className: "rounded-
|
|
3051
|
-
/* @__PURE__ */ jsxs18("
|
|
3052
|
-
/* @__PURE__ */
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3089
|
+
/* @__PURE__ */ jsx27("a", { href: form.loginUrl ?? "/signin", className: "underline font-semibold", children: "Entrar agora" })
|
|
3090
|
+
] }) }) : null,
|
|
3091
|
+
form.error ? /* @__PURE__ */ jsx27("div", { className: "px-5 pt-4", children: /* @__PURE__ */ jsx27("div", { role: "alert", className: "rounded-2xl bg-destructive/10 p-4 text-sm text-destructive border border-destructive/20", children: form.error.message || "N\xE3o foi poss\xEDvel concluir o pagamento. Tente novamente." }) }) : null,
|
|
3092
|
+
/* @__PURE__ */ jsx27("div", { className: "px-5 pt-4", children: form.method === "card" ? /* @__PURE__ */ jsxs18("div", { className: "rounded-2xl bg-card border-[1.5px] border-foreground p-3.5", children: [
|
|
3093
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2 mb-2", children: [
|
|
3094
|
+
/* @__PURE__ */ jsx27(ShieldIcon, { className: "w-4 h-4" }),
|
|
3095
|
+
/* @__PURE__ */ jsx27("div", { className: "text-sm font-bold", children: "Voc\xEA N\xC3O ser\xE1 cobrada hoje" })
|
|
3096
|
+
] }),
|
|
3097
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex justify-between items-baseline text-sm text-muted-foreground", children: [
|
|
3098
|
+
/* @__PURE__ */ jsx27("span", { children: "R$ 0,00 agora" }),
|
|
3099
|
+
/* @__PURE__ */ jsx27("span", { className: "opacity-50", children: "\xB7" }),
|
|
3100
|
+
/* @__PURE__ */ jsxs18("span", { children: [
|
|
3101
|
+
monthlyText,
|
|
3102
|
+
"/m\xEAs ap\xF3s ",
|
|
3103
|
+
trialDays,
|
|
3104
|
+
" dias"
|
|
3105
|
+
] })
|
|
3106
|
+
] }),
|
|
3107
|
+
/* @__PURE__ */ jsxs18("div", { className: "mt-2.5 text-[11px] text-muted-foreground flex items-center gap-1.5", children: [
|
|
3108
|
+
/* @__PURE__ */ jsx27(BellIcon, { className: "w-2.5 h-2.5" }),
|
|
3109
|
+
"Avisamos por email 2 dias antes da primeira cobran\xE7a"
|
|
3110
|
+
] })
|
|
3111
|
+
] }) : /* @__PURE__ */ jsxs18("div", { className: "rounded-2xl p-3.5 bg-emerald-50 border-[1.5px] border-emerald-600/60", children: [
|
|
3112
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2 mb-2 text-emerald-900", children: [
|
|
3113
|
+
/* @__PURE__ */ jsx27(ShieldIcon, { className: "w-4 h-4" }),
|
|
3114
|
+
/* @__PURE__ */ jsxs18("div", { className: "text-sm font-bold", children: [
|
|
3115
|
+
"Garantia incondicional de ",
|
|
3116
|
+
trialDays,
|
|
3117
|
+
" dias"
|
|
3118
|
+
] })
|
|
3119
|
+
] }),
|
|
3120
|
+
/* @__PURE__ */ jsxs18("div", { className: "text-sm text-emerald-900 leading-snug", children: [
|
|
3121
|
+
"Voc\xEA paga ",
|
|
3122
|
+
/* @__PURE__ */ jsx27("b", { children: todayAmount }),
|
|
3123
|
+
" agora via Pix.",
|
|
3124
|
+
/* @__PURE__ */ jsx27("br", {}),
|
|
3125
|
+
"N\xE3o gostou em ",
|
|
3126
|
+
trialDays,
|
|
3127
|
+
" dias? Devolvemos ",
|
|
3128
|
+
/* @__PURE__ */ jsx27("b", { children: "100%" }),
|
|
3129
|
+
" sem perguntas \u2014 direto pelo app."
|
|
3130
|
+
] })
|
|
3131
|
+
] }) }),
|
|
3132
|
+
/* @__PURE__ */ jsxs18("section", { className: "px-5 pt-5", children: [
|
|
3133
|
+
/* @__PURE__ */ jsx27("h2", { className: "font-display text-2xl mb-3.5 leading-tight text-foreground", children: "Quase l\xE1." }),
|
|
3134
|
+
/* @__PURE__ */ jsx27(FieldLabel, { children: "Email" }),
|
|
3064
3135
|
/* @__PURE__ */ jsx27(
|
|
3065
|
-
|
|
3136
|
+
FieldInput,
|
|
3066
3137
|
{
|
|
3067
|
-
label: "E-mail",
|
|
3068
3138
|
type: "email",
|
|
3069
|
-
|
|
3070
|
-
onChange: form.setEmail,
|
|
3071
|
-
onBlur: form.markEmailTouched,
|
|
3072
|
-
error: form.emailError,
|
|
3139
|
+
inputMode: "email",
|
|
3073
3140
|
autoComplete: "email",
|
|
3074
3141
|
autoCapitalize: "none",
|
|
3075
3142
|
autoCorrect: "off",
|
|
3076
3143
|
spellCheck: false,
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
label: "Confirme o e-mail",
|
|
3084
|
-
type: "email",
|
|
3085
|
-
value: form.emailConfirm,
|
|
3086
|
-
onChange: form.setEmailConfirm,
|
|
3087
|
-
onBlur: form.markEmailConfirmTouched,
|
|
3088
|
-
error: form.emailConfirmError,
|
|
3089
|
-
autoComplete: "email",
|
|
3090
|
-
autoCapitalize: "none",
|
|
3091
|
-
autoCorrect: "off",
|
|
3092
|
-
spellCheck: false
|
|
3144
|
+
placeholder: "seu@email.com",
|
|
3145
|
+
value: form.email,
|
|
3146
|
+
onChange: form.setEmail,
|
|
3147
|
+
onBlur: form.markEmailTouched,
|
|
3148
|
+
error: form.emailError,
|
|
3149
|
+
valid: form.emailStatus === "available"
|
|
3093
3150
|
}
|
|
3094
3151
|
),
|
|
3152
|
+
!form.emailError && /* @__PURE__ */ jsx27(FieldHint, { children: form.emailStatus === "checking" ? "Verificando\u2026" : form.emailStatus === "available" ? "\u2713 Dispon\xEDvel" : "Voc\xEA vai usar este email para entrar no app" }),
|
|
3153
|
+
/* @__PURE__ */ jsx27("div", { className: "h-3" }),
|
|
3154
|
+
/* @__PURE__ */ jsx27(FieldLabel, { children: "Nome completo" }),
|
|
3095
3155
|
/* @__PURE__ */ jsx27(
|
|
3096
|
-
|
|
3156
|
+
FieldInput,
|
|
3097
3157
|
{
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3158
|
+
type: "text",
|
|
3159
|
+
autoComplete: "name",
|
|
3160
|
+
placeholder: "como est\xE1 no documento",
|
|
3161
|
+
value: form.name,
|
|
3162
|
+
onChange: form.setName,
|
|
3163
|
+
onBlur: form.markNameTouched,
|
|
3164
|
+
error: form.nameError,
|
|
3165
|
+
valid: !!form.name && !form.nameError
|
|
3106
3166
|
}
|
|
3107
3167
|
),
|
|
3168
|
+
/* @__PURE__ */ jsx27("div", { className: "h-3" }),
|
|
3169
|
+
/* @__PURE__ */ jsx27(FieldLabel, { children: "CPF" }),
|
|
3108
3170
|
/* @__PURE__ */ jsx27(
|
|
3109
|
-
|
|
3171
|
+
FieldInput,
|
|
3110
3172
|
{
|
|
3111
|
-
label: "CPF",
|
|
3112
3173
|
type: "text",
|
|
3113
3174
|
inputMode: "numeric",
|
|
3175
|
+
placeholder: "000.000.000-00",
|
|
3114
3176
|
value: form.cpf,
|
|
3115
|
-
onChange: form.setCpf,
|
|
3177
|
+
onChange: (v) => form.setCpf(formatCpf(v)),
|
|
3116
3178
|
onBlur: form.markCpfTouched,
|
|
3117
3179
|
error: form.cpfError,
|
|
3118
|
-
|
|
3119
|
-
placeholder: "000.000.000-00"
|
|
3180
|
+
valid: !!form.cpf && !form.cpfError
|
|
3120
3181
|
}
|
|
3121
3182
|
)
|
|
3122
3183
|
] }),
|
|
3123
|
-
/* @__PURE__ */ jsxs18("section", { className: "
|
|
3124
|
-
/* @__PURE__ */ jsx27(
|
|
3125
|
-
/* @__PURE__ */ jsxs18("div", { className: "
|
|
3126
|
-
/* @__PURE__ */ jsx27(MethodTab, { active: form.method === "card", onClick: () => form.setMethod("card"), children: "Cart\xE3o" }),
|
|
3127
|
-
/* @__PURE__ */ jsx27(MethodTab, { active: form.method === "pix-auto", onClick: () => form.setMethod("pix-auto"), children: "PIX" })
|
|
3128
|
-
] }),
|
|
3129
|
-
/* @__PURE__ */ jsxs18("div", { className: "grid grid-cols-2 gap-2", role: "tablist", children: [
|
|
3130
|
-
/* @__PURE__ */ jsx27(MethodTab, { active: form.cycle === "MONTHLY", onClick: () => form.setCycle("MONTHLY"), children: "Mensal" }),
|
|
3131
|
-
/* @__PURE__ */ jsx27(MethodTab, { active: form.cycle === "YEARLY", onClick: () => form.setCycle("YEARLY"), children: "Anual" })
|
|
3132
|
-
] }),
|
|
3133
|
-
form.method === "card" ? /* @__PURE__ */ jsxs18("div", { className: "space-y-3 rounded-xl border border-border p-4", children: [
|
|
3184
|
+
/* @__PURE__ */ jsxs18("section", { className: "px-5 pt-5", children: [
|
|
3185
|
+
/* @__PURE__ */ jsx27(FieldLabel, { children: "Forma de pagamento" }),
|
|
3186
|
+
/* @__PURE__ */ jsxs18("div", { role: "tablist", className: "flex gap-1.5 bg-muted p-1 rounded-xl", children: [
|
|
3134
3187
|
/* @__PURE__ */ jsx27(
|
|
3135
|
-
|
|
3188
|
+
TabButton,
|
|
3136
3189
|
{
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3190
|
+
active: form.method === "card",
|
|
3191
|
+
onClick: () => form.setMethod("card"),
|
|
3192
|
+
icon: /* @__PURE__ */ jsx27(CardIcon, { className: "w-3.5 h-3.5" }),
|
|
3193
|
+
label: "Cart\xE3o",
|
|
3194
|
+
subtitle: trialDays > 0 ? `${trialDays} dias gr\xE1tis` : "pague hoje",
|
|
3195
|
+
subtitleActiveClass: "text-emerald-700"
|
|
3141
3196
|
}
|
|
3142
3197
|
),
|
|
3143
3198
|
/* @__PURE__ */ jsx27(
|
|
3144
|
-
|
|
3199
|
+
TabButton,
|
|
3145
3200
|
{
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3201
|
+
active: form.method === "pix-auto",
|
|
3202
|
+
onClick: () => form.setMethod("pix-auto"),
|
|
3203
|
+
icon: /* @__PURE__ */ jsx27(PixIcon, { className: "w-3.5 h-3.5" }),
|
|
3204
|
+
label: "Pix",
|
|
3205
|
+
subtitle: `pague hoje \xB7 garantia ${trialDays}d`,
|
|
3206
|
+
subtitleActiveClass: "text-foreground/70"
|
|
3207
|
+
}
|
|
3208
|
+
)
|
|
3209
|
+
] })
|
|
3210
|
+
] }),
|
|
3211
|
+
form.method === "card" ? /* @__PURE__ */ jsxs18("section", { className: "px-5 pt-3.5", children: [
|
|
3212
|
+
/* @__PURE__ */ jsx27(FieldLabel, { children: "N\xFAmero do cart\xE3o" }),
|
|
3213
|
+
/* @__PURE__ */ jsxs18("div", { className: "relative", children: [
|
|
3214
|
+
/* @__PURE__ */ jsx27(
|
|
3215
|
+
FieldInput,
|
|
3216
|
+
{
|
|
3217
|
+
type: "text",
|
|
3150
3218
|
inputMode: "numeric",
|
|
3151
|
-
|
|
3219
|
+
autoComplete: "cc-number",
|
|
3220
|
+
placeholder: "0000 0000 0000 0000",
|
|
3221
|
+
value: form.card.number,
|
|
3222
|
+
onChange: (v) => form.setCard({ number: formatCardNumber(v) }),
|
|
3223
|
+
style: cardBrand ? { paddingRight: "4.5rem" } : void 0
|
|
3152
3224
|
}
|
|
3153
3225
|
),
|
|
3154
|
-
/* @__PURE__ */
|
|
3226
|
+
cardBrand && /* @__PURE__ */ jsx27("span", { className: "absolute right-3 top-1/2 -translate-y-1/2 text-[10px] font-bold tracking-wide px-1.5 py-0.5 rounded bg-muted text-muted-foreground", children: cardBrand })
|
|
3227
|
+
] }),
|
|
3228
|
+
/* @__PURE__ */ jsx27("div", { className: "h-3" }),
|
|
3229
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex gap-2.5", children: [
|
|
3230
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex-1", children: [
|
|
3231
|
+
/* @__PURE__ */ jsx27(FieldLabel, { children: "Validade" }),
|
|
3155
3232
|
/* @__PURE__ */ jsx27(
|
|
3156
|
-
|
|
3233
|
+
FieldInput,
|
|
3157
3234
|
{
|
|
3158
|
-
|
|
3159
|
-
value: form.card.expiryMonth,
|
|
3160
|
-
onChange: (v) => form.setCard({ expiryMonth: v }),
|
|
3161
|
-
autoComplete: "cc-exp-month",
|
|
3235
|
+
type: "text",
|
|
3162
3236
|
inputMode: "numeric",
|
|
3163
|
-
|
|
3237
|
+
autoComplete: "cc-exp",
|
|
3238
|
+
placeholder: "MM/AA",
|
|
3239
|
+
value: expiryMmAa,
|
|
3240
|
+
onChange: (v) => setExpiryMmAa(formatExpiryMmAa(v))
|
|
3164
3241
|
}
|
|
3165
|
-
)
|
|
3242
|
+
)
|
|
3243
|
+
] }),
|
|
3244
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex-1", children: [
|
|
3245
|
+
/* @__PURE__ */ jsx27(FieldLabel, { children: "CVV" }),
|
|
3166
3246
|
/* @__PURE__ */ jsx27(
|
|
3167
|
-
|
|
3247
|
+
FieldInput,
|
|
3168
3248
|
{
|
|
3169
|
-
|
|
3170
|
-
value: form.card.expiryYear,
|
|
3171
|
-
onChange: (v) => form.setCard({ expiryYear: v }),
|
|
3172
|
-
autoComplete: "cc-exp-year",
|
|
3249
|
+
type: "text",
|
|
3173
3250
|
inputMode: "numeric",
|
|
3174
|
-
placeholder: "AA"
|
|
3175
|
-
}
|
|
3176
|
-
),
|
|
3177
|
-
/* @__PURE__ */ jsx27(
|
|
3178
|
-
FieldRow,
|
|
3179
|
-
{
|
|
3180
|
-
label: "CVV",
|
|
3181
|
-
value: form.card.ccv,
|
|
3182
|
-
onChange: (v) => form.setCard({ ccv: v }),
|
|
3183
3251
|
autoComplete: "cc-csc",
|
|
3184
|
-
|
|
3185
|
-
|
|
3252
|
+
placeholder: "3 d\xEDgitos",
|
|
3253
|
+
value: form.card.ccv,
|
|
3254
|
+
onChange: (v) => form.setCard({ ccv: v.replace(/\D/g, "").slice(0, 4) })
|
|
3186
3255
|
}
|
|
3187
3256
|
)
|
|
3188
3257
|
] })
|
|
3189
|
-
] })
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3258
|
+
] }),
|
|
3259
|
+
/* @__PURE__ */ jsx27("div", { className: "h-3" }),
|
|
3260
|
+
/* @__PURE__ */ jsx27(FieldLabel, { children: "Nome no cart\xE3o" }),
|
|
3261
|
+
/* @__PURE__ */ jsx27(
|
|
3262
|
+
FieldInput,
|
|
3263
|
+
{
|
|
3264
|
+
type: "text",
|
|
3265
|
+
autoComplete: "cc-name",
|
|
3266
|
+
placeholder: "como est\xE1 no cart\xE3o",
|
|
3267
|
+
value: form.card.holderName,
|
|
3268
|
+
onChange: (v) => form.setCard({ holderName: v })
|
|
3269
|
+
}
|
|
3270
|
+
)
|
|
3271
|
+
] }) : /* @__PURE__ */ jsx27("section", { className: "px-5 pt-3.5", children: /* @__PURE__ */ jsxs18("div", { className: "rounded-2xl bg-card border border-border p-3.5 flex gap-3.5 items-center", children: [
|
|
3272
|
+
/* @__PURE__ */ jsx27("div", { className: "w-[72px] h-[72px] rounded-xl shrink-0 border-2 border-foreground relative overflow-hidden bg-muted", children: /* @__PURE__ */ jsx27("div", { className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-[22px] h-[22px] bg-background flex items-center justify-center", children: /* @__PURE__ */ jsx27(PixIcon, { className: "w-3.5 h-3.5 text-foreground" }) }) }),
|
|
3273
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex-1", children: [
|
|
3274
|
+
/* @__PURE__ */ jsx27("div", { className: "text-xs font-bold uppercase tracking-wider text-muted-foreground", children: "pagamento em segundos" }),
|
|
3275
|
+
/* @__PURE__ */ jsxs18("div", { className: "text-sm text-foreground mt-1 leading-snug", children: [
|
|
3276
|
+
"Geramos seu ",
|
|
3277
|
+
/* @__PURE__ */ jsx27("b", { children: "QR Pix" }),
|
|
3278
|
+
" no pr\xF3ximo passo. Pague pelo app do banco e seu acesso libera ",
|
|
3279
|
+
/* @__PURE__ */ jsx27("b", { children: "imediatamente" }),
|
|
3280
|
+
"."
|
|
3281
|
+
] })
|
|
3282
|
+
] })
|
|
3283
|
+
] }) }),
|
|
3284
|
+
/* @__PURE__ */ jsx27("section", { className: "px-5 pt-5", children: /* @__PURE__ */ jsxs18("div", { className: "bg-muted rounded-2xl p-4", children: [
|
|
3285
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex justify-between mb-2.5", children: [
|
|
3286
|
+
/* @__PURE__ */ jsxs18("div", { children: [
|
|
3287
|
+
/* @__PURE__ */ jsx27("div", { className: "text-sm font-semibold text-foreground", children: annual ? "Plano Anual" : "Plano Mensal" }),
|
|
3288
|
+
/* @__PURE__ */ jsx27("div", { className: "text-[11px] text-muted-foreground", children: "Coach" })
|
|
3289
|
+
] }),
|
|
3290
|
+
/* @__PURE__ */ jsxs18("div", { className: "text-right", children: [
|
|
3291
|
+
/* @__PURE__ */ jsxs18("div", { className: "text-sm font-bold text-foreground", children: [
|
|
3292
|
+
cyclePriceText,
|
|
3293
|
+
"/",
|
|
3294
|
+
annual ? "ano" : "m\xEAs"
|
|
3295
|
+
] }),
|
|
3296
|
+
annual && annualSavingsCents > 0 && /* @__PURE__ */ jsxs18("div", { className: "text-[11px] text-emerald-700 font-semibold", children: [
|
|
3297
|
+
"economia ",
|
|
3298
|
+
formatBrl(annualSavingsCents)
|
|
3299
|
+
] })
|
|
3300
|
+
] })
|
|
3301
|
+
] }),
|
|
3302
|
+
/* @__PURE__ */ jsx27("div", { className: "h-px bg-border my-3" }),
|
|
3303
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex justify-between items-baseline", children: [
|
|
3304
|
+
/* @__PURE__ */ jsxs18("div", { children: [
|
|
3305
|
+
/* @__PURE__ */ jsx27("div", { className: "text-sm font-bold text-foreground", children: "Voc\xEA paga hoje" }),
|
|
3306
|
+
form.method === "card" && trialDays > 0 && /* @__PURE__ */ jsxs18("div", { className: "text-[11px] text-muted-foreground mt-0.5", children: [
|
|
3307
|
+
"cobran\xE7a inicia no dia ",
|
|
3308
|
+
trialDays
|
|
3309
|
+
] }),
|
|
3310
|
+
form.method === "pix-auto" && /* @__PURE__ */ jsxs18("div", { className: "text-[11px] text-emerald-700 mt-0.5 font-semibold", children: [
|
|
3311
|
+
"reembolso garantido at\xE9 o dia ",
|
|
3312
|
+
trialDays
|
|
3313
|
+
] })
|
|
3314
|
+
] }),
|
|
3315
|
+
/* @__PURE__ */ jsx27("div", { className: "text-2xl font-bold font-display tracking-tight text-foreground", children: todayAmount })
|
|
3316
|
+
] })
|
|
3317
|
+
] }) }),
|
|
3318
|
+
/* @__PURE__ */ jsx27("div", { className: "h-4" }),
|
|
3319
|
+
/* @__PURE__ */ jsxs18("div", { className: "sticky bottom-0 px-5 pt-3.5 pb-6 bg-gradient-to-b from-transparent to-background", children: [
|
|
3320
|
+
/* @__PURE__ */ jsx27(
|
|
3321
|
+
"button",
|
|
3322
|
+
{
|
|
3323
|
+
type: "submit",
|
|
3324
|
+
disabled: !form.canSubmit,
|
|
3325
|
+
className: "w-full rounded-full bg-primary text-primary-foreground min-h-14 px-5 text-base font-bold inline-flex items-center justify-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed shadow-lg",
|
|
3326
|
+
children: form.submitting ? /* @__PURE__ */ jsxs18(Fragment7, { children: [
|
|
3327
|
+
/* @__PURE__ */ jsx27(Spinner2, {}),
|
|
3328
|
+
" ",
|
|
3329
|
+
form.method === "pix-auto" ? "Gerando QR\u2026" : "Confirmando\u2026"
|
|
3330
|
+
] }) : form.method === "card" ? /* @__PURE__ */ jsxs18(Fragment7, { children: [
|
|
3331
|
+
/* @__PURE__ */ jsx27(LockIcon, { className: "w-3.5 h-3.5" }),
|
|
3332
|
+
" Confirmar e come\xE7ar gr\xE1tis"
|
|
3333
|
+
] }) : /* @__PURE__ */ jsxs18(Fragment7, { children: [
|
|
3334
|
+
/* @__PURE__ */ jsx27(PixIcon, { className: "w-3.5 h-3.5" }),
|
|
3335
|
+
" Gerar QR \xB7 pagar ",
|
|
3336
|
+
todayAmount
|
|
3337
|
+
] })
|
|
3338
|
+
}
|
|
3339
|
+
),
|
|
3340
|
+
/* @__PURE__ */ jsxs18("div", { className: "text-center mt-2.5 text-xs text-muted-foreground", children: [
|
|
3341
|
+
"Ao continuar, voc\xEA concorda com nossos ",
|
|
3342
|
+
/* @__PURE__ */ jsx27("u", { children: "Termos" }),
|
|
3343
|
+
". Pagamento seguro Asaas."
|
|
3344
|
+
] }),
|
|
3345
|
+
/* @__PURE__ */ jsxs18("div", { className: "mt-3 flex items-center justify-center gap-3.5 text-[11px] text-muted-foreground", children: [
|
|
3346
|
+
/* @__PURE__ */ jsxs18("span", { className: "inline-flex items-center gap-1", children: [
|
|
3347
|
+
/* @__PURE__ */ jsx27(LockIcon, { className: "w-2.5 h-2.5 opacity-60" }),
|
|
3348
|
+
" SSL 256-bit"
|
|
3349
|
+
] }),
|
|
3350
|
+
/* @__PURE__ */ jsx27("span", { className: "w-px h-2.5 bg-border" }),
|
|
3351
|
+
/* @__PURE__ */ jsx27("span", { children: "Pagamento via Asaas" }),
|
|
3352
|
+
/* @__PURE__ */ jsx27("span", { className: "w-px h-2.5 bg-border" }),
|
|
3353
|
+
/* @__PURE__ */ jsxs18("span", { children: [
|
|
3354
|
+
"Garantia ",
|
|
3355
|
+
trialDays,
|
|
3356
|
+
" dias"
|
|
3357
|
+
] })
|
|
3358
|
+
] })
|
|
3359
|
+
] })
|
|
3201
3360
|
] }) });
|
|
3202
3361
|
}
|
|
3203
|
-
function
|
|
3204
|
-
return /* @__PURE__ */
|
|
3205
|
-
|
|
3362
|
+
function FieldLabel({ children }) {
|
|
3363
|
+
return /* @__PURE__ */ jsx27("div", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-1.5", children });
|
|
3364
|
+
}
|
|
3365
|
+
function FieldInput(props) {
|
|
3366
|
+
const baseClass = "w-full px-4 rounded-xl bg-card text-base text-foreground outline-none border-[1.5px] transition-colors";
|
|
3367
|
+
const stateClass = props.error ? "border-destructive focus:border-destructive" : props.valid ? "border-emerald-600 focus:border-emerald-700" : "border-border focus:border-foreground";
|
|
3368
|
+
return /* @__PURE__ */ jsxs18(Fragment7, { children: [
|
|
3206
3369
|
/* @__PURE__ */ jsx27(
|
|
3207
3370
|
"input",
|
|
3208
3371
|
{
|
|
3209
3372
|
type: props.type ?? "text",
|
|
3210
|
-
|
|
3211
|
-
onChange: (e) => props.onChange(e.target.value),
|
|
3212
|
-
onBlur: props.onBlur,
|
|
3373
|
+
inputMode: props.inputMode,
|
|
3213
3374
|
autoComplete: props.autoComplete,
|
|
3214
3375
|
autoCapitalize: props.autoCapitalize,
|
|
3215
3376
|
autoCorrect: props.autoCorrect,
|
|
3216
3377
|
spellCheck: props.spellCheck,
|
|
3217
|
-
inputMode: props.inputMode,
|
|
3218
3378
|
placeholder: props.placeholder,
|
|
3219
|
-
|
|
3379
|
+
value: props.value,
|
|
3380
|
+
onChange: (e) => props.onChange(e.target.value),
|
|
3381
|
+
onBlur: props.onBlur,
|
|
3382
|
+
style: { height: "52px", ...props.style },
|
|
3383
|
+
className: `${baseClass} ${stateClass}`
|
|
3220
3384
|
}
|
|
3221
3385
|
),
|
|
3222
|
-
props.error ? /* @__PURE__ */ jsx27("
|
|
3386
|
+
props.error ? /* @__PURE__ */ jsx27("div", { className: "mt-1.5 text-xs text-destructive font-medium", children: props.error }) : null
|
|
3223
3387
|
] });
|
|
3224
3388
|
}
|
|
3225
|
-
function
|
|
3226
|
-
return /* @__PURE__ */ jsx27(
|
|
3389
|
+
function FieldHint({ children }) {
|
|
3390
|
+
return /* @__PURE__ */ jsx27("div", { className: "mt-1.5 text-xs text-muted-foreground", children });
|
|
3391
|
+
}
|
|
3392
|
+
function TabButton({ active, onClick, icon, label, subtitle, subtitleActiveClass }) {
|
|
3393
|
+
return /* @__PURE__ */ jsxs18(
|
|
3227
3394
|
"button",
|
|
3228
3395
|
{
|
|
3229
3396
|
type: "button",
|
|
3230
3397
|
role: "tab",
|
|
3231
3398
|
"aria-selected": active,
|
|
3232
3399
|
onClick,
|
|
3233
|
-
className: `
|
|
3234
|
-
|
|
3400
|
+
className: `flex-1 flex flex-col items-center justify-center gap-0.5 py-2.5 px-1.5 rounded-lg text-sm font-semibold transition-colors ${active ? "bg-card text-foreground shadow-sm" : "bg-transparent text-muted-foreground"}`,
|
|
3401
|
+
style: { minHeight: 56 },
|
|
3402
|
+
children: [
|
|
3403
|
+
/* @__PURE__ */ jsxs18("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
3404
|
+
icon,
|
|
3405
|
+
" ",
|
|
3406
|
+
label
|
|
3407
|
+
] }),
|
|
3408
|
+
/* @__PURE__ */ jsx27("span", { className: `text-[10px] font-medium ${active ? subtitleActiveClass : "text-muted-foreground/70"}`, children: subtitle })
|
|
3409
|
+
]
|
|
3410
|
+
}
|
|
3411
|
+
);
|
|
3412
|
+
}
|
|
3413
|
+
function CardIcon({ className }) {
|
|
3414
|
+
return /* @__PURE__ */ jsxs18("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
3415
|
+
/* @__PURE__ */ jsx27("rect", { x: "2.5", y: "5.5", width: "19", height: "13", rx: "2.5" }),
|
|
3416
|
+
/* @__PURE__ */ jsx27("path", { d: "M2.5 10h19" })
|
|
3417
|
+
] });
|
|
3418
|
+
}
|
|
3419
|
+
function PixIcon({ className }) {
|
|
3420
|
+
return /* @__PURE__ */ jsx27("svg", { className, viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsx27("path", { d: "M12 2L2 12l10 10 10-10L12 2zm0 4.83L17.17 12 12 17.17 6.83 12 12 6.83z" }) });
|
|
3421
|
+
}
|
|
3422
|
+
function LockIcon({ className }) {
|
|
3423
|
+
return /* @__PURE__ */ jsxs18("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
3424
|
+
/* @__PURE__ */ jsx27("rect", { x: "4", y: "10", width: "16", height: "11", rx: "2.5" }),
|
|
3425
|
+
/* @__PURE__ */ jsx27("path", { d: "M7.5 10V7a4.5 4.5 0 119 0v3" })
|
|
3426
|
+
] });
|
|
3427
|
+
}
|
|
3428
|
+
function ShieldIcon({ className }) {
|
|
3429
|
+
return /* @__PURE__ */ jsxs18("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
3430
|
+
/* @__PURE__ */ jsx27("path", { d: "M12 2.5l8 3v6c0 5-3.5 8.5-8 10-4.5-1.5-8-5-8-10v-6l8-3z" }),
|
|
3431
|
+
/* @__PURE__ */ jsx27("path", { d: "M9 12l2 2 4-4" })
|
|
3432
|
+
] });
|
|
3433
|
+
}
|
|
3434
|
+
function BellIcon({ className }) {
|
|
3435
|
+
return /* @__PURE__ */ jsxs18("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
3436
|
+
/* @__PURE__ */ jsx27("path", { d: "M6 17V11a6 6 0 1112 0v6l1.5 2H4.5L6 17z" }),
|
|
3437
|
+
/* @__PURE__ */ jsx27("path", { d: "M10 21a2 2 0 004 0" })
|
|
3438
|
+
] });
|
|
3439
|
+
}
|
|
3440
|
+
function Spinner2() {
|
|
3441
|
+
return /* @__PURE__ */ jsx27(
|
|
3442
|
+
"span",
|
|
3443
|
+
{
|
|
3444
|
+
className: "w-4 h-4 rounded-full border-2 border-white/40 border-t-white",
|
|
3445
|
+
style: { animation: "spin 0.7s linear infinite" }
|
|
3235
3446
|
}
|
|
3236
3447
|
);
|
|
3237
3448
|
}
|
|
3238
3449
|
|
|
3239
3450
|
// src/defaults/PixWaitingPageDefault.tsx
|
|
3240
|
-
import { useEffect as useEffect12, useMemo as useMemo6, useState as
|
|
3451
|
+
import { useEffect as useEffect12, useMemo as useMemo6, useState as useState10 } from "react";
|
|
3241
3452
|
import { useNavigate as useNavigate3 } from "react-router-dom";
|
|
3242
3453
|
import { useHook as useHook11 } from "@hook-sdk/sdk";
|
|
3243
3454
|
import { jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
@@ -3264,8 +3475,8 @@ function PixWaitingPageDefault() {
|
|
|
3264
3475
|
const navigate = useNavigate3();
|
|
3265
3476
|
const { subscription } = useHook11();
|
|
3266
3477
|
const payload = useMemo6(readPixPayload, []);
|
|
3267
|
-
const [copied, setCopied] =
|
|
3268
|
-
const [timedOut, setTimedOut] =
|
|
3478
|
+
const [copied, setCopied] = useState10(false);
|
|
3479
|
+
const [timedOut, setTimedOut] = useState10(false);
|
|
3269
3480
|
useEffect12(() => {
|
|
3270
3481
|
if (!payload) navigate("/paywall/checkout", { replace: true });
|
|
3271
3482
|
}, [payload, navigate]);
|
|
@@ -3337,19 +3548,19 @@ function PixWaitingPageDefault() {
|
|
|
3337
3548
|
}
|
|
3338
3549
|
|
|
3339
3550
|
// src/hooks/useLoginForm.ts
|
|
3340
|
-
import { useCallback as useCallback7, useMemo as useMemo7, useState as
|
|
3551
|
+
import { useCallback as useCallback7, useMemo as useMemo7, useState as useState11 } from "react";
|
|
3341
3552
|
import { useHook as useHook12 } from "@hook-sdk/sdk";
|
|
3342
3553
|
var EMAIL_RE2 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
3343
3554
|
var MIN_PASSWORD = 8;
|
|
3344
3555
|
function useLoginForm() {
|
|
3345
3556
|
const { auth } = useHook12();
|
|
3346
|
-
const [email, setEmail] =
|
|
3347
|
-
const [password, setPassword] =
|
|
3348
|
-
const [submitting, setSubmitting] =
|
|
3349
|
-
const [error, setError] =
|
|
3350
|
-
const [touchedEmail, setTouchedEmail] =
|
|
3351
|
-
const [touchedPassword, setTouchedPassword] =
|
|
3352
|
-
const [formSubmitAttempted, setFormSubmitAttempted] =
|
|
3557
|
+
const [email, setEmail] = useState11("");
|
|
3558
|
+
const [password, setPassword] = useState11("");
|
|
3559
|
+
const [submitting, setSubmitting] = useState11(false);
|
|
3560
|
+
const [error, setError] = useState11(null);
|
|
3561
|
+
const [touchedEmail, setTouchedEmail] = useState11(false);
|
|
3562
|
+
const [touchedPassword, setTouchedPassword] = useState11(false);
|
|
3563
|
+
const [formSubmitAttempted, setFormSubmitAttempted] = useState11(false);
|
|
3353
3564
|
const validateEmail = useMemo7(() => {
|
|
3354
3565
|
if (email.length === 0) return null;
|
|
3355
3566
|
if (!EMAIL_RE2.test(email)) return "Formato de e-mail inv\xE1lido.";
|
|
@@ -3397,21 +3608,21 @@ function useLoginForm() {
|
|
|
3397
3608
|
}
|
|
3398
3609
|
|
|
3399
3610
|
// src/hooks/useSignupForm.ts
|
|
3400
|
-
import { useCallback as useCallback8, useMemo as useMemo8, useState as
|
|
3611
|
+
import { useCallback as useCallback8, useMemo as useMemo8, useState as useState12 } from "react";
|
|
3401
3612
|
import { useHook as useHook13 } from "@hook-sdk/sdk";
|
|
3402
3613
|
var EMAIL_RE3 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
3403
3614
|
var MIN_PASSWORD2 = 8;
|
|
3404
3615
|
function useSignupForm() {
|
|
3405
3616
|
const { auth } = useHook13();
|
|
3406
|
-
const [name, setName] =
|
|
3407
|
-
const [email, setEmail] =
|
|
3408
|
-
const [password, setPassword] =
|
|
3409
|
-
const [submitting, setSubmitting] =
|
|
3410
|
-
const [error, setError] =
|
|
3411
|
-
const [touchedName, setTouchedName] =
|
|
3412
|
-
const [touchedEmail, setTouchedEmail] =
|
|
3413
|
-
const [touchedPassword, setTouchedPassword] =
|
|
3414
|
-
const [formSubmitAttempted, setFormSubmitAttempted] =
|
|
3617
|
+
const [name, setName] = useState12("");
|
|
3618
|
+
const [email, setEmail] = useState12("");
|
|
3619
|
+
const [password, setPassword] = useState12("");
|
|
3620
|
+
const [submitting, setSubmitting] = useState12(false);
|
|
3621
|
+
const [error, setError] = useState12(null);
|
|
3622
|
+
const [touchedName, setTouchedName] = useState12(false);
|
|
3623
|
+
const [touchedEmail, setTouchedEmail] = useState12(false);
|
|
3624
|
+
const [touchedPassword, setTouchedPassword] = useState12(false);
|
|
3625
|
+
const [formSubmitAttempted, setFormSubmitAttempted] = useState12(false);
|
|
3415
3626
|
const validateName = useMemo8(() => {
|
|
3416
3627
|
if (name.length === 0) return null;
|
|
3417
3628
|
if (name.trim().length < 2) return "Nome muito curto.";
|
|
@@ -3469,17 +3680,17 @@ function useSignupForm() {
|
|
|
3469
3680
|
}
|
|
3470
3681
|
|
|
3471
3682
|
// src/hooks/useForgotForm.ts
|
|
3472
|
-
import { useCallback as useCallback9, useMemo as useMemo9, useState as
|
|
3683
|
+
import { useCallback as useCallback9, useMemo as useMemo9, useState as useState13 } from "react";
|
|
3473
3684
|
import { useHook as useHook14 } from "@hook-sdk/sdk";
|
|
3474
3685
|
var EMAIL_RE4 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
3475
3686
|
function useForgotForm() {
|
|
3476
3687
|
const { auth } = useHook14();
|
|
3477
|
-
const [email, setEmail] =
|
|
3478
|
-
const [submitting, setSubmitting] =
|
|
3479
|
-
const [sent, setSent] =
|
|
3480
|
-
const [error, setError] =
|
|
3481
|
-
const [touchedEmail, setTouchedEmail] =
|
|
3482
|
-
const [formSubmitAttempted, setFormSubmitAttempted] =
|
|
3688
|
+
const [email, setEmail] = useState13("");
|
|
3689
|
+
const [submitting, setSubmitting] = useState13(false);
|
|
3690
|
+
const [sent, setSent] = useState13(false);
|
|
3691
|
+
const [error, setError] = useState13(null);
|
|
3692
|
+
const [touchedEmail, setTouchedEmail] = useState13(false);
|
|
3693
|
+
const [formSubmitAttempted, setFormSubmitAttempted] = useState13(false);
|
|
3483
3694
|
const validateEmail = useMemo9(() => {
|
|
3484
3695
|
if (email.length === 0) return null;
|
|
3485
3696
|
if (!EMAIL_RE4.test(email)) return "Formato de e-mail inv\xE1lido.";
|
|
@@ -3518,20 +3729,20 @@ function useForgotForm() {
|
|
|
3518
3729
|
}
|
|
3519
3730
|
|
|
3520
3731
|
// src/hooks/useResetForm.ts
|
|
3521
|
-
import { useCallback as useCallback10, useEffect as useEffect13, useMemo as useMemo10, useState as
|
|
3732
|
+
import { useCallback as useCallback10, useEffect as useEffect13, useMemo as useMemo10, useState as useState14 } from "react";
|
|
3522
3733
|
import { useHook as useHook15 } from "@hook-sdk/sdk";
|
|
3523
3734
|
var MIN_PASSWORD3 = 12;
|
|
3524
3735
|
function useResetForm() {
|
|
3525
3736
|
const { auth } = useHook15();
|
|
3526
|
-
const [token, setToken] =
|
|
3527
|
-
const [password, setPassword] =
|
|
3528
|
-
const [confirm, setConfirm] =
|
|
3529
|
-
const [submitting, setSubmitting] =
|
|
3530
|
-
const [done, setDone] =
|
|
3531
|
-
const [error, setError] =
|
|
3532
|
-
const [touchedPassword, setTouchedPassword] =
|
|
3533
|
-
const [touchedConfirm, setTouchedConfirm] =
|
|
3534
|
-
const [formSubmitAttempted, setFormSubmitAttempted] =
|
|
3737
|
+
const [token, setToken] = useState14(null);
|
|
3738
|
+
const [password, setPassword] = useState14("");
|
|
3739
|
+
const [confirm, setConfirm] = useState14("");
|
|
3740
|
+
const [submitting, setSubmitting] = useState14(false);
|
|
3741
|
+
const [done, setDone] = useState14(false);
|
|
3742
|
+
const [error, setError] = useState14(null);
|
|
3743
|
+
const [touchedPassword, setTouchedPassword] = useState14(false);
|
|
3744
|
+
const [touchedConfirm, setTouchedConfirm] = useState14(false);
|
|
3745
|
+
const [formSubmitAttempted, setFormSubmitAttempted] = useState14(false);
|
|
3535
3746
|
useEffect13(() => {
|
|
3536
3747
|
if (typeof window === "undefined") return;
|
|
3537
3748
|
const params = new URLSearchParams(window.location.search);
|
|
@@ -3669,13 +3880,13 @@ function useSubscription() {
|
|
|
3669
3880
|
}
|
|
3670
3881
|
|
|
3671
3882
|
// src/hooks/useReminders.ts
|
|
3672
|
-
import { useCallback as useCallback11, useEffect as useEffect15, useState as
|
|
3883
|
+
import { useCallback as useCallback11, useEffect as useEffect15, useState as useState15 } from "react";
|
|
3673
3884
|
import { useHook as useHook19 } from "@hook-sdk/sdk";
|
|
3674
3885
|
function useReminders() {
|
|
3675
3886
|
const { push } = useHook19();
|
|
3676
3887
|
const r = push.reminders;
|
|
3677
|
-
const [reminders, setReminders] =
|
|
3678
|
-
const [loading, setLoading] =
|
|
3888
|
+
const [reminders, setReminders] = useState15([]);
|
|
3889
|
+
const [loading, setLoading] = useState15(true);
|
|
3679
3890
|
const reload = useCallback11(async () => {
|
|
3680
3891
|
setLoading(true);
|
|
3681
3892
|
try {
|
|
@@ -3706,9 +3917,9 @@ function useReminders() {
|
|
|
3706
3917
|
}
|
|
3707
3918
|
|
|
3708
3919
|
// src/hooks/useToast.ts
|
|
3709
|
-
import { useCallback as useCallback12, useState as
|
|
3920
|
+
import { useCallback as useCallback12, useState as useState16 } from "react";
|
|
3710
3921
|
function useToast() {
|
|
3711
|
-
const [items, setItems] =
|
|
3922
|
+
const [items, setItems] = useState16([]);
|
|
3712
3923
|
const show = useCallback12((message, kind = "info") => {
|
|
3713
3924
|
const id = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
3714
3925
|
setItems((prev) => [...prev, { id, message, kind }]);
|
|
@@ -4279,7 +4490,7 @@ function PaywallPriceHeadline({
|
|
|
4279
4490
|
}
|
|
4280
4491
|
|
|
4281
4492
|
// src/components/paywall/blocks/PaywallCountdown.tsx
|
|
4282
|
-
import { useEffect as useEffect18, useRef as useRef8, useState as
|
|
4493
|
+
import { useEffect as useEffect18, useRef as useRef8, useState as useState17 } from "react";
|
|
4283
4494
|
import { jsx as jsx42 } from "react/jsx-runtime";
|
|
4284
4495
|
var DEFAULT_COUNTDOWN_CLASSES = "font-mono tabular-nums";
|
|
4285
4496
|
function resolveDeadlineMs(deadline) {
|
|
@@ -4321,7 +4532,7 @@ function PaywallCountdown({
|
|
|
4321
4532
|
if (deadlineMsRef.current === null) {
|
|
4322
4533
|
deadlineMsRef.current = resolveDeadlineMs(deadline);
|
|
4323
4534
|
}
|
|
4324
|
-
const [state, setState] =
|
|
4535
|
+
const [state, setState] = useState17(() => computeRemaining(deadlineMsRef.current));
|
|
4325
4536
|
const expiredCalledRef = useRef8(false);
|
|
4326
4537
|
useEffect18(() => {
|
|
4327
4538
|
if (state.expired) {
|