@vitnode/core 1.2.0-canary.60 → 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.
- package/dist/scripts/get-config.js +15 -0
- package/dist/scripts/plugin.js +188 -0
- package/dist/scripts/prepare-database.js +177 -0
- package/dist/scripts/prepare-plugins-files.js +134 -0
- package/dist/scripts/run-interactive-shell-command.js +21 -0
- package/dist/scripts/scripts.js +39 -13
- package/dist/scripts/shared/file-utils.js +203 -0
- package/dist/src/api/adapters/sso/discord.js +1 -77
- package/dist/src/api/adapters/sso/facebook.js +1 -76
- package/dist/src/api/adapters/sso/google.js +1 -87
- package/dist/src/api/config.js +1 -67
- package/dist/src/api/lib/check-plugin-id.js +1 -43
- package/dist/src/api/lib/cron.js +1 -22
- package/dist/src/api/lib/logger-middleware.js +1 -35
- package/dist/src/api/lib/module.js +1 -22
- package/dist/src/api/lib/plugin.js +1 -22
- package/dist/src/api/lib/route.js +1 -27
- package/dist/src/api/lib/with-pagination.js +1 -83
- package/dist/src/api/middlewares/captcha.middleware.js +1 -63
- package/dist/src/api/middlewares/cron-auth.middleware.js +1 -19
- package/dist/src/api/middlewares/global.middleware.js +1 -93
- package/dist/src/api/middlewares/rate-limiter.middleware.js +1 -32
- package/dist/src/api/models/device.js +1 -61
- package/dist/src/api/models/email.js +1 -76
- package/dist/src/api/models/password.js +1 -36
- package/dist/src/api/models/session-admin.js +1 -106
- package/dist/src/api/models/session.js +1 -85
- package/dist/src/api/models/sso.js +1 -120
- package/dist/src/api/models/user/get-user-by-id.js +1 -19
- package/dist/src/api/models/user/sign-in-with-passwords.js +1 -22
- package/dist/src/api/models/user/sign-up.js +1 -73
- package/dist/src/api/models/user.js +1 -8
- package/dist/src/api/modules/admin/admin.module.js +1 -19
- package/dist/src/api/modules/admin/advanced/advanced.admin.module.js +1 -11
- package/dist/src/api/modules/admin/advanced/cron/cron.admin.module.js +1 -12
- package/dist/src/api/modules/admin/advanced/cron/routes/get.route.js +1 -66
- package/dist/src/api/modules/admin/advanced/cron/routes/run.route.js +1 -95
- package/dist/src/api/modules/admin/debug/debug.admin.module.js +1 -10
- package/dist/src/api/modules/admin/debug/routes/logs.route.js +1 -94
- package/dist/src/api/modules/admin/routes/session.route.js +1 -47
- package/dist/src/api/modules/admin/users/routes/list.route.js +1 -79
- package/dist/src/api/modules/admin/users/routes/users.route.js +1 -84
- package/dist/src/api/modules/admin/users/users.admin.module.js +1 -10
- package/dist/src/api/modules/cron/cron/clean.cron.js +1 -24
- package/dist/src/api/modules/cron/cron.module.js +1 -14
- package/dist/src/api/modules/cron/helpers/process-cron-jobs.d.ts.map +1 -1
- package/dist/src/api/modules/cron/helpers/process-cron-jobs.js +1 -76
- package/dist/src/api/modules/cron/routes/cron.route.js +1 -101
- package/dist/src/api/modules/middleware/middleware.module.js +1 -10
- package/dist/src/api/modules/middleware/route.js +1 -49
- package/dist/src/api/modules/users/avatar-color.js +1 -43
- package/dist/src/api/modules/users/routes/change-password.route.js +1 -58
- package/dist/src/api/modules/users/routes/reset-passowrd.route.js +1 -91
- package/dist/src/api/modules/users/routes/session.route.js +1 -46
- package/dist/src/api/modules/users/routes/sign-in.route.js +1 -71
- package/dist/src/api/modules/users/routes/sign-out.route.js +1 -43
- package/dist/src/api/modules/users/routes/sign-up.route.js +1 -77
- package/dist/src/api/modules/users/routes/test.route.js +1 -33
- package/dist/src/api/modules/users/sso/routes/callback.route.js +1 -52
- package/dist/src/api/modules/users/sso/routes/create-url.route.js +1 -36
- package/dist/src/api/modules/users/sso/sso.module.js +1 -12
- package/dist/src/api/modules/users/users.module.js +1 -26
- package/dist/src/api/plugin.js +1 -15
- package/dist/src/app/login/page.js +1 -16
- package/dist/src/app/login/reset-password/page.js +1 -18
- package/dist/src/app/login/sso/[providerId]/page.js +1 -10
- package/dist/src/app/register/page.js +1 -16
- package/dist/src/app_admin/core/advanced/cron/page.js +1 -42
- package/dist/src/app_admin/core/debug/page.js +1 -45
- package/dist/src/app_admin/core/page.js +1 -5
- package/dist/src/app_admin/core/test/page.js +1 -5
- package/dist/src/app_admin/core/users/page.js +1 -38
- package/dist/src/components/avatar.js +1 -14
- package/dist/src/components/confirm-action/confirm-action-alert-dialog.js +1 -42
- package/dist/src/components/confirm-action/content.js +1 -31
- package/dist/src/components/date-format.js +1 -41
- package/dist/src/components/form/auto-form.js +1 -103
- package/dist/src/components/form/common/desc.js +1 -9
- package/dist/src/components/form/common/label.js +1 -18
- package/dist/src/components/form/fields/checkbox.js +1 -37
- package/dist/src/components/form/fields/combobox-async.js +1 -123
- package/dist/src/components/form/fields/combobox.js +1 -87
- package/dist/src/components/form/fields/input.js +1 -39
- package/dist/src/components/form/fields/radio-group.js +1 -50
- package/dist/src/components/form/fields/select.js +1 -58
- package/dist/src/components/form/fields/switch.js +1 -36
- package/dist/src/components/form/fields/textarea.js +1 -36
- package/dist/src/components/i18n-provider.js +1 -43
- package/dist/src/components/logo-vitnode.js +1 -119
- package/dist/src/components/switchers/langs/language-switcher.js +1 -47
- package/dist/src/components/switchers/themes/theme-switcher.js +1 -28
- package/dist/src/components/table/content.js +1 -81
- package/dist/src/components/table/data-table.js +1 -68
- package/dist/src/components/table/order-table-head.js +1 -50
- package/dist/src/components/table/pagination.js +1 -122
- package/dist/src/components/tiptap/extension.js +1 -33
- package/dist/src/components/tiptap/toolbar/actions/alignment-action.js +1 -91
- package/dist/src/components/tiptap/toolbar/actions/bold-action.js +1 -39
- package/dist/src/components/tiptap/toolbar/actions/headings-action.js +1 -93
- package/dist/src/components/tiptap/toolbar/actions/italic-action.js +1 -38
- package/dist/src/components/tiptap/toolbar/actions/list-action.js +1 -61
- package/dist/src/components/tiptap/toolbar/actions/text-format-more/text-format-more.js +1 -59
- package/dist/src/components/tiptap/toolbar/actions/underline-action.js +1 -38
- package/dist/src/components/tiptap/toolbar/actions/undo-redo-actions.js +1 -63
- package/dist/src/components/tiptap/toolbar/actions/utils/tooltip-shortcut.js +1 -11
- package/dist/src/components/tiptap/toolbar/tiptap-toolbar.js +1 -55
- package/dist/src/components/tiptap/toolbar/use-toolbar-editor.js +1 -5
- package/dist/src/components/ui/accordion.js +1 -46
- package/dist/src/components/ui/alert-dialog.js +1 -123
- package/dist/src/components/ui/alert.js +1 -39
- package/dist/src/components/ui/badge.js +1 -28
- package/dist/src/components/ui/button-client.js +1 -57
- package/dist/src/components/ui/button.js +1 -32
- package/dist/src/components/ui/card.js +1 -52
- package/dist/src/components/ui/checkbox.js +1 -20
- package/dist/src/components/ui/collapsible.js +1 -22
- package/dist/src/components/ui/command.js +1 -98
- package/dist/src/components/ui/context-menu.js +1 -140
- package/dist/src/components/ui/dialog.js +1 -189
- package/dist/src/components/ui/drawer.js +1 -83
- package/dist/src/components/ui/dropdown-menu.js +1 -141
- package/dist/src/components/ui/editor-content.js +1 -10
- package/dist/src/components/ui/editor.js +1 -35
- package/dist/src/components/ui/form.js +1 -148
- package/dist/src/components/ui/header-content.js +1 -30
- package/dist/src/components/ui/hover-card.js +1 -29
- package/dist/src/components/ui/input-otp.js +1 -48
- package/dist/src/components/ui/input.js +1 -11
- package/dist/src/components/ui/label.js +1 -12
- package/dist/src/components/ui/loader.js +1 -16
- package/dist/src/components/ui/menubar.js +1 -151
- package/dist/src/components/ui/navigation-menu.js +1 -82
- package/dist/src/components/ui/popover.js +1 -35
- package/dist/src/components/ui/progress.js +1 -19
- package/dist/src/components/ui/radio-group.js +1 -27
- package/dist/src/components/ui/scroll-area.js +1 -33
- package/dist/src/components/ui/select.js +1 -113
- package/dist/src/components/ui/separator.js +1 -14
- package/dist/src/components/ui/sheet.js +1 -92
- package/dist/src/components/ui/sidebar.js +1 -433
- package/dist/src/components/ui/skeleton.js +1 -10
- package/dist/src/components/ui/slider.js +1 -50
- package/dist/src/components/ui/sonner.js +1 -26
- package/dist/src/components/ui/switch.js +1 -16
- package/dist/src/components/ui/table.js +1 -63
- package/dist/src/components/ui/tabs.js +1 -33
- package/dist/src/components/ui/textarea.js +1 -10
- package/dist/src/components/ui/toggle-group.js +1 -45
- package/dist/src/components/ui/toggle.js +1 -34
- package/dist/src/components/ui/tooltip.js +1 -57
- package/dist/src/config.js +1 -4
- package/dist/src/database/admins.js +1 -74
- package/dist/src/database/cron.js +1 -22
- package/dist/src/database/languages.js +1 -52
- package/dist/src/database/logs.js +1 -34
- package/dist/src/database/moderators.js +1 -37
- package/dist/src/database/roles.js +1 -13
- package/dist/src/database/sessions.js +1 -60
- package/dist/src/database/users.js +1 -145
- package/dist/src/drizzle.config.js +1 -67
- package/dist/src/emails/default-template.js +1 -99
- package/dist/src/emails/reset-password.js +1 -132
- package/dist/src/emails/ui/button.js +1 -36
- package/dist/src/emails/ui/card.js +1 -39
- package/dist/src/hooks/use-before-unload.js +1 -30
- package/dist/src/hooks/use-captcha.js +1 -122
- package/dist/src/hooks/use-mobile.js +1 -16
- package/dist/src/lib/api/get-middleware-api.js +1 -13
- package/dist/src/lib/api/get-next-cron-run-date.js +1 -14
- package/dist/src/lib/api/get-next-cron-run-date.test.js +1 -55
- package/dist/src/lib/api/get-session-admin-api.js +1 -19
- package/dist/src/lib/api/get-session-api.js +1 -14
- package/dist/src/lib/api/should-cron-job-run.js +1 -16
- package/dist/src/lib/api/should-cron-job-run.test.js +1 -213
- package/dist/src/lib/api/validate-cron-schedule.d.ts +2 -0
- package/dist/src/lib/api/validate-cron-schedule.d.ts.map +1 -0
- package/dist/src/lib/api/validate-cron-schedule.js +1 -0
- package/dist/src/lib/api/validate-cron-schedule.test.d.ts +2 -0
- package/dist/src/lib/api/validate-cron-schedule.test.d.ts.map +1 -0
- package/dist/src/lib/api/validate-cron-schedule.test.js +1 -0
- package/dist/src/lib/colors.js +1 -140
- package/dist/src/lib/colors.test.js +1 -173
- package/dist/src/lib/config.js +1 -14
- package/dist/src/lib/ctrl-or-command-character.js +1 -5
- package/dist/src/lib/fetcher/cookie-from-string-to-object.js +1 -12
- package/dist/src/lib/fetcher/cookie-from-string-to-object.test.js +1 -78
- package/dist/src/lib/fetcher/core.js +3 -48
- package/dist/src/lib/fetcher/helpers-server.js +1 -18
- package/dist/src/lib/fetcher/helpers.js +1 -16
- package/dist/src/lib/fetcher/helpers.test.js +1 -37
- package/dist/src/lib/fetcher/types.js +1 -1
- package/dist/src/lib/fetcher-client.js +1 -17
- package/dist/src/lib/fetcher.js +1 -33
- package/dist/src/lib/helpers/auto-form.js +1 -98
- package/dist/src/lib/helpers/auto-form.test.js +1 -336
- package/dist/src/lib/navigation.js +1 -11
- package/dist/src/lib/plugin.js +1 -3
- package/dist/src/lib/special-characters.js +1 -4
- package/dist/src/lib/special-characters.test.js +1 -56
- package/dist/src/lib/utils.js +1 -5
- package/dist/src/locales/en.json +308 -0
- package/dist/src/tests/setup.js +1 -6
- package/dist/src/views/admin/layouts/admin-layout.js +1 -73
- package/dist/src/views/admin/layouts/sidebar/nav/item.js +1 -98
- package/dist/src/views/admin/layouts/sidebar/nav/nav.js +1 -60
- package/dist/src/views/admin/layouts/sidebar/sidebar.js +1 -28
- package/dist/src/views/admin/layouts/sidebar/sign-out.js +1 -14
- package/dist/src/views/admin/layouts/user-bar/client.js +1 -69
- package/dist/src/views/admin/layouts/user-bar/user-bar.js +1 -32
- package/dist/src/views/admin/sign-in/sign-in-admin-view.js +1 -27
- package/dist/src/views/admin/views/core/advanced/cron/cron-table-view.js +1 -97
- package/dist/src/views/admin/views/core/advanced/cron/run-action/mutation-api.js +1 -23
- package/dist/src/views/admin/views/core/advanced/cron/run-action/run-action.js +1 -38
- package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.js +1 -44
- package/dist/src/views/admin/views/core/debug/actions/clear-cache/clear-cache.js +1 -35
- package/dist/src/views/admin/views/core/debug/actions/clear-cache/mutation-api.js +1 -5
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/content.js +1 -281
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/more.js +1 -67
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-status.js +1 -14
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-type-log.js +1 -30
- package/dist/src/views/admin/views/core/debug/system-logs/system-logs-view.js +1 -96
- package/dist/src/views/admin/views/core/test.js +1 -161
- package/dist/src/views/admin/views/core/users/users-admin-view.js +1 -89
- package/dist/src/views/auth/password-reset/change-password-form/form.js +1 -48
- package/dist/src/views/auth/password-reset/change-password-form/mutation-api.js +1 -22
- package/dist/src/views/auth/password-reset/change-password-form/use-form.js +1 -36
- package/dist/src/views/auth/password-reset/form/form.js +1 -104
- package/dist/src/views/auth/password-reset/form/mutation-api.js +1 -21
- package/dist/src/views/auth/password-reset/form/use-form.js +1 -33
- package/dist/src/views/auth/password-reset/password-reset-view.js +1 -37
- package/dist/src/views/auth/sign-in/form/form.js +1 -64
- package/dist/src/views/auth/sign-in/form/mutation-api.js +1 -33
- package/dist/src/views/auth/sign-in/form/use-form.js +1 -38
- package/dist/src/views/auth/sign-in/sign-in-view.js +1 -61
- package/dist/src/views/auth/sign-up/components/password-input.js +1 -96
- package/dist/src/views/auth/sign-up/email-confirmation-view.js +1 -55
- package/dist/src/views/auth/sign-up/form/form.js +1 -89
- package/dist/src/views/auth/sign-up/form/mutation-api.js +1 -30
- package/dist/src/views/auth/sign-up/form/use-form.js +1 -70
- package/dist/src/views/auth/sign-up/sign-up-view.js +1 -65
- package/dist/src/views/auth/sign-up/wrapper.js +1 -22
- package/dist/src/views/auth/sso/buttons/client.js +1 -22
- package/dist/src/views/auth/sso/buttons/mutation-api.js +1 -24
- package/dist/src/views/auth/sso/buttons/sso-buttons.js +1 -56
- package/dist/src/views/auth/sso/callback/callback-sso-view.js +1 -32
- package/dist/src/views/auth/sso/callback/client/client.js +1 -68
- package/dist/src/views/auth/sso/callback/client/mutation-api.js +1 -32
- package/dist/src/views/error/back-button.js +1 -14
- package/dist/src/views/error/error-view.js +1 -58
- package/dist/src/views/error/global-error-view.js +1 -50
- package/dist/src/views/layouts/provider.js +1 -44
- package/dist/src/views/layouts/root-layout.js +1 -25
- package/dist/src/views/layouts/theme/header/header.js +1 -38
- package/dist/src/views/layouts/theme/header/user/auth/auth.js +1 -33
- package/dist/src/views/layouts/theme/header/user/auth/client.js +1 -47
- package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.js +1 -27
- package/dist/src/views/layouts/theme/header/user/user.js +1 -32
- package/dist/src/views/layouts/theme/layout.js +1 -16
- package/dist/src/vitnode.config.js +1 -42
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/tsup.config.js +18 -0
- package/dist/vitest.config.d.ts.map +1 -1
- package/dist/vitest.config.js +49 -0
- package/eslint.config.mjs +2 -0
- package/package.json +6 -10
- package/dist/src/api/adapters/cron/node-cron.adapter.d.ts +0 -3
- package/dist/src/api/adapters/cron/node-cron.adapter.d.ts.map +0 -1
- package/dist/src/api/adapters/cron/node-cron.adapter.js +0 -11
- package/dist/src/api/adapters/email/nodemailer.d.ts +0 -10
- package/dist/src/api/adapters/email/nodemailer.d.ts.map +0 -1
- package/dist/src/api/adapters/email/nodemailer.js +0 -30
- package/dist/src/api/adapters/email/resend.d.ts +0 -6
- package/dist/src/api/adapters/email/resend.d.ts.map +0 -1
- package/dist/src/api/adapters/email/resend.js +0 -21
|
@@ -1,161 +1 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { AutoForm } from "../../../../components/form/auto-form.js";
|
|
5
|
-
import { AutoFormCheckbox } from "../../../../components/form/fields/checkbox.js";
|
|
6
|
-
import { AutoFormCombobox } from "../../../../components/form/fields/combobox.js";
|
|
7
|
-
import { AutoFormInput } from "../../../../components/form/fields/input.js";
|
|
8
|
-
import { AutoFormRadioGroup } from "../../../../components/form/fields/radio-group.js";
|
|
9
|
-
import { AutoFormSelect } from "../../../../components/form/fields/select.js";
|
|
10
|
-
import { AutoFormSwitch } from "../../../../components/form/fields/switch.js";
|
|
11
|
-
import { AutoFormTextarea } from "../../../../components/form/fields/textarea.js";
|
|
12
|
-
import { Card } from "../../../../components/ui/card.js";
|
|
13
|
-
import { Editor } from "../../../../components/ui/editor.js";
|
|
14
|
-
import { EditorContent } from "../../../../components/ui/editor-content.js";
|
|
15
|
-
export const TestView = ()=>{
|
|
16
|
-
const formSchema = z.object({
|
|
17
|
-
provider: z.string().min(1, {
|
|
18
|
-
message: "Provider is required"
|
|
19
|
-
}).describe("This is the provider for your application. It should be a valid provider name."),
|
|
20
|
-
client_secret: z.string().min(1, {
|
|
21
|
-
message: "Client Secret is required"
|
|
22
|
-
}).describe("This is the client secret for your application. It should be kept secret and not shared with anyone."),
|
|
23
|
-
terms: z.boolean().refine((val)=>val, {
|
|
24
|
-
message: "You must accept the terms and conditions"
|
|
25
|
-
}).describe("By checking this box, you agree to the terms and conditions."),
|
|
26
|
-
options: z.enum([
|
|
27
|
-
"option1",
|
|
28
|
-
"option2",
|
|
29
|
-
"option3"
|
|
30
|
-
]).default("option1"),
|
|
31
|
-
options_long: z.enum([
|
|
32
|
-
"option1",
|
|
33
|
-
"option2",
|
|
34
|
-
"option3"
|
|
35
|
-
]).default("option2"),
|
|
36
|
-
switch: z.boolean().default(false).describe("elo"),
|
|
37
|
-
type: z.enum([
|
|
38
|
-
"option-one",
|
|
39
|
-
"option-two"
|
|
40
|
-
])
|
|
41
|
-
});
|
|
42
|
-
return /*#__PURE__*/ _jsx("div", {
|
|
43
|
-
className: "p-4",
|
|
44
|
-
children: /*#__PURE__*/ _jsxs(Card, {
|
|
45
|
-
className: "p-6",
|
|
46
|
-
children: [
|
|
47
|
-
/*#__PURE__*/ _jsx(Editor, {
|
|
48
|
-
value: "<p>Hello World! 🌎️</p>"
|
|
49
|
-
}),
|
|
50
|
-
/*#__PURE__*/ _jsx(EditorContent, {
|
|
51
|
-
content: "<h2>Test header v2</h2><p>Hello World! 🌎️das d alfjnasjf kas djksa fkja sfj AFKJ afj AFJKNAJSKGNSAKFLMSAKLDNASFJNKJnjkdasnfjnas fjknsa fjknsafkjn askjfnkajsgnasjkfnskjanf kjans fjknasjkf naskjf naskjnf kjasn kfjans fjkas kfjnas jknfkasjn fkajsnf jnasfjkangaskjfnajsdnlaskmcdasjfnjskafnsajknfcksajdnasjkfnjkasn cfjksanfjckasnjcnaskjcnaksjcnaksjcnakjcnasjkn</p>"
|
|
52
|
-
}),
|
|
53
|
-
/*#__PURE__*/ _jsx(AutoForm, {
|
|
54
|
-
fields: [
|
|
55
|
-
{
|
|
56
|
-
id: "provider",
|
|
57
|
-
component: (props)=>/*#__PURE__*/ _jsx(AutoFormInput, {
|
|
58
|
-
description: "This is the provider for your application. It should be a valid provider name.",
|
|
59
|
-
label: "Provider",
|
|
60
|
-
...props
|
|
61
|
-
})
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
id: "client_secret",
|
|
65
|
-
component: (props)=>/*#__PURE__*/ _jsx(AutoFormTextarea, {
|
|
66
|
-
description: "This is the client secret for your application. It should be kept secret and not shared with anyone.",
|
|
67
|
-
label: "Client Secret",
|
|
68
|
-
...props
|
|
69
|
-
})
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
id: "terms",
|
|
73
|
-
component: (props)=>/*#__PURE__*/ _jsx(AutoFormCheckbox, {
|
|
74
|
-
description: "By checking this box, you agree to the terms and conditions.",
|
|
75
|
-
label: "I agree to the terms and conditions",
|
|
76
|
-
...props
|
|
77
|
-
})
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
id: "options",
|
|
81
|
-
component: (props)=>/*#__PURE__*/ _jsx(AutoFormRadioGroup, {
|
|
82
|
-
description: "By checking this box, you agree to the terms and conditions.",
|
|
83
|
-
label: "I agree to the terms and conditions",
|
|
84
|
-
labels: [
|
|
85
|
-
{
|
|
86
|
-
value: "option1",
|
|
87
|
-
label: "Option 1 with a very long label that should be truncated"
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
value: "option2",
|
|
91
|
-
label: "Option 2"
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
value: "option3",
|
|
95
|
-
label: "Option 3"
|
|
96
|
-
}
|
|
97
|
-
],
|
|
98
|
-
...props
|
|
99
|
-
})
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
id: "options_long",
|
|
103
|
-
component: (props)=>/*#__PURE__*/ _jsx(AutoFormSelect, {
|
|
104
|
-
description: "By checking this box, you agree to the terms and conditions.",
|
|
105
|
-
label: "I agree to the terms and conditions",
|
|
106
|
-
labels: [
|
|
107
|
-
{
|
|
108
|
-
value: "option1",
|
|
109
|
-
label: "Option 1 with a very long label that should be truncated"
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
value: "option2",
|
|
113
|
-
label: "Option 2"
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
value: "option3",
|
|
117
|
-
label: "Option 3"
|
|
118
|
-
}
|
|
119
|
-
],
|
|
120
|
-
placeholder: "Select an option from the list",
|
|
121
|
-
...props
|
|
122
|
-
})
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
id: "switch",
|
|
126
|
-
component: (props)=>/*#__PURE__*/ _jsx(AutoFormSwitch, {
|
|
127
|
-
...props,
|
|
128
|
-
description: "By checking this box, you agree to the terms and conditions.",
|
|
129
|
-
label: "I agree to the terms and conditions"
|
|
130
|
-
})
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
id: "type",
|
|
134
|
-
component: (props)=>/*#__PURE__*/ _jsx(AutoFormCombobox, {
|
|
135
|
-
description: "By checking this box, you agree to the terms and conditions.",
|
|
136
|
-
label: "Type",
|
|
137
|
-
labels: [
|
|
138
|
-
{
|
|
139
|
-
value: "option-one",
|
|
140
|
-
label: "Option One"
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
value: "option-two",
|
|
144
|
-
label: "Option Two"
|
|
145
|
-
}
|
|
146
|
-
],
|
|
147
|
-
...props
|
|
148
|
-
})
|
|
149
|
-
}
|
|
150
|
-
],
|
|
151
|
-
formSchema: formSchema,
|
|
152
|
-
onSubmit: async (values)=>{
|
|
153
|
-
// eslint-disable-next-line no-console
|
|
154
|
-
console.log("Form submitted", values);
|
|
155
|
-
await new Promise((resolve)=>setTimeout(resolve, 3000));
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
]
|
|
159
|
-
})
|
|
160
|
-
});
|
|
161
|
-
};
|
|
1
|
+
"use client";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{z}from"zod";import{AutoForm}from"../../../../components/form/auto-form.js";import{AutoFormCheckbox}from"../../../../components/form/fields/checkbox.js";import{AutoFormCombobox}from"../../../../components/form/fields/combobox.js";import{AutoFormInput}from"../../../../components/form/fields/input.js";import{AutoFormRadioGroup}from"../../../../components/form/fields/radio-group.js";import{AutoFormSelect}from"../../../../components/form/fields/select.js";import{AutoFormSwitch}from"../../../../components/form/fields/switch.js";import{AutoFormTextarea}from"../../../../components/form/fields/textarea.js";import{Card}from"../../../../components/ui/card.js";import{Editor}from"../../../../components/ui/editor.js";import{EditorContent}from"../../../../components/ui/editor-content.js";export const TestView=()=>{const formSchema=z.object({provider:z.string().min(1,{message:"Provider is required"}).describe("This is the provider for your application. It should be a valid provider name."),client_secret:z.string().min(1,{message:"Client Secret is required"}).describe("This is the client secret for your application. It should be kept secret and not shared with anyone."),terms:z.boolean().refine(val=>val,{message:"You must accept the terms and conditions"}).describe("By checking this box, you agree to the terms and conditions."),options:z.enum(["option1","option2","option3"]).default("option1"),options_long:z.enum(["option1","option2","option3"]).default("option2"),switch:z.boolean().default(false).describe("elo"),type:z.enum(["option-one","option-two"])});return _jsx("div",{className:"p-4",children:_jsxs(Card,{className:"p-6",children:[_jsx(Editor,{value:"<p>Hello World! 🌎️</p>"}),_jsx(EditorContent,{content:"<h2>Test header v2</h2><p>Hello World! 🌎️das d alfjnasjf kas djksa fkja sfj AFKJ afj AFJKNAJSKGNSAKFLMSAKLDNASFJNKJnjkdasnfjnas fjknsa fjknsafkjn askjfnkajsgnasjkfnskjanf kjans fjknasjkf naskjf naskjnf kjasn kfjans fjkas kfjnas jknfkasjn fkajsnf jnasfjkangaskjfnajsdnlaskmcdasjfnjskafnsajknfcksajdnasjkfnjkasn cfjksanfjckasnjcnaskjcnaksjcnaksjcnakjcnasjkn</p>"}),_jsx(AutoForm,{fields:[{id:"provider",component:props=>_jsx(AutoFormInput,{description:"This is the provider for your application. It should be a valid provider name.",label:"Provider",...props})},{id:"client_secret",component:props=>_jsx(AutoFormTextarea,{description:"This is the client secret for your application. It should be kept secret and not shared with anyone.",label:"Client Secret",...props})},{id:"terms",component:props=>_jsx(AutoFormCheckbox,{description:"By checking this box, you agree to the terms and conditions.",label:"I agree to the terms and conditions",...props})},{id:"options",component:props=>_jsx(AutoFormRadioGroup,{description:"By checking this box, you agree to the terms and conditions.",label:"I agree to the terms and conditions",labels:[{value:"option1",label:"Option 1 with a very long label that should be truncated"},{value:"option2",label:"Option 2"},{value:"option3",label:"Option 3"}],...props})},{id:"options_long",component:props=>_jsx(AutoFormSelect,{description:"By checking this box, you agree to the terms and conditions.",label:"I agree to the terms and conditions",labels:[{value:"option1",label:"Option 1 with a very long label that should be truncated"},{value:"option2",label:"Option 2"},{value:"option3",label:"Option 3"}],placeholder:"Select an option from the list",...props})},{id:"switch",component:props=>_jsx(AutoFormSwitch,{...props,description:"By checking this box, you agree to the terms and conditions.",label:"I agree to the terms and conditions"})},{id:"type",component:props=>_jsx(AutoFormCombobox,{description:"By checking this box, you agree to the terms and conditions.",label:"Type",labels:[{value:"option-one",label:"Option One"},{value:"option-two",label:"Option Two"}],...props})}],formSchema:formSchema,onSubmit:async values=>{console.log("Form submitted",values);await new Promise(resolve=>setTimeout(resolve,3e3))}})]})})};
|
|
@@ -1,89 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { MailIcon } from "lucide-react";
|
|
3
|
-
import { getTranslations } from "next-intl/server";
|
|
4
|
-
import { adminModule } from "../../../../../api/modules/admin/admin.module.js";
|
|
5
|
-
import { Avatar } from "../../../../../components/avatar.js";
|
|
6
|
-
import { DateFormat } from "../../../../../components/date-format.js";
|
|
7
|
-
import { DataTable } from "../../../../../components/table/data-table.js";
|
|
8
|
-
import { Tooltip, TooltipContent, TooltipTrigger } from "../../../../../components/ui/tooltip.js";
|
|
9
|
-
import { fetcher } from "../../../../../lib/fetcher.js";
|
|
10
|
-
export const UsersAdminView = async ({ searchParams })=>{
|
|
11
|
-
const t = await getTranslations("admin.user.list");
|
|
12
|
-
const query = await searchParams;
|
|
13
|
-
const res = await fetcher(adminModule, {
|
|
14
|
-
path: "/list",
|
|
15
|
-
method: "get",
|
|
16
|
-
module: "admin/users",
|
|
17
|
-
args: {
|
|
18
|
-
query
|
|
19
|
-
},
|
|
20
|
-
withPagination: true
|
|
21
|
-
});
|
|
22
|
-
const data = await res.json();
|
|
23
|
-
return /*#__PURE__*/ _jsx(DataTable, {
|
|
24
|
-
columns: [
|
|
25
|
-
{
|
|
26
|
-
id: "name",
|
|
27
|
-
label: t("user"),
|
|
28
|
-
cell: ({ row })=>/*#__PURE__*/ _jsxs("div", {
|
|
29
|
-
className: "flex items-center gap-3",
|
|
30
|
-
children: [
|
|
31
|
-
/*#__PURE__*/ _jsx(Avatar, {
|
|
32
|
-
size: 32,
|
|
33
|
-
user: row
|
|
34
|
-
}),
|
|
35
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
36
|
-
className: "flex flex-col",
|
|
37
|
-
children: [
|
|
38
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
39
|
-
className: "flex items-center gap-2",
|
|
40
|
-
children: [
|
|
41
|
-
/*#__PURE__*/ _jsx("span", {
|
|
42
|
-
className: "font-medium",
|
|
43
|
-
children: row.name
|
|
44
|
-
}),
|
|
45
|
-
!row.emailVerified && /*#__PURE__*/ _jsxs(Tooltip, {
|
|
46
|
-
children: [
|
|
47
|
-
/*#__PURE__*/ _jsx(TooltipTrigger, {
|
|
48
|
-
children: /*#__PURE__*/ _jsx(MailIcon, {
|
|
49
|
-
className: "text-destructive size-4"
|
|
50
|
-
})
|
|
51
|
-
}),
|
|
52
|
-
/*#__PURE__*/ _jsx(TooltipContent, {
|
|
53
|
-
children: t("emailNotVerified")
|
|
54
|
-
})
|
|
55
|
-
]
|
|
56
|
-
})
|
|
57
|
-
]
|
|
58
|
-
}),
|
|
59
|
-
/*#__PURE__*/ _jsx("span", {
|
|
60
|
-
className: "text-muted-foreground text-sm",
|
|
61
|
-
children: row.email
|
|
62
|
-
})
|
|
63
|
-
]
|
|
64
|
-
})
|
|
65
|
-
]
|
|
66
|
-
})
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
id: "createdAt",
|
|
70
|
-
label: t("createdAt"),
|
|
71
|
-
cell: ({ row })=>/*#__PURE__*/ _jsx(DateFormat, {
|
|
72
|
-
date: row.createdAt
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
],
|
|
76
|
-
edges: data.edges,
|
|
77
|
-
order: {
|
|
78
|
-
columns: [
|
|
79
|
-
"createdAt",
|
|
80
|
-
"name"
|
|
81
|
-
],
|
|
82
|
-
defaultOrder: {
|
|
83
|
-
column: "createdAt",
|
|
84
|
-
order: "desc"
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
pageInfo: data.pageInfo
|
|
88
|
-
});
|
|
89
|
-
};
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{MailIcon}from"lucide-react";import{getTranslations}from"next-intl/server";import{adminModule}from"../../../../../api/modules/admin/admin.module.js";import{Avatar}from"../../../../../components/avatar.js";import{DateFormat}from"../../../../../components/date-format.js";import{DataTable}from"../../../../../components/table/data-table.js";import{Tooltip,TooltipContent,TooltipTrigger}from"../../../../../components/ui/tooltip.js";import{fetcher}from"../../../../../lib/fetcher.js";export const UsersAdminView=async({searchParams})=>{const t=await getTranslations("admin.user.list");const query=await searchParams;const res=await fetcher(adminModule,{path:"/list",method:"get",module:"admin/users",args:{query},withPagination:true});const data=await res.json();return _jsx(DataTable,{columns:[{id:"name",label:t("user"),cell:({row})=>_jsxs("div",{className:"flex items-center gap-3",children:[_jsx(Avatar,{size:32,user:row}),_jsxs("div",{className:"flex flex-col",children:[_jsxs("div",{className:"flex items-center gap-2",children:[_jsx("span",{className:"font-medium",children:row.name}),!row.emailVerified&&_jsxs(Tooltip,{children:[_jsx(TooltipTrigger,{children:_jsx(MailIcon,{className:"text-destructive size-4"})}),_jsx(TooltipContent,{children:t("emailNotVerified")})]})]}),_jsx("span",{className:"text-muted-foreground text-sm",children:row.email})]})]})},{id:"createdAt",label:t("createdAt"),cell:({row})=>_jsx(DateFormat,{date:row.createdAt})}],edges:data.edges,order:{columns:["createdAt","name"],defaultOrder:{column:"createdAt",order:"desc"}},pageInfo:data.pageInfo})};
|
|
@@ -1,48 +1 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useTranslations } from "next-intl";
|
|
4
|
-
import { AutoForm } from "../../../../components/form/auto-form.js";
|
|
5
|
-
import { CardContent, CardDescription, CardHeader, CardTitle } from "../../../../components/ui/card.js";
|
|
6
|
-
import { PasswordInput } from "../../sign-up/components/password-input.js";
|
|
7
|
-
import { useForm } from "./use-form.js";
|
|
8
|
-
export const ChangePasswordForm = (props)=>{
|
|
9
|
-
const t = useTranslations("core.auth.change_password");
|
|
10
|
-
const tSignUp = useTranslations("core.auth.sign_up");
|
|
11
|
-
const { formSchema, onSubmit } = useForm(props);
|
|
12
|
-
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
13
|
-
children: [
|
|
14
|
-
/*#__PURE__*/ _jsxs(CardHeader, {
|
|
15
|
-
className: "text-center",
|
|
16
|
-
children: [
|
|
17
|
-
/*#__PURE__*/ _jsx(CardTitle, {
|
|
18
|
-
children: /*#__PURE__*/ _jsx("h1", {
|
|
19
|
-
children: t("title")
|
|
20
|
-
})
|
|
21
|
-
}),
|
|
22
|
-
/*#__PURE__*/ _jsx(CardDescription, {
|
|
23
|
-
children: t("desc")
|
|
24
|
-
})
|
|
25
|
-
]
|
|
26
|
-
}),
|
|
27
|
-
/*#__PURE__*/ _jsx(CardContent, {
|
|
28
|
-
children: /*#__PURE__*/ _jsx(AutoForm, {
|
|
29
|
-
fields: [
|
|
30
|
-
{
|
|
31
|
-
id: "password",
|
|
32
|
-
component: (props)=>/*#__PURE__*/ _jsx(PasswordInput, {
|
|
33
|
-
label: tSignUp("password.label"),
|
|
34
|
-
...props
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
],
|
|
38
|
-
formSchema: formSchema,
|
|
39
|
-
onSubmit: onSubmit,
|
|
40
|
-
submitButtonProps: {
|
|
41
|
-
className: "w-full",
|
|
42
|
-
children: t("submit")
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
]
|
|
47
|
-
});
|
|
48
|
-
};
|
|
1
|
+
"use client";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useTranslations}from"next-intl";import{AutoForm}from"../../../../components/form/auto-form.js";import{CardContent,CardDescription,CardHeader,CardTitle}from"../../../../components/ui/card.js";import{PasswordInput}from"../../sign-up/components/password-input.js";import{useForm}from"./use-form.js";export const ChangePasswordForm=props=>{const t=useTranslations("core.auth.change_password");const tSignUp=useTranslations("core.auth.sign_up");const{formSchema,onSubmit}=useForm(props);return _jsxs(_Fragment,{children:[_jsxs(CardHeader,{className:"text-center",children:[_jsx(CardTitle,{children:_jsx("h1",{children:t("title")})}),_jsx(CardDescription,{children:t("desc")})]}),_jsx(CardContent,{children:_jsx(AutoForm,{fields:[{id:"password",component:props=>_jsx(PasswordInput,{label:tSignUp("password.label"),...props})}],formSchema:formSchema,onSubmit:onSubmit,submitButtonProps:{className:"w-full",children:t("submit")}})})]})};
|
|
@@ -1,22 +1 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
import { usersModule } from "../../../../api/modules/users/users.module.js";
|
|
3
|
-
import { fetcher } from "../../../../lib/fetcher.js";
|
|
4
|
-
export const mutationApi = async ({ password, token, userId })=>{
|
|
5
|
-
const res = await fetcher(usersModule, {
|
|
6
|
-
module: "users",
|
|
7
|
-
path: "/change-password",
|
|
8
|
-
method: "post",
|
|
9
|
-
args: {
|
|
10
|
-
body: {
|
|
11
|
-
password,
|
|
12
|
-
token,
|
|
13
|
-
userId
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
if (res.status !== 201) {
|
|
18
|
-
return {
|
|
19
|
-
error: "internal_server_error"
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
};
|
|
1
|
+
"use server";import{usersModule}from"../../../../api/modules/users/users.module.js";import{fetcher}from"../../../../lib/fetcher.js";export const mutationApi=async({password,token,userId})=>{const res=await fetcher(usersModule,{module:"users",path:"/change-password",method:"post",args:{body:{password,token,userId}}});if(res.status!==201){return{error:"internal_server_error"}}};
|
|
@@ -1,36 +1 @@
|
|
|
1
|
-
import { useTranslations }
|
|
2
|
-
import { toast } from "sonner";
|
|
3
|
-
import z from "zod";
|
|
4
|
-
import { useRouter } from "../../../../lib/navigation.js";
|
|
5
|
-
import { usePasswordZodSchema } from "../../sign-up/form/use-form.js";
|
|
6
|
-
import { mutationApi } from "./mutation-api.js";
|
|
7
|
-
export const useForm = ({ token, userId })=>{
|
|
8
|
-
const t = useTranslations("core.auth.change_password");
|
|
9
|
-
const tError = useTranslations("core.global.errors");
|
|
10
|
-
const passwordSchema = usePasswordZodSchema();
|
|
11
|
-
const { replace } = useRouter();
|
|
12
|
-
const formSchema = z.object({
|
|
13
|
-
password: passwordSchema
|
|
14
|
-
});
|
|
15
|
-
const onSubmit = async (data)=>{
|
|
16
|
-
const mutation = await mutationApi({
|
|
17
|
-
password: data.password,
|
|
18
|
-
token,
|
|
19
|
-
userId: +userId
|
|
20
|
-
});
|
|
21
|
-
if (mutation?.error) {
|
|
22
|
-
toast.error(tError("title"), {
|
|
23
|
-
description: tError("internal_server_error")
|
|
24
|
-
});
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
toast.success(t("success.title"), {
|
|
28
|
-
description: t("success.desc")
|
|
29
|
-
});
|
|
30
|
-
replace("/login");
|
|
31
|
-
};
|
|
32
|
-
return {
|
|
33
|
-
formSchema,
|
|
34
|
-
onSubmit
|
|
35
|
-
};
|
|
36
|
-
};
|
|
1
|
+
import{useTranslations}from"next-intl";import{toast}from"sonner";import z from"zod";import{useRouter}from"../../../../lib/navigation.js";import{usePasswordZodSchema}from"../../sign-up/form/use-form.js";import{mutationApi}from"./mutation-api.js";export const useForm=({token,userId})=>{const t=useTranslations("core.auth.change_password");const tError=useTranslations("core.global.errors");const passwordSchema=usePasswordZodSchema();const{replace}=useRouter();const formSchema=z.object({password:passwordSchema});const onSubmit=async data=>{const mutation=await mutationApi({password:data.password,token,userId:+userId});if(mutation?.error){toast.error(tError("title"),{description:tError("internal_server_error")});return}toast.success(t("success.title"),{description:t("success.desc")});replace("/login")};return{formSchema,onSubmit}};
|
|
@@ -1,104 +1 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { MailCheckIcon } 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 { CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "../../../../components/ui/card.js";
|
|
8
|
-
import { Input } from "../../../../components/ui/input.js";
|
|
9
|
-
import { Label } from "../../../../components/ui/label.js";
|
|
10
|
-
import { useForm } from "./use-form.js";
|
|
11
|
-
function ConfirmationView({ email }) {
|
|
12
|
-
const t = useTranslations("core.auth.reset_password");
|
|
13
|
-
const tSignUp = useTranslations("core.auth.sign_up");
|
|
14
|
-
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
15
|
-
children: [
|
|
16
|
-
/*#__PURE__*/ _jsxs(CardHeader, {
|
|
17
|
-
className: "flex flex-col items-center text-center",
|
|
18
|
-
children: [
|
|
19
|
-
/*#__PURE__*/ _jsx("div", {
|
|
20
|
-
className: "mb-3 rounded-2xl border p-3",
|
|
21
|
-
children: /*#__PURE__*/ _jsx(MailCheckIcon, {
|
|
22
|
-
className: "size-8"
|
|
23
|
-
})
|
|
24
|
-
}),
|
|
25
|
-
/*#__PURE__*/ _jsx(CardTitle, {
|
|
26
|
-
className: "text-balance",
|
|
27
|
-
children: t("confirmation.title")
|
|
28
|
-
}),
|
|
29
|
-
/*#__PURE__*/ _jsx(CardDescription, {
|
|
30
|
-
className: "text-pretty",
|
|
31
|
-
children: t("confirmation.desc")
|
|
32
|
-
})
|
|
33
|
-
]
|
|
34
|
-
}),
|
|
35
|
-
/*#__PURE__*/ _jsxs(CardContent, {
|
|
36
|
-
className: "space-y-2",
|
|
37
|
-
children: [
|
|
38
|
-
/*#__PURE__*/ _jsx(Label, {
|
|
39
|
-
htmlFor: "email",
|
|
40
|
-
children: tSignUp("email.label")
|
|
41
|
-
}),
|
|
42
|
-
/*#__PURE__*/ _jsx(Input, {
|
|
43
|
-
className: "w-full",
|
|
44
|
-
id: "email",
|
|
45
|
-
readOnly: true,
|
|
46
|
-
value: email
|
|
47
|
-
})
|
|
48
|
-
]
|
|
49
|
-
}),
|
|
50
|
-
/*#__PURE__*/ _jsx(CardFooter, {
|
|
51
|
-
children: /*#__PURE__*/ _jsx(CardDescription, {
|
|
52
|
-
children: t("confirmation.check_spam")
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
]
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
export const PasswordResetForm = ({ captcha })=>{
|
|
59
|
-
const { formSchema, onSubmit, sentEmail } = useForm();
|
|
60
|
-
const t = useTranslations("core.auth.reset_password");
|
|
61
|
-
const tSignUp = useTranslations("core.auth.sign_up");
|
|
62
|
-
if (sentEmail) {
|
|
63
|
-
return /*#__PURE__*/ _jsx(ConfirmationView, {
|
|
64
|
-
email: sentEmail
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
68
|
-
children: [
|
|
69
|
-
/*#__PURE__*/ _jsxs(CardHeader, {
|
|
70
|
-
className: "text-center",
|
|
71
|
-
children: [
|
|
72
|
-
/*#__PURE__*/ _jsx(CardTitle, {
|
|
73
|
-
children: /*#__PURE__*/ _jsx("h1", {
|
|
74
|
-
children: t("title")
|
|
75
|
-
})
|
|
76
|
-
}),
|
|
77
|
-
/*#__PURE__*/ _jsx(CardDescription, {
|
|
78
|
-
children: t("desc")
|
|
79
|
-
})
|
|
80
|
-
]
|
|
81
|
-
}),
|
|
82
|
-
/*#__PURE__*/ _jsx(CardContent, {
|
|
83
|
-
children: /*#__PURE__*/ _jsx(AutoForm, {
|
|
84
|
-
captcha: captcha,
|
|
85
|
-
fields: [
|
|
86
|
-
{
|
|
87
|
-
id: "email",
|
|
88
|
-
component: (props)=>/*#__PURE__*/ _jsx(AutoFormInput, {
|
|
89
|
-
...props,
|
|
90
|
-
label: tSignUp("email.label")
|
|
91
|
-
})
|
|
92
|
-
}
|
|
93
|
-
],
|
|
94
|
-
formSchema: formSchema,
|
|
95
|
-
onSubmit: onSubmit,
|
|
96
|
-
submitButtonProps: {
|
|
97
|
-
className: "w-full",
|
|
98
|
-
children: t("submit")
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
})
|
|
102
|
-
]
|
|
103
|
-
});
|
|
104
|
-
};
|
|
1
|
+
"use client";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{MailCheckIcon}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{CardContent,CardDescription,CardFooter,CardHeader,CardTitle}from"../../../../components/ui/card.js";import{Input}from"../../../../components/ui/input.js";import{Label}from"../../../../components/ui/label.js";import{useForm}from"./use-form.js";function ConfirmationView({email}){const t=useTranslations("core.auth.reset_password");const tSignUp=useTranslations("core.auth.sign_up");return _jsxs(_Fragment,{children:[_jsxs(CardHeader,{className:"flex flex-col items-center text-center",children:[_jsx("div",{className:"mb-3 rounded-2xl border p-3",children:_jsx(MailCheckIcon,{className:"size-8"})}),_jsx(CardTitle,{className:"text-balance",children:t("confirmation.title")}),_jsx(CardDescription,{className:"text-pretty",children:t("confirmation.desc")})]}),_jsxs(CardContent,{className:"space-y-2",children:[_jsx(Label,{htmlFor:"email",children:tSignUp("email.label")}),_jsx(Input,{className:"w-full",id:"email",readOnly:true,value:email})]}),_jsx(CardFooter,{children:_jsx(CardDescription,{children:t("confirmation.check_spam")})})]})}export const PasswordResetForm=({captcha})=>{const{formSchema,onSubmit,sentEmail}=useForm();const t=useTranslations("core.auth.reset_password");const tSignUp=useTranslations("core.auth.sign_up");if(sentEmail){return _jsx(ConfirmationView,{email:sentEmail})}return _jsxs(_Fragment,{children:[_jsxs(CardHeader,{className:"text-center",children:[_jsx(CardTitle,{children:_jsx("h1",{children:t("title")})}),_jsx(CardDescription,{children:t("desc")})]}),_jsx(CardContent,{children:_jsx(AutoForm,{captcha:captcha,fields:[{id:"email",component:props=>_jsx(AutoFormInput,{...props,label:tSignUp("email.label")})}],formSchema:formSchema,onSubmit:onSubmit,submitButtonProps:{className:"w-full",children:t("submit")}})})]})};
|
|
@@ -1,21 +1 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
import { usersModule } from "../../../../api/modules/users/users.module.js";
|
|
3
|
-
import { fetcher } from "../../../../lib/fetcher.js";
|
|
4
|
-
export const mutationApi = async ({ email, captchaToken })=>{
|
|
5
|
-
const res = await fetcher(usersModule, {
|
|
6
|
-
module: "users",
|
|
7
|
-
path: "/reset-password",
|
|
8
|
-
method: "post",
|
|
9
|
-
captchaToken,
|
|
10
|
-
args: {
|
|
11
|
-
body: {
|
|
12
|
-
email
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
if (res.status !== 201) {
|
|
17
|
-
return {
|
|
18
|
-
error: "internal_server_error"
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
};
|
|
1
|
+
"use server";import{usersModule}from"../../../../api/modules/users/users.module.js";import{fetcher}from"../../../../lib/fetcher.js";export const mutationApi=async({email,captchaToken})=>{const res=await fetcher(usersModule,{module:"users",path:"/reset-password",method:"post",captchaToken,args:{body:{email}}});if(res.status!==201){return{error:"internal_server_error"}}};
|
|
@@ -1,33 +1 @@
|
|
|
1
|
-
import { useTranslations }
|
|
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 useForm = ()=>{
|
|
7
|
-
const t = useTranslations("core.auth.sign_up");
|
|
8
|
-
const tError = useTranslations("core.global.errors");
|
|
9
|
-
const [sentEmail, setSentEmail] = React.useState("");
|
|
10
|
-
const formSchema = z.object({
|
|
11
|
-
email: z.email({
|
|
12
|
-
message: t("email.invalid")
|
|
13
|
-
}).default("")
|
|
14
|
-
});
|
|
15
|
-
const onSubmit = async (data, _form, { captchaToken })=>{
|
|
16
|
-
const mutation = await mutationApi({
|
|
17
|
-
email: data.email,
|
|
18
|
-
captchaToken
|
|
19
|
-
});
|
|
20
|
-
if (mutation?.error) {
|
|
21
|
-
toast.error(tError("title"), {
|
|
22
|
-
description: tError("internal_server_error")
|
|
23
|
-
});
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
setSentEmail(data.email);
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
formSchema,
|
|
30
|
-
onSubmit,
|
|
31
|
-
sentEmail
|
|
32
|
-
};
|
|
33
|
-
};
|
|
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 useForm=()=>{const t=useTranslations("core.auth.sign_up");const tError=useTranslations("core.global.errors");const[sentEmail,setSentEmail]=React.useState("");const formSchema=z.object({email:z.email({message:t("email.invalid")}).default("")});const onSubmit=async(data,_form,{captchaToken})=>{const mutation=await mutationApi({email:data.email,captchaToken});if(mutation?.error){toast.error(tError("title"),{description:tError("internal_server_error")});return}setSentEmail(data.email)};return{formSchema,onSubmit,sentEmail}};
|
|
@@ -1,37 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { notFound } from "next/navigation";
|
|
3
|
-
import { I18nProvider } from "../../../components/i18n-provider.js";
|
|
4
|
-
import { Card } from "../../../components/ui/card.js";
|
|
5
|
-
import { getMiddlewareApi } from "../../../lib/api/get-middleware-api.js";
|
|
6
|
-
import { ChangePasswordForm } from "./change-password-form/form.js";
|
|
7
|
-
import { PasswordResetForm } from "./form/form.js";
|
|
8
|
-
export const PasswordResetView = async ({ searchParams })=>{
|
|
9
|
-
const [{ isEmail, captcha }, { token, userId }] = await Promise.all([
|
|
10
|
-
getMiddlewareApi(),
|
|
11
|
-
searchParams
|
|
12
|
-
]);
|
|
13
|
-
if (!isEmail) notFound();
|
|
14
|
-
return /*#__PURE__*/ _jsx("div", {
|
|
15
|
-
className: "mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col justify-center px-4 py-16",
|
|
16
|
-
children: /*#__PURE__*/ _jsx(Card, {
|
|
17
|
-
children: token && userId ? /*#__PURE__*/ _jsx(I18nProvider, {
|
|
18
|
-
namespaces: [
|
|
19
|
-
"core.auth.sign_up",
|
|
20
|
-
"core.auth.change_password"
|
|
21
|
-
],
|
|
22
|
-
children: /*#__PURE__*/ _jsx(ChangePasswordForm, {
|
|
23
|
-
token: token,
|
|
24
|
-
userId: userId
|
|
25
|
-
})
|
|
26
|
-
}) : /*#__PURE__*/ _jsx(I18nProvider, {
|
|
27
|
-
namespaces: [
|
|
28
|
-
"core.auth.sign_up",
|
|
29
|
-
"core.auth.reset_password"
|
|
30
|
-
],
|
|
31
|
-
children: /*#__PURE__*/ _jsx(PasswordResetForm, {
|
|
32
|
-
captcha: captcha
|
|
33
|
-
})
|
|
34
|
-
})
|
|
35
|
-
})
|
|
36
|
-
});
|
|
37
|
-
};
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{notFound}from"next/navigation";import{I18nProvider}from"../../../components/i18n-provider.js";import{Card}from"../../../components/ui/card.js";import{getMiddlewareApi}from"../../../lib/api/get-middleware-api.js";import{ChangePasswordForm}from"./change-password-form/form.js";import{PasswordResetForm}from"./form/form.js";export const PasswordResetView=async({searchParams})=>{const[{isEmail,captcha},{token,userId}]=await Promise.all([getMiddlewareApi(),searchParams]);if(!isEmail)notFound();return _jsx("div",{className:"mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col justify-center px-4 py-16",children:_jsx(Card,{children:token&&userId?_jsx(I18nProvider,{namespaces:["core.auth.sign_up","core.auth.change_password"],children:_jsx(ChangePasswordForm,{token:token,userId:userId})}):_jsx(I18nProvider,{namespaces:["core.auth.sign_up","core.auth.reset_password"],children:_jsx(PasswordResetForm,{captcha:captcha})})})})};
|