@vitnode/core 1.2.0-canary.59 → 1.2.0-canary.61

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 (283) hide show
  1. package/dist/scripts/get-config.js +15 -0
  2. package/dist/scripts/plugin.js +188 -0
  3. package/dist/scripts/prepare-database.js +177 -0
  4. package/dist/scripts/prepare-plugins-files.js +134 -0
  5. package/dist/scripts/run-interactive-shell-command.js +21 -0
  6. package/dist/scripts/scripts.js +39 -13
  7. package/dist/scripts/shared/file-utils.js +203 -0
  8. package/dist/src/api/adapters/sso/discord.js +1 -77
  9. package/dist/src/api/adapters/sso/facebook.js +1 -76
  10. package/dist/src/api/adapters/sso/google.js +1 -87
  11. package/dist/src/api/config.js +1 -67
  12. package/dist/src/api/lib/check-plugin-id.js +1 -43
  13. package/dist/src/api/lib/cron.js +1 -22
  14. package/dist/src/api/lib/logger-middleware.js +1 -35
  15. package/dist/src/api/lib/module.js +1 -22
  16. package/dist/src/api/lib/plugin.js +1 -22
  17. package/dist/src/api/lib/route.js +1 -27
  18. package/dist/src/api/lib/with-pagination.js +1 -83
  19. package/dist/src/api/middlewares/captcha.middleware.js +1 -63
  20. package/dist/src/api/middlewares/cron-auth.middleware.js +1 -19
  21. package/dist/src/api/middlewares/global.middleware.d.ts.map +1 -1
  22. package/dist/src/api/middlewares/global.middleware.js +1 -104
  23. package/dist/src/api/middlewares/rate-limiter.middleware.js +1 -32
  24. package/dist/src/api/models/device.js +1 -61
  25. package/dist/src/api/models/email.d.ts.map +1 -1
  26. package/dist/src/api/models/email.js +1 -77
  27. package/dist/src/api/models/password.js +1 -36
  28. package/dist/src/api/models/session-admin.d.ts.map +1 -1
  29. package/dist/src/api/models/session-admin.js +1 -97
  30. package/dist/src/api/models/session.d.ts.map +1 -1
  31. package/dist/src/api/models/session.js +1 -76
  32. package/dist/src/api/models/sso.js +1 -120
  33. package/dist/src/api/models/user/get-user-by-id.js +1 -19
  34. package/dist/src/api/models/user/sign-in-with-passwords.js +1 -22
  35. package/dist/src/api/models/user/sign-up.js +1 -73
  36. package/dist/src/api/models/user.js +1 -8
  37. package/dist/src/api/modules/admin/admin.module.js +1 -19
  38. package/dist/src/api/modules/admin/advanced/advanced.admin.module.js +1 -11
  39. package/dist/src/api/modules/admin/advanced/cron/cron.admin.module.js +1 -12
  40. package/dist/src/api/modules/admin/advanced/cron/routes/get.route.js +1 -66
  41. package/dist/src/api/modules/admin/advanced/cron/routes/run.route.js +1 -95
  42. package/dist/src/api/modules/admin/debug/debug.admin.module.js +1 -10
  43. package/dist/src/api/modules/admin/debug/routes/logs.route.js +1 -94
  44. package/dist/src/api/modules/admin/routes/session.route.js +1 -47
  45. package/dist/src/api/modules/admin/users/routes/list.route.js +1 -79
  46. package/dist/src/api/modules/admin/users/routes/users.route.js +1 -84
  47. package/dist/src/api/modules/admin/users/users.admin.module.js +1 -10
  48. package/dist/src/api/modules/cron/cron/clean.cron.js +1 -24
  49. package/dist/src/api/modules/cron/cron.module.js +1 -14
  50. package/dist/src/api/modules/cron/helpers/process-cron-jobs.d.ts.map +1 -1
  51. package/dist/src/api/modules/cron/helpers/process-cron-jobs.js +1 -72
  52. package/dist/src/api/modules/cron/routes/cron.route.d.ts.map +1 -1
  53. package/dist/src/api/modules/cron/routes/cron.route.js +1 -95
  54. package/dist/src/api/modules/middleware/middleware.module.js +1 -10
  55. package/dist/src/api/modules/middleware/route.js +1 -49
  56. package/dist/src/api/modules/users/avatar-color.js +1 -43
  57. package/dist/src/api/modules/users/routes/change-password.route.js +1 -58
  58. package/dist/src/api/modules/users/routes/reset-passowrd.route.js +1 -91
  59. package/dist/src/api/modules/users/routes/session.route.js +1 -46
  60. package/dist/src/api/modules/users/routes/sign-in.route.js +1 -71
  61. package/dist/src/api/modules/users/routes/sign-out.route.js +1 -43
  62. package/dist/src/api/modules/users/routes/sign-up.route.js +1 -77
  63. package/dist/src/api/modules/users/routes/test.route.js +1 -33
  64. package/dist/src/api/modules/users/sso/routes/callback.route.js +1 -52
  65. package/dist/src/api/modules/users/sso/routes/create-url.route.js +1 -36
  66. package/dist/src/api/modules/users/sso/sso.module.js +1 -12
  67. package/dist/src/api/modules/users/users.module.js +1 -26
  68. package/dist/src/api/plugin.js +1 -15
  69. package/dist/src/app/login/page.js +1 -16
  70. package/dist/src/app/login/reset-password/page.js +1 -18
  71. package/dist/src/app/login/sso/[providerId]/page.js +1 -10
  72. package/dist/src/app/register/page.js +1 -16
  73. package/dist/src/app_admin/core/advanced/cron/page.js +1 -42
  74. package/dist/src/app_admin/core/debug/page.js +1 -45
  75. package/dist/src/app_admin/core/page.js +1 -5
  76. package/dist/src/app_admin/core/test/page.js +1 -5
  77. package/dist/src/app_admin/core/users/page.js +1 -38
  78. package/dist/src/components/avatar.js +1 -14
  79. package/dist/src/components/confirm-action/confirm-action-alert-dialog.js +1 -42
  80. package/dist/src/components/confirm-action/content.js +1 -31
  81. package/dist/src/components/date-format.js +1 -41
  82. package/dist/src/components/form/auto-form.js +1 -103
  83. package/dist/src/components/form/common/desc.js +1 -9
  84. package/dist/src/components/form/common/label.js +1 -18
  85. package/dist/src/components/form/fields/checkbox.js +1 -37
  86. package/dist/src/components/form/fields/combobox-async.js +1 -123
  87. package/dist/src/components/form/fields/combobox.js +1 -87
  88. package/dist/src/components/form/fields/input.js +1 -39
  89. package/dist/src/components/form/fields/radio-group.js +1 -50
  90. package/dist/src/components/form/fields/select.js +1 -58
  91. package/dist/src/components/form/fields/switch.js +1 -36
  92. package/dist/src/components/form/fields/textarea.js +1 -36
  93. package/dist/src/components/i18n-provider.js +1 -43
  94. package/dist/src/components/logo-vitnode.js +1 -119
  95. package/dist/src/components/switchers/langs/language-switcher.js +1 -47
  96. package/dist/src/components/switchers/themes/theme-switcher.js +1 -28
  97. package/dist/src/components/table/content.js +1 -81
  98. package/dist/src/components/table/data-table.js +1 -68
  99. package/dist/src/components/table/order-table-head.js +1 -50
  100. package/dist/src/components/table/pagination.js +1 -122
  101. package/dist/src/components/tiptap/extension.js +1 -33
  102. package/dist/src/components/tiptap/toolbar/actions/alignment-action.js +1 -91
  103. package/dist/src/components/tiptap/toolbar/actions/bold-action.js +1 -39
  104. package/dist/src/components/tiptap/toolbar/actions/headings-action.js +1 -93
  105. package/dist/src/components/tiptap/toolbar/actions/italic-action.js +1 -38
  106. package/dist/src/components/tiptap/toolbar/actions/list-action.js +1 -61
  107. package/dist/src/components/tiptap/toolbar/actions/text-format-more/text-format-more.js +1 -59
  108. package/dist/src/components/tiptap/toolbar/actions/underline-action.js +1 -38
  109. package/dist/src/components/tiptap/toolbar/actions/undo-redo-actions.js +1 -63
  110. package/dist/src/components/tiptap/toolbar/actions/utils/tooltip-shortcut.js +1 -11
  111. package/dist/src/components/tiptap/toolbar/tiptap-toolbar.js +1 -55
  112. package/dist/src/components/tiptap/toolbar/use-toolbar-editor.js +1 -5
  113. package/dist/src/components/ui/accordion.js +1 -46
  114. package/dist/src/components/ui/alert-dialog.js +1 -123
  115. package/dist/src/components/ui/alert.js +1 -39
  116. package/dist/src/components/ui/badge.js +1 -28
  117. package/dist/src/components/ui/button-client.js +1 -57
  118. package/dist/src/components/ui/button.js +1 -32
  119. package/dist/src/components/ui/card.js +1 -52
  120. package/dist/src/components/ui/checkbox.js +1 -20
  121. package/dist/src/components/ui/collapsible.js +1 -22
  122. package/dist/src/components/ui/command.js +1 -98
  123. package/dist/src/components/ui/context-menu.js +1 -140
  124. package/dist/src/components/ui/dialog.js +1 -189
  125. package/dist/src/components/ui/drawer.js +1 -83
  126. package/dist/src/components/ui/dropdown-menu.js +1 -141
  127. package/dist/src/components/ui/editor-content.js +1 -10
  128. package/dist/src/components/ui/editor.js +1 -35
  129. package/dist/src/components/ui/form.js +1 -148
  130. package/dist/src/components/ui/header-content.js +1 -30
  131. package/dist/src/components/ui/hover-card.js +1 -29
  132. package/dist/src/components/ui/input-otp.js +1 -48
  133. package/dist/src/components/ui/input.js +1 -11
  134. package/dist/src/components/ui/label.js +1 -12
  135. package/dist/src/components/ui/loader.js +1 -16
  136. package/dist/src/components/ui/menubar.js +1 -151
  137. package/dist/src/components/ui/navigation-menu.js +1 -82
  138. package/dist/src/components/ui/popover.js +1 -35
  139. package/dist/src/components/ui/progress.js +1 -19
  140. package/dist/src/components/ui/radio-group.js +1 -27
  141. package/dist/src/components/ui/scroll-area.js +1 -33
  142. package/dist/src/components/ui/select.js +1 -113
  143. package/dist/src/components/ui/separator.js +1 -14
  144. package/dist/src/components/ui/sheet.js +1 -92
  145. package/dist/src/components/ui/sidebar.js +1 -433
  146. package/dist/src/components/ui/skeleton.js +1 -10
  147. package/dist/src/components/ui/slider.js +1 -50
  148. package/dist/src/components/ui/sonner.js +1 -26
  149. package/dist/src/components/ui/switch.js +1 -16
  150. package/dist/src/components/ui/table.js +1 -63
  151. package/dist/src/components/ui/tabs.js +1 -33
  152. package/dist/src/components/ui/textarea.js +1 -10
  153. package/dist/src/components/ui/toggle-group.js +1 -45
  154. package/dist/src/components/ui/toggle.js +1 -34
  155. package/dist/src/components/ui/tooltip.js +1 -57
  156. package/dist/src/config.js +1 -4
  157. package/dist/src/database/admins.js +1 -74
  158. package/dist/src/database/cron.js +1 -22
  159. package/dist/src/database/languages.js +1 -52
  160. package/dist/src/database/logs.js +1 -34
  161. package/dist/src/database/moderators.js +1 -37
  162. package/dist/src/database/roles.js +1 -13
  163. package/dist/src/database/sessions.js +1 -60
  164. package/dist/src/database/users.js +1 -145
  165. package/dist/src/drizzle.config.js +1 -67
  166. package/dist/src/emails/default-template.js +1 -99
  167. package/dist/src/emails/reset-password.js +1 -132
  168. package/dist/src/emails/ui/button.js +1 -36
  169. package/dist/src/emails/ui/card.js +1 -39
  170. package/dist/src/hooks/use-before-unload.js +1 -30
  171. package/dist/src/hooks/use-captcha.js +1 -122
  172. package/dist/src/hooks/use-mobile.js +1 -16
  173. package/dist/src/lib/api/get-middleware-api.js +1 -13
  174. package/dist/src/lib/api/get-next-cron-run-date.js +1 -14
  175. package/dist/src/lib/api/get-next-cron-run-date.test.js +1 -55
  176. package/dist/src/lib/api/get-session-admin-api.js +1 -19
  177. package/dist/src/lib/api/get-session-api.js +1 -14
  178. package/dist/src/lib/api/should-cron-job-run.js +1 -16
  179. package/dist/src/lib/api/should-cron-job-run.test.js +1 -213
  180. package/dist/src/lib/api/validate-cron-schedule.d.ts +2 -0
  181. package/dist/src/lib/api/validate-cron-schedule.d.ts.map +1 -0
  182. package/dist/src/lib/api/validate-cron-schedule.js +1 -0
  183. package/dist/src/lib/api/validate-cron-schedule.test.d.ts +2 -0
  184. package/dist/src/lib/api/validate-cron-schedule.test.d.ts.map +1 -0
  185. package/dist/src/lib/api/validate-cron-schedule.test.js +1 -0
  186. package/dist/src/lib/colors.js +1 -140
  187. package/dist/src/lib/colors.test.js +1 -173
  188. package/dist/src/lib/config.js +1 -14
  189. package/dist/src/lib/ctrl-or-command-character.js +1 -5
  190. package/dist/src/lib/fetcher/cookie-from-string-to-object.js +1 -12
  191. package/dist/src/lib/fetcher/cookie-from-string-to-object.test.js +1 -78
  192. package/dist/src/lib/fetcher/core.js +3 -48
  193. package/dist/src/lib/fetcher/helpers-server.js +1 -18
  194. package/dist/src/lib/fetcher/helpers.js +1 -16
  195. package/dist/src/lib/fetcher/helpers.test.js +1 -37
  196. package/dist/src/lib/fetcher/types.js +1 -1
  197. package/dist/src/lib/fetcher-client.js +1 -17
  198. package/dist/src/lib/fetcher.js +1 -33
  199. package/dist/src/lib/helpers/auto-form.js +1 -98
  200. package/dist/src/lib/helpers/auto-form.test.js +1 -336
  201. package/dist/src/lib/navigation.d.ts +15 -13
  202. package/dist/src/lib/navigation.d.ts.map +1 -1
  203. package/dist/src/lib/navigation.js +1 -11
  204. package/dist/src/lib/plugin.js +1 -3
  205. package/dist/src/lib/special-characters.js +1 -4
  206. package/dist/src/lib/special-characters.test.js +1 -56
  207. package/dist/src/lib/utils.js +1 -5
  208. package/dist/src/locales/en.json +308 -0
  209. package/dist/src/tests/setup.js +1 -6
  210. package/dist/src/views/admin/layouts/admin-layout.js +1 -73
  211. package/dist/src/views/admin/layouts/sidebar/nav/item.js +1 -98
  212. package/dist/src/views/admin/layouts/sidebar/nav/nav.js +1 -60
  213. package/dist/src/views/admin/layouts/sidebar/sidebar.js +1 -28
  214. package/dist/src/views/admin/layouts/sidebar/sign-out.js +1 -14
  215. package/dist/src/views/admin/layouts/user-bar/client.js +1 -69
  216. package/dist/src/views/admin/layouts/user-bar/user-bar.js +1 -32
  217. package/dist/src/views/admin/sign-in/sign-in-admin-view.js +1 -27
  218. package/dist/src/views/admin/views/core/advanced/cron/cron-table-view.js +1 -97
  219. package/dist/src/views/admin/views/core/advanced/cron/run-action/mutation-api.js +1 -23
  220. package/dist/src/views/admin/views/core/advanced/cron/run-action/run-action.js +1 -38
  221. package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.js +1 -44
  222. package/dist/src/views/admin/views/core/debug/actions/clear-cache/clear-cache.js +1 -35
  223. package/dist/src/views/admin/views/core/debug/actions/clear-cache/mutation-api.js +1 -5
  224. package/dist/src/views/admin/views/core/debug/system-logs/actions/more/content.js +1 -281
  225. package/dist/src/views/admin/views/core/debug/system-logs/actions/more/more.js +1 -67
  226. package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-status.js +1 -14
  227. package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-type-log.js +1 -30
  228. package/dist/src/views/admin/views/core/debug/system-logs/system-logs-view.js +1 -96
  229. package/dist/src/views/admin/views/core/test.js +1 -161
  230. package/dist/src/views/admin/views/core/users/users-admin-view.js +1 -89
  231. package/dist/src/views/auth/password-reset/change-password-form/form.js +1 -48
  232. package/dist/src/views/auth/password-reset/change-password-form/mutation-api.js +1 -22
  233. package/dist/src/views/auth/password-reset/change-password-form/use-form.js +1 -36
  234. package/dist/src/views/auth/password-reset/form/form.js +1 -104
  235. package/dist/src/views/auth/password-reset/form/mutation-api.js +1 -21
  236. package/dist/src/views/auth/password-reset/form/use-form.js +1 -33
  237. package/dist/src/views/auth/password-reset/password-reset-view.js +1 -37
  238. package/dist/src/views/auth/sign-in/form/form.js +1 -64
  239. package/dist/src/views/auth/sign-in/form/mutation-api.js +1 -33
  240. package/dist/src/views/auth/sign-in/form/use-form.d.ts.map +1 -1
  241. package/dist/src/views/auth/sign-in/form/use-form.js +1 -38
  242. package/dist/src/views/auth/sign-in/sign-in-view.js +1 -61
  243. package/dist/src/views/auth/sign-up/components/password-input.js +1 -96
  244. package/dist/src/views/auth/sign-up/email-confirmation-view.js +1 -55
  245. package/dist/src/views/auth/sign-up/form/form.js +1 -89
  246. package/dist/src/views/auth/sign-up/form/mutation-api.js +1 -30
  247. package/dist/src/views/auth/sign-up/form/use-form.js +1 -70
  248. package/dist/src/views/auth/sign-up/sign-up-view.js +1 -65
  249. package/dist/src/views/auth/sign-up/wrapper.js +1 -22
  250. package/dist/src/views/auth/sso/buttons/client.js +1 -22
  251. package/dist/src/views/auth/sso/buttons/mutation-api.js +1 -24
  252. package/dist/src/views/auth/sso/buttons/sso-buttons.js +1 -56
  253. package/dist/src/views/auth/sso/callback/callback-sso-view.js +1 -32
  254. package/dist/src/views/auth/sso/callback/client/client.js +1 -68
  255. package/dist/src/views/auth/sso/callback/client/mutation-api.js +1 -32
  256. package/dist/src/views/error/back-button.js +1 -14
  257. package/dist/src/views/error/error-view.js +1 -58
  258. package/dist/src/views/error/global-error-view.js +1 -50
  259. package/dist/src/views/layouts/provider.js +1 -44
  260. package/dist/src/views/layouts/root-layout.js +1 -25
  261. package/dist/src/views/layouts/theme/header/header.js +1 -38
  262. package/dist/src/views/layouts/theme/header/user/auth/auth.js +1 -33
  263. package/dist/src/views/layouts/theme/header/user/auth/client.js +1 -47
  264. package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.js +1 -27
  265. package/dist/src/views/layouts/theme/header/user/user.js +1 -32
  266. package/dist/src/views/layouts/theme/layout.js +1 -16
  267. package/dist/src/vitnode.config.d.ts.map +1 -1
  268. package/dist/src/vitnode.config.js +1 -42
  269. package/dist/tsconfig.tsbuildinfo +1 -1
  270. package/dist/tsup.config.js +18 -0
  271. package/dist/vitest.config.d.ts.map +1 -1
  272. package/dist/vitest.config.js +49 -0
  273. package/eslint.config.mjs +2 -0
  274. package/package.json +40 -44
  275. package/dist/src/api/adapters/cron/node-cron.adapter.d.ts +0 -3
  276. package/dist/src/api/adapters/cron/node-cron.adapter.d.ts.map +0 -1
  277. package/dist/src/api/adapters/cron/node-cron.adapter.js +0 -11
  278. package/dist/src/api/adapters/email/nodemailer.d.ts +0 -10
  279. package/dist/src/api/adapters/email/nodemailer.d.ts.map +0 -1
  280. package/dist/src/api/adapters/email/nodemailer.js +0 -30
  281. package/dist/src/api/adapters/email/resend.d.ts +0 -6
  282. package/dist/src/api/adapters/email/resend.d.ts.map +0 -1
  283. package/dist/src/api/adapters/email/resend.js +0 -21
