nextworks 0.1.0-alpha.13 → 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 (55) hide show
  1. package/README.md +20 -9
  2. package/dist/kits/auth-core/.nextworks/docs/AUTH_CORE_README.md +2 -2
  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 +1 -1
  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/package-deps.json +3 -3
  27. package/dist/kits/data/.nextworks/docs/DATA_QUICKSTART.md +128 -112
  28. package/dist/kits/data/.nextworks/docs/DATA_README.md +2 -1
  29. package/dist/kits/data/app/api/posts/[id]/route.ts +83 -83
  30. package/dist/kits/data/app/api/posts/route.ts +136 -138
  31. package/dist/kits/data/app/api/seed-demo/route.ts +1 -2
  32. package/dist/kits/data/app/api/users/[id]/route.ts +29 -17
  33. package/dist/kits/data/app/api/users/check-email/route.ts +1 -1
  34. package/dist/kits/data/app/api/users/check-unique/route.ts +30 -27
  35. package/dist/kits/data/app/api/users/route.ts +0 -2
  36. package/dist/kits/data/app/examples/demo/create-post-form.tsx +108 -106
  37. package/dist/kits/data/app/examples/demo/page.tsx +2 -1
  38. package/dist/kits/data/app/examples/demo/seed-demo-button.tsx +1 -1
  39. package/dist/kits/data/components/admin/posts-manager.tsx +727 -719
  40. package/dist/kits/data/components/admin/users-manager.tsx +435 -432
  41. package/dist/kits/data/lib/server/result.ts +5 -2
  42. package/dist/kits/data/package-deps.json +1 -1
  43. package/dist/kits/data/scripts/seed-demo.mjs +1 -2
  44. package/dist/kits/forms/app/api/wizard/route.ts +76 -71
  45. package/dist/kits/forms/app/examples/forms/server-action/page.tsx +78 -71
  46. package/dist/kits/forms/components/hooks/useCheckUnique.ts +85 -79
  47. package/dist/kits/forms/components/ui/form/form-control.tsx +28 -28
  48. package/dist/kits/forms/components/ui/form/form-description.tsx +23 -22
  49. package/dist/kits/forms/components/ui/form/form-item.tsx +21 -21
  50. package/dist/kits/forms/components/ui/form/form-label.tsx +24 -24
  51. package/dist/kits/forms/components/ui/form/form-message.tsx +28 -29
  52. package/dist/kits/forms/components/ui/switch.tsx +78 -78
  53. package/dist/kits/forms/lib/forms/map-errors.ts +1 -1
  54. package/dist/kits/forms/lib/validation/forms.ts +1 -2
  55. package/package.json +1 -1
