@hook-sdk/template 0.8.1 → 0.9.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 +616 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -17
- package/dist/index.d.ts +30 -17
- package/dist/index.js +633 -96
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/AppRoot.tsx
|
|
2
2
|
import { useCallback as useCallback7, useEffect as useEffect8, useRef as useRef3, useState as useState12 } from "react";
|
|
3
|
-
import { useHook as
|
|
3
|
+
import { useHook as useHook9 } from "@hook-sdk/sdk";
|
|
4
4
|
|
|
5
5
|
// src/internal/TemplateConfigContext.tsx
|
|
6
6
|
import { createContext, useContext, useMemo } from "react";
|
|
@@ -92,53 +92,69 @@ function AuthGate({ Login, Signup, Forgot, Reset, children }) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
// src/hooks/usePaywallState.ts
|
|
95
|
-
import { useCallback, useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
95
|
+
import { useCallback, useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState2 } from "react";
|
|
96
96
|
import { useHook as useHook2 } from "@hook-sdk/sdk";
|
|
97
97
|
function usePaywallState() {
|
|
98
|
-
const { subscription } = useHook2();
|
|
98
|
+
const { subscription, plan } = useHook2();
|
|
99
99
|
const [opening, setOpening] = useState2(false);
|
|
100
100
|
const [error, setError] = useState2(null);
|
|
101
101
|
const [pixPending, setPixPending] = useState2(null);
|
|
102
102
|
const status = subscription.status();
|
|
103
103
|
const daysLeftInTrial = subscription.daysLeftInTrial();
|
|
104
104
|
const initialLoadComplete = subscription.initialLoadComplete;
|
|
105
|
+
const availableMethods = useMemo2(
|
|
106
|
+
() => ["card", "pix-auto"],
|
|
107
|
+
[]
|
|
108
|
+
);
|
|
109
|
+
const priceCents = plan.data?.priceCents ?? 0;
|
|
110
|
+
const yearlyPriceCents = plan.data?.yearlyPriceCents ?? null;
|
|
111
|
+
const monthlyEquivalent = useCallback(
|
|
112
|
+
(cycle) => {
|
|
113
|
+
if (cycle === "YEARLY" && yearlyPriceCents) {
|
|
114
|
+
return Math.round(yearlyPriceCents / 12);
|
|
115
|
+
}
|
|
116
|
+
return priceCents;
|
|
117
|
+
},
|
|
118
|
+
[priceCents, yearlyPriceCents]
|
|
119
|
+
);
|
|
105
120
|
const checkout = useCallback(
|
|
106
121
|
async (args) => {
|
|
107
122
|
setOpening(true);
|
|
108
123
|
setError(null);
|
|
109
124
|
setPixPending(null);
|
|
110
|
-
const method = args.method ?? "card";
|
|
111
|
-
const cycle = args.cycle ?? "MONTHLY";
|
|
112
125
|
try {
|
|
113
|
-
if (method === "card") {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
expiresAt: null,
|
|
125
|
-
paid: false
|
|
126
|
+
if (args.method === "card") {
|
|
127
|
+
if (!args.card || !args.holderInfo) {
|
|
128
|
+
throw new Error('card and holderInfo are required when method is "card"');
|
|
129
|
+
}
|
|
130
|
+
await subscription.checkout({
|
|
131
|
+
method: "card",
|
|
132
|
+
cycle: args.cycle,
|
|
133
|
+
cpf: args.cpf,
|
|
134
|
+
card: args.card,
|
|
135
|
+
holderInfo: args.holderInfo,
|
|
136
|
+
...args.remoteIp ? { remoteIp: args.remoteIp } : {}
|
|
126
137
|
});
|
|
138
|
+
await subscription.refresh();
|
|
127
139
|
setOpening(false);
|
|
128
140
|
return;
|
|
129
141
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
paid: false
|
|
138
|
-
});
|
|
139
|
-
setOpening(false);
|
|
140
|
-
return;
|
|
142
|
+
const result = await subscription.checkout({
|
|
143
|
+
method: "pix-auto",
|
|
144
|
+
cycle: args.cycle,
|
|
145
|
+
cpf: args.cpf
|
|
146
|
+
});
|
|
147
|
+
if (result.method !== "pix-auto") {
|
|
148
|
+
throw new Error(`unexpected checkout result method: ${result.method}`);
|
|
141
149
|
}
|
|
150
|
+
setPixPending({
|
|
151
|
+
method: "pix-auto",
|
|
152
|
+
qrCodePayload: result.qrCodePayload,
|
|
153
|
+
qrCodeBase64: result.qrCodeBase64,
|
|
154
|
+
expiresAt: null,
|
|
155
|
+
paid: false
|
|
156
|
+
});
|
|
157
|
+
setOpening(false);
|
|
142
158
|
} catch (err) {
|
|
143
159
|
setError(err);
|
|
144
160
|
setOpening(false);
|
|
@@ -191,7 +207,9 @@ function usePaywallState() {
|
|
|
191
207
|
opening,
|
|
192
208
|
error,
|
|
193
209
|
pixPending,
|
|
194
|
-
dismissPix
|
|
210
|
+
dismissPix,
|
|
211
|
+
availableMethods,
|
|
212
|
+
monthlyEquivalent
|
|
195
213
|
};
|
|
196
214
|
}
|
|
197
215
|
|
|
@@ -1534,7 +1552,7 @@ var ErrorBoundary = class extends Component {
|
|
|
1534
1552
|
};
|
|
1535
1553
|
|
|
1536
1554
|
// src/hooks/useLoginForm.ts
|
|
1537
|
-
import { useCallback as useCallback3, useMemo as
|
|
1555
|
+
import { useCallback as useCallback3, useMemo as useMemo3, useState as useState6 } from "react";
|
|
1538
1556
|
import { useHook as useHook4 } from "@hook-sdk/sdk";
|
|
1539
1557
|
|
|
1540
1558
|
// src/errors.ts
|
|
@@ -1575,12 +1593,12 @@ function useLoginForm() {
|
|
|
1575
1593
|
const [password, setPassword] = useState6("");
|
|
1576
1594
|
const [submitting, setSubmitting] = useState6(false);
|
|
1577
1595
|
const [error, setError] = useState6(null);
|
|
1578
|
-
const emailError =
|
|
1596
|
+
const emailError = useMemo3(() => {
|
|
1579
1597
|
if (email.length === 0) return null;
|
|
1580
1598
|
if (!EMAIL_RE.test(email)) return "Formato de e-mail inv\xE1lido.";
|
|
1581
1599
|
return null;
|
|
1582
1600
|
}, [email]);
|
|
1583
|
-
const passwordError =
|
|
1601
|
+
const passwordError = useMemo3(() => {
|
|
1584
1602
|
if (password.length === 0) return null;
|
|
1585
1603
|
if (password.length < MIN_PASSWORD) return `M\xEDnimo de ${MIN_PASSWORD} caracteres.`;
|
|
1586
1604
|
return null;
|
|
@@ -1840,7 +1858,7 @@ function DefaultLoginScreen({ onNavigate }) {
|
|
|
1840
1858
|
}
|
|
1841
1859
|
|
|
1842
1860
|
// src/hooks/useSignupForm.ts
|
|
1843
|
-
import { useCallback as useCallback4, useMemo as
|
|
1861
|
+
import { useCallback as useCallback4, useMemo as useMemo4, useState as useState8 } from "react";
|
|
1844
1862
|
import { useHook as useHook5 } from "@hook-sdk/sdk";
|
|
1845
1863
|
var EMAIL_RE2 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
1846
1864
|
var MIN_PASSWORD2 = 8;
|
|
@@ -1851,17 +1869,17 @@ function useSignupForm() {
|
|
|
1851
1869
|
const [password, setPassword] = useState8("");
|
|
1852
1870
|
const [submitting, setSubmitting] = useState8(false);
|
|
1853
1871
|
const [error, setError] = useState8(null);
|
|
1854
|
-
const nameError =
|
|
1872
|
+
const nameError = useMemo4(() => {
|
|
1855
1873
|
if (name.length === 0) return null;
|
|
1856
1874
|
if (name.trim().length < 2) return "Nome muito curto.";
|
|
1857
1875
|
return null;
|
|
1858
1876
|
}, [name]);
|
|
1859
|
-
const emailError =
|
|
1877
|
+
const emailError = useMemo4(() => {
|
|
1860
1878
|
if (email.length === 0) return null;
|
|
1861
1879
|
if (!EMAIL_RE2.test(email)) return "Formato de e-mail inv\xE1lido.";
|
|
1862
1880
|
return null;
|
|
1863
1881
|
}, [email]);
|
|
1864
|
-
const passwordError =
|
|
1882
|
+
const passwordError = useMemo4(() => {
|
|
1865
1883
|
if (password.length === 0) return null;
|
|
1866
1884
|
if (password.length < MIN_PASSWORD2) return `M\xEDnimo de ${MIN_PASSWORD2} caracteres.`;
|
|
1867
1885
|
return null;
|
|
@@ -1955,7 +1973,7 @@ function DefaultSignupScreen({ onNavigate }) {
|
|
|
1955
1973
|
}
|
|
1956
1974
|
|
|
1957
1975
|
// src/hooks/useForgotForm.ts
|
|
1958
|
-
import { useCallback as useCallback5, useMemo as
|
|
1976
|
+
import { useCallback as useCallback5, useMemo as useMemo5, useState as useState9 } from "react";
|
|
1959
1977
|
import { useHook as useHook6 } from "@hook-sdk/sdk";
|
|
1960
1978
|
var EMAIL_RE3 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
1961
1979
|
function useForgotForm() {
|
|
@@ -1964,7 +1982,7 @@ function useForgotForm() {
|
|
|
1964
1982
|
const [submitting, setSubmitting] = useState9(false);
|
|
1965
1983
|
const [sent, setSent] = useState9(false);
|
|
1966
1984
|
const [error, setError] = useState9(null);
|
|
1967
|
-
const emailError =
|
|
1985
|
+
const emailError = useMemo5(() => {
|
|
1968
1986
|
if (email.length === 0) return null;
|
|
1969
1987
|
if (!EMAIL_RE3.test(email)) return "Formato de e-mail inv\xE1lido.";
|
|
1970
1988
|
return null;
|
|
@@ -2029,7 +2047,7 @@ function DefaultForgotScreen({ onNavigate }) {
|
|
|
2029
2047
|
}
|
|
2030
2048
|
|
|
2031
2049
|
// src/hooks/useResetForm.ts
|
|
2032
|
-
import { useCallback as useCallback6, useEffect as useEffect7, useMemo as
|
|
2050
|
+
import { useCallback as useCallback6, useEffect as useEffect7, useMemo as useMemo6, useState as useState10 } from "react";
|
|
2033
2051
|
import { useHook as useHook7 } from "@hook-sdk/sdk";
|
|
2034
2052
|
var MIN_PASSWORD3 = 12;
|
|
2035
2053
|
function useResetForm() {
|
|
@@ -2046,12 +2064,12 @@ function useResetForm() {
|
|
|
2046
2064
|
const t = params.get("token");
|
|
2047
2065
|
setToken(t && t.length > 0 ? t : null);
|
|
2048
2066
|
}, []);
|
|
2049
|
-
const passwordError =
|
|
2067
|
+
const passwordError = useMemo6(() => {
|
|
2050
2068
|
if (password.length === 0) return null;
|
|
2051
2069
|
if (password.length < MIN_PASSWORD3) return `M\xEDnimo de ${MIN_PASSWORD3} caracteres.`;
|
|
2052
2070
|
return null;
|
|
2053
2071
|
}, [password]);
|
|
2054
|
-
const confirmError =
|
|
2072
|
+
const confirmError = useMemo6(() => {
|
|
2055
2073
|
if (confirm.length === 0) return null;
|
|
2056
2074
|
if (confirm !== password) return "Senhas n\xE3o coincidem.";
|
|
2057
2075
|
return null;
|
|
@@ -2135,44 +2153,486 @@ function DefaultResetScreen({ onNavigate }) {
|
|
|
2135
2153
|
}
|
|
2136
2154
|
|
|
2137
2155
|
// src/defaults/DefaultPaywall.tsx
|
|
2138
|
-
import { useState as useState11 } from "react";
|
|
2139
|
-
|
|
2156
|
+
import { useMemo as useMemo7, useState as useState11 } from "react";
|
|
2157
|
+
|
|
2158
|
+
// src/hooks/usePlan.ts
|
|
2159
|
+
import { useHook as useHook8 } from "@hook-sdk/sdk";
|
|
2160
|
+
function usePlan() {
|
|
2161
|
+
const { plan } = useHook8();
|
|
2162
|
+
return plan;
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
// src/utils/price.ts
|
|
2166
|
+
function formatBRL(cents) {
|
|
2167
|
+
if (cents === null || cents === void 0) return "";
|
|
2168
|
+
const reais = cents / 100;
|
|
2169
|
+
return new Intl.NumberFormat("pt-BR", {
|
|
2170
|
+
style: "currency",
|
|
2171
|
+
currency: "BRL"
|
|
2172
|
+
}).format(reais);
|
|
2173
|
+
}
|
|
2174
|
+
function monthlyFromYearly(yearlyCents) {
|
|
2175
|
+
if (yearlyCents === null || yearlyCents === void 0) return 0;
|
|
2176
|
+
return Math.round(yearlyCents / 12);
|
|
2177
|
+
}
|
|
2178
|
+
function dailyFromYearly(yearlyCents) {
|
|
2179
|
+
if (yearlyCents === null || yearlyCents === void 0) return 0;
|
|
2180
|
+
return Math.round(yearlyCents / 365);
|
|
2181
|
+
}
|
|
2182
|
+
function computeAnchorCents(baseCents, multiplier) {
|
|
2183
|
+
if (multiplier === null || multiplier === void 0) return null;
|
|
2184
|
+
if (!Number.isFinite(multiplier)) return null;
|
|
2185
|
+
if (multiplier <= 1) return null;
|
|
2186
|
+
return Math.round(baseCents * multiplier);
|
|
2187
|
+
}
|
|
2188
|
+
function discountPercent(anchorCents, realCents) {
|
|
2189
|
+
if (anchorCents <= realCents) return 0;
|
|
2190
|
+
return Math.floor((anchorCents - realCents) / anchorCents * 100);
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
// src/defaults/DefaultPaywall.tsx
|
|
2194
|
+
import { Fragment as Fragment6, jsx as jsx24, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2140
2195
|
function DefaultPaywall() {
|
|
2141
2196
|
const config = useTemplateConfig();
|
|
2142
|
-
const
|
|
2197
|
+
const plan = usePlan();
|
|
2198
|
+
const {
|
|
2199
|
+
checkout,
|
|
2200
|
+
opening,
|
|
2201
|
+
error,
|
|
2202
|
+
availableMethods,
|
|
2203
|
+
monthlyEquivalent,
|
|
2204
|
+
pixPending,
|
|
2205
|
+
dismissPix
|
|
2206
|
+
} = usePaywallState();
|
|
2143
2207
|
const p = config.subscription.paywall_config;
|
|
2208
|
+
const paywallCfg = plan.data?.paywallConfig ?? {};
|
|
2209
|
+
const anchorMultiplier = paywallCfg.anchorMultiplier ?? p.anchorMultiplier;
|
|
2210
|
+
const anchorPriceCents = paywallCfg.anchorPriceCents ?? p.anchorPriceCents;
|
|
2211
|
+
const [cycle, setCycle] = useState11("MONTHLY");
|
|
2212
|
+
const [method, setMethod] = useState11("card");
|
|
2144
2213
|
const [cpf, setCpf] = useState11("");
|
|
2214
|
+
const [cardNumber, setCardNumber] = useState11("");
|
|
2215
|
+
const [cardHolderName, setCardHolderName] = useState11("");
|
|
2216
|
+
const [cardExpiryMonth, setCardExpiryMonth] = useState11("");
|
|
2217
|
+
const [cardExpiryYear, setCardExpiryYear] = useState11("");
|
|
2218
|
+
const [cardCcv, setCardCcv] = useState11("");
|
|
2219
|
+
const [holderName, setHolderName] = useState11("");
|
|
2220
|
+
const [holderEmail, setHolderEmail] = useState11("");
|
|
2221
|
+
const [holderPostalCode, setHolderPostalCode] = useState11("");
|
|
2222
|
+
const [holderAddressNumber, setHolderAddressNumber] = useState11("");
|
|
2223
|
+
const [holderPhone, setHolderPhone] = useState11("");
|
|
2224
|
+
const trialDays = plan.data?.trialDays ?? 0;
|
|
2225
|
+
const monthlyCents = plan.data?.priceCents ?? 0;
|
|
2226
|
+
const yearlyCents = plan.data?.yearlyPriceCents ?? null;
|
|
2227
|
+
const activeCents = cycle === "YEARLY" && yearlyCents ? monthlyEquivalent("YEARLY") : monthlyCents;
|
|
2228
|
+
const cycleValueCents = cycle === "YEARLY" && yearlyCents ? yearlyCents : monthlyCents;
|
|
2229
|
+
const cycleLabel = cycle === "YEARLY" ? "por ano" : "por m\xEAs";
|
|
2230
|
+
const pct = useMemo7(() => {
|
|
2231
|
+
if (!yearlyCents || !monthlyCents) return 0;
|
|
2232
|
+
const derived = Math.round((1 - yearlyCents / 12 / monthlyCents) * 100);
|
|
2233
|
+
return Math.max(0, derived);
|
|
2234
|
+
}, [monthlyCents, yearlyCents]);
|
|
2235
|
+
const anchorBaseCents = cycle === "YEARLY" && yearlyCents ? monthlyFromYearly(yearlyCents) : monthlyCents;
|
|
2236
|
+
const anchorCents = computeAnchorCents(anchorBaseCents, anchorMultiplier) ?? (anchorPriceCents && anchorPriceCents > anchorBaseCents ? anchorPriceCents : null);
|
|
2237
|
+
const anchorDiscount = anchorCents ? discountPercent(anchorCents, activeCents) : 0;
|
|
2145
2238
|
const cpfDigits = cpf.replace(/\D/g, "");
|
|
2146
|
-
const
|
|
2147
|
-
|
|
2239
|
+
const cardFieldsFilled = cardNumber.replace(/\s/g, "").length >= 13 && cardHolderName.trim().length > 0 && cardExpiryMonth.length === 2 && cardExpiryYear.length >= 2 && cardCcv.length >= 3 && holderName.trim().length > 0 && /.+@.+\..+/.test(holderEmail) && holderPostalCode.replace(/\D/g, "").length === 8 && holderAddressNumber.trim().length > 0;
|
|
2240
|
+
const canCheckout = cpfDigits.length === 11 && !opening && (method === "pix-auto" || cardFieldsFilled);
|
|
2241
|
+
const ctaLabel = useMemo7(() => {
|
|
2242
|
+
if (opening) return "Abrindo\u2026";
|
|
2243
|
+
if (trialDays > 0) return `Comece trial de ${trialDays} dias gr\xE1tis`;
|
|
2244
|
+
return p.cta ?? "Assinar agora";
|
|
2245
|
+
}, [opening, trialDays, p.cta]);
|
|
2246
|
+
const footer = useMemo7(() => {
|
|
2247
|
+
if (trialDays > 0) {
|
|
2248
|
+
return `Sem cobran\xE7a agora. Cobran\xE7a autom\xE1tica em ${trialDays} dias. Cancele quando quiser.`;
|
|
2249
|
+
}
|
|
2250
|
+
return "Cobran\xE7a imediata. Cancele quando quiser.";
|
|
2251
|
+
}, [trialDays]);
|
|
2252
|
+
const yearSuffix = cardExpiryYear.length === 2 ? `20${cardExpiryYear}` : cardExpiryYear;
|
|
2253
|
+
const phoneDigits = holderPhone.replace(/\D/g, "");
|
|
2254
|
+
const postalDigits = holderPostalCode.replace(/\D/g, "");
|
|
2255
|
+
const submit = () => {
|
|
2256
|
+
if (method === "card") {
|
|
2257
|
+
void checkout({
|
|
2258
|
+
cpf: cpfDigits,
|
|
2259
|
+
cycle,
|
|
2260
|
+
method: "card",
|
|
2261
|
+
card: {
|
|
2262
|
+
number: cardNumber.replace(/\s/g, ""),
|
|
2263
|
+
holderName: cardHolderName.trim(),
|
|
2264
|
+
expiryMonth: cardExpiryMonth,
|
|
2265
|
+
expiryYear: yearSuffix,
|
|
2266
|
+
ccv: cardCcv
|
|
2267
|
+
},
|
|
2268
|
+
holderInfo: {
|
|
2269
|
+
name: holderName.trim(),
|
|
2270
|
+
email: holderEmail.trim(),
|
|
2271
|
+
cpfCnpj: cpfDigits,
|
|
2272
|
+
postalCode: postalDigits,
|
|
2273
|
+
addressNumber: holderAddressNumber.trim(),
|
|
2274
|
+
...phoneDigits ? { phone: phoneDigits } : {}
|
|
2275
|
+
}
|
|
2276
|
+
});
|
|
2277
|
+
return;
|
|
2278
|
+
}
|
|
2279
|
+
void checkout({ cpf: cpfDigits, cycle, method: "pix-auto" });
|
|
2280
|
+
};
|
|
2281
|
+
const inputStyle = {
|
|
2282
|
+
width: "100%",
|
|
2283
|
+
padding: 10,
|
|
2284
|
+
fontSize: 14,
|
|
2285
|
+
borderRadius: 8,
|
|
2286
|
+
border: "1px solid #ccc",
|
|
2287
|
+
boxSizing: "border-box"
|
|
2288
|
+
};
|
|
2289
|
+
const labelStyle = { display: "block", fontSize: 13, opacity: 0.75, marginBottom: 4 };
|
|
2290
|
+
const fieldGroup = { marginBottom: 10, textAlign: "left" };
|
|
2291
|
+
return /* @__PURE__ */ jsxs18("main", { style: { padding: 24, maxWidth: 480, margin: "0 auto", textAlign: "center" }, children: [
|
|
2148
2292
|
/* @__PURE__ */ jsx24("h1", { style: { marginBottom: 8 }, children: p.title }),
|
|
2149
2293
|
p.subtitle && /* @__PURE__ */ jsx24("p", { style: { opacity: 0.7, marginBottom: 24 }, children: p.subtitle }),
|
|
2150
|
-
/* @__PURE__ */
|
|
2294
|
+
/* @__PURE__ */ jsxs18(
|
|
2295
|
+
"div",
|
|
2296
|
+
{
|
|
2297
|
+
role: "group",
|
|
2298
|
+
"aria-label": "Per\xEDodo de cobran\xE7a",
|
|
2299
|
+
style: { display: "flex", gap: 8, marginBottom: 16 },
|
|
2300
|
+
children: [
|
|
2301
|
+
/* @__PURE__ */ jsx24(
|
|
2302
|
+
"button",
|
|
2303
|
+
{
|
|
2304
|
+
type: "button",
|
|
2305
|
+
"aria-pressed": cycle === "MONTHLY",
|
|
2306
|
+
onClick: () => setCycle("MONTHLY"),
|
|
2307
|
+
style: {
|
|
2308
|
+
flex: 1,
|
|
2309
|
+
padding: 12,
|
|
2310
|
+
borderRadius: 8,
|
|
2311
|
+
border: cycle === "MONTHLY" ? "2px solid var(--hook-color-primary)" : "1px solid #ccc",
|
|
2312
|
+
background: cycle === "MONTHLY" ? "var(--hook-color-primary-soft, #eef)" : "white",
|
|
2313
|
+
cursor: "pointer"
|
|
2314
|
+
},
|
|
2315
|
+
children: "Mensal"
|
|
2316
|
+
}
|
|
2317
|
+
),
|
|
2318
|
+
/* @__PURE__ */ jsxs18(
|
|
2319
|
+
"button",
|
|
2320
|
+
{
|
|
2321
|
+
type: "button",
|
|
2322
|
+
"aria-pressed": cycle === "YEARLY",
|
|
2323
|
+
onClick: () => setCycle("YEARLY"),
|
|
2324
|
+
disabled: !yearlyCents,
|
|
2325
|
+
style: {
|
|
2326
|
+
flex: 1,
|
|
2327
|
+
padding: 12,
|
|
2328
|
+
borderRadius: 8,
|
|
2329
|
+
border: cycle === "YEARLY" ? "2px solid var(--hook-color-primary)" : "1px solid #ccc",
|
|
2330
|
+
background: cycle === "YEARLY" ? "var(--hook-color-primary-soft, #eef)" : "white",
|
|
2331
|
+
cursor: yearlyCents ? "pointer" : "not-allowed",
|
|
2332
|
+
opacity: yearlyCents ? 1 : 0.5
|
|
2333
|
+
},
|
|
2334
|
+
children: [
|
|
2335
|
+
"Anual",
|
|
2336
|
+
pct > 0 ? ` \u2212${pct}%` : ""
|
|
2337
|
+
]
|
|
2338
|
+
}
|
|
2339
|
+
)
|
|
2340
|
+
]
|
|
2341
|
+
}
|
|
2342
|
+
),
|
|
2343
|
+
/* @__PURE__ */ jsxs18("div", { style: { marginBottom: 8 }, children: [
|
|
2344
|
+
/* @__PURE__ */ jsxs18("div", { style: { fontSize: 32, fontWeight: 700, lineHeight: 1 }, children: [
|
|
2345
|
+
formatBRL(activeCents),
|
|
2346
|
+
/* @__PURE__ */ jsx24("span", { style: { fontSize: 16, fontWeight: 400, opacity: 0.7 }, children: "/m\xEAs" })
|
|
2347
|
+
] }),
|
|
2348
|
+
anchorCents && /* @__PURE__ */ jsxs18("div", { style: { fontSize: 14, opacity: 0.6, marginTop: 4 }, children: [
|
|
2349
|
+
/* @__PURE__ */ jsx24("span", { style: { textDecoration: "line-through" }, children: formatBRL(anchorCents) }),
|
|
2350
|
+
anchorDiscount > 0 && /* @__PURE__ */ jsxs18("span", { style: { marginLeft: 6 }, children: [
|
|
2351
|
+
"\u2212",
|
|
2352
|
+
anchorDiscount,
|
|
2353
|
+
"%"
|
|
2354
|
+
] })
|
|
2355
|
+
] }),
|
|
2356
|
+
cycle === "YEARLY" && yearlyCents && /* @__PURE__ */ jsxs18("div", { style: { fontSize: 12, opacity: 0.6, marginTop: 4 }, children: [
|
|
2357
|
+
"Cobrado ",
|
|
2358
|
+
formatBRL(yearlyCents),
|
|
2359
|
+
" por ano"
|
|
2360
|
+
] })
|
|
2361
|
+
] }),
|
|
2362
|
+
/* @__PURE__ */ jsx24("ul", { style: { listStyle: "none", padding: 0, textAlign: "left", margin: "24px 0" }, children: p.benefits.map((b) => /* @__PURE__ */ jsxs18("li", { style: { padding: "8px 0", display: "flex", alignItems: "center" }, children: [
|
|
2151
2363
|
/* @__PURE__ */ jsx24("span", { "aria-hidden": true, style: { marginRight: 8 }, children: "\u2713" }),
|
|
2152
2364
|
/* @__PURE__ */ jsx24("span", { children: b })
|
|
2153
2365
|
] }, b)) }),
|
|
2154
|
-
/* @__PURE__ */
|
|
2155
|
-
|
|
2366
|
+
/* @__PURE__ */ jsx24("div", { role: "tablist", "aria-label": "M\xE9todo de pagamento", style: { display: "flex", gap: 8, marginBottom: 16 }, children: availableMethods.map((m) => /* @__PURE__ */ jsx24(
|
|
2367
|
+
"button",
|
|
2368
|
+
{
|
|
2369
|
+
type: "button",
|
|
2370
|
+
role: "tab",
|
|
2371
|
+
"aria-selected": method === m,
|
|
2372
|
+
onClick: () => setMethod(m),
|
|
2373
|
+
style: {
|
|
2374
|
+
flex: 1,
|
|
2375
|
+
padding: 10,
|
|
2376
|
+
borderRadius: 8,
|
|
2377
|
+
border: method === m ? "2px solid var(--hook-color-primary)" : "1px solid #ccc",
|
|
2378
|
+
background: method === m ? "var(--hook-color-primary-soft, #eef)" : "white",
|
|
2379
|
+
cursor: "pointer"
|
|
2380
|
+
},
|
|
2381
|
+
children: m === "card" ? "\u{1F4B3} Cart\xE3o" : "\u{1F4F1} Pix Autom\xE1tico"
|
|
2382
|
+
},
|
|
2383
|
+
m
|
|
2384
|
+
)) }),
|
|
2385
|
+
method === "card" && /* @__PURE__ */ jsxs18(
|
|
2386
|
+
"fieldset",
|
|
2387
|
+
{
|
|
2388
|
+
"data-testid": "paywall-card-form",
|
|
2389
|
+
style: { border: "none", padding: 0, marginBottom: 16 },
|
|
2390
|
+
children: [
|
|
2391
|
+
/* @__PURE__ */ jsx24("legend", { style: { fontSize: 13, opacity: 0.75, marginBottom: 8 }, children: "Dados do cart\xE3o" }),
|
|
2392
|
+
/* @__PURE__ */ jsxs18("div", { style: fieldGroup, children: [
|
|
2393
|
+
/* @__PURE__ */ jsx24("label", { htmlFor: "pw-card-number", style: labelStyle, children: "N\xFAmero do cart\xE3o" }),
|
|
2394
|
+
/* @__PURE__ */ jsx24(
|
|
2395
|
+
"input",
|
|
2396
|
+
{
|
|
2397
|
+
id: "pw-card-number",
|
|
2398
|
+
"data-testid": "pw-card-number",
|
|
2399
|
+
type: "text",
|
|
2400
|
+
inputMode: "numeric",
|
|
2401
|
+
autoComplete: "cc-number",
|
|
2402
|
+
placeholder: "0000 0000 0000 0000",
|
|
2403
|
+
value: cardNumber,
|
|
2404
|
+
onChange: (e) => setCardNumber(e.target.value),
|
|
2405
|
+
style: inputStyle
|
|
2406
|
+
}
|
|
2407
|
+
)
|
|
2408
|
+
] }),
|
|
2409
|
+
/* @__PURE__ */ jsxs18("div", { style: fieldGroup, children: [
|
|
2410
|
+
/* @__PURE__ */ jsx24("label", { htmlFor: "pw-card-holder", style: labelStyle, children: "Nome impresso no cart\xE3o" }),
|
|
2411
|
+
/* @__PURE__ */ jsx24(
|
|
2412
|
+
"input",
|
|
2413
|
+
{
|
|
2414
|
+
id: "pw-card-holder",
|
|
2415
|
+
"data-testid": "pw-card-holder",
|
|
2416
|
+
type: "text",
|
|
2417
|
+
autoComplete: "cc-name",
|
|
2418
|
+
placeholder: "NOME SOBRENOME",
|
|
2419
|
+
value: cardHolderName,
|
|
2420
|
+
onChange: (e) => setCardHolderName(e.target.value),
|
|
2421
|
+
style: inputStyle
|
|
2422
|
+
}
|
|
2423
|
+
)
|
|
2424
|
+
] }),
|
|
2425
|
+
/* @__PURE__ */ jsxs18("div", { style: { display: "flex", gap: 8, marginBottom: 10 }, children: [
|
|
2426
|
+
/* @__PURE__ */ jsxs18("div", { style: { flex: 1, textAlign: "left" }, children: [
|
|
2427
|
+
/* @__PURE__ */ jsx24("label", { htmlFor: "pw-card-exp-m", style: labelStyle, children: "M\xEAs" }),
|
|
2428
|
+
/* @__PURE__ */ jsx24(
|
|
2429
|
+
"input",
|
|
2430
|
+
{
|
|
2431
|
+
id: "pw-card-exp-m",
|
|
2432
|
+
"data-testid": "pw-card-exp-m",
|
|
2433
|
+
type: "text",
|
|
2434
|
+
inputMode: "numeric",
|
|
2435
|
+
autoComplete: "cc-exp-month",
|
|
2436
|
+
placeholder: "MM",
|
|
2437
|
+
maxLength: 2,
|
|
2438
|
+
value: cardExpiryMonth,
|
|
2439
|
+
onChange: (e) => setCardExpiryMonth(e.target.value.replace(/\D/g, "")),
|
|
2440
|
+
style: inputStyle
|
|
2441
|
+
}
|
|
2442
|
+
)
|
|
2443
|
+
] }),
|
|
2444
|
+
/* @__PURE__ */ jsxs18("div", { style: { flex: 1, textAlign: "left" }, children: [
|
|
2445
|
+
/* @__PURE__ */ jsx24("label", { htmlFor: "pw-card-exp-y", style: labelStyle, children: "Ano" }),
|
|
2446
|
+
/* @__PURE__ */ jsx24(
|
|
2447
|
+
"input",
|
|
2448
|
+
{
|
|
2449
|
+
id: "pw-card-exp-y",
|
|
2450
|
+
"data-testid": "pw-card-exp-y",
|
|
2451
|
+
type: "text",
|
|
2452
|
+
inputMode: "numeric",
|
|
2453
|
+
autoComplete: "cc-exp-year",
|
|
2454
|
+
placeholder: "AA",
|
|
2455
|
+
maxLength: 4,
|
|
2456
|
+
value: cardExpiryYear,
|
|
2457
|
+
onChange: (e) => setCardExpiryYear(e.target.value.replace(/\D/g, "")),
|
|
2458
|
+
style: inputStyle
|
|
2459
|
+
}
|
|
2460
|
+
)
|
|
2461
|
+
] }),
|
|
2462
|
+
/* @__PURE__ */ jsxs18("div", { style: { flex: 1, textAlign: "left" }, children: [
|
|
2463
|
+
/* @__PURE__ */ jsx24("label", { htmlFor: "pw-card-cvv", style: labelStyle, children: "CVV" }),
|
|
2464
|
+
/* @__PURE__ */ jsx24(
|
|
2465
|
+
"input",
|
|
2466
|
+
{
|
|
2467
|
+
id: "pw-card-cvv",
|
|
2468
|
+
"data-testid": "pw-card-cvv",
|
|
2469
|
+
type: "text",
|
|
2470
|
+
inputMode: "numeric",
|
|
2471
|
+
autoComplete: "cc-csc",
|
|
2472
|
+
placeholder: "123",
|
|
2473
|
+
maxLength: 4,
|
|
2474
|
+
value: cardCcv,
|
|
2475
|
+
onChange: (e) => setCardCcv(e.target.value.replace(/\D/g, "")),
|
|
2476
|
+
style: inputStyle
|
|
2477
|
+
}
|
|
2478
|
+
)
|
|
2479
|
+
] })
|
|
2480
|
+
] }),
|
|
2481
|
+
/* @__PURE__ */ jsx24("legend", { style: { fontSize: 13, opacity: 0.75, marginBottom: 8, marginTop: 8 }, children: "Dados do titular" }),
|
|
2482
|
+
/* @__PURE__ */ jsxs18("div", { style: fieldGroup, children: [
|
|
2483
|
+
/* @__PURE__ */ jsx24("label", { htmlFor: "pw-holder-name", style: labelStyle, children: "Nome completo" }),
|
|
2484
|
+
/* @__PURE__ */ jsx24(
|
|
2485
|
+
"input",
|
|
2486
|
+
{
|
|
2487
|
+
id: "pw-holder-name",
|
|
2488
|
+
"data-testid": "pw-holder-name",
|
|
2489
|
+
type: "text",
|
|
2490
|
+
autoComplete: "name",
|
|
2491
|
+
placeholder: "Nome Sobrenome",
|
|
2492
|
+
value: holderName,
|
|
2493
|
+
onChange: (e) => setHolderName(e.target.value),
|
|
2494
|
+
style: inputStyle
|
|
2495
|
+
}
|
|
2496
|
+
)
|
|
2497
|
+
] }),
|
|
2498
|
+
/* @__PURE__ */ jsxs18("div", { style: fieldGroup, children: [
|
|
2499
|
+
/* @__PURE__ */ jsx24("label", { htmlFor: "pw-holder-email", style: labelStyle, children: "E-mail" }),
|
|
2500
|
+
/* @__PURE__ */ jsx24(
|
|
2501
|
+
"input",
|
|
2502
|
+
{
|
|
2503
|
+
id: "pw-holder-email",
|
|
2504
|
+
"data-testid": "pw-holder-email",
|
|
2505
|
+
type: "email",
|
|
2506
|
+
autoComplete: "email",
|
|
2507
|
+
placeholder: "voce@email.com",
|
|
2508
|
+
value: holderEmail,
|
|
2509
|
+
onChange: (e) => setHolderEmail(e.target.value),
|
|
2510
|
+
style: inputStyle
|
|
2511
|
+
}
|
|
2512
|
+
)
|
|
2513
|
+
] }),
|
|
2514
|
+
/* @__PURE__ */ jsxs18("div", { style: { display: "flex", gap: 8, marginBottom: 10 }, children: [
|
|
2515
|
+
/* @__PURE__ */ jsxs18("div", { style: { flex: 1, textAlign: "left" }, children: [
|
|
2516
|
+
/* @__PURE__ */ jsx24("label", { htmlFor: "pw-holder-cep", style: labelStyle, children: "CEP" }),
|
|
2517
|
+
/* @__PURE__ */ jsx24(
|
|
2518
|
+
"input",
|
|
2519
|
+
{
|
|
2520
|
+
id: "pw-holder-cep",
|
|
2521
|
+
"data-testid": "pw-holder-cep",
|
|
2522
|
+
type: "text",
|
|
2523
|
+
inputMode: "numeric",
|
|
2524
|
+
autoComplete: "postal-code",
|
|
2525
|
+
placeholder: "00000-000",
|
|
2526
|
+
value: holderPostalCode,
|
|
2527
|
+
onChange: (e) => setHolderPostalCode(e.target.value),
|
|
2528
|
+
style: inputStyle
|
|
2529
|
+
}
|
|
2530
|
+
)
|
|
2531
|
+
] }),
|
|
2532
|
+
/* @__PURE__ */ jsxs18("div", { style: { flex: 1, textAlign: "left" }, children: [
|
|
2533
|
+
/* @__PURE__ */ jsx24("label", { htmlFor: "pw-holder-addr-n", style: labelStyle, children: "N\xFAmero" }),
|
|
2534
|
+
/* @__PURE__ */ jsx24(
|
|
2535
|
+
"input",
|
|
2536
|
+
{
|
|
2537
|
+
id: "pw-holder-addr-n",
|
|
2538
|
+
"data-testid": "pw-holder-addr-n",
|
|
2539
|
+
type: "text",
|
|
2540
|
+
inputMode: "numeric",
|
|
2541
|
+
placeholder: "123",
|
|
2542
|
+
value: holderAddressNumber,
|
|
2543
|
+
onChange: (e) => setHolderAddressNumber(e.target.value),
|
|
2544
|
+
style: inputStyle
|
|
2545
|
+
}
|
|
2546
|
+
)
|
|
2547
|
+
] })
|
|
2548
|
+
] }),
|
|
2549
|
+
/* @__PURE__ */ jsxs18("div", { style: fieldGroup, children: [
|
|
2550
|
+
/* @__PURE__ */ jsx24("label", { htmlFor: "pw-holder-phone", style: labelStyle, children: "Telefone (opcional)" }),
|
|
2551
|
+
/* @__PURE__ */ jsx24(
|
|
2552
|
+
"input",
|
|
2553
|
+
{
|
|
2554
|
+
id: "pw-holder-phone",
|
|
2555
|
+
"data-testid": "pw-holder-phone",
|
|
2556
|
+
type: "tel",
|
|
2557
|
+
inputMode: "tel",
|
|
2558
|
+
autoComplete: "tel",
|
|
2559
|
+
placeholder: "(11) 99999-9999",
|
|
2560
|
+
value: holderPhone,
|
|
2561
|
+
onChange: (e) => setHolderPhone(e.target.value),
|
|
2562
|
+
style: inputStyle
|
|
2563
|
+
}
|
|
2564
|
+
)
|
|
2565
|
+
] })
|
|
2566
|
+
]
|
|
2567
|
+
}
|
|
2568
|
+
),
|
|
2569
|
+
/* @__PURE__ */ jsxs18("div", { style: fieldGroup, children: [
|
|
2570
|
+
/* @__PURE__ */ jsx24("label", { htmlFor: "pw-cpf", style: labelStyle, children: "Seu CPF" }),
|
|
2156
2571
|
/* @__PURE__ */ jsx24(
|
|
2157
2572
|
"input",
|
|
2158
2573
|
{
|
|
2574
|
+
id: "pw-cpf",
|
|
2159
2575
|
"data-testid": "paywall-cpf",
|
|
2160
2576
|
type: "text",
|
|
2161
2577
|
inputMode: "numeric",
|
|
2162
2578
|
placeholder: "000.000.000-00",
|
|
2163
2579
|
value: cpf,
|
|
2164
2580
|
onChange: (e) => setCpf(e.target.value),
|
|
2165
|
-
style:
|
|
2581
|
+
style: inputStyle
|
|
2166
2582
|
}
|
|
2167
2583
|
)
|
|
2168
2584
|
] }),
|
|
2169
2585
|
error && /* @__PURE__ */ jsx24("div", { role: "alert", style: { color: "#c00", marginBottom: 12 }, children: error.message }),
|
|
2586
|
+
method === "pix-auto" && /* @__PURE__ */ jsxs18(
|
|
2587
|
+
"div",
|
|
2588
|
+
{
|
|
2589
|
+
"data-testid": "paywall-pix-callout",
|
|
2590
|
+
style: {
|
|
2591
|
+
background: "rgba(0,0,0,0.04)",
|
|
2592
|
+
borderLeft: "3px solid var(--hook-color-primary)",
|
|
2593
|
+
padding: "10px 12px",
|
|
2594
|
+
marginBottom: 12,
|
|
2595
|
+
borderRadius: 4,
|
|
2596
|
+
fontSize: 12,
|
|
2597
|
+
lineHeight: 1.45,
|
|
2598
|
+
textAlign: "left"
|
|
2599
|
+
},
|
|
2600
|
+
children: [
|
|
2601
|
+
/* @__PURE__ */ jsx24("strong", { children: "Como funciona:" }),
|
|
2602
|
+
" no app do seu banco vai aparecer uma cobran\xE7a de",
|
|
2603
|
+
" ",
|
|
2604
|
+
/* @__PURE__ */ jsx24("strong", { children: "R$ 0,01" }),
|
|
2605
|
+
" \u2014 \xE9 simb\xF3lica, s\xF3 pra ativar o PIX Autom\xE1tico.",
|
|
2606
|
+
trialDays > 0 ? /* @__PURE__ */ jsxs18(Fragment6, { children: [
|
|
2607
|
+
" ",
|
|
2608
|
+
"Depois, ",
|
|
2609
|
+
/* @__PURE__ */ jsxs18("strong", { children: [
|
|
2610
|
+
trialDays,
|
|
2611
|
+
" dias gr\xE1tis"
|
|
2612
|
+
] }),
|
|
2613
|
+
"; a cobran\xE7a de",
|
|
2614
|
+
" ",
|
|
2615
|
+
/* @__PURE__ */ jsx24("strong", { children: formatBRL(cycleValueCents) }),
|
|
2616
|
+
" ",
|
|
2617
|
+
cycleLabel,
|
|
2618
|
+
" s\xF3 come\xE7a depois."
|
|
2619
|
+
] }) : /* @__PURE__ */ jsxs18(Fragment6, { children: [
|
|
2620
|
+
" ",
|
|
2621
|
+
"A cobran\xE7a de ",
|
|
2622
|
+
/* @__PURE__ */ jsx24("strong", { children: formatBRL(cycleValueCents) }),
|
|
2623
|
+
" ",
|
|
2624
|
+
cycleLabel,
|
|
2625
|
+
" vem em seguida."
|
|
2626
|
+
] })
|
|
2627
|
+
]
|
|
2628
|
+
}
|
|
2629
|
+
),
|
|
2170
2630
|
/* @__PURE__ */ jsx24(
|
|
2171
2631
|
"button",
|
|
2172
2632
|
{
|
|
2173
2633
|
"data-testid": "paywall-cta",
|
|
2174
2634
|
type: "button",
|
|
2175
|
-
onClick:
|
|
2635
|
+
onClick: submit,
|
|
2176
2636
|
disabled: !canCheckout,
|
|
2177
2637
|
style: {
|
|
2178
2638
|
width: "100%",
|
|
@@ -2183,21 +2643,133 @@ function DefaultPaywall() {
|
|
|
2183
2643
|
borderRadius: 8,
|
|
2184
2644
|
opacity: canCheckout ? 1 : 0.5,
|
|
2185
2645
|
fontSize: 16,
|
|
2186
|
-
fontWeight: 600
|
|
2646
|
+
fontWeight: 600,
|
|
2647
|
+
cursor: canCheckout ? "pointer" : "not-allowed"
|
|
2187
2648
|
},
|
|
2188
|
-
children:
|
|
2649
|
+
children: ctaLabel
|
|
2189
2650
|
}
|
|
2190
2651
|
),
|
|
2191
|
-
|
|
2192
|
-
p.
|
|
2652
|
+
/* @__PURE__ */ jsx24("p", { style: { opacity: 0.55, marginTop: 16, fontSize: 12 }, children: footer }),
|
|
2653
|
+
p.priceHint && /* @__PURE__ */ jsx24("p", { style: { opacity: 0.6, marginTop: 8, fontSize: 12 }, children: p.priceHint }),
|
|
2654
|
+
p.footerNote && /* @__PURE__ */ jsx24("p", { style: { opacity: 0.5, marginTop: 8, fontSize: 12 }, children: p.footerNote }),
|
|
2655
|
+
pixPending && /* @__PURE__ */ jsx24(
|
|
2656
|
+
"div",
|
|
2657
|
+
{
|
|
2658
|
+
"data-testid": "paywall-pix-modal",
|
|
2659
|
+
role: "dialog",
|
|
2660
|
+
"aria-label": "Pagamento Pix pendente",
|
|
2661
|
+
style: {
|
|
2662
|
+
position: "fixed",
|
|
2663
|
+
inset: 0,
|
|
2664
|
+
background: "rgba(0,0,0,0.6)",
|
|
2665
|
+
display: "flex",
|
|
2666
|
+
alignItems: "center",
|
|
2667
|
+
justifyContent: "center",
|
|
2668
|
+
padding: 24,
|
|
2669
|
+
zIndex: 1e3
|
|
2670
|
+
},
|
|
2671
|
+
children: /* @__PURE__ */ jsxs18("div", { style: {
|
|
2672
|
+
background: "#fff",
|
|
2673
|
+
borderRadius: 12,
|
|
2674
|
+
padding: 24,
|
|
2675
|
+
maxWidth: 360,
|
|
2676
|
+
width: "100%",
|
|
2677
|
+
textAlign: "center"
|
|
2678
|
+
}, children: [
|
|
2679
|
+
pixPending.paid ? /* @__PURE__ */ jsxs18(Fragment6, { children: [
|
|
2680
|
+
/* @__PURE__ */ jsx24("h2", { style: { marginTop: 0 }, children: "Pagamento confirmado!" }),
|
|
2681
|
+
/* @__PURE__ */ jsx24("p", { style: { opacity: 0.7 }, children: "Liberando acesso\u2026" })
|
|
2682
|
+
] }) : /* @__PURE__ */ jsxs18(Fragment6, { children: [
|
|
2683
|
+
/* @__PURE__ */ jsx24("h2", { style: { marginTop: 0, fontSize: 18 }, children: "Pague com Pix Autom\xE1tico" }),
|
|
2684
|
+
/* @__PURE__ */ jsx24("p", { style: { fontSize: 13, opacity: 0.75 }, children: "Escaneie o QR Code no app do seu banco pra autorizar o d\xE9bito recorrente." }),
|
|
2685
|
+
/* @__PURE__ */ jsxs18(
|
|
2686
|
+
"p",
|
|
2687
|
+
{
|
|
2688
|
+
"data-testid": "pix-modal-explain",
|
|
2689
|
+
style: { fontSize: 12, opacity: 0.65, marginTop: 8, lineHeight: 1.4 },
|
|
2690
|
+
children: [
|
|
2691
|
+
"Seu banco vai mostrar uma cobran\xE7a de ",
|
|
2692
|
+
/* @__PURE__ */ jsx24("strong", { children: "R$ 0,01" }),
|
|
2693
|
+
" \u2014 \xE9 simb\xF3lica, s\xF3 pra ativar o PIX Autom\xE1tico.",
|
|
2694
|
+
trialDays > 0 ? /* @__PURE__ */ jsxs18(Fragment6, { children: [
|
|
2695
|
+
" ",
|
|
2696
|
+
"A cobran\xE7a de ",
|
|
2697
|
+
/* @__PURE__ */ jsx24("strong", { children: formatBRL(cycleValueCents) }),
|
|
2698
|
+
" ",
|
|
2699
|
+
cycleLabel,
|
|
2700
|
+
" come\xE7a depois dos ",
|
|
2701
|
+
/* @__PURE__ */ jsxs18("strong", { children: [
|
|
2702
|
+
trialDays,
|
|
2703
|
+
" dias gr\xE1tis"
|
|
2704
|
+
] }),
|
|
2705
|
+
", automaticamente."
|
|
2706
|
+
] }) : /* @__PURE__ */ jsxs18(Fragment6, { children: [
|
|
2707
|
+
" ",
|
|
2708
|
+
"A cobran\xE7a de ",
|
|
2709
|
+
/* @__PURE__ */ jsx24("strong", { children: formatBRL(cycleValueCents) }),
|
|
2710
|
+
" ",
|
|
2711
|
+
cycleLabel,
|
|
2712
|
+
" vem logo em seguida."
|
|
2713
|
+
] })
|
|
2714
|
+
]
|
|
2715
|
+
}
|
|
2716
|
+
),
|
|
2717
|
+
pixPending.qrCodeBase64 && /* @__PURE__ */ jsx24(
|
|
2718
|
+
"img",
|
|
2719
|
+
{
|
|
2720
|
+
"data-testid": "pix-qr-image",
|
|
2721
|
+
alt: "QR Code Pix",
|
|
2722
|
+
src: `data:image/png;base64,${pixPending.qrCodeBase64}`,
|
|
2723
|
+
style: { width: "100%", maxWidth: 240, margin: "12px auto", display: "block" }
|
|
2724
|
+
}
|
|
2725
|
+
),
|
|
2726
|
+
pixPending.qrCodePayload && /* @__PURE__ */ jsx24(
|
|
2727
|
+
"textarea",
|
|
2728
|
+
{
|
|
2729
|
+
"data-testid": "pix-qr-payload",
|
|
2730
|
+
readOnly: true,
|
|
2731
|
+
value: pixPending.qrCodePayload,
|
|
2732
|
+
style: {
|
|
2733
|
+
width: "100%",
|
|
2734
|
+
minHeight: 72,
|
|
2735
|
+
padding: 8,
|
|
2736
|
+
fontSize: 11,
|
|
2737
|
+
fontFamily: "monospace",
|
|
2738
|
+
borderRadius: 6,
|
|
2739
|
+
border: "1px solid #ccc",
|
|
2740
|
+
resize: "none"
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
),
|
|
2744
|
+
/* @__PURE__ */ jsx24("p", { style: { fontSize: 11, opacity: 0.55, marginTop: 12 }, children: "Aguardando confirma\xE7\xE3o do banco\u2026 Pode levar alguns segundos." })
|
|
2745
|
+
] }),
|
|
2746
|
+
/* @__PURE__ */ jsx24(
|
|
2747
|
+
"button",
|
|
2748
|
+
{
|
|
2749
|
+
type: "button",
|
|
2750
|
+
onClick: dismissPix,
|
|
2751
|
+
style: {
|
|
2752
|
+
marginTop: 16,
|
|
2753
|
+
padding: "8px 16px",
|
|
2754
|
+
border: "1px solid #ccc",
|
|
2755
|
+
borderRadius: 6,
|
|
2756
|
+
background: "white",
|
|
2757
|
+
cursor: "pointer"
|
|
2758
|
+
},
|
|
2759
|
+
children: "Fechar"
|
|
2760
|
+
}
|
|
2761
|
+
)
|
|
2762
|
+
] })
|
|
2763
|
+
}
|
|
2764
|
+
)
|
|
2193
2765
|
] });
|
|
2194
2766
|
}
|
|
2195
2767
|
|
|
2196
2768
|
// src/AppRoot.tsx
|
|
2197
|
-
import { Fragment as
|
|
2769
|
+
import { Fragment as Fragment7, jsx as jsx25, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2198
2770
|
var BACKOFF_MS = [2e3, 5e3, 1e4, 2e4, 4e4];
|
|
2199
2771
|
function PaymentReturnHandler({ children }) {
|
|
2200
|
-
const { subscription } =
|
|
2772
|
+
const { subscription } = useHook9();
|
|
2201
2773
|
const subRef = useRef3(subscription);
|
|
2202
2774
|
subRef.current = subscription;
|
|
2203
2775
|
const runIdRef = useRef3(0);
|
|
@@ -2265,7 +2837,7 @@ function PaymentReturnHandler({ children }) {
|
|
|
2265
2837
|
)
|
|
2266
2838
|
] }) });
|
|
2267
2839
|
}
|
|
2268
|
-
return /* @__PURE__ */ jsx25(
|
|
2840
|
+
return /* @__PURE__ */ jsx25(Fragment7, { children });
|
|
2269
2841
|
}
|
|
2270
2842
|
var overlayStyle2 = {
|
|
2271
2843
|
position: "fixed",
|
|
@@ -2306,7 +2878,7 @@ function AppRoot({
|
|
|
2306
2878
|
|
|
2307
2879
|
// src/hooks/usePush.ts
|
|
2308
2880
|
import { useCallback as useCallback8, useEffect as useEffect9, useState as useState13 } from "react";
|
|
2309
|
-
import { useHook as
|
|
2881
|
+
import { useHook as useHook10 } from "@hook-sdk/sdk";
|
|
2310
2882
|
function detectIosNeedsInstall() {
|
|
2311
2883
|
if (typeof navigator === "undefined" || typeof window === "undefined") return false;
|
|
2312
2884
|
const ua = navigator.userAgent || "";
|
|
@@ -2332,7 +2904,7 @@ function deriveState(push) {
|
|
|
2332
2904
|
return { kind: "prompt" };
|
|
2333
2905
|
}
|
|
2334
2906
|
function usePush() {
|
|
2335
|
-
const { push } =
|
|
2907
|
+
const { push } = useHook10();
|
|
2336
2908
|
const [state, setState] = useState13(() => deriveState(push));
|
|
2337
2909
|
useEffect9(() => {
|
|
2338
2910
|
setState(deriveState(push));
|
|
@@ -2414,41 +2986,6 @@ function EmptyState({ title, description, action }) {
|
|
|
2414
2986
|
] });
|
|
2415
2987
|
}
|
|
2416
2988
|
|
|
2417
|
-
// src/hooks/usePlan.ts
|
|
2418
|
-
import { useHook as useHook10 } from "@hook-sdk/sdk";
|
|
2419
|
-
function usePlan() {
|
|
2420
|
-
const { plan } = useHook10();
|
|
2421
|
-
return plan;
|
|
2422
|
-
}
|
|
2423
|
-
|
|
2424
|
-
// src/utils/price.ts
|
|
2425
|
-
function formatBRL(cents) {
|
|
2426
|
-
if (cents === null || cents === void 0) return "";
|
|
2427
|
-
const reais = cents / 100;
|
|
2428
|
-
return new Intl.NumberFormat("pt-BR", {
|
|
2429
|
-
style: "currency",
|
|
2430
|
-
currency: "BRL"
|
|
2431
|
-
}).format(reais);
|
|
2432
|
-
}
|
|
2433
|
-
function monthlyFromYearly(yearlyCents) {
|
|
2434
|
-
if (yearlyCents === null || yearlyCents === void 0) return 0;
|
|
2435
|
-
return Math.round(yearlyCents / 12);
|
|
2436
|
-
}
|
|
2437
|
-
function dailyFromYearly(yearlyCents) {
|
|
2438
|
-
if (yearlyCents === null || yearlyCents === void 0) return 0;
|
|
2439
|
-
return Math.round(yearlyCents / 365);
|
|
2440
|
-
}
|
|
2441
|
-
function computeAnchorCents(baseCents, multiplier) {
|
|
2442
|
-
if (multiplier === null || multiplier === void 0) return null;
|
|
2443
|
-
if (!Number.isFinite(multiplier)) return null;
|
|
2444
|
-
if (multiplier <= 1) return null;
|
|
2445
|
-
return Math.round(baseCents * multiplier);
|
|
2446
|
-
}
|
|
2447
|
-
function discountPercent(anchorCents, realCents) {
|
|
2448
|
-
if (anchorCents <= realCents) return 0;
|
|
2449
|
-
return Math.floor((anchorCents - realCents) / anchorCents * 100);
|
|
2450
|
-
}
|
|
2451
|
-
|
|
2452
2989
|
// src/hooks/useAuthPrimitives.ts
|
|
2453
2990
|
import { useEffect as useEffect10 } from "react";
|
|
2454
2991
|
import { useHook as useHook11 } from "@hook-sdk/sdk";
|