nextworks 0.1.0-alpha.11 → 0.1.0-alpha.14

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.
Files changed (57) hide show
  1. package/README.md +20 -9
  2. package/dist/kits/auth-core/.nextworks/docs/AUTH_CORE_README.md +3 -3
  3. package/dist/kits/auth-core/.nextworks/docs/AUTH_QUICKSTART.md +264 -244
  4. package/dist/kits/auth-core/app/(protected)/settings/profile/profile-form.tsx +120 -114
  5. package/dist/kits/auth-core/app/api/auth/forgot-password/route.ts +116 -114
  6. package/dist/kits/auth-core/app/api/auth/reset-password/route.ts +66 -63
  7. package/dist/kits/auth-core/app/api/auth/send-verify-email/route.ts +1 -1
  8. package/dist/kits/auth-core/app/api/users/[id]/route.ts +134 -127
  9. package/dist/kits/auth-core/app/auth/reset-password/page.tsx +186 -187
  10. package/dist/kits/auth-core/components/auth/dashboard.tsx +25 -2
  11. package/dist/kits/auth-core/components/auth/forgot-password-form.tsx +90 -90
  12. package/dist/kits/auth-core/components/auth/login-form.tsx +492 -467
  13. package/dist/kits/auth-core/components/auth/signup-form.tsx +28 -29
  14. package/dist/kits/auth-core/lib/auth.ts +46 -15
  15. package/dist/kits/auth-core/lib/forms/map-errors.ts +37 -11
  16. package/dist/kits/auth-core/lib/server/result.ts +45 -45
  17. package/dist/kits/auth-core/lib/validation/forms.ts +1 -2
  18. package/dist/kits/auth-core/package-deps.json +4 -2
  19. package/dist/kits/auth-core/types/next-auth.d.ts +1 -1
  20. package/dist/kits/blocks/.nextworks/docs/BLOCKS_QUICKSTART.md +2 -8
  21. package/dist/kits/blocks/.nextworks/docs/THEME_GUIDE.md +18 -1
  22. package/dist/kits/blocks/app/templates/productlaunch/page.tsx +0 -2
  23. package/dist/kits/blocks/components/sections/FAQ.tsx +0 -1
  24. package/dist/kits/blocks/components/sections/Newsletter.tsx +2 -2
  25. package/dist/kits/blocks/components/ui/switch.tsx +78 -78
  26. package/dist/kits/blocks/components/ui/theme-selector.tsx +1 -1
  27. package/dist/kits/blocks/lib/themes.ts +1 -0
  28. package/dist/kits/blocks/package-deps.json +4 -4
  29. package/dist/kits/data/.nextworks/docs/DATA_QUICKSTART.md +128 -112
  30. package/dist/kits/data/.nextworks/docs/DATA_README.md +2 -1
  31. package/dist/kits/data/app/api/posts/[id]/route.ts +83 -83
  32. package/dist/kits/data/app/api/posts/route.ts +136 -138
  33. package/dist/kits/data/app/api/seed-demo/route.ts +1 -2
  34. package/dist/kits/data/app/api/users/[id]/route.ts +29 -17
  35. package/dist/kits/data/app/api/users/check-email/route.ts +1 -1
  36. package/dist/kits/data/app/api/users/check-unique/route.ts +30 -27
  37. package/dist/kits/data/app/api/users/route.ts +0 -2
  38. package/dist/kits/data/app/examples/demo/create-post-form.tsx +108 -106
  39. package/dist/kits/data/app/examples/demo/page.tsx +2 -1
  40. package/dist/kits/data/app/examples/demo/seed-demo-button.tsx +1 -1
  41. package/dist/kits/data/components/admin/posts-manager.tsx +727 -719
  42. package/dist/kits/data/components/admin/users-manager.tsx +435 -432
  43. package/dist/kits/data/lib/server/result.ts +5 -2
  44. package/dist/kits/data/package-deps.json +1 -1
  45. package/dist/kits/data/scripts/seed-demo.mjs +1 -2
  46. package/dist/kits/forms/app/api/wizard/route.ts +76 -71
  47. package/dist/kits/forms/app/examples/forms/server-action/page.tsx +78 -71
  48. package/dist/kits/forms/components/hooks/useCheckUnique.ts +85 -79
  49. package/dist/kits/forms/components/ui/form/form-control.tsx +28 -28
  50. package/dist/kits/forms/components/ui/form/form-description.tsx +23 -22
  51. package/dist/kits/forms/components/ui/form/form-item.tsx +21 -21
  52. package/dist/kits/forms/components/ui/form/form-label.tsx +24 -24
  53. package/dist/kits/forms/components/ui/form/form-message.tsx +28 -29
  54. package/dist/kits/forms/components/ui/switch.tsx +78 -78
  55. package/dist/kits/forms/lib/forms/map-errors.ts +1 -1
  56. package/dist/kits/forms/lib/validation/forms.ts +1 -2
  57. package/package.json +1 -1