@@ -1,64 +1 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { AlertCircle } from "lucide-react";
4
- import { useTranslations } from "next-intl";
5
- import { AutoForm } from "../../../../components/form/auto-form.js";
6
- import { AutoFormInput } from "../../../../components/form/fields/input.js";
7
- import { Alert, AlertDescription, AlertTitle } from "../../../../components/ui/alert.js";
8
- import { Link } from "../../../../lib/navigation.js";
9
- import { useFormSignIn } from "./use-form.js";
10
- export const FormSignIn = ({ isAdmin, isEmail })=>{
11
- const t = useTranslations("core.auth.sign_in");
12
- const { onSubmit, error, formSchema } = useFormSignIn({
13
- isAdmin
14
- });
15
- return /*#__PURE__*/ _jsxs("div", {
16
- className: "space-y-4",
17
- children: [
18
- error && /*#__PURE__*/ _jsxs(Alert, {
19
- variant: "destructive",
20
- children: [
21
- /*#__PURE__*/ _jsx(AlertCircle, {
22
- className: "size-4"
23
- }),
24
- /*#__PURE__*/ _jsx(AlertTitle, {
25
- children: t(`errors.${error}.title`)
26
- }),
27
- /*#__PURE__*/ _jsx(AlertDescription, {
28
- children: t(`errors.${error}.desc`)
29
- })
30
- ]
31
- }),
32
- /*#__PURE__*/ _jsx(AutoForm, {
33
- fields: [
34
- {
35
- id: "email",
36
- component: (props)=>/*#__PURE__*/ _jsx(AutoFormInput, {
37
- label: t("email.label"),
38
- ...props
39
- })
40
- },
41
- {
42
- id: "password",
43
- component: (props)=>/*#__PURE__*/ _jsx(AutoFormInput, {
44
- label: t("password.label"),
45
- labelRight: isEmail ? /*#__PURE__*/ _jsx(Link, {
46
- className: "text-primary hover:underline",
47
- href: "/login/reset-password",
48
- children: t("password.reset")
49
- }) : undefined,
50
- type: "password",
51
- ...props
52
- })
53
- }
54
- ],
55
- formSchema: formSchema,
56
- onSubmit: onSubmit,
57
- submitButtonProps: {
58
- className: "w-full",
59
- children: t("submit")
60
- }
61
- })
62
- ]
63
- });
64
- };
1
+ "use client";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{AlertCircle}from"lucide-react";import{useTranslations}from"next-intl";import{AutoForm}from"../../../../components/form/auto-form.js";import{AutoFormInput}from"../../../../components/form/fields/input.js";import{Alert,AlertDescription,AlertTitle}from"../../../../components/ui/alert.js";import{Link}from"../../../../lib/navigation.js";import{useFormSignIn}from"./use-form.js";export const FormSignIn=({isAdmin,isEmail})=>{const t=useTranslations("core.auth.sign_in");const{onSubmit,error,formSchema}=useFormSignIn({isAdmin});return _jsxs("div",{className:"space-y-4",children:[error&&_jsxs(Alert,{variant:"destructive",children:[_jsx(AlertCircle,{className:"size-4"}),_jsx(AlertTitle,{children:t(`errors.${error}.title`)}),_jsx(AlertDescription,{children:t(`errors.${error}.desc`)})]}),_jsx(AutoForm,{fields:[{id:"email",component:props=>_jsx(AutoFormInput,{label:t("email.label"),...props})},{id:"password",component:props=>_jsx(AutoFormInput,{label:t("password.label"),labelRight:isEmail?_jsx(Link,{className:"text-primary hover:underline",href:"/login/reset-password",children:t("password.reset")}):undefined,type:"password",...props})}],formSchema:formSchema,onSubmit:onSubmit,submitButtonProps:{className:"w-full",children:t("submit")}})]})};
@@ -1,33 +1 @@
1
- "use server";
2
- import { revalidatePath } from "next/cache";
3
- import { usersModule } from "../../../../api/modules/users/users.module.js";
4
- import { fetcher } from "../../../../lib/fetcher.js";
5
- import { redirect } from "../../../../lib/navigation.js";
6
- export const mutationApi = async (input)=>{
7
- const res = await fetcher(usersModule, {
8
- path: "/sign_in",
9
- method: "post",
10
- module: "users",
11
- allowSaveCookies: true,
12
- args: {
13
- body: input
14
- }
15
- });
16
- if (res.status === 403) {
17
- return {
18
- message: "access_denied"
19
- };
20
- }
21
- if (res.status !== 201) {
22
- return {
23
- message: "Internal Server Error"
24
- };
25
- }
26
- if (input.isAdmin) {
27
- revalidatePath("/[locale]/admin", "layout");
28
- await redirect("/admin/core");
29
- return;
30
- }
31
- revalidatePath("/[locale]/(main)", "layout");
32
- await redirect("/");
33
- };
1
+ "use server";import{revalidatePath}from"next/cache";import{usersModule}from"../../../../api/modules/users/users.module.js";import{fetcher}from"../../../../lib/fetcher.js";import{redirect}from"../../../../lib/navigation.js";export const mutationApi=async input=>{const res=await fetcher(usersModule,{path:"/sign_in",method:"post",module:"users",allowSaveCookies:true,args:{body:input}});if(res.status===403){return{message:"access_denied"}}if(res.status!==201){return{message:"Internal Server Error"}}if(input.isAdmin){revalidatePath("/[locale]/admin","layout");await redirect("/admin/core");return}revalidatePath("/[locale]/(main)","layout");await redirect("/")};
@@ -1 +1 @@
1
- {"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["../../../../../../src/views/auth/sign-in/form/use-form.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAIpE,eAAO,MAAM,aAAa,GAAI,aAAa;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE;;;;;;;;;;CA6B/D,CAAC"}
1
+ {"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["../../../../../../src/views/auth/sign-in/form/use-form.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAIpE,eAAO,MAAM,aAAa,GAAI,aAAqB;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE;;;;;;;;;;CA6BvE,CAAC"}
@@ -1,38 +1 @@
1
- import { useTranslations } from "next-intl";
2
- import React from "react";
3
- import { toast } from "sonner";
4
- import { z } from "zod";
5
- import { mutationApi } from "./mutation-api.js";
6
- export const useFormSignIn = ({ isAdmin })=>{
7
- const [error, setError] = React.useState("");
8
- const t = useTranslations("core.auth.sign_in");
9
- const tErrors = useTranslations("core.global.errors");
10
- const formSchema = z.object({
11
- email: z.email({
12
- message: t("email.invalid")
13
- }).default(""),
14
- password: z.string().min(1, {
15
- message: t("password.required")
16
- }).default("")
17
- });
18
- const onSubmit = async (values)=>{
19
- setError("");
20
- const mutation = await mutationApi({
21
- ...values,
22
- isAdmin
23
- });
24
- if (!mutation?.message) return;
25
- if (mutation?.message !== "Internal Server Error") {
26
- setError(mutation.message);
27
- return;
28
- }
29
- toast.error(tErrors("title"), {
30
- description: tErrors("internal_server_error")
31
- });
32
- };
33
- return {
34
- onSubmit,
35
- error,
36
- formSchema
37
- };
38
- };
1
+ import{useTranslations}from"next-intl";import React from"react";import{toast}from"sonner";import{z}from"zod";import{mutationApi}from"./mutation-api.js";export const useFormSignIn=({isAdmin=false})=>{const[error,setError]=React.useState("");const t=useTranslations("core.auth.sign_in");const tErrors=useTranslations("core.global.errors");const formSchema=z.object({email:z.email({message:t("email.invalid")}).default(""),password:z.string().min(1,{message:t("password.required")}).default("")});const onSubmit=async values=>{setError("");const mutation=await mutationApi({...values,isAdmin});if(!mutation?.message)return;if(mutation?.message!=="Internal Server Error"){setError(mutation.message);return}toast.error(tErrors("title"),{description:tErrors("internal_server_error")})};return{onSubmit,error,formSchema}};
@@ -1,61 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { getTranslations } from "next-intl/server";
3
- import React from "react";
4
- import { Card, CardDescription } from "../../../components/ui/card.js";
5
- import { getMiddlewareApi } from "../../../lib/api/get-middleware-api.js";
6
- import { Link } from "../../../lib/navigation.js";
7
- import { I18nProvider } from "../../../components/i18n-provider.js";
8
- import { SSOButtons, SSOButtonsSkeleton } from "../sso/buttons/sso-buttons.js";
9
- import { FormSignIn } from "./form/form.js";
10
- export const SignInView = async ()=>{
11
- const [t, tGlobal, { isEmail }] = await Promise.all([
12
- getTranslations("core.auth.sign_in"),
13
- getTranslations("core.global"),
14
- getMiddlewareApi()
15
- ]);
16
- return /*#__PURE__*/ _jsx(I18nProvider, {
17
- namespaces: "core.auth.sign_in",
18
- children: /*#__PURE__*/ _jsx("div", {
19
- className: "mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col justify-center px-4 py-16",
20
- children: /*#__PURE__*/ _jsxs(Card, {
21
- className: "bg-muted gap-0 p-0",
22
- children: [
23
- /*#__PURE__*/ _jsxs("div", {
24
- className: "bg-card rounded-xl p-6",
25
- children: [
26
- /*#__PURE__*/ _jsxs("div", {
27
- className: "mb-10 space-y-2 text-center",
28
- children: [
29
- /*#__PURE__*/ _jsx("h1", {
30
- className: "text-2xl font-semibold leading-none tracking-tight",
31
- children: tGlobal("login")
32
- }),
33
- /*#__PURE__*/ _jsx(CardDescription, {
34
- children: t("desc")
35
- })
36
- ]
37
- }),
38
- /*#__PURE__*/ _jsx(FormSignIn, {
39
- isEmail: isEmail
40
- }),
41
- /*#__PURE__*/ _jsx(React.Suspense, {
42
- fallback: /*#__PURE__*/ _jsx(SSOButtonsSkeleton, {}),
43
- children: /*#__PURE__*/ _jsx(SSOButtons, {})
44
- })
45
- ]
46
- }),
47
- /*#__PURE__*/ _jsx("div", {
48
- className: "text-accent-foreground p-6 text-center text-sm",
49
- children: t.rich("do_not_have_account", {
50
- link: (text)=>/*#__PURE__*/ _jsx(Link, {
51
- className: "text-primary font-semibold",
52
- href: "/register",
53
- children: text
54
- })
55
- })
56
- })
57
- ]
58
- })
59
- })
60
- });
61
- };
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{getTranslations}from"next-intl/server";import React from"react";import{Card,CardDescription}from"../../../components/ui/card.js";import{getMiddlewareApi}from"../../../lib/api/get-middleware-api.js";import{Link}from"../../../lib/navigation.js";import{I18nProvider}from"../../../components/i18n-provider.js";import{SSOButtons,SSOButtonsSkeleton}from"../sso/buttons/sso-buttons.js";import{FormSignIn}from"./form/form.js";export const SignInView=async()=>{const[t,tGlobal,{isEmail}]=await Promise.all([getTranslations("core.auth.sign_in"),getTranslations("core.global"),getMiddlewareApi()]);return _jsx(I18nProvider,{namespaces:"core.auth.sign_in",children:_jsx("div",{className:"mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col justify-center px-4 py-16",children:_jsxs(Card,{className:"bg-muted gap-0 p-0",children:[_jsxs("div",{className:"bg-card rounded-xl p-6",children:[_jsxs("div",{className:"mb-10 space-y-2 text-center",children:[_jsx("h1",{className:"text-2xl leading-none font-semibold tracking-tight",children:tGlobal("login")}),_jsx(CardDescription,{children:t("desc")})]}),_jsx(FormSignIn,{isEmail:isEmail}),_jsx(React.Suspense,{fallback:_jsx(SSOButtonsSkeleton,{}),children:_jsx(SSOButtons,{})})]}),_jsx("div",{className:"text-accent-foreground p-6 text-center text-sm",children:t.rich("do_not_have_account",{link:text=>_jsx(Link,{className:"text-primary font-semibold",href:"/register",children:text})})})]})})})};
@@ -1,96 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { CheckIcon, XIcon } from "lucide-react";
3
- import { useTranslations } from "next-intl";
4
- import React from "react";
5
- import { AutoFormLabel } from "../../../../components/form/common/label.js";
6
- import { FormControl, FormItem, FormMessage } from "../../../../components/ui/form.js";
7
- import { Input } from "../../../../components/ui/input.js";
8
- import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../../../../components/ui/tooltip.js";
9
- export const PasswordInput = ({ label, // eslint-disable-next-line @typescript-eslint/no-unused-vars
10
- description: _, field, otherProps: { maxLength, minLength, pattern }, ...props })=>{
11
- const t = useTranslations("core.auth.sign_up");
12
- const [openTooltip, setOpenTooltip] = React.useState(false);
13
- const value = field.value ?? "";
14
- const regexArray = [
15
- {
16
- regex: /^.{8,}$/.test(value),
17
- id: "min_length"
18
- },
19
- {
20
- regex: /[A-Z]/.test(value),
21
- id: "uppercase"
22
- },
23
- {
24
- regex: /\d/.test(value),
25
- id: "number"
26
- },
27
- {
28
- regex: /\W|_/.test(value),
29
- id: "special_char"
30
- }
31
- ];
32
- return /*#__PURE__*/ _jsxs(FormItem, {
33
- children: [
34
- /*#__PURE__*/ _jsx(AutoFormLabel, {
35
- children: label
36
- }),
37
- /*#__PURE__*/ _jsx(TooltipProvider, {
38
- delayDuration: 0,
39
- children: /*#__PURE__*/ _jsxs(Tooltip, {
40
- open: openTooltip,
41
- children: [
42
- /*#__PURE__*/ _jsx(TooltipTrigger, {
43
- asChild: true,
44
- children: /*#__PURE__*/ _jsx(FormControl, {
45
- children: /*#__PURE__*/ _jsx(Input, {
46
- type: "password",
47
- ...field,
48
- maxLength: maxLength ?? props.maxLength,
49
- minLength: minLength ?? props.minLength,
50
- onBlur: (e)=>{
51
- setOpenTooltip(false);
52
- field.onBlur();
53
- props.onBlur?.(e);
54
- },
55
- onChange: (e)=>{
56
- setOpenTooltip(true);
57
- field.onChange(e);
58
- props.onChange?.(e);
59
- },
60
- pattern: pattern ?? props.pattern,
61
- value: field.value ?? "",
62
- ...props
63
- })
64
- })
65
- }),
66
- /*#__PURE__*/ _jsxs(TooltipContent, {
67
- className: "flex flex-col gap-2 text-sm",
68
- sideOffset: 8,
69
- children: [
70
- /*#__PURE__*/ _jsx("span", {
71
- className: "text-based font-semibold",
72
- children: t("password.requirements.label")
73
- }),
74
- /*#__PURE__*/ _jsx("ul", {
75
- className: "space-y-1",
76
- children: regexArray.map(({ regex, id })=>/*#__PURE__*/ _jsxs("li", {
77
- className: "flex items-center gap-1",
78
- children: [
79
- regex ? /*#__PURE__*/ _jsx(CheckIcon, {
80
- className: "size-4"
81
- }) : /*#__PURE__*/ _jsx(XIcon, {
82
- className: "size-4"
83
- }),
84
- t(`password.requirements.${id}`)
85
- ]
86
- }, id))
87
- })
88
- ]
89
- })
90
- ]
91
- })
92
- }),
93
- /*#__PURE__*/ _jsx(FormMessage, {})
94
- ]
95
- });
96
- };
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{CheckIcon,XIcon}from"lucide-react";import{useTranslations}from"next-intl";import React from"react";import{AutoFormLabel}from"../../../../components/form/common/label.js";import{FormControl,FormItem,FormMessage}from"../../../../components/ui/form.js";import{Input}from"../../../../components/ui/input.js";import{Tooltip,TooltipContent,TooltipProvider,TooltipTrigger}from"../../../../components/ui/tooltip.js";export const PasswordInput=({label,description:_,field,otherProps:{maxLength,minLength,pattern},...props})=>{const t=useTranslations("core.auth.sign_up");const[openTooltip,setOpenTooltip]=React.useState(false);const value=field.value??"";const regexArray=[{regex:/^.{8,}$/.test(value),id:"min_length"},{regex:/[A-Z]/.test(value),id:"uppercase"},{regex:/\d/.test(value),id:"number"},{regex:/\W|_/.test(value),id:"special_char"}];return _jsxs(FormItem,{children:[_jsx(AutoFormLabel,{children:label}),_jsx(TooltipProvider,{delayDuration:0,children:_jsxs(Tooltip,{open:openTooltip,children:[_jsx(TooltipTrigger,{asChild:true,children:_jsx(FormControl,{children:_jsx(Input,{type:"password",...field,maxLength:maxLength??props.maxLength,minLength:minLength??props.minLength,onBlur:e=>{setOpenTooltip(false);field.onBlur();props.onBlur?.(e)},onChange:e=>{setOpenTooltip(true);field.onChange(e);props.onChange?.(e)},pattern:pattern??props.pattern,value:field.value??"",...props})})}),_jsxs(TooltipContent,{className:"flex flex-col gap-2 text-sm",sideOffset:8,children:[_jsx("span",{className:"text-based font-semibold",children:t("password.requirements.label")}),_jsx("ul",{className:"space-y-1",children:regexArray.map(({regex,id})=>_jsxs("li",{className:"flex items-center gap-1",children:[regex?_jsx(CheckIcon,{className:"size-4"}):_jsx(XIcon,{className:"size-4"}),t(`password.requirements.${id}`)]},id))})]})]})}),_jsx(FormMessage,{})]})};
@@ -1,55 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Mail, MailboxIcon } from "lucide-react";
3
- import { useTranslations } from "next-intl";
4
- import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "../../../components/ui/card.js";
5
- export const EmailConfirmationView = ({ email })=>{
6
- const t = useTranslations("core.auth.sign_up.email_confirmation");
7
- return /*#__PURE__*/ _jsxs(Card, {
8
- className: "w-full max-w-md p-6",
9
- children: [
10
- /*#__PURE__*/ _jsxs(CardHeader, {
11
- className: "text-center",
12
- children: [
13
- /*#__PURE__*/ _jsx("div", {
14
- className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-green-100 dark:bg-green-900",
15
- children: /*#__PURE__*/ _jsx(MailboxIcon, {
16
- className: "h-8 w-8 text-green-600 dark:text-green-400"
17
- })
18
- }),
19
- /*#__PURE__*/ _jsx(CardTitle, {
20
- className: "text-2xl font-bold",
21
- children: t("title")
22
- }),
23
- /*#__PURE__*/ _jsx(CardDescription, {
24
- className: "text-base",
25
- children: t("desc")
26
- })
27
- ]
28
- }),
29
- /*#__PURE__*/ _jsxs(CardContent, {
30
- className: "space-y-6",
31
- children: [
32
- /*#__PURE__*/ _jsx("div", {
33
- className: "bg-muted rounded-lg p-4",
34
- children: /*#__PURE__*/ _jsxs("div", {
35
- className: "flex items-center gap-3",
36
- children: [
37
- /*#__PURE__*/ _jsx("span", {
38
- className: "text-sm font-medium",
39
- children: email
40
- }),
41
- /*#__PURE__*/ _jsx(Mail, {
42
- className: "text-muted-foreground ml-auto size-5"
43
- })
44
- ]
45
- })
46
- }),
47
- /*#__PURE__*/ _jsx("p", {
48
- className: "text-muted-foreground text-center text-sm",
49
- children: t("check_spam")
50
- })
51
- ]
52
- })
53
- ]
54
- });
55
- };
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Mail,MailboxIcon}from"lucide-react";import{useTranslations}from"next-intl";import{Card,CardContent,CardDescription,CardHeader,CardTitle}from"../../../components/ui/card.js";export const EmailConfirmationView=({email})=>{const t=useTranslations("core.auth.sign_up.email_confirmation");return _jsxs(Card,{className:"w-full max-w-md p-6",children:[_jsxs(CardHeader,{className:"text-center",children:[_jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-green-100 dark:bg-green-900",children:_jsx(MailboxIcon,{className:"h-8 w-8 text-green-600 dark:text-green-400"})}),_jsx(CardTitle,{className:"text-2xl font-bold",children:t("title")}),_jsx(CardDescription,{className:"text-base",children:t("desc")})]}),_jsxs(CardContent,{className:"space-y-6",children:[_jsx("div",{className:"bg-muted rounded-lg p-4",children:_jsxs("div",{className:"flex items-center gap-3",children:[_jsx("span",{className:"text-sm font-medium",children:email}),_jsx(Mail,{className:"text-muted-foreground ml-auto size-5"})]})}),_jsx("p",{className:"text-muted-foreground text-center text-sm",children:t("check_spam")})]})]})};
@@ -1,89 +1 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useTranslations } from "next-intl";
4
- import { AutoForm } from "../../../../components/form/auto-form.js";
5
- import { AutoFormCheckbox } from "../../../../components/form/fields/checkbox.js";
6
- import { AutoFormInput } from "../../../../components/form/fields/input.js";
7
- import { Link } from "../../../../lib/navigation.js";
8
- import { removeSpecialCharacters } from "../../../../lib/special-characters.js";
9
- import { PasswordInput } from "../components/password-input.js";
10
- import { useFormSignUp } from "./use-form.js";
11
- export const FormSignUp = ({ isEmail, captcha })=>{
12
- const t = useTranslations("core.auth.sign_up");
13
- const { onSubmit, formSchema } = useFormSignUp();
14
- return /*#__PURE__*/ _jsx(AutoForm, {
15
- captcha: captcha,
16
- fields: [
17
- {
18
- id: "name",
19
- component: ({ field, ...props })=>{
20
- const value = field.value ?? "";
21
- return /*#__PURE__*/ _jsxs("div", {
22
- className: "space-y-2",
23
- children: [
24
- /*#__PURE__*/ _jsx(AutoFormInput, {
25
- field: field,
26
- label: t("username.label"),
27
- ...props
28
- }),
29
- value.length >= 3 && /*#__PURE__*/ _jsx("div", {
30
- className: "text-muted-foreground text-sm",
31
- children: t.rich("username.your_user_code", {
32
- code: ()=>/*#__PURE__*/ _jsx("span", {
33
- className: "text-foreground",
34
- children: removeSpecialCharacters(value)
35
- })
36
- })
37
- })
38
- ]
39
- });
40
- }
41
- },
42
- {
43
- id: "email",
44
- component: (props)=>/*#__PURE__*/ _jsx(AutoFormInput, {
45
- label: t("email.label"),
46
- ...props
47
- })
48
- },
49
- {
50
- id: "password",
51
- component: (props)=>/*#__PURE__*/ _jsx(PasswordInput, {
52
- label: t("password.label"),
53
- ...props
54
- })
55
- },
56
- {
57
- id: "terms",
58
- component: (props)=>/*#__PURE__*/ _jsx(AutoFormCheckbox, {
59
- ...props,
60
- description: t.rich("terms.desc", {
61
- link: (text)=>/*#__PURE__*/ _jsx(Link, {
62
- className: "text-primary",
63
- href: "/terms",
64
- children: text
65
- })
66
- }),
67
- label: t("terms.label")
68
- })
69
- },
70
- ...isEmail ? [
71
- {
72
- id: "newsletter",
73
- component: (props)=>/*#__PURE__*/ _jsx(AutoFormCheckbox, {
74
- ...props,
75
- description: t("newsletter.desc"),
76
- label: t("newsletter.label")
77
- })
78
- }
79
- ] : []
80
- ],
81
- formSchema: formSchema,
82
- mode: "all",
83
- onSubmit: onSubmit,
84
- submitButtonProps: {
85
- className: "w-full",
86
- children: t("submit")
87
- }
88
- });
89
- };
1
+ "use client";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useTranslations}from"next-intl";import{AutoForm}from"../../../../components/form/auto-form.js";import{AutoFormCheckbox}from"../../../../components/form/fields/checkbox.js";import{AutoFormInput}from"../../../../components/form/fields/input.js";import{Link}from"../../../../lib/navigation.js";import{removeSpecialCharacters}from"../../../../lib/special-characters.js";import{PasswordInput}from"../components/password-input.js";import{useFormSignUp}from"./use-form.js";export const FormSignUp=({isEmail,captcha})=>{const t=useTranslations("core.auth.sign_up");const{onSubmit,formSchema}=useFormSignUp();return _jsx(AutoForm,{captcha:captcha,fields:[{id:"name",component:({field,...props})=>{const value=field.value??"";return _jsxs("div",{className:"space-y-2",children:[_jsx(AutoFormInput,{field:field,label:t("username.label"),...props}),value.length>=3&&_jsx("div",{className:"text-muted-foreground text-sm",children:t.rich("username.your_user_code",{code:()=>_jsx("span",{className:"text-foreground",children:removeSpecialCharacters(value)})})})]})}},{id:"email",component:props=>_jsx(AutoFormInput,{label:t("email.label"),...props})},{id:"password",component:props=>_jsx(PasswordInput,{label:t("password.label"),...props})},{id:"terms",component:props=>_jsx(AutoFormCheckbox,{...props,description:t.rich("terms.desc",{link:text=>_jsx(Link,{className:"text-primary",href:"/terms",children:text})}),label:t("terms.label")})},...isEmail?[{id:"newsletter",component:props=>_jsx(AutoFormCheckbox,{...props,description:t("newsletter.desc"),label:t("newsletter.label")})}]:[]],formSchema:formSchema,mode:"all",onSubmit:onSubmit,submitButtonProps:{className:"w-full",children:t("submit")}})};
@@ -1,30 +1 @@
1
- "use server";
2
- import { revalidatePath } from "next/cache";
3
- import { usersModule } from "../../../../api/modules/users/users.module.js";
4
- import { fetcher } from "../../../../lib/fetcher.js";
5
- import { redirect } from "../../../../lib/navigation.js";
6
- export const mutationApi = async ({ captchaToken, ...input })=>{
7
- const res = await fetcher(usersModule, {
8
- path: "/sign_up",
9
- method: "post",
10
- module: "users",
11
- allowSaveCookies: true,
12
- captchaToken,
13
- args: {
14
- body: input
15
- }
16
- });
17
- if (res.status !== 201) {
18
- return {
19
- error: await res.text()
20
- };
21
- }
22
- const data = await res.json();
23
- if (data.emailVerified) {
24
- revalidatePath("/[locale]/(main)", "layout");
25
- await redirect("/");
26
- }
27
- return {
28
- data
29
- };
30
- };
1
+ "use server";import{revalidatePath}from"next/cache";import{usersModule}from"../../../../api/modules/users/users.module.js";import{fetcher}from"../../../../lib/fetcher.js";import{redirect}from"../../../../lib/navigation.js";export const mutationApi=async({captchaToken,...input})=>{const res=await fetcher(usersModule,{path:"/sign_up",method:"post",module:"users",allowSaveCookies:true,captchaToken,args:{body:input}});if(res.status!==201){return{error:await res.text()}}const data=await res.json();if(data.emailVerified){revalidatePath("/[locale]/(main)","layout");await redirect("/")}return{data}};
@@ -1,70 +1 @@
1
- import { useTranslations } from "next-intl";
2
- import { toast } from "sonner";
3
- import { z } from "zod";
4
- import { useWrapperSignUp } from "../wrapper.js";
5
- import { mutationApi } from "./mutation-api.js";
6
- export const usePasswordZodSchema = ()=>{
7
- const t = useTranslations("core.auth.sign_up");
8
- const tError = useTranslations("core.global.errors");
9
- const invalidPassword = t("password.invalid");
10
- return z.string({
11
- message: tError("field_required")
12
- }).regex(/^.{8,}$/, invalidPassword).regex(/[A-Z]/, invalidPassword).regex(/\d/, invalidPassword).regex(/\W|_/, invalidPassword).default("");
13
- };
14
- export const useFormSignUp = ()=>{
15
- const t = useTranslations("core.auth.sign_up");
16
- const tError = useTranslations("core.global.errors");
17
- const passwordSchema = usePasswordZodSchema();
18
- const formSchema = z.object({
19
- name: z.string({
20
- message: tError("field_required")
21
- }).min(3, t("username.min_length")).max(32, t("username.max_length")).default(""),
22
- // .refine(value => nameRegex.test(value), t('name.invalid'))
23
- email: z.email({
24
- message: t("email.invalid")
25
- }).default("test@test.com"),
26
- password: passwordSchema,
27
- terms: z.boolean().refine((value)=>value, t("terms.required")).default(false),
28
- newsletter: z.boolean().default(false).optional()
29
- });
30
- const { setSendingEmail } = useWrapperSignUp();
31
- const onSubmit = async (values, form, { captchaToken })=>{
32
- const mutation = await mutationApi({
33
- ...values,
34
- captchaToken
35
- });
36
- if (mutation.data) {
37
- if (!mutation.data.emailVerified) {
38
- setSendingEmail(mutation.data.email);
39
- }
40
- return;
41
- }
42
- const errorMessages = {
43
- "Email already exists": {
44
- field: "email",
45
- message: t("email.exists")
46
- },
47
- "Name already exists": {
48
- field: "name",
49
- message: t("username.exists")
50
- }
51
- };
52
- const errorConfig = errorMessages[mutation.error];
53
- if (errorConfig) {
54
- form.setError(errorConfig.field, {
55
- type: "manual",
56
- message: errorConfig.message
57
- }, {
58
- shouldFocus: true
59
- });
60
- return;
61
- }
62
- toast.error(tError("title"), {
63
- description: tError("internal_server_error")
64
- });
65
- };
66
- return {
67
- onSubmit,
68
- formSchema
69
- };
70
- };
1
+ import{useTranslations}from"next-intl";import{toast}from"sonner";import{z}from"zod";import{useWrapperSignUp}from"../wrapper.js";import{mutationApi}from"./mutation-api.js";export const usePasswordZodSchema=()=>{const t=useTranslations("core.auth.sign_up");const tError=useTranslations("core.global.errors");const invalidPassword=t("password.invalid");return z.string({message:tError("field_required")}).regex(/^.{8,}$/,invalidPassword).regex(/[A-Z]/,invalidPassword).regex(/\d/,invalidPassword).regex(/\W|_/,invalidPassword).default("")};export const useFormSignUp=()=>{const t=useTranslations("core.auth.sign_up");const tError=useTranslations("core.global.errors");const passwordSchema=usePasswordZodSchema();const formSchema=z.object({name:z.string({message:tError("field_required")}).min(3,t("username.min_length")).max(32,t("username.max_length")).default(""),email:z.email({message:t("email.invalid")}).default("test@test.com"),password:passwordSchema,terms:z.boolean().refine(value=>value,t("terms.required")).default(false),newsletter:z.boolean().default(false).optional()});const{setSendingEmail}=useWrapperSignUp();const onSubmit=async(values,form,{captchaToken})=>{const mutation=await mutationApi({...values,captchaToken});if(mutation.data){if(!mutation.data.emailVerified){setSendingEmail(mutation.data.email)}return}const errorMessages={"Email already exists":{field:"email",message:t("email.exists")},"Name already exists":{field:"name",message:t("username.exists")}};const errorConfig=errorMessages[mutation.error];if(errorConfig){form.setError(errorConfig.field,{type:"manual",message:errorConfig.message},{shouldFocus:true});return}toast.error(tError("title"),{description:tError("internal_server_error")})};return{onSubmit,formSchema}};
@@ -1,65 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { getTranslations } from "next-intl/server";
3
- import React from "react";
4
- import { Card, CardDescription } from "../../../components/ui/card.js";
5
- import { getMiddlewareApi } from "../../../lib/api/get-middleware-api.js";
6
- import { Link } from "../../../lib/navigation.js";
7
- import { I18nProvider } from "../../../components/i18n-provider.js";
8
- import { SSOButtons, SSOButtonsSkeleton } from "../sso/buttons/sso-buttons.js";
9
- import { FormSignUp } from "./form/form.js";
10
- import { WrapperSignUp } from "./wrapper.js";
11
- export const SignUpView = async ()=>{
12
- const [t, tGlobal, { isEmail, captcha }] = await Promise.all([
13
- getTranslations("core.auth.sign_up"),
14
- getTranslations("core.global"),
15
- getMiddlewareApi()
16
- ]);
17
- return /*#__PURE__*/ _jsx(I18nProvider, {
18
- namespaces: "core.auth.sign_up",
19
- children: /*#__PURE__*/ _jsx("div", {
20
- className: "mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col justify-center px-4 py-16",
21
- children: /*#__PURE__*/ _jsx(WrapperSignUp, {
22
- children: /*#__PURE__*/ _jsxs(Card, {
23
- className: "bg-muted gap-0 p-0",
24
- children: [
25
- /*#__PURE__*/ _jsxs("div", {
26
- className: "bg-card rounded-xl p-6",
27
- children: [
28
- /*#__PURE__*/ _jsxs("div", {
29
- className: "mb-10 space-y-2 text-center",
30
- children: [
31
- /*#__PURE__*/ _jsx("h1", {
32
- className: "text-2xl font-semibold leading-none tracking-tight",
33
- children: tGlobal("register")
34
- }),
35
- /*#__PURE__*/ _jsx(CardDescription, {
36
- children: t("desc")
37
- })
38
- ]
39
- }),
40
- /*#__PURE__*/ _jsx(FormSignUp, {
41
- captcha: captcha,
42
- isEmail: isEmail
43
- }),
44
- /*#__PURE__*/ _jsx(React.Suspense, {
45
- fallback: /*#__PURE__*/ _jsx(SSOButtonsSkeleton, {}),
46
- children: /*#__PURE__*/ _jsx(SSOButtons, {})
47
- })
48
- ]
49
- }),
50
- /*#__PURE__*/ _jsx("div", {
51
- className: "text-accent-foreground p-6 text-center text-sm",
52
- children: t.rich("already_have_account", {
53
- link: (text)=>/*#__PURE__*/ _jsx(Link, {
54
- className: "text-primary font-semibold",
55
- href: "/login",
56
- children: text
57
- })
58
- })
59
- })
60
- ]
61
- })
62
- })
63
- })
64
- });
65
- };
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{getTranslations}from"next-intl/server";import React from"react";import{Card,CardDescription}from"../../../components/ui/card.js";import{getMiddlewareApi}from"../../../lib/api/get-middleware-api.js";import{Link}from"../../../lib/navigation.js";import{I18nProvider}from"../../../components/i18n-provider.js";import{SSOButtons,SSOButtonsSkeleton}from"../sso/buttons/sso-buttons.js";import{FormSignUp}from"./form/form.js";import{WrapperSignUp}from"./wrapper.js";export const SignUpView=async()=>{const[t,tGlobal,{isEmail,captcha}]=await Promise.all([getTranslations("core.auth.sign_up"),getTranslations("core.global"),getMiddlewareApi()]);return _jsx(I18nProvider,{namespaces:"core.auth.sign_up",children:_jsx("div",{className:"mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col justify-center px-4 py-16",children:_jsx(WrapperSignUp,{children:_jsxs(Card,{className:"bg-muted gap-0 p-0",children:[_jsxs("div",{className:"bg-card rounded-xl p-6",children:[_jsxs("div",{className:"mb-10 space-y-2 text-center",children:[_jsx("h1",{className:"text-2xl leading-none font-semibold tracking-tight",children:tGlobal("register")}),_jsx(CardDescription,{children:t("desc")})]}),_jsx(FormSignUp,{captcha:captcha,isEmail:isEmail}),_jsx(React.Suspense,{fallback:_jsx(SSOButtonsSkeleton,{}),children:_jsx(SSOButtons,{})})]}),_jsx("div",{className:"text-accent-foreground p-6 text-center text-sm",children:t.rich("already_have_account",{link:text=>_jsx(Link,{className:"text-primary font-semibold",href:"/login",children:text})})})]})})})})};