@vitnode/core 1.2.0-canary.60 → 1.2.0-canary.62

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 (274) 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.js +1 -93
  22. package/dist/src/api/middlewares/rate-limiter.middleware.js +1 -32
  23. package/dist/src/api/models/device.js +1 -61
  24. package/dist/src/api/models/email.js +1 -76
  25. package/dist/src/api/models/password.js +1 -36
  26. package/dist/src/api/models/session-admin.js +1 -106
  27. package/dist/src/api/models/session.js +1 -85
  28. package/dist/src/api/models/sso.js +1 -120
  29. package/dist/src/api/models/user/get-user-by-id.js +1 -19
  30. package/dist/src/api/models/user/sign-in-with-passwords.js +1 -22
  31. package/dist/src/api/models/user/sign-up.js +1 -73
  32. package/dist/src/api/models/user.js +1 -8
  33. package/dist/src/api/modules/admin/admin.module.js +1 -19
  34. package/dist/src/api/modules/admin/advanced/advanced.admin.module.js +1 -11
  35. package/dist/src/api/modules/admin/advanced/cron/cron.admin.module.js +1 -12
  36. package/dist/src/api/modules/admin/advanced/cron/routes/get.route.js +1 -66
  37. package/dist/src/api/modules/admin/advanced/cron/routes/run.route.js +1 -95
  38. package/dist/src/api/modules/admin/debug/debug.admin.module.js +1 -10
  39. package/dist/src/api/modules/admin/debug/routes/logs.route.js +1 -94
  40. package/dist/src/api/modules/admin/routes/session.route.js +1 -47
  41. package/dist/src/api/modules/admin/users/routes/list.route.js +1 -79
  42. package/dist/src/api/modules/admin/users/routes/users.route.js +1 -84
  43. package/dist/src/api/modules/admin/users/users.admin.module.js +1 -10
  44. package/dist/src/api/modules/cron/cron/clean.cron.js +1 -24
  45. package/dist/src/api/modules/cron/cron.module.js +1 -14
  46. package/dist/src/api/modules/cron/helpers/process-cron-jobs.d.ts.map +1 -1
  47. package/dist/src/api/modules/cron/helpers/process-cron-jobs.js +1 -76
  48. package/dist/src/api/modules/cron/routes/cron.route.js +1 -101
  49. package/dist/src/api/modules/middleware/middleware.module.js +1 -10
  50. package/dist/src/api/modules/middleware/route.js +1 -49
  51. package/dist/src/api/modules/users/avatar-color.js +1 -43
  52. package/dist/src/api/modules/users/routes/change-password.route.js +1 -58
  53. package/dist/src/api/modules/users/routes/reset-passowrd.route.js +1 -91
  54. package/dist/src/api/modules/users/routes/session.route.js +1 -46
  55. package/dist/src/api/modules/users/routes/sign-in.route.js +1 -71
  56. package/dist/src/api/modules/users/routes/sign-out.route.js +1 -43
  57. package/dist/src/api/modules/users/routes/sign-up.route.js +1 -77
  58. package/dist/src/api/modules/users/routes/test.route.js +1 -33
  59. package/dist/src/api/modules/users/sso/routes/callback.route.js +1 -52
  60. package/dist/src/api/modules/users/sso/routes/create-url.route.js +1 -36
  61. package/dist/src/api/modules/users/sso/sso.module.js +1 -12
  62. package/dist/src/api/modules/users/users.module.js +1 -26
  63. package/dist/src/api/plugin.js +1 -15
  64. package/dist/src/app/login/page.js +1 -16
  65. package/dist/src/app/login/reset-password/page.js +1 -18
  66. package/dist/src/app/login/sso/[providerId]/page.js +1 -10
  67. package/dist/src/app/register/page.js +1 -16
  68. package/dist/src/app_admin/core/advanced/cron/page.js +1 -42
  69. package/dist/src/app_admin/core/debug/page.js +1 -45
  70. package/dist/src/app_admin/core/page.js +1 -5
  71. package/dist/src/app_admin/core/test/page.js +1 -5
  72. package/dist/src/app_admin/core/users/page.js +1 -38
  73. package/dist/src/components/avatar.js +1 -14
  74. package/dist/src/components/confirm-action/confirm-action-alert-dialog.js +1 -42
  75. package/dist/src/components/confirm-action/content.js +1 -31
  76. package/dist/src/components/date-format.js +1 -41
  77. package/dist/src/components/form/auto-form.js +1 -103
  78. package/dist/src/components/form/common/desc.js +1 -9
  79. package/dist/src/components/form/common/label.js +1 -18
  80. package/dist/src/components/form/fields/checkbox.js +1 -37
  81. package/dist/src/components/form/fields/combobox-async.js +1 -123
  82. package/dist/src/components/form/fields/combobox.js +1 -87
  83. package/dist/src/components/form/fields/input.js +1 -39
  84. package/dist/src/components/form/fields/radio-group.js +1 -50
  85. package/dist/src/components/form/fields/select.js +1 -58
  86. package/dist/src/components/form/fields/switch.js +1 -36
  87. package/dist/src/components/form/fields/textarea.js +1 -36
  88. package/dist/src/components/i18n-provider.js +1 -43
  89. package/dist/src/components/logo-vitnode.js +1 -119
  90. package/dist/src/components/switchers/langs/language-switcher.js +1 -47
  91. package/dist/src/components/switchers/themes/theme-switcher.js +1 -28
  92. package/dist/src/components/table/content.js +1 -81
  93. package/dist/src/components/table/data-table.js +1 -68
  94. package/dist/src/components/table/order-table-head.js +1 -50
  95. package/dist/src/components/table/pagination.js +1 -122
  96. package/dist/src/components/tiptap/extension.js +1 -33
  97. package/dist/src/components/tiptap/toolbar/actions/alignment-action.js +1 -91
  98. package/dist/src/components/tiptap/toolbar/actions/bold-action.js +1 -39
  99. package/dist/src/components/tiptap/toolbar/actions/headings-action.js +1 -93
  100. package/dist/src/components/tiptap/toolbar/actions/italic-action.js +1 -38
  101. package/dist/src/components/tiptap/toolbar/actions/list-action.js +1 -61
  102. package/dist/src/components/tiptap/toolbar/actions/text-format-more/text-format-more.js +1 -59
  103. package/dist/src/components/tiptap/toolbar/actions/underline-action.js +1 -38
  104. package/dist/src/components/tiptap/toolbar/actions/undo-redo-actions.js +1 -63
  105. package/dist/src/components/tiptap/toolbar/actions/utils/tooltip-shortcut.js +1 -11
  106. package/dist/src/components/tiptap/toolbar/tiptap-toolbar.js +1 -55
  107. package/dist/src/components/tiptap/toolbar/use-toolbar-editor.js +1 -5
  108. package/dist/src/components/ui/accordion.js +1 -46
  109. package/dist/src/components/ui/alert-dialog.js +1 -123
  110. package/dist/src/components/ui/alert.js +1 -39
  111. package/dist/src/components/ui/badge.js +1 -28
  112. package/dist/src/components/ui/button-client.js +1 -57
  113. package/dist/src/components/ui/button.js +1 -32
  114. package/dist/src/components/ui/card.js +1 -52
  115. package/dist/src/components/ui/checkbox.js +1 -20
  116. package/dist/src/components/ui/collapsible.js +1 -22
  117. package/dist/src/components/ui/command.js +1 -98
  118. package/dist/src/components/ui/context-menu.js +1 -140
  119. package/dist/src/components/ui/dialog.js +1 -189
  120. package/dist/src/components/ui/drawer.js +1 -83
  121. package/dist/src/components/ui/dropdown-menu.js +1 -141
  122. package/dist/src/components/ui/editor-content.js +1 -10
  123. package/dist/src/components/ui/editor.js +1 -35
  124. package/dist/src/components/ui/form.js +1 -148
  125. package/dist/src/components/ui/header-content.js +1 -30
  126. package/dist/src/components/ui/hover-card.js +1 -29
  127. package/dist/src/components/ui/input-otp.js +1 -48
  128. package/dist/src/components/ui/input.js +1 -11
  129. package/dist/src/components/ui/label.js +1 -12
  130. package/dist/src/components/ui/loader.js +1 -16
  131. package/dist/src/components/ui/menubar.js +1 -151
  132. package/dist/src/components/ui/navigation-menu.js +1 -82
  133. package/dist/src/components/ui/popover.js +1 -35
  134. package/dist/src/components/ui/progress.js +1 -19
  135. package/dist/src/components/ui/radio-group.js +1 -27
  136. package/dist/src/components/ui/scroll-area.js +1 -33
  137. package/dist/src/components/ui/select.js +1 -113
  138. package/dist/src/components/ui/separator.js +1 -14
  139. package/dist/src/components/ui/sheet.js +1 -92
  140. package/dist/src/components/ui/sidebar.js +1 -433
  141. package/dist/src/components/ui/skeleton.js +1 -10
  142. package/dist/src/components/ui/slider.js +1 -50
  143. package/dist/src/components/ui/sonner.js +1 -26
  144. package/dist/src/components/ui/switch.js +1 -16
  145. package/dist/src/components/ui/table.js +1 -63
  146. package/dist/src/components/ui/tabs.js +1 -33
  147. package/dist/src/components/ui/textarea.js +1 -10
  148. package/dist/src/components/ui/toggle-group.js +1 -45
  149. package/dist/src/components/ui/toggle.js +1 -34
  150. package/dist/src/components/ui/tooltip.js +1 -57
  151. package/dist/src/config.js +1 -4
  152. package/dist/src/database/admins.js +1 -74
  153. package/dist/src/database/cron.js +1 -22
  154. package/dist/src/database/languages.js +1 -52
  155. package/dist/src/database/logs.js +1 -34
  156. package/dist/src/database/moderators.js +1 -37
  157. package/dist/src/database/roles.js +1 -13
  158. package/dist/src/database/sessions.js +1 -60
  159. package/dist/src/database/users.js +1 -145
  160. package/dist/src/drizzle.config.js +1 -67
  161. package/dist/src/emails/default-template.js +1 -99
  162. package/dist/src/emails/reset-password.js +1 -132
  163. package/dist/src/emails/ui/button.js +1 -36
  164. package/dist/src/emails/ui/card.js +1 -39
  165. package/dist/src/hooks/use-before-unload.js +1 -30
  166. package/dist/src/hooks/use-captcha.js +1 -122
  167. package/dist/src/hooks/use-mobile.js +1 -16
  168. package/dist/src/lib/api/get-middleware-api.js +1 -13
  169. package/dist/src/lib/api/get-next-cron-run-date.js +1 -14
  170. package/dist/src/lib/api/get-next-cron-run-date.test.js +1 -55
  171. package/dist/src/lib/api/get-session-admin-api.js +1 -19
  172. package/dist/src/lib/api/get-session-api.js +1 -14
  173. package/dist/src/lib/api/should-cron-job-run.js +1 -16
  174. package/dist/src/lib/api/should-cron-job-run.test.js +1 -213
  175. package/dist/src/lib/api/validate-cron-schedule.d.ts +2 -0
  176. package/dist/src/lib/api/validate-cron-schedule.d.ts.map +1 -0
  177. package/dist/src/lib/api/validate-cron-schedule.js +1 -0
  178. package/dist/src/lib/api/validate-cron-schedule.test.d.ts +2 -0
  179. package/dist/src/lib/api/validate-cron-schedule.test.d.ts.map +1 -0
  180. package/dist/src/lib/api/validate-cron-schedule.test.js +1 -0
  181. package/dist/src/lib/colors.js +1 -140
  182. package/dist/src/lib/colors.test.js +1 -173
  183. package/dist/src/lib/config.js +1 -14
  184. package/dist/src/lib/ctrl-or-command-character.js +1 -5
  185. package/dist/src/lib/fetcher/cookie-from-string-to-object.js +1 -12
  186. package/dist/src/lib/fetcher/cookie-from-string-to-object.test.js +1 -78
  187. package/dist/src/lib/fetcher/core.js +3 -48
  188. package/dist/src/lib/fetcher/helpers-server.js +1 -18
  189. package/dist/src/lib/fetcher/helpers.js +1 -16
  190. package/dist/src/lib/fetcher/helpers.test.js +1 -37
  191. package/dist/src/lib/fetcher/types.js +1 -1
  192. package/dist/src/lib/fetcher-client.js +1 -17
  193. package/dist/src/lib/fetcher.js +1 -33
  194. package/dist/src/lib/helpers/auto-form.js +1 -98
  195. package/dist/src/lib/helpers/auto-form.test.js +1 -336
  196. package/dist/src/lib/navigation.js +1 -11
  197. package/dist/src/lib/plugin.js +1 -3
  198. package/dist/src/lib/special-characters.js +1 -4
  199. package/dist/src/lib/special-characters.test.js +1 -56
  200. package/dist/src/lib/utils.js +1 -5
  201. package/dist/src/locales/en.json +308 -0
  202. package/dist/src/tests/setup.js +1 -6
  203. package/dist/src/views/admin/layouts/admin-layout.js +1 -73
  204. package/dist/src/views/admin/layouts/sidebar/nav/item.js +1 -98
  205. package/dist/src/views/admin/layouts/sidebar/nav/nav.js +1 -60
  206. package/dist/src/views/admin/layouts/sidebar/sidebar.js +1 -28
  207. package/dist/src/views/admin/layouts/sidebar/sign-out.js +1 -14
  208. package/dist/src/views/admin/layouts/user-bar/client.js +1 -69
  209. package/dist/src/views/admin/layouts/user-bar/user-bar.js +1 -32
  210. package/dist/src/views/admin/sign-in/sign-in-admin-view.js +1 -27
  211. package/dist/src/views/admin/views/core/advanced/cron/cron-table-view.js +1 -97
  212. package/dist/src/views/admin/views/core/advanced/cron/run-action/mutation-api.js +1 -23
  213. package/dist/src/views/admin/views/core/advanced/cron/run-action/run-action.js +1 -38
  214. package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.js +1 -44
  215. package/dist/src/views/admin/views/core/debug/actions/clear-cache/clear-cache.js +1 -35
  216. package/dist/src/views/admin/views/core/debug/actions/clear-cache/mutation-api.js +1 -5
  217. package/dist/src/views/admin/views/core/debug/system-logs/actions/more/content.js +1 -281
  218. package/dist/src/views/admin/views/core/debug/system-logs/actions/more/more.js +1 -67
  219. package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-status.js +1 -14
  220. package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-type-log.js +1 -30
  221. package/dist/src/views/admin/views/core/debug/system-logs/system-logs-view.js +1 -96
  222. package/dist/src/views/admin/views/core/test.js +1 -161
  223. package/dist/src/views/admin/views/core/users/users-admin-view.js +1 -89
  224. package/dist/src/views/auth/password-reset/change-password-form/form.js +1 -48
  225. package/dist/src/views/auth/password-reset/change-password-form/mutation-api.js +1 -22
  226. package/dist/src/views/auth/password-reset/change-password-form/use-form.js +1 -36
  227. package/dist/src/views/auth/password-reset/form/form.js +1 -104
  228. package/dist/src/views/auth/password-reset/form/mutation-api.js +1 -21
  229. package/dist/src/views/auth/password-reset/form/use-form.js +1 -33
  230. package/dist/src/views/auth/password-reset/password-reset-view.js +1 -37
  231. package/dist/src/views/auth/sign-in/form/form.js +1 -64
  232. package/dist/src/views/auth/sign-in/form/mutation-api.js +1 -33
  233. package/dist/src/views/auth/sign-in/form/use-form.js +1 -38
  234. package/dist/src/views/auth/sign-in/sign-in-view.js +1 -61
  235. package/dist/src/views/auth/sign-up/components/password-input.js +1 -96
  236. package/dist/src/views/auth/sign-up/email-confirmation-view.js +1 -55
  237. package/dist/src/views/auth/sign-up/form/form.js +1 -89
  238. package/dist/src/views/auth/sign-up/form/mutation-api.js +1 -30
  239. package/dist/src/views/auth/sign-up/form/use-form.js +1 -70
  240. package/dist/src/views/auth/sign-up/sign-up-view.js +1 -65
  241. package/dist/src/views/auth/sign-up/wrapper.js +1 -22
  242. package/dist/src/views/auth/sso/buttons/client.js +1 -22
  243. package/dist/src/views/auth/sso/buttons/mutation-api.js +1 -24
  244. package/dist/src/views/auth/sso/buttons/sso-buttons.js +1 -56
  245. package/dist/src/views/auth/sso/callback/callback-sso-view.js +1 -32
  246. package/dist/src/views/auth/sso/callback/client/client.js +1 -68
  247. package/dist/src/views/auth/sso/callback/client/mutation-api.js +1 -32
  248. package/dist/src/views/error/back-button.js +1 -14
  249. package/dist/src/views/error/error-view.js +1 -58
  250. package/dist/src/views/error/global-error-view.js +1 -50
  251. package/dist/src/views/layouts/provider.js +1 -44
  252. package/dist/src/views/layouts/root-layout.js +1 -25
  253. package/dist/src/views/layouts/theme/header/header.js +1 -38
  254. package/dist/src/views/layouts/theme/header/user/auth/auth.js +1 -33
  255. package/dist/src/views/layouts/theme/header/user/auth/client.js +1 -47
  256. package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.js +1 -27
  257. package/dist/src/views/layouts/theme/header/user/user.js +1 -32
  258. package/dist/src/views/layouts/theme/layout.js +1 -16
  259. package/dist/src/vitnode.config.js +1 -42
  260. package/dist/tsconfig.tsbuildinfo +1 -1
  261. package/dist/tsup.config.js +18 -0
  262. package/dist/vitest.config.d.ts.map +1 -1
  263. package/dist/vitest.config.js +49 -0
  264. package/eslint.config.mjs +2 -0
  265. package/package.json +6 -10
  266. package/dist/src/api/adapters/cron/node-cron.adapter.d.ts +0 -3
  267. package/dist/src/api/adapters/cron/node-cron.adapter.d.ts.map +0 -1
  268. package/dist/src/api/adapters/cron/node-cron.adapter.js +0 -11
  269. package/dist/src/api/adapters/email/nodemailer.d.ts +0 -10
  270. package/dist/src/api/adapters/email/nodemailer.d.ts.map +0 -1
  271. package/dist/src/api/adapters/email/nodemailer.js +0 -30
  272. package/dist/src/api/adapters/email/resend.d.ts +0 -6
  273. package/dist/src/api/adapters/email/resend.d.ts.map +0 -1
  274. package/dist/src/api/adapters/email/resend.js +0 -21