@@ -134,8 +134,31 @@ export default function Dashboard({
134
134
  .join("")
135
135
  .toUpperCase();
136
136
 
137
- const createdAtRaw =
138
- (session as any)?.user?.createdAt ?? (session as any)?.createdAt;
137
+ const createdAtRaw = (() => {
138
+ const s = session as unknown;
139
+ if (!s || typeof s !== "object") return null;
140
+
141
+ const sessionCreatedAt =
142
+ "createdAt" in s &&
143
+ (typeof (s as { createdAt?: unknown }).createdAt === "string" ||
144
+ (s as { createdAt?: unknown }).createdAt instanceof Date)
145
+ ? (s as { createdAt?: string | Date }).createdAt
146
+ : null;
147
+
148
+ const user = "user" in s && (s as { user?: unknown }).user && typeof (s as { user?: unknown }).user === "object"
149
+ ? (s as { user: Record<string, unknown> }).user
150
+ : null;
151
+
152
+ const userCreatedAt =
153
+ user &&
154
+ "createdAt" in user &&
155
+ (typeof (user as { createdAt?: unknown }).createdAt === "string" ||
156
+ (user as { createdAt?: unknown }).createdAt instanceof Date)
157
+ ? (user as { createdAt?: string | Date }).createdAt
158
+ : null;
159
+
160
+ return userCreatedAt ?? sessionCreatedAt;
161
+ })();
139
162
  const createdAt = createdAtRaw ? new Date(createdAtRaw) : null;
140
163
 
141
164
  return (
@@ -1,90 +1,90 @@
1
- "use client";
2
-
3
- import React from "react";
4
- import { useForm } from "react-hook-form";
5
- import { zodResolver } from "@hookform/resolvers/zod";
6
- import {
7
- forgotPasswordSchema,
8
- type ForgotPasswordFormValues,
9
- } from "@/lib/validation/forms";
10
- import { Input } from "@/components/ui/input";
11
- import { Button } from "@/components/ui/button";
12
- import { Form } from "@/components/ui/form/form";
13
- import { FormField } from "@/components/ui/form/form-field";
14
- import { FormItem } from "@/components/ui/form/form-item";
15
- import { FormLabel } from "@/components/ui/form/form-label";
16
- import { FormControl } from "@/components/ui/form/form-control";
17
- import { FormMessage } from "@/components/ui/form/form-message";
18
- import { toast } from "sonner";
19
-
20
- export default function ForgotPasswordForm() {
21
- const methods = useForm<ForgotPasswordFormValues>({
22
- resolver: zodResolver(forgotPasswordSchema) as any,
23
- defaultValues: { email: "" },
24
- });
25
- const {
26
- handleSubmit,
27
- control,
28
- formState: { isSubmitting },
29
- } = methods;
30
-
31
- const onSubmit = async (data: any) => {
32
- try {
33
- const res = await fetch("/api/auth/forgot-password", {
34
- method: "POST",
35
- body: JSON.stringify(data),
36
- headers: { "Content-Type": "application/json" },
37
- });
38
- if (res.ok) {
39
- toast.success(
40
- "If an account exists, a reset link was sent (check server console in dev).",
41
- );
42
- } else {
43
- toast.error("Failed to request password reset");
44
- }
45
- } catch (e) {
46
- toast.error("Failed to request password reset");
47
- }
48
- };
49
-
50
- return (
51
- <div className="mx-auto w-full max-w-md pt-6">
52
- <h2 className="text-foreground text-center text-2xl font-bold">
53
- Forgot password
54
- </h2>
55
- <p className="text-muted-foreground mt-1 text-center text-sm">
56
- Enter your email and we will send a reset link.
57
- </p>
58
-
59
- <Form methods={methods}>
60
- <form
61
- onSubmit={handleSubmit(onSubmit)}
62
- className="border-border bg-card space-y-4 rounded-lg border p-6 shadow-sm"
63
- >
64
- <FormField
65
- control={control}
66
- name="email"
67
- render={({ field: f }) => (
68
- <FormItem>
69
- <FormLabel>Email</FormLabel>
70
- <FormControl>
71
- <Input
72
- id="email"
73
- type="email"
74
- placeholder="you@example.com"
75
- {...f}
76
- />
77
- </FormControl>
78
- <FormMessage />
79
- </FormItem>
80
- )}
81
- />
82
-
83
- <Button type="submit" disabled={isSubmitting} className="w-full">
84
- Request reset
85
- </Button>
86
- </form>
87
- </Form>
88
- </div>
89
- );
90
- }
1
+ "use client";
2
+
3
+ import React from "react";
4
+ import { useForm } from "react-hook-form";
5
+ import { zodResolver } from "@hookform/resolvers/zod";
6
+ import {
7
+ forgotPasswordSchema,
8
+ type ForgotPasswordFormValues,
9
+ } from "@/lib/validation/forms";
10
+ import { Input } from "@/components/ui/input";
11
+ import { Button } from "@/components/ui/button";
12
+ import { Form } from "@/components/ui/form/form";
13
+ import { FormField } from "@/components/ui/form/form-field";
14
+ import { FormItem } from "@/components/ui/form/form-item";
15
+ import { FormLabel } from "@/components/ui/form/form-label";
16
+ import { FormControl } from "@/components/ui/form/form-control";
17
+ import { FormMessage } from "@/components/ui/form/form-message";
18
+ import { toast } from "sonner";
19
+
20
+ export default function ForgotPasswordForm() {
21
+ const methods = useForm<ForgotPasswordFormValues>({
22
+ resolver: zodResolver(forgotPasswordSchema),
23
+ defaultValues: { email: "" },
24
+ });
25
+ const {
26
+ handleSubmit,
27
+ control,
28
+ formState: { isSubmitting },
29
+ } = methods;
30
+
31
+ const onSubmit = async (data: ForgotPasswordFormValues) => {
32
+ try {
33
+ const res = await fetch("/api/auth/forgot-password", {
34
+ method: "POST",
35
+ body: JSON.stringify(data),
36
+ headers: { "Content-Type": "application/json" },
37
+ });
38
+ if (res.ok) {
39
+ toast.success(
40
+ "If an account exists, a reset link was sent (check server console in dev).",
41
+ );
42
+ } else {
43
+ toast.error("Failed to request password reset");
44
+ }
45
+ } catch {
46
+ toast.error("Failed to request password reset");
47
+ }
48
+ };
49
+
50
+ return (
51
+ <div className="mx-auto w-full max-w-md pt-6">
52
+ <h2 className="text-foreground text-center text-2xl font-bold">
53
+ Forgot password
54
+ </h2>
55
+ <p className="text-muted-foreground mt-1 text-center text-sm">
56
+ Enter your email and we will send a reset link.
57
+ </p>
58
+
59
+ <Form methods={methods}>
60
+ <form
61
+ onSubmit={handleSubmit(onSubmit)}
62
+ className="border-border bg-card space-y-4 rounded-lg border p-6 shadow-sm"
63
+ >
64
+ <FormField
65
+ control={control}
66
+ name="email"
67
+ render={({ field: f }) => (
68
+ <FormItem>
69
+ <FormLabel>Email</FormLabel>
70
+ <FormControl>
71
+ <Input
72
+ id="email"
73
+ type="email"
74
+ placeholder="you@example.com"
75
+ {...f}
76
+ />
77
+ </FormControl>
78
+ <FormMessage />
79
+ </FormItem>
80
+ )}
81
+ />
82
+
83
+ <Button type="submit" disabled={isSubmitting} className="w-full">
84
+ Request reset
85
+ </Button>
86
+ </form>
87
+ </Form>
88
+ </div>
89
+ );
90
+ }