@hook-sdk/template 0.2.0 → 0.3.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 +347 -167
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +326 -146
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -45,7 +45,7 @@ __export(index_exports, {
|
|
|
45
45
|
module.exports = __toCommonJS(index_exports);
|
|
46
46
|
|
|
47
47
|
// src/AppRoot.tsx
|
|
48
|
-
var
|
|
48
|
+
var import_react12 = require("react");
|
|
49
49
|
var import_sdk9 = require("@hook-sdk/sdk");
|
|
50
50
|
|
|
51
51
|
// src/internal/TemplateConfigContext.tsx
|
|
@@ -309,25 +309,183 @@ function useLoginForm() {
|
|
|
309
309
|
submit,
|
|
310
310
|
submitting,
|
|
311
311
|
canSubmit,
|
|
312
|
-
error
|
|
312
|
+
error,
|
|
313
|
+
loginWithGoogle: () => auth.loginWithGoogle()
|
|
313
314
|
};
|
|
314
315
|
}
|
|
315
316
|
|
|
316
|
-
// src/
|
|
317
|
+
// src/internal/GoogleSignInButton.tsx
|
|
317
318
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
319
|
+
function GoogleSignInButton({
|
|
320
|
+
onClick,
|
|
321
|
+
testId = "oauth-google",
|
|
322
|
+
label = "Continuar com Google"
|
|
323
|
+
}) {
|
|
324
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
325
|
+
"button",
|
|
326
|
+
{
|
|
327
|
+
"data-testid": testId,
|
|
328
|
+
type: "button",
|
|
329
|
+
onClick,
|
|
330
|
+
style: {
|
|
331
|
+
width: "100%",
|
|
332
|
+
padding: "10px 12px",
|
|
333
|
+
display: "flex",
|
|
334
|
+
alignItems: "center",
|
|
335
|
+
justifyContent: "center",
|
|
336
|
+
gap: 10,
|
|
337
|
+
background: "#fff",
|
|
338
|
+
color: "#1f1f1f",
|
|
339
|
+
border: "1px solid #dadce0",
|
|
340
|
+
borderRadius: 8,
|
|
341
|
+
cursor: "pointer",
|
|
342
|
+
fontSize: 14,
|
|
343
|
+
fontWeight: 500,
|
|
344
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'
|
|
345
|
+
},
|
|
346
|
+
children: [
|
|
347
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(GoogleGlyph, {}),
|
|
348
|
+
label
|
|
349
|
+
]
|
|
350
|
+
}
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
function GoogleGlyph() {
|
|
354
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("svg", { width: "18", height: "18", viewBox: "0 0 18 18", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", children: [
|
|
355
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
356
|
+
"path",
|
|
357
|
+
{
|
|
358
|
+
d: "M17.64 9.2c0-.637-.057-1.251-.164-1.84H9v3.481h4.844a4.14 4.14 0 0 1-1.796 2.716v2.259h2.908c1.702-1.567 2.684-3.874 2.684-6.615z",
|
|
359
|
+
fill: "#4285F4"
|
|
360
|
+
}
|
|
361
|
+
),
|
|
362
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
363
|
+
"path",
|
|
364
|
+
{
|
|
365
|
+
d: "M9 18c2.43 0 4.467-.806 5.956-2.18l-2.908-2.259c-.806.54-1.837.86-3.048.86-2.344 0-4.328-1.584-5.036-3.711H.957v2.332A8.997 8.997 0 0 0 9 18z",
|
|
366
|
+
fill: "#34A853"
|
|
367
|
+
}
|
|
368
|
+
),
|
|
369
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
370
|
+
"path",
|
|
371
|
+
{
|
|
372
|
+
d: "M3.964 10.71A5.41 5.41 0 0 1 3.682 9c0-.593.102-1.17.282-1.71V4.958H.957A8.996 8.996 0 0 0 0 9c0 1.452.348 2.827.957 4.042l3.007-2.332z",
|
|
373
|
+
fill: "#FBBC05"
|
|
374
|
+
}
|
|
375
|
+
),
|
|
376
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
377
|
+
"path",
|
|
378
|
+
{
|
|
379
|
+
d: "M9 3.58c1.321 0 2.508.454 3.44 1.345l2.582-2.58C13.463.891 11.426 0 9 0A8.997 8.997 0 0 0 .957 4.958L3.964 7.29C4.672 5.163 6.656 3.58 9 3.58z",
|
|
380
|
+
fill: "#EA4335"
|
|
381
|
+
}
|
|
382
|
+
)
|
|
383
|
+
] });
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// src/internal/OAuthErrorBanner.tsx
|
|
387
|
+
var import_react7 = require("react");
|
|
388
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
389
|
+
var ERROR_MESSAGES = {
|
|
390
|
+
invalid_state: "Sess\xE3o expirou, tente de novo.",
|
|
391
|
+
access_denied: "Voc\xEA cancelou o login com Google.",
|
|
392
|
+
provider_error: "O Google recusou a autentica\xE7\xE3o. Tente de novo em alguns segundos.",
|
|
393
|
+
invalid_return_to: "Link inv\xE1lido. Tente entrar novamente."
|
|
394
|
+
};
|
|
395
|
+
function readErrorCode() {
|
|
396
|
+
if (typeof window === "undefined") return null;
|
|
397
|
+
const code = new URLSearchParams(window.location.search).get("oauth_error");
|
|
398
|
+
if (!code) return null;
|
|
399
|
+
return code;
|
|
400
|
+
}
|
|
401
|
+
function stripErrorFromUrl() {
|
|
402
|
+
if (typeof window === "undefined") return;
|
|
403
|
+
const url = new URL(window.location.href);
|
|
404
|
+
url.searchParams.delete("oauth_error");
|
|
405
|
+
window.history.replaceState({}, "", url.toString());
|
|
406
|
+
}
|
|
407
|
+
function OAuthErrorBanner() {
|
|
408
|
+
const [code, setCode] = (0, import_react7.useState)(() => readErrorCode());
|
|
409
|
+
(0, import_react7.useEffect)(() => {
|
|
410
|
+
if (code !== null) stripErrorFromUrl();
|
|
411
|
+
}, [code]);
|
|
412
|
+
if (!code) return null;
|
|
413
|
+
const message = ERROR_MESSAGES[code] ?? "N\xE3o conseguimos conectar ao Google. Tente de novo.";
|
|
414
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
415
|
+
"div",
|
|
416
|
+
{
|
|
417
|
+
role: "alert",
|
|
418
|
+
"data-testid": "oauth-error-banner",
|
|
419
|
+
style: {
|
|
420
|
+
padding: "10px 12px",
|
|
421
|
+
marginBottom: 16,
|
|
422
|
+
background: "#fce8e6",
|
|
423
|
+
color: "#a50e0e",
|
|
424
|
+
borderRadius: 8,
|
|
425
|
+
fontSize: 14
|
|
426
|
+
},
|
|
427
|
+
children: [
|
|
428
|
+
message,
|
|
429
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
430
|
+
"button",
|
|
431
|
+
{
|
|
432
|
+
type: "button",
|
|
433
|
+
onClick: () => setCode(null),
|
|
434
|
+
"aria-label": "Fechar",
|
|
435
|
+
style: {
|
|
436
|
+
float: "right",
|
|
437
|
+
background: "none",
|
|
438
|
+
border: "none",
|
|
439
|
+
color: "#a50e0e",
|
|
440
|
+
cursor: "pointer",
|
|
441
|
+
fontSize: 16,
|
|
442
|
+
lineHeight: 1,
|
|
443
|
+
padding: 0
|
|
444
|
+
},
|
|
445
|
+
children: "\xD7"
|
|
446
|
+
}
|
|
447
|
+
)
|
|
448
|
+
]
|
|
449
|
+
}
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// src/defaults/DefaultLoginScreen.tsx
|
|
454
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
318
455
|
function DefaultLoginScreen({ onNavigate }) {
|
|
319
456
|
const { name } = useTemplateConfig();
|
|
320
457
|
const f = useLoginForm();
|
|
321
|
-
return /* @__PURE__ */ (0,
|
|
322
|
-
/* @__PURE__ */ (0,
|
|
323
|
-
/* @__PURE__ */ (0,
|
|
324
|
-
/* @__PURE__ */ (0,
|
|
458
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("main", { style: { padding: 24, maxWidth: 360, margin: "0 auto" }, children: [
|
|
459
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h1", { style: { marginBottom: 8 }, children: name }),
|
|
460
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { style: { opacity: 0.7, marginBottom: 24 }, children: "Entre na sua conta" }),
|
|
461
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(OAuthErrorBanner, {}),
|
|
462
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(GoogleSignInButton, { onClick: f.loginWithGoogle, testId: "login-oauth-google" }),
|
|
463
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
464
|
+
"div",
|
|
465
|
+
{
|
|
466
|
+
"aria-hidden": "true",
|
|
467
|
+
style: {
|
|
468
|
+
display: "flex",
|
|
469
|
+
alignItems: "center",
|
|
470
|
+
gap: 8,
|
|
471
|
+
margin: "16px 0",
|
|
472
|
+
color: "rgba(0,0,0,0.45)",
|
|
473
|
+
fontSize: 12
|
|
474
|
+
},
|
|
475
|
+
children: [
|
|
476
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { style: { flex: 1, height: 1, background: "rgba(0,0,0,0.1)" } }),
|
|
477
|
+
"ou",
|
|
478
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { style: { flex: 1, height: 1, background: "rgba(0,0,0,0.1)" } })
|
|
479
|
+
]
|
|
480
|
+
}
|
|
481
|
+
),
|
|
482
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("form", { onSubmit: (e) => {
|
|
325
483
|
e.preventDefault();
|
|
326
484
|
void f.submit();
|
|
327
485
|
}, children: [
|
|
328
|
-
/* @__PURE__ */ (0,
|
|
486
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("label", { style: { display: "block", marginBottom: 12 }, children: [
|
|
329
487
|
"E-mail",
|
|
330
|
-
/* @__PURE__ */ (0,
|
|
488
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
331
489
|
"input",
|
|
332
490
|
{
|
|
333
491
|
"data-testid": "login-email",
|
|
@@ -337,11 +495,11 @@ function DefaultLoginScreen({ onNavigate }) {
|
|
|
337
495
|
style: { display: "block", width: "100%" }
|
|
338
496
|
}
|
|
339
497
|
),
|
|
340
|
-
f.emailError && /* @__PURE__ */ (0,
|
|
498
|
+
f.emailError && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("small", { style: { color: "#c00" }, children: f.emailError })
|
|
341
499
|
] }),
|
|
342
|
-
/* @__PURE__ */ (0,
|
|
500
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("label", { style: { display: "block", marginBottom: 12 }, children: [
|
|
343
501
|
"Senha",
|
|
344
|
-
/* @__PURE__ */ (0,
|
|
502
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
345
503
|
"input",
|
|
346
504
|
{
|
|
347
505
|
"data-testid": "login-password",
|
|
@@ -351,10 +509,10 @@ function DefaultLoginScreen({ onNavigate }) {
|
|
|
351
509
|
style: { display: "block", width: "100%" }
|
|
352
510
|
}
|
|
353
511
|
),
|
|
354
|
-
f.passwordError && /* @__PURE__ */ (0,
|
|
512
|
+
f.passwordError && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("small", { style: { color: "#c00" }, children: f.passwordError })
|
|
355
513
|
] }),
|
|
356
|
-
f.error && /* @__PURE__ */ (0,
|
|
357
|
-
/* @__PURE__ */ (0,
|
|
514
|
+
f.error && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { role: "alert", style: { color: "#c00", marginBottom: 12 }, children: f.error.message }),
|
|
515
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
358
516
|
"button",
|
|
359
517
|
{
|
|
360
518
|
"data-testid": "login-submit",
|
|
@@ -373,42 +531,42 @@ function DefaultLoginScreen({ onNavigate }) {
|
|
|
373
531
|
}
|
|
374
532
|
)
|
|
375
533
|
] }),
|
|
376
|
-
/* @__PURE__ */ (0,
|
|
377
|
-
/* @__PURE__ */ (0,
|
|
378
|
-
/* @__PURE__ */ (0,
|
|
534
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { style: { marginTop: 16, display: "flex", justifyContent: "space-between" }, children: [
|
|
535
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { "data-testid": "login-goto-signup", type: "button", onClick: () => onNavigate("signup"), style: { background: "none", border: "none", cursor: "pointer" }, children: "Criar conta" }),
|
|
536
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { "data-testid": "login-goto-forgot", type: "button", onClick: () => onNavigate("forgot"), style: { background: "none", border: "none", cursor: "pointer" }, children: "Esqueci senha" })
|
|
379
537
|
] })
|
|
380
538
|
] });
|
|
381
539
|
}
|
|
382
540
|
|
|
383
541
|
// src/hooks/useSignupForm.ts
|
|
384
|
-
var
|
|
542
|
+
var import_react8 = require("react");
|
|
385
543
|
var import_sdk6 = require("@hook-sdk/sdk");
|
|
386
544
|
var EMAIL_RE2 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
387
545
|
var MIN_PASSWORD2 = 8;
|
|
388
546
|
function useSignupForm() {
|
|
389
547
|
const { auth } = (0, import_sdk6.useHook)();
|
|
390
|
-
const [name, setName] = (0,
|
|
391
|
-
const [email, setEmail] = (0,
|
|
392
|
-
const [password, setPassword] = (0,
|
|
393
|
-
const [submitting, setSubmitting] = (0,
|
|
394
|
-
const [error, setError] = (0,
|
|
395
|
-
const nameError = (0,
|
|
548
|
+
const [name, setName] = (0, import_react8.useState)("");
|
|
549
|
+
const [email, setEmail] = (0, import_react8.useState)("");
|
|
550
|
+
const [password, setPassword] = (0, import_react8.useState)("");
|
|
551
|
+
const [submitting, setSubmitting] = (0, import_react8.useState)(false);
|
|
552
|
+
const [error, setError] = (0, import_react8.useState)(null);
|
|
553
|
+
const nameError = (0, import_react8.useMemo)(() => {
|
|
396
554
|
if (name.length === 0) return null;
|
|
397
555
|
if (name.trim().length < 2) return "Nome muito curto.";
|
|
398
556
|
return null;
|
|
399
557
|
}, [name]);
|
|
400
|
-
const emailError = (0,
|
|
558
|
+
const emailError = (0, import_react8.useMemo)(() => {
|
|
401
559
|
if (email.length === 0) return null;
|
|
402
560
|
if (!EMAIL_RE2.test(email)) return "Formato de e-mail inv\xE1lido.";
|
|
403
561
|
return null;
|
|
404
562
|
}, [email]);
|
|
405
|
-
const passwordError = (0,
|
|
563
|
+
const passwordError = (0, import_react8.useMemo)(() => {
|
|
406
564
|
if (password.length === 0) return null;
|
|
407
565
|
if (password.length < MIN_PASSWORD2) return `M\xEDnimo de ${MIN_PASSWORD2} caracteres.`;
|
|
408
566
|
return null;
|
|
409
567
|
}, [password]);
|
|
410
568
|
const canSubmit = name.trim().length >= 2 && email.length > 0 && password.length >= MIN_PASSWORD2 && nameError === null && emailError === null && passwordError === null && !submitting;
|
|
411
|
-
const submit = (0,
|
|
569
|
+
const submit = (0, import_react8.useCallback)(async () => {
|
|
412
570
|
if (!canSubmit) return false;
|
|
413
571
|
setSubmitting(true);
|
|
414
572
|
setError(null);
|
|
@@ -435,61 +593,83 @@ function useSignupForm() {
|
|
|
435
593
|
submit,
|
|
436
594
|
submitting,
|
|
437
595
|
canSubmit,
|
|
438
|
-
error
|
|
596
|
+
error,
|
|
597
|
+
loginWithGoogle: () => auth.loginWithGoogle()
|
|
439
598
|
};
|
|
440
599
|
}
|
|
441
600
|
|
|
442
601
|
// src/defaults/DefaultSignupScreen.tsx
|
|
443
|
-
var
|
|
602
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
444
603
|
function DefaultSignupScreen({ onNavigate }) {
|
|
445
604
|
const { name } = useTemplateConfig();
|
|
446
605
|
const f = useSignupForm();
|
|
447
|
-
return /* @__PURE__ */ (0,
|
|
448
|
-
/* @__PURE__ */ (0,
|
|
449
|
-
/* @__PURE__ */ (0,
|
|
450
|
-
/* @__PURE__ */ (0,
|
|
606
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("main", { style: { padding: 24, maxWidth: 360, margin: "0 auto" }, children: [
|
|
607
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h1", { style: { marginBottom: 8 }, children: name }),
|
|
608
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { style: { opacity: 0.7, marginBottom: 24 }, children: "Criar sua conta" }),
|
|
609
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(OAuthErrorBanner, {}),
|
|
610
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(GoogleSignInButton, { onClick: f.loginWithGoogle, testId: "signup-oauth-google" }),
|
|
611
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
612
|
+
"div",
|
|
613
|
+
{
|
|
614
|
+
"aria-hidden": "true",
|
|
615
|
+
style: {
|
|
616
|
+
display: "flex",
|
|
617
|
+
alignItems: "center",
|
|
618
|
+
gap: 8,
|
|
619
|
+
margin: "16px 0",
|
|
620
|
+
color: "rgba(0,0,0,0.45)",
|
|
621
|
+
fontSize: 12
|
|
622
|
+
},
|
|
623
|
+
children: [
|
|
624
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { style: { flex: 1, height: 1, background: "rgba(0,0,0,0.1)" } }),
|
|
625
|
+
"ou",
|
|
626
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { style: { flex: 1, height: 1, background: "rgba(0,0,0,0.1)" } })
|
|
627
|
+
]
|
|
628
|
+
}
|
|
629
|
+
),
|
|
630
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("form", { onSubmit: (e) => {
|
|
451
631
|
e.preventDefault();
|
|
452
632
|
void f.submit();
|
|
453
633
|
}, children: [
|
|
454
|
-
/* @__PURE__ */ (0,
|
|
634
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { style: { display: "block", marginBottom: 12 }, children: [
|
|
455
635
|
"Nome",
|
|
456
|
-
/* @__PURE__ */ (0,
|
|
457
|
-
f.nameError && /* @__PURE__ */ (0,
|
|
636
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { "data-testid": "signup-name", value: f.name, onChange: (e) => f.setName(e.target.value), style: { display: "block", width: "100%" } }),
|
|
637
|
+
f.nameError && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("small", { style: { color: "#c00" }, children: f.nameError })
|
|
458
638
|
] }),
|
|
459
|
-
/* @__PURE__ */ (0,
|
|
639
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { style: { display: "block", marginBottom: 12 }, children: [
|
|
460
640
|
"E-mail",
|
|
461
|
-
/* @__PURE__ */ (0,
|
|
462
|
-
f.emailError && /* @__PURE__ */ (0,
|
|
641
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { "data-testid": "signup-email", type: "email", value: f.email, onChange: (e) => f.setEmail(e.target.value), style: { display: "block", width: "100%" } }),
|
|
642
|
+
f.emailError && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("small", { style: { color: "#c00" }, children: f.emailError })
|
|
463
643
|
] }),
|
|
464
|
-
/* @__PURE__ */ (0,
|
|
644
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { style: { display: "block", marginBottom: 12 }, children: [
|
|
465
645
|
"Senha",
|
|
466
|
-
/* @__PURE__ */ (0,
|
|
467
|
-
f.passwordError && /* @__PURE__ */ (0,
|
|
646
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { "data-testid": "signup-password", type: "password", value: f.password, onChange: (e) => f.setPassword(e.target.value), style: { display: "block", width: "100%" } }),
|
|
647
|
+
f.passwordError && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("small", { style: { color: "#c00" }, children: f.passwordError })
|
|
468
648
|
] }),
|
|
469
|
-
f.error && /* @__PURE__ */ (0,
|
|
470
|
-
/* @__PURE__ */ (0,
|
|
649
|
+
f.error && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { role: "alert", style: { color: "#c00", marginBottom: 12 }, children: f.error.message }),
|
|
650
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { "data-testid": "signup-submit", type: "submit", disabled: !f.canSubmit, style: { width: "100%", padding: 12, background: "var(--hook-color-primary)", color: "#fff", border: "none", borderRadius: 8, opacity: f.canSubmit ? 1 : 0.5 }, children: f.submitting ? "Criando..." : "Criar conta" })
|
|
471
651
|
] }),
|
|
472
|
-
/* @__PURE__ */ (0,
|
|
652
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { marginTop: 16 }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { "data-testid": "signup-goto-login", type: "button", onClick: () => onNavigate("login"), style: { background: "none", border: "none", cursor: "pointer" }, children: "J\xE1 tem conta? Entre" }) })
|
|
473
653
|
] });
|
|
474
654
|
}
|
|
475
655
|
|
|
476
656
|
// src/hooks/useForgotForm.ts
|
|
477
|
-
var
|
|
657
|
+
var import_react9 = require("react");
|
|
478
658
|
var import_sdk7 = require("@hook-sdk/sdk");
|
|
479
659
|
var EMAIL_RE3 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
480
660
|
function useForgotForm() {
|
|
481
661
|
const { auth } = (0, import_sdk7.useHook)();
|
|
482
|
-
const [email, setEmail] = (0,
|
|
483
|
-
const [submitting, setSubmitting] = (0,
|
|
484
|
-
const [sent, setSent] = (0,
|
|
485
|
-
const [error, setError] = (0,
|
|
486
|
-
const emailError = (0,
|
|
662
|
+
const [email, setEmail] = (0, import_react9.useState)("");
|
|
663
|
+
const [submitting, setSubmitting] = (0, import_react9.useState)(false);
|
|
664
|
+
const [sent, setSent] = (0, import_react9.useState)(false);
|
|
665
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
666
|
+
const emailError = (0, import_react9.useMemo)(() => {
|
|
487
667
|
if (email.length === 0) return null;
|
|
488
668
|
if (!EMAIL_RE3.test(email)) return "Formato de e-mail inv\xE1lido.";
|
|
489
669
|
return null;
|
|
490
670
|
}, [email]);
|
|
491
671
|
const canSubmit = email.length > 0 && emailError === null && !submitting;
|
|
492
|
-
const submit = (0,
|
|
672
|
+
const submit = (0, import_react9.useCallback)(async () => {
|
|
493
673
|
if (!canSubmit) return false;
|
|
494
674
|
setSubmitting(true);
|
|
495
675
|
setError(null);
|
|
@@ -517,66 +697,66 @@ function useForgotForm() {
|
|
|
517
697
|
}
|
|
518
698
|
|
|
519
699
|
// src/defaults/DefaultForgotScreen.tsx
|
|
520
|
-
var
|
|
700
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
521
701
|
function DefaultForgotScreen({ onNavigate }) {
|
|
522
702
|
const { name } = useTemplateConfig();
|
|
523
703
|
const f = useForgotForm();
|
|
524
704
|
if (f.sent) {
|
|
525
|
-
return /* @__PURE__ */ (0,
|
|
526
|
-
/* @__PURE__ */ (0,
|
|
527
|
-
/* @__PURE__ */ (0,
|
|
528
|
-
/* @__PURE__ */ (0,
|
|
705
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("main", { style: { padding: 24, maxWidth: 360, margin: "0 auto", textAlign: "center" }, children: [
|
|
706
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h1", { children: "Verifique seu e-mail" }),
|
|
707
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { style: { opacity: 0.7 }, children: "Enviamos um link pra redefinir sua senha." }),
|
|
708
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { "data-testid": "forgot-back-login", type: "button", onClick: () => onNavigate("login"), children: "Voltar pro login" })
|
|
529
709
|
] });
|
|
530
710
|
}
|
|
531
|
-
return /* @__PURE__ */ (0,
|
|
532
|
-
/* @__PURE__ */ (0,
|
|
533
|
-
/* @__PURE__ */ (0,
|
|
534
|
-
/* @__PURE__ */ (0,
|
|
711
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("main", { style: { padding: 24, maxWidth: 360, margin: "0 auto" }, children: [
|
|
712
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h1", { style: { marginBottom: 8 }, children: name }),
|
|
713
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { style: { opacity: 0.7, marginBottom: 24 }, children: "Redefinir senha" }),
|
|
714
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("form", { onSubmit: (e) => {
|
|
535
715
|
e.preventDefault();
|
|
536
716
|
void f.submit();
|
|
537
717
|
}, children: [
|
|
538
|
-
/* @__PURE__ */ (0,
|
|
718
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { style: { display: "block", marginBottom: 12 }, children: [
|
|
539
719
|
"E-mail",
|
|
540
|
-
/* @__PURE__ */ (0,
|
|
541
|
-
f.emailError && /* @__PURE__ */ (0,
|
|
720
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { "data-testid": "forgot-email", type: "email", value: f.email, onChange: (e) => f.setEmail(e.target.value), style: { display: "block", width: "100%" } }),
|
|
721
|
+
f.emailError && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("small", { style: { color: "#c00" }, children: f.emailError })
|
|
542
722
|
] }),
|
|
543
|
-
f.error && /* @__PURE__ */ (0,
|
|
544
|
-
/* @__PURE__ */ (0,
|
|
723
|
+
f.error && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { role: "alert", style: { color: "#c00", marginBottom: 12 }, children: f.error.message }),
|
|
724
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { "data-testid": "forgot-submit", type: "submit", disabled: !f.canSubmit, style: { width: "100%", padding: 12, background: "var(--hook-color-primary)", color: "#fff", border: "none", borderRadius: 8, opacity: f.canSubmit ? 1 : 0.5 }, children: f.submitting ? "Enviando..." : "Enviar link" })
|
|
545
725
|
] }),
|
|
546
|
-
/* @__PURE__ */ (0,
|
|
726
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: { marginTop: 16 }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { "data-testid": "forgot-goto-login", type: "button", onClick: () => onNavigate("login"), style: { background: "none", border: "none", cursor: "pointer" }, children: "Voltar pro login" }) })
|
|
547
727
|
] });
|
|
548
728
|
}
|
|
549
729
|
|
|
550
730
|
// src/hooks/useResetForm.ts
|
|
551
|
-
var
|
|
731
|
+
var import_react10 = require("react");
|
|
552
732
|
var import_sdk8 = require("@hook-sdk/sdk");
|
|
553
733
|
var MIN_PASSWORD3 = 12;
|
|
554
734
|
function useResetForm() {
|
|
555
735
|
const { auth } = (0, import_sdk8.useHook)();
|
|
556
|
-
const [token, setToken] = (0,
|
|
557
|
-
const [password, setPassword] = (0,
|
|
558
|
-
const [confirm, setConfirm] = (0,
|
|
559
|
-
const [submitting, setSubmitting] = (0,
|
|
560
|
-
const [done, setDone] = (0,
|
|
561
|
-
const [error, setError] = (0,
|
|
562
|
-
(0,
|
|
736
|
+
const [token, setToken] = (0, import_react10.useState)(null);
|
|
737
|
+
const [password, setPassword] = (0, import_react10.useState)("");
|
|
738
|
+
const [confirm, setConfirm] = (0, import_react10.useState)("");
|
|
739
|
+
const [submitting, setSubmitting] = (0, import_react10.useState)(false);
|
|
740
|
+
const [done, setDone] = (0, import_react10.useState)(false);
|
|
741
|
+
const [error, setError] = (0, import_react10.useState)(null);
|
|
742
|
+
(0, import_react10.useEffect)(() => {
|
|
563
743
|
if (typeof window === "undefined") return;
|
|
564
744
|
const params = new URLSearchParams(window.location.search);
|
|
565
745
|
const t = params.get("token");
|
|
566
746
|
setToken(t && t.length > 0 ? t : null);
|
|
567
747
|
}, []);
|
|
568
|
-
const passwordError = (0,
|
|
748
|
+
const passwordError = (0, import_react10.useMemo)(() => {
|
|
569
749
|
if (password.length === 0) return null;
|
|
570
750
|
if (password.length < MIN_PASSWORD3) return `M\xEDnimo de ${MIN_PASSWORD3} caracteres.`;
|
|
571
751
|
return null;
|
|
572
752
|
}, [password]);
|
|
573
|
-
const confirmError = (0,
|
|
753
|
+
const confirmError = (0, import_react10.useMemo)(() => {
|
|
574
754
|
if (confirm.length === 0) return null;
|
|
575
755
|
if (confirm !== password) return "Senhas n\xE3o coincidem.";
|
|
576
756
|
return null;
|
|
577
757
|
}, [confirm, password]);
|
|
578
758
|
const canSubmit = token !== null && password.length >= MIN_PASSWORD3 && confirm === password && passwordError === null && confirmError === null && !submitting && !done;
|
|
579
|
-
const submit = (0,
|
|
759
|
+
const submit = (0, import_react10.useCallback)(async () => {
|
|
580
760
|
if (!canSubmit || token === null) return;
|
|
581
761
|
setSubmitting(true);
|
|
582
762
|
setError(null);
|
|
@@ -612,67 +792,67 @@ function useResetForm() {
|
|
|
612
792
|
}
|
|
613
793
|
|
|
614
794
|
// src/defaults/DefaultResetScreen.tsx
|
|
615
|
-
var
|
|
795
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
616
796
|
function DefaultResetScreen({ onNavigate }) {
|
|
617
797
|
const { name } = useTemplateConfig();
|
|
618
798
|
const f = useResetForm();
|
|
619
799
|
if (f.done) {
|
|
620
|
-
return /* @__PURE__ */ (0,
|
|
621
|
-
/* @__PURE__ */ (0,
|
|
622
|
-
/* @__PURE__ */ (0,
|
|
623
|
-
/* @__PURE__ */ (0,
|
|
800
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("main", { style: { padding: 24, maxWidth: 360, margin: "0 auto", textAlign: "center" }, children: [
|
|
801
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h1", { children: "Senha alterada" }),
|
|
802
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { style: { opacity: 0.7 }, children: "Agora \xE9 s\xF3 fazer login com a nova senha." }),
|
|
803
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { "data-testid": "reset-back-login", type: "button", onClick: () => onNavigate("login"), children: "Ir pro login" })
|
|
624
804
|
] });
|
|
625
805
|
}
|
|
626
806
|
if (f.token === null) {
|
|
627
|
-
return /* @__PURE__ */ (0,
|
|
628
|
-
/* @__PURE__ */ (0,
|
|
629
|
-
/* @__PURE__ */ (0,
|
|
630
|
-
/* @__PURE__ */ (0,
|
|
807
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("main", { style: { padding: 24, maxWidth: 360, margin: "0 auto", textAlign: "center" }, children: [
|
|
808
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h1", { children: "Link inv\xE1lido" }),
|
|
809
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { style: { opacity: 0.7 }, children: "Pe\xE7a um novo link de reset." }),
|
|
810
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { "data-testid": "reset-goto-forgot", type: "button", onClick: () => onNavigate("forgot"), children: "Pedir novo link" })
|
|
631
811
|
] });
|
|
632
812
|
}
|
|
633
|
-
return /* @__PURE__ */ (0,
|
|
634
|
-
/* @__PURE__ */ (0,
|
|
635
|
-
/* @__PURE__ */ (0,
|
|
636
|
-
/* @__PURE__ */ (0,
|
|
813
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("main", { style: { padding: 24, maxWidth: 360, margin: "0 auto" }, children: [
|
|
814
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h1", { style: { marginBottom: 8 }, children: name }),
|
|
815
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { style: { opacity: 0.7, marginBottom: 24 }, children: "Escolha uma nova senha" }),
|
|
816
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("form", { onSubmit: (e) => {
|
|
637
817
|
e.preventDefault();
|
|
638
818
|
void f.submit();
|
|
639
819
|
}, children: [
|
|
640
|
-
/* @__PURE__ */ (0,
|
|
820
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { style: { display: "block", marginBottom: 12 }, children: [
|
|
641
821
|
"Nova senha",
|
|
642
|
-
/* @__PURE__ */ (0,
|
|
643
|
-
f.passwordError && /* @__PURE__ */ (0,
|
|
822
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { "data-testid": "reset-password", type: "password", value: f.password, onChange: (e) => f.setPassword(e.target.value), style: { display: "block", width: "100%" }, autoComplete: "new-password" }),
|
|
823
|
+
f.passwordError && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("small", { style: { color: "#c00" }, children: f.passwordError })
|
|
644
824
|
] }),
|
|
645
|
-
/* @__PURE__ */ (0,
|
|
825
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { style: { display: "block", marginBottom: 12 }, children: [
|
|
646
826
|
"Confirmar senha",
|
|
647
|
-
/* @__PURE__ */ (0,
|
|
648
|
-
f.confirmError && /* @__PURE__ */ (0,
|
|
827
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { "data-testid": "reset-confirm", type: "password", value: f.confirm, onChange: (e) => f.setConfirm(e.target.value), style: { display: "block", width: "100%" }, autoComplete: "new-password" }),
|
|
828
|
+
f.confirmError && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("small", { style: { color: "#c00" }, children: f.confirmError })
|
|
649
829
|
] }),
|
|
650
|
-
f.error && /* @__PURE__ */ (0,
|
|
651
|
-
/* @__PURE__ */ (0,
|
|
830
|
+
f.error && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { role: "alert", style: { color: "#c00", marginBottom: 12 }, children: f.error.message }),
|
|
831
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { "data-testid": "reset-submit", type: "submit", disabled: !f.canSubmit, style: { width: "100%", padding: 12, background: "var(--hook-color-primary)", color: "#fff", border: "none", borderRadius: 8, opacity: f.canSubmit ? 1 : 0.5 }, children: f.submitting ? "Alterando..." : "Alterar senha" })
|
|
652
832
|
] })
|
|
653
833
|
] });
|
|
654
834
|
}
|
|
655
835
|
|
|
656
836
|
// src/defaults/DefaultPaywall.tsx
|
|
657
|
-
var
|
|
658
|
-
var
|
|
837
|
+
var import_react11 = require("react");
|
|
838
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
659
839
|
function DefaultPaywall() {
|
|
660
840
|
const config = useTemplateConfig();
|
|
661
841
|
const { checkout, opening, error } = usePaywallState();
|
|
662
842
|
const p = config.subscription.paywall_config;
|
|
663
|
-
const [cpf, setCpf] = (0,
|
|
843
|
+
const [cpf, setCpf] = (0, import_react11.useState)("");
|
|
664
844
|
const cpfDigits = cpf.replace(/\D/g, "");
|
|
665
845
|
const canCheckout = cpfDigits.length === 11 && !opening;
|
|
666
|
-
return /* @__PURE__ */ (0,
|
|
667
|
-
/* @__PURE__ */ (0,
|
|
668
|
-
p.subtitle && /* @__PURE__ */ (0,
|
|
669
|
-
/* @__PURE__ */ (0,
|
|
670
|
-
/* @__PURE__ */ (0,
|
|
671
|
-
/* @__PURE__ */ (0,
|
|
846
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("main", { style: { padding: 24, maxWidth: 440, margin: "0 auto", textAlign: "center" }, children: [
|
|
847
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h1", { style: { marginBottom: 8 }, children: p.title }),
|
|
848
|
+
p.subtitle && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { style: { opacity: 0.7, marginBottom: 24 }, children: p.subtitle }),
|
|
849
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("ul", { style: { listStyle: "none", padding: 0, textAlign: "left", marginBottom: 24 }, children: p.benefits.map((b) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("li", { style: { padding: "8px 0", display: "flex", alignItems: "center" }, children: [
|
|
850
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { "aria-hidden": true, style: { marginRight: 8 }, children: "\u2713" }),
|
|
851
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: b })
|
|
672
852
|
] }, b)) }),
|
|
673
|
-
/* @__PURE__ */ (0,
|
|
674
|
-
/* @__PURE__ */ (0,
|
|
675
|
-
/* @__PURE__ */ (0,
|
|
853
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: { textAlign: "left", marginBottom: 16 }, children: [
|
|
854
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { style: { display: "block", fontSize: 14, opacity: 0.7, marginBottom: 4 }, children: "Seu CPF (pra emiss\xE3o de recibo)" }),
|
|
855
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
676
856
|
"input",
|
|
677
857
|
{
|
|
678
858
|
"data-testid": "paywall-cpf",
|
|
@@ -685,8 +865,8 @@ function DefaultPaywall() {
|
|
|
685
865
|
}
|
|
686
866
|
)
|
|
687
867
|
] }),
|
|
688
|
-
error && /* @__PURE__ */ (0,
|
|
689
|
-
/* @__PURE__ */ (0,
|
|
868
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { role: "alert", style: { color: "#c00", marginBottom: 12 }, children: error.message }),
|
|
869
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
690
870
|
"button",
|
|
691
871
|
{
|
|
692
872
|
"data-testid": "paywall-cta",
|
|
@@ -707,21 +887,21 @@ function DefaultPaywall() {
|
|
|
707
887
|
children: opening ? "Abrindo..." : p.cta
|
|
708
888
|
}
|
|
709
889
|
),
|
|
710
|
-
p.priceHint && /* @__PURE__ */ (0,
|
|
711
|
-
p.footerNote && /* @__PURE__ */ (0,
|
|
890
|
+
p.priceHint && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { style: { opacity: 0.6, marginTop: 12 }, children: p.priceHint }),
|
|
891
|
+
p.footerNote && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { style: { opacity: 0.5, marginTop: 16, fontSize: 12 }, children: p.footerNote })
|
|
712
892
|
] });
|
|
713
893
|
}
|
|
714
894
|
|
|
715
895
|
// src/AppRoot.tsx
|
|
716
|
-
var
|
|
896
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
717
897
|
var BACKOFF_MS = [2e3, 5e3, 1e4, 2e4, 4e4];
|
|
718
898
|
function PaymentReturnHandler({ children }) {
|
|
719
899
|
const { subscription } = (0, import_sdk9.useHook)();
|
|
720
|
-
const subRef = (0,
|
|
900
|
+
const subRef = (0, import_react12.useRef)(subscription);
|
|
721
901
|
subRef.current = subscription;
|
|
722
|
-
const runIdRef = (0,
|
|
723
|
-
const [state, setState] = (0,
|
|
724
|
-
const runPoll = (0,
|
|
902
|
+
const runIdRef = (0, import_react12.useRef)(0);
|
|
903
|
+
const [state, setState] = (0, import_react12.useState)("idle");
|
|
904
|
+
const runPoll = (0, import_react12.useCallback)(() => {
|
|
725
905
|
const runId = ++runIdRef.current;
|
|
726
906
|
setState("confirming");
|
|
727
907
|
let attempts = 0;
|
|
@@ -750,7 +930,7 @@ function PaymentReturnHandler({ children }) {
|
|
|
750
930
|
};
|
|
751
931
|
void tick();
|
|
752
932
|
}, []);
|
|
753
|
-
(0,
|
|
933
|
+
(0, import_react12.useEffect)(() => {
|
|
754
934
|
if (typeof window === "undefined") return;
|
|
755
935
|
const url = new URL(window.location.href);
|
|
756
936
|
if (url.searchParams.get("paymentReturn") !== "1") return;
|
|
@@ -760,7 +940,7 @@ function PaymentReturnHandler({ children }) {
|
|
|
760
940
|
};
|
|
761
941
|
}, [runPoll]);
|
|
762
942
|
if (state === "confirming") {
|
|
763
|
-
return /* @__PURE__ */ (0,
|
|
943
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
764
944
|
"div",
|
|
765
945
|
{
|
|
766
946
|
role: "status",
|
|
@@ -771,9 +951,9 @@ function PaymentReturnHandler({ children }) {
|
|
|
771
951
|
);
|
|
772
952
|
}
|
|
773
953
|
if (state === "waiting") {
|
|
774
|
-
return /* @__PURE__ */ (0,
|
|
775
|
-
/* @__PURE__ */ (0,
|
|
776
|
-
/* @__PURE__ */ (0,
|
|
954
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { role: "status", "aria-live": "polite", style: overlayStyle, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: { maxWidth: 320, textAlign: "center", lineHeight: 1.5 }, children: [
|
|
955
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: { marginBottom: 16 }, children: "Pagamento aceito. Estamos confirmando com o banco \u2014 pode levar alguns minutos." }),
|
|
956
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
777
957
|
"button",
|
|
778
958
|
{
|
|
779
959
|
type: "button",
|
|
@@ -784,7 +964,7 @@ function PaymentReturnHandler({ children }) {
|
|
|
784
964
|
)
|
|
785
965
|
] }) });
|
|
786
966
|
}
|
|
787
|
-
return /* @__PURE__ */ (0,
|
|
967
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children });
|
|
788
968
|
}
|
|
789
969
|
var overlayStyle = {
|
|
790
970
|
position: "fixed",
|
|
@@ -817,14 +997,14 @@ function AppRoot({
|
|
|
817
997
|
Reset = DefaultResetScreen,
|
|
818
998
|
Paywall = DefaultPaywall
|
|
819
999
|
}) {
|
|
820
|
-
return /* @__PURE__ */ (0,
|
|
1000
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PaymentReturnHandler, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TemplateConfigProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(AuthGate, { Login, Signup, Forgot, Reset, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PersistedKeysPrefetch, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(SubscriptionGate, { Paywall, children: [
|
|
821
1001
|
children,
|
|
822
|
-
/* @__PURE__ */ (0,
|
|
1002
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PushPrompt, {})
|
|
823
1003
|
] }) }) }) }) }) }) });
|
|
824
1004
|
}
|
|
825
1005
|
|
|
826
1006
|
// src/hooks/usePush.ts
|
|
827
|
-
var
|
|
1007
|
+
var import_react13 = require("react");
|
|
828
1008
|
var import_sdk10 = require("@hook-sdk/sdk");
|
|
829
1009
|
function detectIosNeedsInstall() {
|
|
830
1010
|
if (typeof navigator === "undefined" || typeof window === "undefined") return false;
|
|
@@ -852,11 +1032,11 @@ function deriveState(push) {
|
|
|
852
1032
|
}
|
|
853
1033
|
function usePush() {
|
|
854
1034
|
const { push } = (0, import_sdk10.useHook)();
|
|
855
|
-
const [state, setState] = (0,
|
|
856
|
-
(0,
|
|
1035
|
+
const [state, setState] = (0, import_react13.useState)(() => deriveState(push));
|
|
1036
|
+
(0, import_react13.useEffect)(() => {
|
|
857
1037
|
setState(deriveState(push));
|
|
858
1038
|
}, [push]);
|
|
859
|
-
const subscribe = (0,
|
|
1039
|
+
const subscribe = (0, import_react13.useCallback)(async () => {
|
|
860
1040
|
try {
|
|
861
1041
|
await push.subscribe();
|
|
862
1042
|
setState({ kind: "subscribed" });
|
|
@@ -868,7 +1048,7 @@ function usePush() {
|
|
|
868
1048
|
throw e;
|
|
869
1049
|
}
|
|
870
1050
|
}, [push]);
|
|
871
|
-
const unsubscribe = (0,
|
|
1051
|
+
const unsubscribe = (0, import_react13.useCallback)(async () => {
|
|
872
1052
|
try {
|
|
873
1053
|
await push.unsubscribe();
|
|
874
1054
|
setState({ kind: "prompt" });
|
|
@@ -881,31 +1061,31 @@ function usePush() {
|
|
|
881
1061
|
}
|
|
882
1062
|
|
|
883
1063
|
// src/components/PushPrompt.tsx
|
|
884
|
-
var
|
|
1064
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
885
1065
|
function PushPrompt2({ texts, onSubscribed, onDeclined, onInstallRequested, className }) {
|
|
886
1066
|
const { state, subscribe } = usePush();
|
|
887
1067
|
if (state.kind === "subscribed") return null;
|
|
888
1068
|
if (state.kind === "ios_needs_install") {
|
|
889
|
-
return /* @__PURE__ */ (0,
|
|
890
|
-
/* @__PURE__ */ (0,
|
|
891
|
-
/* @__PURE__ */ (0,
|
|
892
|
-
onInstallRequested && texts.iosInstallCta && /* @__PURE__ */ (0,
|
|
1069
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className, role: "region", "aria-label": texts.iosInstallTitle, children: [
|
|
1070
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("h3", { children: texts.iosInstallTitle }),
|
|
1071
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { children: texts.iosInstallBody }),
|
|
1072
|
+
onInstallRequested && texts.iosInstallCta && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { onClick: onInstallRequested, children: texts.iosInstallCta })
|
|
893
1073
|
] });
|
|
894
1074
|
}
|
|
895
1075
|
if (state.kind === "denied") {
|
|
896
|
-
return /* @__PURE__ */ (0,
|
|
897
|
-
/* @__PURE__ */ (0,
|
|
898
|
-
/* @__PURE__ */ (0,
|
|
1076
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className, role: "region", "aria-label": texts.deniedTitle, children: [
|
|
1077
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("h3", { children: texts.deniedTitle }),
|
|
1078
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { children: texts.deniedBody })
|
|
899
1079
|
] });
|
|
900
1080
|
}
|
|
901
1081
|
if (state.kind === "unsupported") {
|
|
902
|
-
return /* @__PURE__ */ (0,
|
|
1082
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className, role: "region", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { children: texts.unsupportedBody }) });
|
|
903
1083
|
}
|
|
904
1084
|
if (state.kind === "error") {
|
|
905
|
-
return /* @__PURE__ */ (0,
|
|
1085
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className, role: "region", "aria-label": "error", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { children: state.message }) });
|
|
906
1086
|
}
|
|
907
|
-
return /* @__PURE__ */ (0,
|
|
908
|
-
/* @__PURE__ */ (0,
|
|
1087
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className, role: "region", children: [
|
|
1088
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
909
1089
|
"button",
|
|
910
1090
|
{
|
|
911
1091
|
type: "button",
|
|
@@ -919,27 +1099,27 @@ function PushPrompt2({ texts, onSubscribed, onDeclined, onInstallRequested, clas
|
|
|
919
1099
|
children: texts.cta
|
|
920
1100
|
}
|
|
921
1101
|
),
|
|
922
|
-
onDeclined && /* @__PURE__ */ (0,
|
|
1102
|
+
onDeclined && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", onClick: onDeclined, children: texts.declineCta })
|
|
923
1103
|
] });
|
|
924
1104
|
}
|
|
925
1105
|
|
|
926
1106
|
// src/defaults/EmptyState.tsx
|
|
927
|
-
var
|
|
1107
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
928
1108
|
function EmptyState({ title, description, action }) {
|
|
929
|
-
return /* @__PURE__ */ (0,
|
|
930
|
-
/* @__PURE__ */ (0,
|
|
931
|
-
description && /* @__PURE__ */ (0,
|
|
932
|
-
action && /* @__PURE__ */ (0,
|
|
1109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { role: "status", style: { padding: 32, textAlign: "center" }, children: [
|
|
1110
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h2", { style: { marginBottom: 8 }, children: title }),
|
|
1111
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { style: { opacity: 0.7 }, children: description }),
|
|
1112
|
+
action && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { marginTop: 16 }, children: action })
|
|
933
1113
|
] });
|
|
934
1114
|
}
|
|
935
1115
|
|
|
936
1116
|
// src/hooks/useAuthPrimitives.ts
|
|
937
|
-
var
|
|
1117
|
+
var import_react14 = require("react");
|
|
938
1118
|
var import_sdk11 = require("@hook-sdk/sdk");
|
|
939
1119
|
var warned = false;
|
|
940
1120
|
function useAuthPrimitives() {
|
|
941
1121
|
const { auth } = (0, import_sdk11.useHook)();
|
|
942
|
-
(0,
|
|
1122
|
+
(0, import_react14.useEffect)(() => {
|
|
943
1123
|
if (!warned && process.env.NODE_ENV !== "production") {
|
|
944
1124
|
warned = true;
|
|
945
1125
|
console.warn(
|
|
@@ -970,14 +1150,14 @@ function useSubscription() {
|
|
|
970
1150
|
}
|
|
971
1151
|
|
|
972
1152
|
// src/hooks/useReminders.ts
|
|
973
|
-
var
|
|
1153
|
+
var import_react15 = require("react");
|
|
974
1154
|
var import_sdk13 = require("@hook-sdk/sdk");
|
|
975
1155
|
function useReminders() {
|
|
976
1156
|
const { push } = (0, import_sdk13.useHook)();
|
|
977
1157
|
const r = push.reminders;
|
|
978
|
-
const [reminders, setReminders] = (0,
|
|
979
|
-
const [loading, setLoading] = (0,
|
|
980
|
-
const reload = (0,
|
|
1158
|
+
const [reminders, setReminders] = (0, import_react15.useState)([]);
|
|
1159
|
+
const [loading, setLoading] = (0, import_react15.useState)(true);
|
|
1160
|
+
const reload = (0, import_react15.useCallback)(async () => {
|
|
981
1161
|
setLoading(true);
|
|
982
1162
|
try {
|
|
983
1163
|
const next = await r.list();
|
|
@@ -986,38 +1166,38 @@ function useReminders() {
|
|
|
986
1166
|
setLoading(false);
|
|
987
1167
|
}
|
|
988
1168
|
}, [r]);
|
|
989
|
-
(0,
|
|
1169
|
+
(0, import_react15.useEffect)(() => {
|
|
990
1170
|
void reload();
|
|
991
1171
|
}, [reload]);
|
|
992
|
-
const setReminder = (0,
|
|
1172
|
+
const setReminder = (0, import_react15.useCallback)(async (input) => {
|
|
993
1173
|
await r.set(input);
|
|
994
1174
|
await reload();
|
|
995
1175
|
}, [r, reload]);
|
|
996
|
-
const deleteReminder = (0,
|
|
1176
|
+
const deleteReminder = (0, import_react15.useCallback)(async (slot) => {
|
|
997
1177
|
await r.delete(slot);
|
|
998
1178
|
await reload();
|
|
999
1179
|
}, [r, reload]);
|
|
1000
|
-
const schedule = (0,
|
|
1180
|
+
const schedule = (0, import_react15.useCallback)(async (items) => {
|
|
1001
1181
|
return r.schedule(items);
|
|
1002
1182
|
}, [r]);
|
|
1003
|
-
const setFallbacks = (0,
|
|
1183
|
+
const setFallbacks = (0, import_react15.useCallback)(async (items) => {
|
|
1004
1184
|
return r.setFallbacks(items);
|
|
1005
1185
|
}, [r]);
|
|
1006
1186
|
return { reminders, loading, setReminder, deleteReminder, schedule, setFallbacks };
|
|
1007
1187
|
}
|
|
1008
1188
|
|
|
1009
1189
|
// src/hooks/useToast.ts
|
|
1010
|
-
var
|
|
1190
|
+
var import_react16 = require("react");
|
|
1011
1191
|
function useToast() {
|
|
1012
|
-
const [items, setItems] = (0,
|
|
1013
|
-
const show = (0,
|
|
1192
|
+
const [items, setItems] = (0, import_react16.useState)([]);
|
|
1193
|
+
const show = (0, import_react16.useCallback)((message, kind = "info") => {
|
|
1014
1194
|
const id = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
1015
1195
|
setItems((prev) => [...prev, { id, message, kind }]);
|
|
1016
1196
|
setTimeout(() => {
|
|
1017
1197
|
setItems((prev) => prev.filter((t) => t.id !== id));
|
|
1018
1198
|
}, 4e3);
|
|
1019
1199
|
}, []);
|
|
1020
|
-
const dismiss = (0,
|
|
1200
|
+
const dismiss = (0, import_react16.useCallback)((id) => {
|
|
1021
1201
|
setItems((prev) => prev.filter((t) => t.id !== id));
|
|
1022
1202
|
}, []);
|
|
1023
1203
|
return { items, show, dismiss };
|