@@ -1,22 +1 @@
1
- "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import React from "react";
4
- import { EmailConfirmationView } from "./email-confirmation-view.js";
5
- const WrapperSignUpContext = /*#__PURE__*/ React.createContext({
6
- setSendingEmail: ()=>{}
7
- });
8
- export const useWrapperSignUp = ()=>React.use(WrapperSignUpContext);
9
- export const WrapperSignUp = ({ children })=>{
10
- const [sendingEmail, setSendingEmail] = React.useState("");
11
- const contextValue = React.useMemo(()=>({
12
- setSendingEmail
13
- }), [
14
- setSendingEmail
15
- ]);
16
- return /*#__PURE__*/ _jsx(WrapperSignUpContext, {
17
- value: contextValue,
18
- children: sendingEmail ? /*#__PURE__*/ _jsx(EmailConfirmationView, {
19
- email: sendingEmail
20
- }) : children
21
- });
22
- };
1
+ "use client";import{jsx as _jsx}from"react/jsx-runtime";import React from"react";import{EmailConfirmationView}from"./email-confirmation-view.js";const WrapperSignUpContext=React.createContext({setSendingEmail:()=>{}});export const useWrapperSignUp=()=>React.use(WrapperSignUpContext);export const WrapperSignUp=({children})=>{const[sendingEmail,setSendingEmail]=React.useState("");const contextValue=React.useMemo(()=>({setSendingEmail}),[setSendingEmail]);return _jsx(WrapperSignUpContext,{value:contextValue,children:sendingEmail?_jsx(EmailConfirmationView,{email:sendingEmail}):children})};
@@ -1,22 +1 @@
1
- "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { useTranslations } from "next-intl";
4
- import { toast } from "sonner";
5
- import { Button } from "../../../../components/ui/button.js";
6
- import { mutationApi } from "./mutation-api.js";
7
- export const ButtonSSOButtons = ({ children, providerId })=>{
8
- const tErrors = useTranslations("core.global.errors");
9
- return /*#__PURE__*/ _jsx(Button, {
10
- className: "bg-card w-[calc(50%-0.5rem)]",
11
- onClick: async ()=>{
12
- const mutation = await mutationApi(providerId);
13
- if (mutation?.message) {
14
- toast.error(tErrors("title"), {
15
- description: tErrors("internal_server_error")
16
- });
17
- }
18
- },
19
- variant: "outline",
20
- children: children
21
- });
22
- };
1
+ "use client";import{jsx as _jsx}from"react/jsx-runtime";import{useTranslations}from"next-intl";import{toast}from"sonner";import{Button}from"../../../../components/ui/button.js";import{mutationApi}from"./mutation-api.js";export const ButtonSSOButtons=({children,providerId})=>{const tErrors=useTranslations("core.global.errors");return _jsx(Button,{className:"bg-card w-[calc(50%-0.5rem)]",onClick:async()=>{const mutation=await mutationApi(providerId);if(mutation?.message){toast.error(tErrors("title"),{description:tErrors("internal_server_error")})}},variant:"outline",children:children})};
@@ -1,24 +1 @@
1
- "use server";
2
- import { usersModule } from "../../../../api/modules/users/users.module.js";
3
- import { fetcher } from "../../../../lib/fetcher.js";
4
- import { redirect } from "../../../../lib/navigation.js";
5
- export const mutationApi = async (providerId)=>{
6
- const res = await fetcher(usersModule, {
7
- path: "/{providerId}",
8
- method: "post",
9
- module: "users/sso",
10
- args: {
11
- params: {
12
- providerId
13
- }
14
- },
15
- allowSaveCookies: true
16
- });
17
- if (res.status !== 200) {
18
- return {
19
- message: "Something is wrong"
20
- };
21
- }
22
- const data = await res.json();
23
- await redirect(data.url);
24
- };
1
+ "use server";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 providerId=>{const res=await fetcher(usersModule,{path:"/{providerId}",method:"post",module:"users/sso",args:{params:{providerId}},allowSaveCookies:true});if(res.status!==200){return{message:"Something is wrong"}}const data=await res.json();await redirect(data.url)};
@@ -1,56 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { getTranslations } from "next-intl/server";
3
- import { Skeleton } from "../../../../components/ui/skeleton.js";
4
- import { getMiddlewareApi } from "../../../../lib/api/get-middleware-api.js";
5
- import { ButtonSSOButtons } from "./client.js";
6
- export const SSOButtonsSkeleton = ()=>{
7
- return /*#__PURE__*/ _jsxs("div", {
8
- className: "flex gap-4",
9
- children: [
10
- /*#__PURE__*/ _jsx(Skeleton, {
11
- className: "mt-6 h-8 w-full"
12
- }),
13
- /*#__PURE__*/ _jsx(Skeleton, {
14
- className: "mt-6 h-8 w-full"
15
- })
16
- ]
17
- });
18
- };
19
- export const SSOButtons = async ()=>{
20
- const [t, { sso }] = await Promise.all([
21
- getTranslations("core.auth.sso"),
22
- getMiddlewareApi()
23
- ]);
24
- if (!sso.length) {
25
- return null;
26
- }
27
- return /*#__PURE__*/ _jsxs(_Fragment, {
28
- children: [
29
- /*#__PURE__*/ _jsxs("div", {
30
- className: "relative my-6",
31
- children: [
32
- /*#__PURE__*/ _jsx("div", {
33
- className: "absolute inset-0 flex items-center",
34
- children: /*#__PURE__*/ _jsx("span", {
35
- className: "w-full border-t"
36
- })
37
- }),
38
- /*#__PURE__*/ _jsx("div", {
39
- className: "relative flex justify-center text-xs",
40
- children: /*#__PURE__*/ _jsx("span", {
41
- className: "bg-card text-muted-foreground px-4",
42
- children: t("or")
43
- })
44
- })
45
- ]
46
- }),
47
- /*#__PURE__*/ _jsx("div", {
48
- className: "flex flex-wrap items-center justify-center gap-4",
49
- children: sso.map((provider)=>/*#__PURE__*/ _jsx(ButtonSSOButtons, {
50
- providerId: provider.id,
51
- children: provider.name
52
- }, provider.id))
53
- })
54
- ]
55
- });
56
- };
1
+ import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{getTranslations}from"next-intl/server";import{Skeleton}from"../../../../components/ui/skeleton.js";import{getMiddlewareApi}from"../../../../lib/api/get-middleware-api.js";import{ButtonSSOButtons}from"./client.js";export const SSOButtonsSkeleton=()=>{return _jsxs("div",{className:"flex gap-4",children:[_jsx(Skeleton,{className:"mt-6 h-8 w-full"}),_jsx(Skeleton,{className:"mt-6 h-8 w-full"})]})};export const SSOButtons=async()=>{const[t,{sso}]=await Promise.all([getTranslations("core.auth.sso"),getMiddlewareApi()]);if(!sso.length){return null}return _jsxs(_Fragment,{children:[_jsxs("div",{className:"relative my-6",children:[_jsx("div",{className:"absolute inset-0 flex items-center",children:_jsx("span",{className:"w-full border-t"})}),_jsx("div",{className:"relative flex justify-center text-xs",children:_jsx("span",{className:"bg-card text-muted-foreground px-4",children:t("or")})})]}),_jsx("div",{className:"flex flex-wrap items-center justify-center gap-4",children:sso.map(provider=>_jsx(ButtonSSOButtons,{providerId:provider.id,children:provider.name},provider.id))})]})};
@@ -1,32 +1 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { getTranslations } from "next-intl/server";
3
- import { I18nProvider } from "../../../../components/i18n-provider.js";
4
- import { ErrorView } from "../../../error/error-view.js";
5
- import { getMiddlewareApi } from "../../../../lib/api/get-middleware-api.js";
6
- import { ClientCallbackSSO } from "./client/client.js";
7
- export const CallbackSSOView = async ({ providerId, searchParams: { code, error, state } })=>{
8
- const [t, { sso }] = await Promise.all([
9
- getTranslations("core.auth.sso"),
10
- getMiddlewareApi()
11
- ]);
12
- if (error === "access_denied") {
13
- return /*#__PURE__*/ _jsx(ErrorView, {
14
- code: 403,
15
- customDescription: t("access_denied")
16
- });
17
- }
18
- return /*#__PURE__*/ _jsx(I18nProvider, {
19
- namespaces: [
20
- "core.auth.sso"
21
- ],
22
- children: error === "access_denied" ? /*#__PURE__*/ _jsx(ErrorView, {
23
- code: 403,
24
- customDescription: t("access_denied")
25
- }) : /*#__PURE__*/ _jsx(ClientCallbackSSO, {
26
- code: code,
27
- providerId: providerId,
28
- sso: sso,
29
- state: state
30
- })
31
- });
32
- };
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{getTranslations}from"next-intl/server";import{I18nProvider}from"../../../../components/i18n-provider.js";import{ErrorView}from"../../../error/error-view.js";import{getMiddlewareApi}from"../../../../lib/api/get-middleware-api.js";import{ClientCallbackSSO}from"./client/client.js";export const CallbackSSOView=async({providerId,searchParams:{code,error,state}})=>{const[t,{sso}]=await Promise.all([getTranslations("core.auth.sso"),getMiddlewareApi()]);if(error==="access_denied"){return _jsx(ErrorView,{code:403,customDescription:t("access_denied")})}return _jsx(I18nProvider,{namespaces:["core.auth.sso"],children:error==="access_denied"?_jsx(ErrorView,{code:403,customDescription:t("access_denied")}):_jsx(ClientCallbackSSO,{code:code,providerId:providerId,sso:sso,state:state})})};
@@ -1,68 +1 @@
1
- "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { useQuery } from "@tanstack/react-query";
4
- import { useTranslations } from "next-intl";
5
- import { Loader } from "../../../../../components/ui/loader.js";
6
- import { Link, useRouter } from "../../../../../lib/navigation.js";
7
- import { ErrorView } from "../../../../error/error-view.js";
8
- import { Button } from "../../../../../components/ui/button.js";
9
- import { mutationApi } from "./mutation-api.js";
10
- export const ClientCallbackSSO = ({ providerId, code, state, sso })=>{
11
- const t = useTranslations("core.auth.sso");
12
- const { replace } = useRouter();
13
- const { isError, error } = useQuery({
14
- queryKey: [
15
- "core.auth.sso.callback.sign-up",
16
- providerId,
17
- code
18
- ],
19
- queryFn: async ()=>{
20
- const mutation = await mutationApi({
21
- providerId,
22
- code,
23
- state
24
- });
25
- if (mutation?.error) {
26
- throw new Error(mutation.error);
27
- }
28
- replace("/");
29
- return "";
30
- },
31
- retry: false
32
- });
33
- const provider = sso.find((p)=>p.id === providerId);
34
- if (error?.message === "Email already exists") {
35
- return /*#__PURE__*/ _jsx(ErrorView, {
36
- code: 409,
37
- customActions: /*#__PURE__*/ _jsx(Button, {
38
- asChild: true,
39
- size: "lg",
40
- children: /*#__PURE__*/ _jsx(Link, {
41
- href: "/login",
42
- children: t("email_exists.sign_in")
43
- })
44
- }),
45
- customDescription: t.rich("email_exists.desc", {
46
- provider: ()=>/*#__PURE__*/ _jsx("span", {
47
- className: "font-semibold",
48
- children: provider?.name ?? providerId
49
- })
50
- }),
51
- customTitle: t.rich("email_exists.title", {
52
- provider: ()=>/*#__PURE__*/ _jsx("span", {
53
- className: "font-semibold",
54
- children: provider?.name ?? providerId
55
- })
56
- })
57
- });
58
- }
59
- if (isError) {
60
- return /*#__PURE__*/ _jsx(ErrorView, {
61
- code: 500
62
- });
63
- }
64
- return /*#__PURE__*/ _jsx("div", {
65
- className: "container mx-auto flex items-center justify-center p-4",
66
- children: /*#__PURE__*/ _jsx(Loader, {})
67
- });
68
- };
1
+ "use client";import{jsx as _jsx}from"react/jsx-runtime";import{useQuery}from"@tanstack/react-query";import{useTranslations}from"next-intl";import{Loader}from"../../../../../components/ui/loader.js";import{Link,useRouter}from"../../../../../lib/navigation.js";import{ErrorView}from"../../../../error/error-view.js";import{Button}from"../../../../../components/ui/button.js";import{mutationApi}from"./mutation-api.js";export const ClientCallbackSSO=({providerId,code,state,sso})=>{const t=useTranslations("core.auth.sso");const{replace}=useRouter();const{isError,error}=useQuery({queryKey:["core.auth.sso.callback.sign-up",providerId,code],queryFn:async()=>{const mutation=await mutationApi({providerId,code,state});if(mutation?.error){throw new Error(mutation.error)}replace("/");return""},retry:false});const provider=sso.find(p=>p.id===providerId);if(error?.message==="Email already exists"){return _jsx(ErrorView,{code:409,customActions:_jsx(Button,{asChild:true,size:"lg",children:_jsx(Link,{href:"/login",children:t("email_exists.sign_in")})}),customDescription:t.rich("email_exists.desc",{provider:()=>_jsx("span",{className:"font-semibold",children:provider?.name??providerId})}),customTitle:t.rich("email_exists.title",{provider:()=>_jsx("span",{className:"font-semibold",children:provider?.name??providerId})})})}if(isError){return _jsx(ErrorView,{code:500})}return _jsx("div",{className:"container mx-auto flex items-center justify-center p-4",children:_jsx(Loader,{})})};
@@ -1,32 +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
- export const mutationApi = async ({ code, providerId, state })=>{
6
- const res = await fetcher(usersModule, {
7
- path: "/{providerId}/callback",
8
- method: "get",
9
- module: "users/sso",
10
- allowSaveCookies: true,
11
- args: {
12
- params: {
13
- providerId
14
- },
15
- query: {
16
- code,
17
- state
18
- }
19
- }
20
- });
21
- if (res.status === 409) {
22
- return {
23
- error: "Email already exists"
24
- };
25
- }
26
- if (res.status !== 200) {
27
- return {
28
- error: "Something went wrong"
29
- };
30
- }
31
- revalidatePath("/[locale]/(main)", "layout");
32
- };
1
+ "use server";import{revalidatePath}from"next/cache";import{usersModule}from"../../../../../api/modules/users/users.module.js";import{fetcher}from"../../../../../lib/fetcher.js";export const mutationApi=async({code,providerId,state})=>{const res=await fetcher(usersModule,{path:"/{providerId}/callback",method:"get",module:"users/sso",allowSaveCookies:true,args:{params:{providerId},query:{code,state}}});if(res.status===409){return{error:"Email already exists"}}if(res.status!==200){return{error:"Something went wrong"}}revalidatePath("/[locale]/(main)","layout")};
@@ -1,14 +1 @@
1
- "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { Button } from "../../components/ui/button.js";
4
- import { useRouter } from "../../lib/navigation.js";
5
- export const BackButtonNotFound = ({ children, className })=>{
6
- const { back } = useRouter();
7
- return /*#__PURE__*/ _jsx(Button, {
8
- className: className,
9
- onClick: back,
10
- size: "lg",
11
- variant: "ghost",
12
- children: children
13
- });
14
- };
1
+ "use client";import{jsx as _jsx}from"react/jsx-runtime";import{Button}from"../../components/ui/button.js";import{useRouter}from"../../lib/navigation.js";export const BackButtonNotFound=({children,className})=>{const{back}=useRouter();return _jsx(Button,{className:className,onClick:back,size:"lg",variant:"ghost",children:children})};
@@ -1,58 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { ArrowLeft, HomeIcon } from "lucide-react";
3
- import { useTranslations } from "next-intl";
4
- import { buttonVariants } from "../../components/ui/button.js";
5
- import { Link } from "../../lib/navigation.js";
6
- import { cn } from "../../lib/utils.js";
7
- import { BackButtonNotFound } from "./back-button.js";
8
- export const ErrorView = ({ code, customDescription, customTitle, customActions })=>{
9
- const t = useTranslations("core.global");
10
- return /*#__PURE__*/ _jsx("div", {
11
- className: "flex flex-col items-center justify-center px-4 py-10 sm:py-20",
12
- children: /*#__PURE__*/ _jsxs("div", {
13
- className: "max-w-md space-y-6 text-center",
14
- children: [
15
- /*#__PURE__*/ _jsxs("div", {
16
- className: "space-y-2",
17
- children: [
18
- /*#__PURE__*/ _jsx("h1", {
19
- className: "text-primary text-8xl font-bold",
20
- children: code
21
- }),
22
- /*#__PURE__*/ _jsx("h2", {
23
- className: "text-2xl font-medium",
24
- children: customTitle ?? t(`errors.${code}.title`)
25
- }),
26
- /*#__PURE__*/ _jsx("p", {
27
- className: "text-muted-foreground",
28
- children: customDescription ?? t(`errors.${code}.desc`)
29
- })
30
- ]
31
- }),
32
- /*#__PURE__*/ _jsx("div", {
33
- className: "flex flex-col items-center justify-center gap-3 sm:flex-row",
34
- children: customActions ?? /*#__PURE__*/ _jsxs(_Fragment, {
35
- children: [
36
- /*#__PURE__*/ _jsxs(BackButtonNotFound, {
37
- children: [
38
- /*#__PURE__*/ _jsx(ArrowLeft, {}),
39
- t("go_back")
40
- ]
41
- }),
42
- /*#__PURE__*/ _jsxs(Link, {
43
- className: cn(buttonVariants({
44
- size: "lg"
45
- })),
46
- href: "/",
47
- children: [
48
- /*#__PURE__*/ _jsx(HomeIcon, {}),
49
- t("back_home")
50
- ]
51
- })
52
- ]
53
- })
54
- })
55
- ]
56
- })
57
- });
58
- };
1
+ import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{ArrowLeft,HomeIcon}from"lucide-react";import{useTranslations}from"next-intl";import{buttonVariants}from"../../components/ui/button.js";import{Link}from"../../lib/navigation.js";import{cn}from"../../lib/utils.js";import{BackButtonNotFound}from"./back-button.js";export const ErrorView=({code,customDescription,customTitle,customActions})=>{const t=useTranslations("core.global");return _jsx("div",{className:"flex flex-col items-center justify-center px-4 py-10 sm:py-20",children:_jsxs("div",{className:"max-w-md space-y-6 text-center",children:[_jsxs("div",{className:"space-y-2",children:[_jsx("h1",{className:"text-primary text-8xl font-bold",children:code}),_jsx("h2",{className:"text-2xl font-medium",children:customTitle??t(`errors.${code}.title`)}),_jsx("p",{className:"text-muted-foreground",children:customDescription??t(`errors.${code}.desc`)})]}),_jsx("div",{className:"flex flex-col items-center justify-center gap-3 sm:flex-row",children:customActions??_jsxs(_Fragment,{children:[_jsxs(BackButtonNotFound,{children:[_jsx(ArrowLeft,{}),t("go_back")]}),_jsxs(Link,{className:cn(buttonVariants({size:"lg"})),href:"/",children:[_jsx(HomeIcon,{}),t("back_home")]})]})})]})})};
@@ -1,50 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ThemeProvider } from "next-themes";
3
- // eslint-disable-next-line no-restricted-imports
4
- import Link from "next/link";
5
- import { LogoVitNode } from "../../components/logo-vitnode.js";
6
- import { Card, CardContent } from "../../components/ui/card.js";
7
- export const metadata = {
8
- title: "Error 500!"
9
- };
10
- export const GlobalErrorView = ({ className })=>{
11
- return /*#__PURE__*/ _jsx("html", {
12
- lang: "en",
13
- suppressHydrationWarning: true,
14
- children: /*#__PURE__*/ _jsx("body", {
15
- className: className,
16
- children: /*#__PURE__*/ _jsx(ThemeProvider, {
17
- attribute: "class",
18
- disableTransitionOnChange: true,
19
- enableSystem: true,
20
- children: /*#__PURE__*/ _jsx("div", {
21
- className: "bg-background flex min-h-screen flex-col items-center justify-center p-4",
22
- children: /*#__PURE__*/ _jsxs("div", {
23
- className: "container mx-auto flex w-full max-w-md flex-col items-center justify-center gap-6 text-center",
24
- children: [
25
- /*#__PURE__*/ _jsx(Link, {
26
- href: "/",
27
- children: /*#__PURE__*/ _jsx(LogoVitNode, {
28
- className: "mb-4 h-12 w-auto"
29
- })
30
- }),
31
- /*#__PURE__*/ _jsx("h1", {
32
- className: "text-3xl font-semibold tracking-tight",
33
- children: "Oops! Something went wrong."
34
- }),
35
- /*#__PURE__*/ _jsx(Card, {
36
- className: "w-full",
37
- children: /*#__PURE__*/ _jsx(CardContent, {
38
- children: /*#__PURE__*/ _jsx("p", {
39
- className: "text-muted-foreground",
40
- children: "An unexpected error occurred. Please try refreshing the page or come back later."
41
- })
42
- })
43
- })
44
- ]
45
- })
46
- })
47
- })
48
- })
49
- });
50
- };
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{ThemeProvider}from"next-themes";import Link from"next/link";import{LogoVitNode}from"../../components/logo-vitnode.js";import{Card,CardContent}from"../../components/ui/card.js";export const metadata={title:"Error 500!"};export const GlobalErrorView=({className})=>{return _jsx("html",{lang:"en",suppressHydrationWarning:true,children:_jsx("body",{className:className,children:_jsx(ThemeProvider,{attribute:"class",disableTransitionOnChange:true,enableSystem:true,children:_jsx("div",{className:"bg-background flex min-h-screen flex-col items-center justify-center p-4",children:_jsxs("div",{className:"container mx-auto flex w-full max-w-md flex-col items-center justify-center gap-6 text-center",children:[_jsx(Link,{href:"/",children:_jsx(LogoVitNode,{className:"mb-4 h-12 w-auto"})}),_jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Oops! Something went wrong."}),_jsx(Card,{className:"w-full",children:_jsx(CardContent,{children:_jsx("p",{className:"text-muted-foreground",children:"An unexpected error occurred. Please try refreshing the page or come back later."})})})]})})})})})};
@@ -1,44 +1 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
4
- import { ThemeProvider } from "next-themes";
5
- import React from "react";
6
- import { scan } from "react-scan";
7
- import { CONFIG } from "../../lib/config.js";
8
- import { Toaster } from "../../components/ui/sonner.js";
9
- export const RootProvider = ({ children, theme, toaster, debug })=>{
10
- React.useEffect(()=>{
11
- if (!(debug && CONFIG.node_development)) return;
12
- scan({
13
- enabled: true
14
- });
15
- }, [
16
- debug
17
- ]);
18
- // eslint-disable-next-line @eslint-react/naming-convention/use-state
19
- const [queryClient] = React.useState(()=>new QueryClient({
20
- defaultOptions: {
21
- queries: {
22
- refetchOnWindowFocus: false,
23
- refetchOnMount: false
24
- }
25
- }
26
- }));
27
- return /*#__PURE__*/ _jsx(QueryClientProvider, {
28
- client: queryClient,
29
- children: /*#__PURE__*/ _jsxs(ThemeProvider, {
30
- attribute: "class",
31
- disableTransitionOnChange: true,
32
- enableSystem: true,
33
- ...theme,
34
- children: [
35
- /*#__PURE__*/ _jsx(Toaster, {
36
- closeButton: true,
37
- position: toaster?.position ?? "top-center",
38
- ...toaster
39
- }),
40
- children
41
- ]
42
- })
43
- });
44
- };
1
+ "use client";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{QueryClient,QueryClientProvider}from"@tanstack/react-query";import{ThemeProvider}from"next-themes";import React from"react";import{scan}from"react-scan";import{CONFIG}from"../../lib/config.js";import{Toaster}from"../../components/ui/sonner.js";export const RootProvider=({children,theme,toaster,debug})=>{React.useEffect(()=>{if(!(debug&&CONFIG.node_development))return;scan({enabled:true})},[debug]);const[queryClient]=React.useState(()=>new QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:false,refetchOnMount:false}}}));return _jsx(QueryClientProvider,{client:queryClient,children:_jsxs(ThemeProvider,{attribute:"class",disableTransitionOnChange:true,enableSystem:true,...theme,children:[_jsx(Toaster,{closeButton:true,position:toaster?.position??"top-center",...toaster}),children]})})};
@@ -1,25 +1 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { setRequestLocale } from "next-intl/server";
3
- import { I18nProvider } from "../../components/i18n-provider.js";
4
- import { RootProvider } from "./provider.js";
5
- export const generateMetadataRootLayout = ({ metadata: { title, shortTitle } })=>{
6
- return {
7
- title: {
8
- default: title,
9
- template: `%s - ${shortTitle ?? title}`
10
- },
11
- description: "Generated by create next app"
12
- };
13
- };
14
- export const RootLayout = async ({ children, params, config })=>{
15
- const { locale } = await params;
16
- setRequestLocale(locale);
17
- return /*#__PURE__*/ _jsx(I18nProvider, {
18
- namespaces: [],
19
- children: /*#__PURE__*/ _jsx(RootProvider, {
20
- debug: config.debug,
21
- theme: config.theme,
22
- children: children
23
- })
24
- });
25
- };
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{setRequestLocale}from"next-intl/server";import{I18nProvider}from"../../components/i18n-provider.js";import{RootProvider}from"./provider.js";export const generateMetadataRootLayout=({metadata:{title,shortTitle}})=>{return{title:{default:title,template:`%s - ${shortTitle??title}`},description:"Generated by create next app"}};export const RootLayout=async({children,params,config})=>{const{locale}=await params;setRequestLocale(locale);return _jsx(I18nProvider,{namespaces:[],children:_jsx(RootProvider,{debug:config.debug,theme:config.theme,children:children})})};
@@ -1,38 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React from "react";
3
- import { LanguageSwitcher } from "../../../../components/switchers/langs/language-switcher.js";
4
- import { ThemeSwitcher } from "../../../../components/switchers/themes/theme-switcher.js";
5
- import { Skeleton } from "../../../../components/ui/skeleton.js";
6
- import { Link } from "../../../../lib/navigation.js";
7
- import { cn } from "../../../../lib/utils.js";
8
- import { UserHeader } from "./user/user.js";
9
- export const HeaderLayout = ({ logo, className, vitNodeConfig, ...props })=>{
10
- return /*#__PURE__*/ _jsx("header", {
11
- className: cn("sticky top-0 z-20 w-full sm:top-2 sm:mb-2", className),
12
- ...props,
13
- children: /*#__PURE__*/ _jsxs("div", {
14
- className: "dark:bg-background/75 bg-card/75 container mx-auto flex h-14 items-center border-b px-4 py-2 backdrop-blur sm:rounded-lg sm:border sm:shadow-sm",
15
- children: [
16
- /*#__PURE__*/ _jsx(Link, {
17
- href: "/",
18
- children: logo
19
- }),
20
- /*#__PURE__*/ _jsxs("div", {
21
- className: "ml-auto flex items-center gap-2",
22
- children: [
23
- vitNodeConfig.i18n.locales.length > 1 && /*#__PURE__*/ _jsx(LanguageSwitcher, {
24
- locales: vitNodeConfig.i18n.locales
25
- }),
26
- /*#__PURE__*/ _jsx(ThemeSwitcher, {}),
27
- /*#__PURE__*/ _jsx(React.Suspense, {
28
- fallback: /*#__PURE__*/ _jsx(Skeleton, {
29
- className: "h-9 w-32"
30
- }),
31
- children: /*#__PURE__*/ _jsx(UserHeader, {})
32
- })
33
- ]
34
- })
35
- ]
36
- })
37
- });
38
- };
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import React from"react";import{LanguageSwitcher}from"../../../../components/switchers/langs/language-switcher.js";import{ThemeSwitcher}from"../../../../components/switchers/themes/theme-switcher.js";import{Skeleton}from"../../../../components/ui/skeleton.js";import{Link}from"../../../../lib/navigation.js";import{cn}from"../../../../lib/utils.js";import{UserHeader}from"./user/user.js";export const HeaderLayout=({logo,className,vitNodeConfig,...props})=>{return _jsx("header",{className:cn("sticky top-0 z-20 w-full sm:top-2 sm:mb-2",className),...props,children:_jsxs("div",{className:"dark:bg-background/75 bg-card/75 container mx-auto flex h-14 items-center border-b px-4 py-2 backdrop-blur sm:rounded-lg sm:border sm:shadow-sm",children:[_jsx(Link,{href:"/",children:logo}),_jsxs("div",{className:"ml-auto flex items-center gap-2",children:[vitNodeConfig.i18n.locales.length>1&&_jsx(LanguageSwitcher,{locales:vitNodeConfig.i18n.locales}),_jsx(ThemeSwitcher,{}),_jsx(React.Suspense,{fallback:_jsx(Skeleton,{className:"h-9 w-32"}),children:_jsx(UserHeader,{})})]})]})})};
@@ -1,33 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Avatar } from "../../../../../../components/avatar.js";
3
- import { Button } from "../../../../../../components/ui/button.js";
4
- import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from "../../../../../../components/ui/dropdown-menu.js";
5
- import { getSessionApi } from "../../../../../../lib/api/get-session-api.js";
6
- import { ClientAuthUserHeader } from "./client.js";
7
- export const AuthUserHeader = async ()=>{
8
- const { user } = await getSessionApi();
9
- if (!user) return null;
10
- return /*#__PURE__*/ _jsxs(DropdownMenu, {
11
- children: [
12
- /*#__PURE__*/ _jsx(DropdownMenuTrigger, {
13
- asChild: true,
14
- children: /*#__PURE__*/ _jsx(Button, {
15
- "aria-label": user.name,
16
- size: "icon",
17
- variant: "ghost",
18
- children: /*#__PURE__*/ _jsx(Avatar, {
19
- size: 24,
20
- user: user
21
- })
22
- })
23
- }),
24
- /*#__PURE__*/ _jsx(DropdownMenuContent, {
25
- align: "end",
26
- className: "w-64 p-2",
27
- children: /*#__PURE__*/ _jsx(ClientAuthUserHeader, {
28
- user: user
29
- })
30
- })
31
- ]
32
- });
33
- };
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Avatar}from"../../../../../../components/avatar.js";import{Button}from"../../../../../../components/ui/button.js";import{DropdownMenu,DropdownMenuContent,DropdownMenuTrigger}from"../../../../../../components/ui/dropdown-menu.js";import{getSessionApi}from"../../../../../../lib/api/get-session-api.js";import{ClientAuthUserHeader}from"./client.js";export const AuthUserHeader=async()=>{const{user}=await getSessionApi();if(!user)return null;return _jsxs(DropdownMenu,{children:[_jsx(DropdownMenuTrigger,{asChild:true,children:_jsx(Button,{"aria-label":user.name,size:"icon",variant:"ghost",children:_jsx(Avatar,{size:24,user:user})})}),_jsx(DropdownMenuContent,{align:"end",className:"w-64 p-2",children:_jsx(ClientAuthUserHeader,{user:user})})]})};
@@ -1,47 +1 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { KeyRoundIcon, LogOutIcon } from "lucide-react";
4
- import { useTranslations } from "next-intl";
5
- import { DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator } from "../../../../../../components/ui/dropdown-menu.js";
6
- import { Link } from "../../../../../../lib/navigation.js";
7
- import { logOutMutationApi } from "./log-out-mutation-api.js";
8
- export const ClientAuthUserHeader = ({ user })=>{
9
- const t = useTranslations("core.global.user_bar");
10
- return /*#__PURE__*/ _jsxs(_Fragment, {
11
- children: [
12
- user.isAdmin && /*#__PURE__*/ _jsxs(_Fragment, {
13
- children: [
14
- /*#__PURE__*/ _jsx(DropdownMenuGroup, {
15
- children: /*#__PURE__*/ _jsx(DropdownMenuItem, {
16
- asChild: true,
17
- children: /*#__PURE__*/ _jsxs(Link, {
18
- href: "/admin",
19
- target: "_blank",
20
- children: [
21
- /*#__PURE__*/ _jsx(KeyRoundIcon, {}),
22
- /*#__PURE__*/ _jsx("span", {
23
- children: t("admin_cp")
24
- })
25
- ]
26
- })
27
- })
28
- }),
29
- /*#__PURE__*/ _jsx(DropdownMenuSeparator, {})
30
- ]
31
- }),
32
- /*#__PURE__*/ _jsx(DropdownMenuGroup, {
33
- children: /*#__PURE__*/ _jsxs(DropdownMenuItem, {
34
- onClick: async ()=>{
35
- await logOutMutationApi({});
36
- },
37
- children: [
38
- /*#__PURE__*/ _jsx(LogOutIcon, {}),
39
- /*#__PURE__*/ _jsx("span", {
40
- children: t("log_out")
41
- })
42
- ]
43
- })
44
- })
45
- ]
46
- });
47
- };
1
+ "use client";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{KeyRoundIcon,LogOutIcon}from"lucide-react";import{useTranslations}from"next-intl";import{DropdownMenuGroup,DropdownMenuItem,DropdownMenuSeparator}from"../../../../../../components/ui/dropdown-menu.js";import{Link}from"../../../../../../lib/navigation.js";import{logOutMutationApi}from"./log-out-mutation-api.js";export const ClientAuthUserHeader=({user})=>{const t=useTranslations("core.global.user_bar");return _jsxs(_Fragment,{children:[user.isAdmin&&_jsxs(_Fragment,{children:[_jsx(DropdownMenuGroup,{children:_jsx(DropdownMenuItem,{asChild:true,children:_jsxs(Link,{href:"/admin",target:"_blank",children:[_jsx(KeyRoundIcon,{}),_jsx("span",{children:t("admin_cp")})]})})}),_jsx(DropdownMenuSeparator,{})]}),_jsx(DropdownMenuGroup,{children:_jsxs(DropdownMenuItem,{onClick:async()=>{await logOutMutationApi({})},children:[_jsx(LogOutIcon,{}),_jsx("span",{children:t("log_out")})]})})]})};