@@ -1,106 +1,108 @@
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 { postSchema } from "@/lib/validation/forms";
7
- import { z } from "zod";
8
- import { useRouter } from "next/navigation";
9
- import { Form } from "@/components/ui/form/form";
10
- import { FormField } from "@/components/ui/form/form-field";
11
- import { FormItem } from "@/components/ui/form/form-item";
12
- import { FormLabel } from "@/components/ui/form/form-label";
13
- import { FormControl } from "@/components/ui/form/form-control";
14
- import { FormMessage } from "@/components/ui/form/form-message";
15
- import { Input } from "@/components/ui/input";
16
- import { Textarea } from "@/components/ui/textarea";
17
- import { Button } from "@/components/ui/button";
18
- import { mapApiErrorsToForm } from "@/lib/forms/map-errors";
19
- import { toast } from "sonner";
20
-
21
- import { useSession } from "next-auth/react";
22
-
23
- export default function CreatePostForm() {
24
- // Relax the schema for this demo form: authorId is optional here
25
- const postFormSchema = postSchema.extend({
26
- authorId: postSchema.shape.authorId.optional().or(z.literal("")),
27
- });
28
-
29
- const methods = useForm({
30
- resolver: zodResolver(postFormSchema),
31
- defaultValues: { title: "", content: "" },
32
- });
33
- const { control, handleSubmit, reset } = methods;
34
-
35
- const session = useSession();
36
- const router = useRouter();
37
-
38
- const onSubmit = async (values: any) => {
39
- if (session.status !== "authenticated") {
40
- toast.error(
41
- "You must be signed in to create a post. Use the Sign up / Log in links above.",
42
- );
43
- return;
44
- }
45
- try {
46
- const res = await fetch("/api/posts", {
47
- method: "POST",
48
- headers: { "Content-Type": "application/json" },
49
- body: JSON.stringify(values),
50
- });
51
- const payload = await res.json().catch(() => null);
52
- if (!res.ok || !payload?.success) {
53
- const msg = payload ? mapApiErrorsToForm(methods, payload) : undefined;
54
- toast.error(msg || payload?.message || "Create failed");
55
- return;
56
- }
57
- reset();
58
- toast.success("Post created");
59
- // Refresh the server-rendered list below
60
- router.refresh();
61
- } catch (e) {
62
- toast.error("Create failed");
63
- }
64
- };
65
-
66
- return (
67
- <div className="bg-card rounded-md p-6">
68
- <h3 className="mb-3 text-lg font-semibold">
69
- Create a post (requires sign in)
70
- </h3>
71
- <Form methods={methods}>
72
- <form onSubmit={handleSubmit(onSubmit)} className="space-y-3">
73
- <FormField
74
- control={control}
75
- name="title"
76
- render={({ field }) => (
77
- <FormItem>
78
- <FormLabel>Title</FormLabel>
79
- <FormControl>
80
- <Input {...field} />
81
- </FormControl>
82
- <FormMessage />
83
- </FormItem>
84
- )}
85
- />
86
-
87
- <FormField
88
- control={control}
89
- name="content"
90
- render={({ field }) => (
91
- <FormItem>
92
- <FormLabel>Content</FormLabel>
93
- <FormControl>
94
- <Textarea {...field} rows={4} />
95
- </FormControl>
96
- <FormMessage />
97
- </FormItem>
98
- )}
99
- />
100
-
101
- <Button type="submit">Create Post</Button>
102
- </form>
103
- </Form>
104
- </div>
105
- );
106
- }
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 { postSchema } from "@/lib/validation/forms";
7
+ import { z } from "zod";
8
+ import { useRouter } from "next/navigation";
9
+ import { Form } from "@/components/ui/form/form";
10
+ import { FormField } from "@/components/ui/form/form-field";
11
+ import { FormItem } from "@/components/ui/form/form-item";
12
+ import { FormLabel } from "@/components/ui/form/form-label";
13
+ import { FormControl } from "@/components/ui/form/form-control";
14
+ import { FormMessage } from "@/components/ui/form/form-message";
15
+ import { Input } from "@/components/ui/input";
16
+ import { Textarea } from "@/components/ui/textarea";
17
+ import { Button } from "@/components/ui/button";
18
+ import { mapApiErrorsToForm } from "@/lib/forms/map-errors";
19
+ import { toast } from "sonner";
20
+
21
+ import { useSession } from "next-auth/react";
22
+
23
+ export default function CreatePostForm() {
24
+ // Relax the schema for this demo form: authorId is optional here
25
+ const postFormSchema = postSchema.extend({
26
+ authorId: postSchema.shape.authorId.optional().or(z.literal("")),
27
+ });
28
+
29
+ const methods = useForm({
30
+ resolver: zodResolver(postFormSchema),
31
+ defaultValues: { title: "", content: "" },
32
+ });
33
+ const { control, handleSubmit, reset } = methods;
34
+
35
+ const session = useSession();
36
+ const router = useRouter();
37
+
38
+ type CreatePostFormValues = z.infer<typeof postFormSchema>;
39
+
40
+ const onSubmit = async (values: CreatePostFormValues) => {
41
+ if (session.status !== "authenticated") {
42
+ toast.error(
43
+ "You must be signed in to create a post. Use the Sign up / Log in links above.",
44
+ );
45
+ return;
46
+ }
47
+ try {
48
+ const res = await fetch("/api/posts", {
49
+ method: "POST",
50
+ headers: { "Content-Type": "application/json" },
51
+ body: JSON.stringify(values),
52
+ });
53
+ const payload = await res.json().catch(() => null);
54
+ if (!res.ok || !payload?.success) {
55
+ const msg = payload ? mapApiErrorsToForm(methods, payload) : undefined;
56
+ toast.error(msg || payload?.message || "Create failed");
57
+ return;
58
+ }
59
+ reset();
60
+ toast.success("Post created");
61
+ // Refresh the server-rendered list below
62
+ router.refresh();
63
+ } catch {
64
+ toast.error("Create failed");
65
+ }
66
+ };
67
+
68
+ return (
69
+ <div className="bg-card rounded-md p-6">
70
+ <h3 className="mb-3 text-lg font-semibold">
71
+ Create a post (requires sign in)
72
+ </h3>
73
+ <Form methods={methods}>
74
+ <form onSubmit={handleSubmit(onSubmit)} className="space-y-3">
75
+ <FormField
76
+ control={control}
77
+ name="title"
78
+ render={({ field }) => (
79
+ <FormItem>
80
+ <FormLabel>Title</FormLabel>
81
+ <FormControl>
82
+ <Input {...field} />
83
+ </FormControl>
84
+ <FormMessage />
85
+ </FormItem>
86
+ )}
87
+ />
88
+
89
+ <FormField
90
+ control={control}
91
+ name="content"
92
+ render={({ field }) => (
93
+ <FormItem>
94
+ <FormLabel>Content</FormLabel>
95
+ <FormControl>
96
+ <Textarea {...field} rows={4} />
97
+ </FormControl>
98
+ <FormMessage />
99
+ </FormItem>
100
+ )}
101
+ />
102
+
103
+ <Button type="submit">Create Post</Button>
104
+ </form>
105
+ </Form>
106
+ </div>
107
+ );
108
+ }
@@ -79,7 +79,8 @@ export default async function DemoPage() {
79
79
  <h2 className="mb-3 text-lg font-semibold">Your posts</h2>
80
80
  {posts.length === 0 ? (
81
81
  <p className="text-muted-foreground text-sm">
82
- No posts yet. Use the form above or click "Seed demo data" to create
82
+ No posts yet. Use the form above or click &quot;Seed demo data&quot; to create
83
+
83
84
  sample posts.
84
85
  </p>
85
86
  ) : (
@@ -22,7 +22,7 @@ export default function SeedDemoButton() {
22
22
  toast.success("Demo data seeded");
23
23
  // Refresh to show new posts if the page lists them
24
24
  router.refresh();
25
- } catch (e) {
25
+ } catch {
26
26
  toast.error("Failed to seed demo data");
27
27
  } finally {
28
28
  setLoading(false);