create-ej-app 6.0.0 → 8.0.0

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 (364) hide show
  1. package/cli.js +88 -14
  2. package/cli.ts +100 -17
  3. package/package.json +2 -2
  4. package/template/base/.env.example +11 -15
  5. package/template/base/Dockerfile +15 -0
  6. package/template/base/components.json +10 -5
  7. package/template/base/drizzle.config.ts +4 -5
  8. package/template/{new → base}/eslint.config.mjs +6 -1
  9. package/template/base/package.json +58 -75
  10. package/template/base/postcss.config.mjs +1 -4
  11. package/template/base/src/app/(admin)/layout.tsx +20 -0
  12. package/template/base/src/app/(app)/layout.tsx +13 -118
  13. package/template/base/src/app/(auth)/login/page.tsx +65 -42
  14. package/template/base/src/app/(marketing)/layout.tsx +7 -35
  15. package/template/base/src/app/(marketing)/page.tsx +2 -96
  16. package/template/base/src/app/(marketing)/privacy/page.tsx +3 -0
  17. package/template/base/src/app/(marketing)/terms/page.tsx +3 -0
  18. package/template/base/src/app/globals.css +118 -66
  19. package/template/base/src/app/layout.tsx +27 -12
  20. package/template/base/src/app/not-found.tsx +27 -0
  21. package/template/base/src/components/site-footer.tsx +16 -24
  22. package/template/base/src/components/ui/button.tsx +31 -27
  23. package/template/base/src/components/ui/card.tsx +83 -70
  24. package/template/base/src/components/ui/form.tsx +38 -47
  25. package/template/base/src/components/ui/input.tsx +16 -20
  26. package/template/base/src/components/ui/label.tsx +16 -18
  27. package/template/base/src/components/ui/separator.tsx +11 -14
  28. package/template/base/src/components/ui/sonner.tsx +22 -13
  29. package/template/base/src/db/index.ts +4 -11
  30. package/template/base/src/db/schema.ts +60 -268
  31. package/template/{new → base}/src/env.ts +2 -2
  32. package/template/{new → base}/src/lib/auth-client.ts +2 -0
  33. package/template/base/src/lib/auth.ts +64 -80
  34. package/template/base/src/lib/safe-action.ts +30 -6
  35. package/template/base/tsconfig.json +9 -7
  36. package/template/{prisma-advanced → old}/.env.example +10 -9
  37. package/template/{prisma → old}/components.json +1 -1
  38. package/template/old/drizzle.config.ts +11 -0
  39. package/template/old/package.json +87 -0
  40. package/template/old/postcss.config.mjs +8 -0
  41. package/template/{prisma-advanced → old}/src/app/(app)/layout.tsx +11 -3
  42. package/template/{prisma-advanced → old}/src/app/(auth)/login/page.tsx +2 -2
  43. package/template/{prisma → old}/src/app/(marketing)/page.tsx +8 -7
  44. package/template/old/src/app/layout.tsx +31 -0
  45. package/template/old/src/components/ui/sonner.tsx +31 -0
  46. package/template/old/src/db/index.ts +14 -0
  47. package/template/old/src/db/schema.ts +287 -0
  48. package/template/old/src/lib/auth.ts +89 -0
  49. package/template/old/src/lib/safe-action.ts +19 -0
  50. package/template/{prisma-advanced → old}/tsconfig.json +3 -2
  51. package/template/new/.env.example +0 -13
  52. package/template/new/components.json +0 -22
  53. package/template/new/drizzle.config.ts +0 -10
  54. package/template/new/package.json +0 -81
  55. package/template/new/postcss.config.mjs +0 -5
  56. package/template/new/src/app/(auth)/login/page.tsx +0 -72
  57. package/template/new/src/app/globals.css +0 -128
  58. package/template/new/src/app/layout.tsx +0 -50
  59. package/template/new/src/app/page.tsx +0 -3
  60. package/template/new/src/components/ui/button.tsx +0 -60
  61. package/template/new/src/components/ui/card.tsx +0 -92
  62. package/template/new/src/components/ui/form.tsx +0 -167
  63. package/template/new/src/components/ui/input.tsx +0 -21
  64. package/template/new/src/components/ui/label.tsx +0 -24
  65. package/template/new/src/components/ui/separator.tsx +0 -28
  66. package/template/new/src/components/ui/sonner.tsx +0 -40
  67. package/template/new/src/db/index.ts +0 -7
  68. package/template/new/src/db/schema.ts +0 -74
  69. package/template/new/src/lib/auth.ts +0 -67
  70. package/template/new/src/lib/safe-action.ts +0 -15
  71. package/template/new/tsconfig.json +0 -49
  72. package/template/prisma/.env.example +0 -16
  73. package/template/prisma/.eslintrc.cjs +0 -24
  74. package/template/prisma/next.config.mjs +0 -15
  75. package/template/prisma/package.json +0 -80
  76. package/template/prisma/postcss.config.cjs +0 -6
  77. package/template/prisma/prettier.config.ts +0 -11
  78. package/template/prisma/prisma/schema.prisma +0 -115
  79. package/template/prisma/public/next.svg +0 -1
  80. package/template/prisma/src/app/(app)/dashboard/page.tsx +0 -19
  81. package/template/prisma/src/app/(app)/layout.tsx +0 -90
  82. package/template/prisma/src/app/(app)/settings/actions.ts +0 -18
  83. package/template/prisma/src/app/(app)/settings/loading.tsx +0 -28
  84. package/template/prisma/src/app/(app)/settings/page.tsx +0 -28
  85. package/template/prisma/src/app/(app)/settings/render.tsx +0 -113
  86. package/template/prisma/src/app/(app)/tasks/[id]/actions.ts +0 -147
  87. package/template/prisma/src/app/(app)/tasks/[id]/page.tsx +0 -25
  88. package/template/prisma/src/app/(app)/tasks/[id]/render.tsx +0 -413
  89. package/template/prisma/src/app/(app)/tasks/actions.ts +0 -69
  90. package/template/prisma/src/app/(app)/tasks/page.tsx +0 -53
  91. package/template/prisma/src/app/(app)/tasks/render.tsx +0 -107
  92. package/template/prisma/src/app/(app)/users/[id]/actions.ts +0 -83
  93. package/template/prisma/src/app/(app)/users/[id]/page.tsx +0 -32
  94. package/template/prisma/src/app/(app)/users/[id]/render.tsx +0 -240
  95. package/template/prisma/src/app/(app)/users/actions.ts +0 -55
  96. package/template/prisma/src/app/(app)/users/page.tsx +0 -49
  97. package/template/prisma/src/app/(app)/users/render.tsx +0 -80
  98. package/template/prisma/src/app/(auth)/layout.tsx +0 -20
  99. package/template/prisma/src/app/(auth)/login/page.tsx +0 -49
  100. package/template/prisma/src/app/(auth)/login/user-auth-form.tsx +0 -152
  101. package/template/prisma/src/app/api/auth/[...nextauth]/route.ts +0 -7
  102. package/template/prisma/src/app/api/upload/route.ts +0 -36
  103. package/template/prisma/src/app/favicon.ico +0 -0
  104. package/template/prisma/src/app/layout.tsx +0 -34
  105. package/template/prisma/src/components/app-nav-command.tsx +0 -160
  106. package/template/prisma/src/components/dark-mode-toggle.tsx +0 -43
  107. package/template/prisma/src/components/data-table/data-table-column-header.tsx +0 -91
  108. package/template/prisma/src/components/data-table/data-table-faceted-filter.tsx +0 -149
  109. package/template/prisma/src/components/data-table/data-table-loading.tsx +0 -77
  110. package/template/prisma/src/components/data-table/data-table-pagination.tsx +0 -94
  111. package/template/prisma/src/components/data-table/data-table-toolbar.tsx +0 -78
  112. package/template/prisma/src/components/data-table/data-table-types.ts +0 -17
  113. package/template/prisma/src/components/data-table/data-table-view-options.tsx +0 -59
  114. package/template/prisma/src/components/data-table/data-table.tsx +0 -301
  115. package/template/prisma/src/components/data-table/simple-data-table.tsx +0 -109
  116. package/template/prisma/src/components/empty-placeholder.tsx +0 -78
  117. package/template/prisma/src/components/heading.tsx +0 -17
  118. package/template/prisma/src/components/icons.tsx +0 -85
  119. package/template/prisma/src/components/main-nav.tsx +0 -64
  120. package/template/prisma/src/components/mobile-nav.tsx +0 -50
  121. package/template/prisma/src/components/shell.tsx +0 -13
  122. package/template/prisma/src/components/side-nav.tsx +0 -51
  123. package/template/prisma/src/components/site-footer.tsx +0 -31
  124. package/template/prisma/src/components/system-info.tsx +0 -36
  125. package/template/prisma/src/components/theme-provider.tsx +0 -13
  126. package/template/prisma/src/components/ui/alert-dialog.tsx +0 -141
  127. package/template/prisma/src/components/ui/avatar.tsx +0 -50
  128. package/template/prisma/src/components/ui/badge.tsx +0 -36
  129. package/template/prisma/src/components/ui/button.tsx +0 -56
  130. package/template/prisma/src/components/ui/card.tsx +0 -79
  131. package/template/prisma/src/components/ui/checkbox.tsx +0 -30
  132. package/template/prisma/src/components/ui/command.tsx +0 -155
  133. package/template/prisma/src/components/ui/dialog.tsx +0 -122
  134. package/template/prisma/src/components/ui/dropdown-menu.tsx +0 -200
  135. package/template/prisma/src/components/ui/form.tsx +0 -176
  136. package/template/prisma/src/components/ui/input.tsx +0 -25
  137. package/template/prisma/src/components/ui/label.tsx +0 -26
  138. package/template/prisma/src/components/ui/popover.tsx +0 -31
  139. package/template/prisma/src/components/ui/select.tsx +0 -160
  140. package/template/prisma/src/components/ui/separator.tsx +0 -31
  141. package/template/prisma/src/components/ui/skeleton.tsx +0 -15
  142. package/template/prisma/src/components/ui/table.tsx +0 -117
  143. package/template/prisma/src/components/ui/textarea.tsx +0 -24
  144. package/template/prisma/src/components/ui/toast.tsx +0 -127
  145. package/template/prisma/src/components/ui/toaster.tsx +0 -35
  146. package/template/prisma/src/components/ui/use-toast.ts +0 -189
  147. package/template/prisma/src/components/user-account-nav.tsx +0 -60
  148. package/template/prisma/src/components/user-avatar.tsx +0 -25
  149. package/template/prisma/src/env.mjs +0 -78
  150. package/template/prisma/src/hooks/use-debounce.ts +0 -17
  151. package/template/prisma/src/hooks/use-lock-body.tsx +0 -12
  152. package/template/prisma/src/lib/auth.ts +0 -80
  153. package/template/prisma/src/lib/cn.ts +0 -4
  154. package/template/prisma/src/lib/db.ts +0 -20
  155. package/template/prisma/src/lib/delay.ts +0 -2
  156. package/template/prisma/src/lib/formatDate.ts +0 -11
  157. package/template/prisma/src/lib/generateLabel.ts +0 -5
  158. package/template/prisma/src/lib/siteConfig.ts +0 -4
  159. package/template/prisma/src/lib/storageClient.ts +0 -11
  160. package/template/prisma/src/styles/editor.css +0 -61
  161. package/template/prisma/src/styles/globals.css +0 -76
  162. package/template/prisma/src/types/UnwrapPromise.ts +0 -1
  163. package/template/prisma/tailwind.config.ts +0 -80
  164. package/template/prisma/tsconfig.json +0 -46
  165. package/template/prisma-advanced/.eslintrc.cjs +0 -24
  166. package/template/prisma-advanced/components.json +0 -17
  167. package/template/prisma-advanced/next.config.mjs +0 -15
  168. package/template/prisma-advanced/package.json +0 -80
  169. package/template/prisma-advanced/postcss.config.cjs +0 -6
  170. package/template/prisma-advanced/prettier.config.ts +0 -11
  171. package/template/prisma-advanced/prisma/schema.prisma +0 -154
  172. package/template/prisma-advanced/public/next.svg +0 -1
  173. package/template/prisma-advanced/src/app/(app)/dashboard/page.tsx +0 -19
  174. package/template/prisma-advanced/src/app/(app)/roles/[id]/actions.ts +0 -100
  175. package/template/prisma-advanced/src/app/(app)/roles/[id]/page.tsx +0 -36
  176. package/template/prisma-advanced/src/app/(app)/roles/[id]/render.tsx +0 -266
  177. package/template/prisma-advanced/src/app/(app)/roles/actions.ts +0 -67
  178. package/template/prisma-advanced/src/app/(app)/roles/page.tsx +0 -51
  179. package/template/prisma-advanced/src/app/(app)/roles/render.tsx +0 -70
  180. package/template/prisma-advanced/src/app/(app)/settings/actions.ts +0 -18
  181. package/template/prisma-advanced/src/app/(app)/settings/loading.tsx +0 -28
  182. package/template/prisma-advanced/src/app/(app)/settings/page.tsx +0 -28
  183. package/template/prisma-advanced/src/app/(app)/settings/render.tsx +0 -113
  184. package/template/prisma-advanced/src/app/(app)/tasks/[id]/actions.ts +0 -147
  185. package/template/prisma-advanced/src/app/(app)/tasks/[id]/page.tsx +0 -55
  186. package/template/prisma-advanced/src/app/(app)/tasks/[id]/render.tsx +0 -418
  187. package/template/prisma-advanced/src/app/(app)/tasks/actions.ts +0 -69
  188. package/template/prisma-advanced/src/app/(app)/tasks/page.tsx +0 -63
  189. package/template/prisma-advanced/src/app/(app)/tasks/render.tsx +0 -114
  190. package/template/prisma-advanced/src/app/(app)/users/[id]/actions.ts +0 -104
  191. package/template/prisma-advanced/src/app/(app)/users/[id]/page.tsx +0 -39
  192. package/template/prisma-advanced/src/app/(app)/users/[id]/render.tsx +0 -320
  193. package/template/prisma-advanced/src/app/(app)/users/actions.ts +0 -67
  194. package/template/prisma-advanced/src/app/(app)/users/page.tsx +0 -61
  195. package/template/prisma-advanced/src/app/(app)/users/render.tsx +0 -108
  196. package/template/prisma-advanced/src/app/(auth)/layout.tsx +0 -20
  197. package/template/prisma-advanced/src/app/(auth)/login/user-auth-form.tsx +0 -152
  198. package/template/prisma-advanced/src/app/(marketing)/layout.tsx +0 -42
  199. package/template/prisma-advanced/src/app/(marketing)/page.tsx +0 -96
  200. package/template/prisma-advanced/src/app/api/auth/[...nextauth]/route.ts +0 -7
  201. package/template/prisma-advanced/src/app/api/upload/route.ts +0 -36
  202. package/template/prisma-advanced/src/app/favicon.ico +0 -0
  203. package/template/prisma-advanced/src/app/layout.tsx +0 -34
  204. package/template/prisma-advanced/src/components/app-nav-command.tsx +0 -160
  205. package/template/prisma-advanced/src/components/dark-mode-toggle.tsx +0 -43
  206. package/template/prisma-advanced/src/components/data-table/data-table-column-header.tsx +0 -91
  207. package/template/prisma-advanced/src/components/data-table/data-table-faceted-filter.tsx +0 -149
  208. package/template/prisma-advanced/src/components/data-table/data-table-loading.tsx +0 -77
  209. package/template/prisma-advanced/src/components/data-table/data-table-pagination.tsx +0 -94
  210. package/template/prisma-advanced/src/components/data-table/data-table-toolbar.tsx +0 -78
  211. package/template/prisma-advanced/src/components/data-table/data-table-types.ts +0 -17
  212. package/template/prisma-advanced/src/components/data-table/data-table-view-options.tsx +0 -59
  213. package/template/prisma-advanced/src/components/data-table/data-table.tsx +0 -301
  214. package/template/prisma-advanced/src/components/data-table/simple-data-table.tsx +0 -109
  215. package/template/prisma-advanced/src/components/empty-placeholder.tsx +0 -78
  216. package/template/prisma-advanced/src/components/heading.tsx +0 -17
  217. package/template/prisma-advanced/src/components/icons.tsx +0 -85
  218. package/template/prisma-advanced/src/components/main-nav.tsx +0 -64
  219. package/template/prisma-advanced/src/components/shell.tsx +0 -13
  220. package/template/prisma-advanced/src/components/side-nav.tsx +0 -51
  221. package/template/prisma-advanced/src/components/system-info.tsx +0 -36
  222. package/template/prisma-advanced/src/components/theme-provider.tsx +0 -13
  223. package/template/prisma-advanced/src/components/ui/alert-dialog.tsx +0 -141
  224. package/template/prisma-advanced/src/components/ui/avatar.tsx +0 -50
  225. package/template/prisma-advanced/src/components/ui/badge.tsx +0 -36
  226. package/template/prisma-advanced/src/components/ui/checkbox.tsx +0 -30
  227. package/template/prisma-advanced/src/components/ui/command.tsx +0 -155
  228. package/template/prisma-advanced/src/components/ui/dialog.tsx +0 -122
  229. package/template/prisma-advanced/src/components/ui/dropdown-menu.tsx +0 -200
  230. package/template/prisma-advanced/src/components/ui/popover.tsx +0 -31
  231. package/template/prisma-advanced/src/components/ui/select.tsx +0 -160
  232. package/template/prisma-advanced/src/components/ui/skeleton.tsx +0 -15
  233. package/template/prisma-advanced/src/components/ui/table.tsx +0 -117
  234. package/template/prisma-advanced/src/components/ui/textarea.tsx +0 -24
  235. package/template/prisma-advanced/src/components/ui/toast.tsx +0 -127
  236. package/template/prisma-advanced/src/components/ui/toaster.tsx +0 -35
  237. package/template/prisma-advanced/src/components/ui/use-toast.ts +0 -189
  238. package/template/prisma-advanced/src/components/user-account-nav.tsx +0 -60
  239. package/template/prisma-advanced/src/components/user-avatar.tsx +0 -25
  240. package/template/prisma-advanced/src/env.mjs +0 -78
  241. package/template/prisma-advanced/src/hooks/use-debounce.ts +0 -17
  242. package/template/prisma-advanced/src/hooks/use-lock-body.tsx +0 -12
  243. package/template/prisma-advanced/src/lib/auth.ts +0 -180
  244. package/template/prisma-advanced/src/lib/cn.ts +0 -4
  245. package/template/prisma-advanced/src/lib/db.ts +0 -20
  246. package/template/prisma-advanced/src/lib/delay.ts +0 -2
  247. package/template/prisma-advanced/src/lib/formatDate.ts +0 -11
  248. package/template/prisma-advanced/src/lib/generateLabel.ts +0 -5
  249. package/template/prisma-advanced/src/lib/siteConfig.ts +0 -4
  250. package/template/prisma-advanced/src/lib/storageClient.ts +0 -11
  251. package/template/prisma-advanced/src/styles/editor.css +0 -61
  252. package/template/prisma-advanced/src/types/UnwrapPromise.ts +0 -1
  253. package/template/prisma-advanced/tailwind.config.ts +0 -80
  254. package/template/{new → base}/next.config.ts +0 -0
  255. package/template/{new → base}/public/placeholder.svg +0 -0
  256. package/template/{new → base}/src/app/(auth)/login/email-login-form.tsx +0 -0
  257. package/template/{new → base}/src/app/(auth)/login/social-login-buttons.tsx +0 -0
  258. package/template/{new → base}/src/app/api/auth/[...all]/route.ts +0 -0
  259. package/template/{new → base}/src/components/loader.tsx +0 -0
  260. package/template/{new → base}/src/components/react-query-provider.tsx +0 -0
  261. package/template/{new → base}/src/components/screen-size.tsx +0 -0
  262. package/template/{new → base}/src/components/theme-toggle.tsx +0 -0
  263. package/template/{new → base}/src/lib/toast-message.ts +0 -0
  264. package/template/{base → old}/.eslintrc.cjs +0 -0
  265. package/template/{base → old}/next.config.mjs +0 -0
  266. package/template/{new → old}/prettier.config.mjs +0 -0
  267. package/template/{base → old}/public/next.svg +0 -0
  268. package/template/{base → old}/public/vercel.svg +0 -0
  269. package/template/{base → old}/src/app/(app)/dashboard/layout.tsx +0 -0
  270. package/template/{base → old}/src/app/(app)/dashboard/page.tsx +0 -0
  271. package/template/{base → old}/src/app/(app)/roles/[id]/actions.ts +0 -0
  272. package/template/{base → old}/src/app/(app)/roles/[id]/page.tsx +0 -0
  273. package/template/{base → old}/src/app/(app)/roles/[id]/render.tsx +0 -0
  274. package/template/{base → old}/src/app/(app)/roles/[id]/validation.ts +0 -0
  275. package/template/{base → old}/src/app/(app)/roles/actions.ts +0 -0
  276. package/template/{base → old}/src/app/(app)/roles/page.tsx +0 -0
  277. package/template/{base → old}/src/app/(app)/roles/render.tsx +0 -0
  278. package/template/{base → old}/src/app/(app)/settings/actions.ts +0 -0
  279. package/template/{base → old}/src/app/(app)/settings/layout.tsx +0 -0
  280. package/template/{base → old}/src/app/(app)/settings/loading.tsx +0 -0
  281. package/template/{base → old}/src/app/(app)/settings/page.tsx +0 -0
  282. package/template/{base → old}/src/app/(app)/settings/render.tsx +0 -0
  283. package/template/{base → old}/src/app/(app)/settings/validation.ts +0 -0
  284. package/template/{base → old}/src/app/(app)/tasks/[id]/actions.ts +0 -0
  285. package/template/{base → old}/src/app/(app)/tasks/[id]/page.tsx +0 -0
  286. package/template/{base → old}/src/app/(app)/tasks/[id]/render.tsx +0 -0
  287. package/template/{base → old}/src/app/(app)/tasks/[id]/validation.ts +0 -0
  288. package/template/{base → old}/src/app/(app)/tasks/actions.ts +0 -0
  289. package/template/{base → old}/src/app/(app)/tasks/page.tsx +0 -0
  290. package/template/{base → old}/src/app/(app)/tasks/render.tsx +0 -0
  291. package/template/{base → old}/src/app/(app)/tasks/statusEnum.ts +0 -0
  292. package/template/{base → old}/src/app/(app)/users/[id]/actions.ts +0 -0
  293. package/template/{base → old}/src/app/(app)/users/[id]/page.tsx +0 -0
  294. package/template/{base → old}/src/app/(app)/users/[id]/render.tsx +0 -0
  295. package/template/{base → old}/src/app/(app)/users/[id]/validation.ts +0 -0
  296. package/template/{base → old}/src/app/(app)/users/actions.ts +0 -0
  297. package/template/{base → old}/src/app/(app)/users/page.tsx +0 -0
  298. package/template/{base → old}/src/app/(app)/users/render.tsx +0 -0
  299. package/template/{base → old}/src/app/(auth)/layout.tsx +0 -0
  300. package/template/{base → old}/src/app/(auth)/login/render.tsx +0 -0
  301. package/template/{prisma → old}/src/app/(marketing)/layout.tsx +1 -1
  302. /package/template/{base → old}/src/app/api/auth/[...nextauth]/route.ts +0 -0
  303. /package/template/{new → old}/src/app/favicon.ico +0 -0
  304. /package/template/{prisma-advanced/src/styles → old/src/app}/globals.css +0 -0
  305. /package/template/{base → old}/src/components/app-nav-command.tsx +0 -0
  306. /package/template/{base → old}/src/components/dark-mode-toggle.tsx +0 -0
  307. /package/template/{base → old}/src/components/data-table/data-table-column-header.tsx +0 -0
  308. /package/template/{base → old}/src/components/data-table/data-table-faceted-filter.tsx +0 -0
  309. /package/template/{base → old}/src/components/data-table/data-table-loading.tsx +0 -0
  310. /package/template/{base → old}/src/components/data-table/data-table-pagination.tsx +0 -0
  311. /package/template/{base → old}/src/components/data-table/data-table-toolbar.tsx +0 -0
  312. /package/template/{base → old}/src/components/data-table/data-table-types.ts +0 -0
  313. /package/template/{base → old}/src/components/data-table/data-table-view-options.tsx +0 -0
  314. /package/template/{base → old}/src/components/data-table/data-table.tsx +0 -0
  315. /package/template/{base → old}/src/components/data-table/simple-data-table.tsx +0 -0
  316. /package/template/{base → old}/src/components/empty-placeholder.tsx +0 -0
  317. /package/template/{base → old}/src/components/heading.tsx +0 -0
  318. /package/template/{base → old}/src/components/icons.tsx +0 -0
  319. /package/template/{base → old}/src/components/main-nav.tsx +0 -0
  320. /package/template/{base → old}/src/components/mobile-nav.tsx +0 -0
  321. /package/template/{base → old}/src/components/shell.tsx +0 -0
  322. /package/template/{base → old}/src/components/side-nav.tsx +0 -0
  323. /package/template/{prisma-advanced → old}/src/components/site-footer.tsx +0 -0
  324. /package/template/{base → old}/src/components/system-info.tsx +0 -0
  325. /package/template/{base → old}/src/components/ui/alert-dialog.tsx +0 -0
  326. /package/template/{base → old}/src/components/ui/avatar.tsx +0 -0
  327. /package/template/{base → old}/src/components/ui/badge.tsx +0 -0
  328. /package/template/{prisma-advanced → old}/src/components/ui/button.tsx +0 -0
  329. /package/template/{prisma-advanced → old}/src/components/ui/card.tsx +0 -0
  330. /package/template/{base → old}/src/components/ui/checkbox.tsx +0 -0
  331. /package/template/{base → old}/src/components/ui/command.tsx +0 -0
  332. /package/template/{base → old}/src/components/ui/dialog.tsx +0 -0
  333. /package/template/{base → old}/src/components/ui/dropdown-menu.tsx +0 -0
  334. /package/template/{prisma-advanced → old}/src/components/ui/form.tsx +0 -0
  335. /package/template/{prisma-advanced → old}/src/components/ui/input.tsx +0 -0
  336. /package/template/{prisma-advanced → old}/src/components/ui/label.tsx +0 -0
  337. /package/template/{base → old}/src/components/ui/popover.tsx +0 -0
  338. /package/template/{base → old}/src/components/ui/select.tsx +0 -0
  339. /package/template/{prisma-advanced → old}/src/components/ui/separator.tsx +0 -0
  340. /package/template/{base → old}/src/components/ui/skeleton.tsx +0 -0
  341. /package/template/{base → old}/src/components/ui/table.tsx +0 -0
  342. /package/template/{base → old}/src/components/user-account-nav.tsx +0 -0
  343. /package/template/{base → old}/src/components/user-avatar.tsx +0 -0
  344. /package/template/{base → old}/src/data-access/resource.ts +0 -0
  345. /package/template/{base → old}/src/data-access/role-permission.ts +0 -0
  346. /package/template/{base → old}/src/data-access/role.ts +0 -0
  347. /package/template/{base → old}/src/data-access/task.ts +0 -0
  348. /package/template/{base → old}/src/data-access/user.ts +0 -0
  349. /package/template/{base → old}/src/env.mjs +0 -0
  350. /package/template/{base → old}/src/hooks/use-debounce.tsx +0 -0
  351. /package/template/{base → old}/src/hooks/use-lock-body.tsx +0 -0
  352. /package/template/{new → old}/src/lib/cn.ts +0 -0
  353. /package/template/{base → old}/src/lib/currentUser.ts +0 -0
  354. /package/template/{new → old}/src/lib/delay.ts +0 -0
  355. /package/template/{base → old}/src/lib/formatDate.ts +0 -0
  356. /package/template/{base → old}/src/lib/generateLabel.ts +0 -0
  357. /package/template/{base → old}/src/lib/s3Client.ts +0 -0
  358. /package/template/{new → old}/src/lib/siteConfig.ts +0 -0
  359. /package/template/{base → old}/src/lib/sortOrderEnum.ts +0 -0
  360. /package/template/{base → old}/src/use-case/role-permission.ts +0 -0
  361. /package/template/{base → old}/src/use-case/role.ts +0 -0
  362. /package/template/{base → old}/src/use-case/task.ts +0 -0
  363. /package/template/{base → old}/src/use-case/user.ts +0 -0
  364. /package/template/{base → old}/tailwind.config.ts +0 -0
@@ -1,154 +0,0 @@
1
- generator client {
2
- provider = "prisma-client-js"
3
- }
4
-
5
- datasource db {
6
- provider = "postgresql"
7
- url = env("DATABASE_URL")
8
- }
9
-
10
- model Account {
11
- id String @id @default(cuid())
12
- userId String
13
- type String
14
- provider String
15
- providerAccountId String
16
- refresh_token String? @db.Text
17
- access_token String? @db.Text
18
- expires_at Int?
19
- token_type String?
20
- scope String?
21
- id_token String? @db.Text
22
- session_state String?
23
-
24
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
25
-
26
- createdAt DateTime @default(now()) @db.Timestamptz()
27
- updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz()
28
-
29
- @@unique([provider, providerAccountId])
30
- @@map("Accounts")
31
- }
32
-
33
- model Session {
34
- id String @id @default(cuid())
35
- sessionToken String @unique
36
- userId String
37
- expires DateTime @db.Timestamptz()
38
-
39
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
40
-
41
- createdAt DateTime @default(now()) @db.Timestamptz()
42
- updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz()
43
-
44
- @@map("Sessions")
45
- }
46
-
47
- model Role {
48
- id String @id @default(cuid())
49
- name String @unique
50
-
51
- createdAt DateTime @default(now()) @db.Timestamptz()
52
- updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz()
53
-
54
- permissions RolePermission[] @relation("rolePermissions")
55
- users User[] @relation("userRole")
56
-
57
- @@map("Roles")
58
- }
59
-
60
- enum Permissions {
61
- TaskList
62
- TaskView
63
- TaskCreate
64
- TaskUpdate
65
- TaskDelete
66
- }
67
-
68
- model RolePermission {
69
- id String @id @default(cuid())
70
- roleId String
71
- permission Permissions
72
-
73
- role Role @relation("rolePermissions", fields: [roleId], references: [id], onDelete: Cascade)
74
-
75
- @@map("RolePermissions")
76
- }
77
-
78
- enum UserType {
79
- Root
80
- Normal
81
- }
82
-
83
- model User {
84
- id String @id @default(cuid())
85
- name String?
86
- email String? @unique
87
- emailVerified DateTime? @db.Timestamptz()
88
- image String?
89
- type UserType @default(Normal)
90
- roleId String?
91
-
92
- createdAt DateTime @default(now()) @db.Timestamptz()
93
- updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz()
94
-
95
- accounts Account[]
96
- sessions Session[]
97
- role Role? @relation("userRole", fields: [roleId], references: [id])
98
-
99
- createdTasks Task[] @relation("createdTasks")
100
- updatedTasks Task[] @relation("updatedTasks")
101
-
102
- @@map("Users")
103
- }
104
-
105
- model VerificationToken {
106
- identifier String
107
- token String @unique
108
- expires DateTime @db.Timestamptz()
109
-
110
- @@unique([identifier, token])
111
- @@map("VerificationTokens")
112
- }
113
-
114
- enum TaskStatus {
115
- Backlog
116
- Todo
117
- In_Progress
118
- Done
119
- Cancelled
120
- }
121
-
122
- model Task {
123
- id String @id @default(cuid())
124
- title String
125
- status TaskStatus
126
- description Json?
127
-
128
- images Resource[] @relation("taskImages")
129
-
130
- createdAt DateTime @default(now()) @db.Timestamptz()
131
- updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz()
132
- createdById String
133
- createdBy User @relation("createdTasks", fields: [createdById], references: [id], onDelete: Cascade)
134
- updatedById String
135
- updatedBy User @relation("updatedTasks", fields: [updatedById], references: [id], onDelete: Cascade)
136
-
137
- @@map("Tasks")
138
- }
139
-
140
- model Resource {
141
- id String @id @default(cuid())
142
- originalFilename String
143
- newFilename String @unique
144
- url String @unique
145
-
146
- taskId String?
147
- task Task? @relation("taskImages", fields: [taskId], references: [id])
148
-
149
- createdAt DateTime @default(now()) @db.Timestamptz()
150
- updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz()
151
-
152
- @@index([taskId])
153
- @@map("Resources")
154
- }
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
@@ -1,19 +0,0 @@
1
- import { Metadata } from 'next'
2
-
3
- import { Heading } from '@/components/heading'
4
- import { Shell } from '@/components/shell'
5
- import { siteConfig } from '@/lib/siteConfig'
6
-
7
- export const metadata: Metadata = {
8
- title: 'Dashboard' + ' | ' + siteConfig.name
9
- }
10
-
11
- const DashboardPage = () => {
12
- return (
13
- <Shell>
14
- <Heading heading="Dashboard" />
15
- </Shell>
16
- )
17
- }
18
-
19
- export default DashboardPage
@@ -1,100 +0,0 @@
1
- 'use server'
2
-
3
- import { Permissions } from '@prisma/client'
4
- import { revalidatePath } from 'next/cache'
5
-
6
- import { authGuard } from '@/lib/auth'
7
- import { prisma } from '@/lib/db'
8
- import { UnwrapPromise } from '@/types/UnwrapPromise'
9
-
10
- export const getRole = async (id: string) => {
11
- const session = await authGuard(['Root'])
12
- if (!session) throw new Error('Unauthorized')
13
-
14
- return await prisma.role.findUnique({
15
- where: {
16
- id
17
- },
18
- include: {
19
- permissions: true
20
- }
21
- })
22
- }
23
-
24
- export type GetRoleFnDataType = UnwrapPromise<ReturnType<typeof getRole>>
25
-
26
- export const createRole = async ({
27
- name,
28
- permissions
29
- }: {
30
- name: string
31
- permissions: Permissions[]
32
- }) => {
33
- const session = await authGuard(['Root'])
34
- if (!session) throw new Error('Unauthorized')
35
-
36
- const { id } = await prisma.role.create({
37
- data: {
38
- name,
39
- permissions: {
40
- createMany: {
41
- data: permissions.map(permission => ({
42
- permission
43
- }))
44
- }
45
- }
46
- }
47
- })
48
-
49
- revalidatePath('/roles')
50
- revalidatePath(`/roles/${id}`)
51
-
52
- return id
53
- }
54
-
55
- export const updateRole = async ({
56
- id,
57
- name,
58
- permissions
59
- }: {
60
- id: string
61
- name: string
62
- permissions: Permissions[]
63
- }) => {
64
- const session = await authGuard(['Root'])
65
- if (!session) throw new Error('Unauthorized')
66
-
67
- await prisma.role.update({
68
- where: {
69
- id
70
- },
71
- data: {
72
- name
73
- }
74
- })
75
- await prisma.rolePermission.deleteMany({
76
- where: {
77
- roleId: id
78
- }
79
- })
80
- await prisma.rolePermission.createMany({
81
- data: permissions.map(permission => ({ permission, roleId: id }))
82
- })
83
-
84
- revalidatePath('/roles')
85
- revalidatePath(`/roles/${id}`)
86
- }
87
-
88
- export const deleteRole = async (id: string) => {
89
- const session = await authGuard(['Root'])
90
- if (!session) throw new Error('Unauthorized')
91
-
92
- await prisma.role.delete({
93
- where: {
94
- id
95
- }
96
- })
97
-
98
- revalidatePath('/roles')
99
- revalidatePath(`/roles/${id}`)
100
- }
@@ -1,36 +0,0 @@
1
- import { Metadata } from 'next'
2
- import { notFound } from 'next/navigation'
3
-
4
- import { authGuard } from '@/lib/auth'
5
- import { siteConfig } from '@/lib/siteConfig'
6
- import { GetRoleFnDataType, getRole } from './actions'
7
- import { Render } from './render'
8
-
9
- export const generateMetadata = async (props: {
10
- params: { id: string }
11
- }): Promise<Metadata> => ({
12
- title: 'Role - ' + props.params.id + ' | ' + siteConfig.name
13
- })
14
-
15
- const RolePage = async ({
16
- params: { id }
17
- }: {
18
- params: {
19
- id: string
20
- }
21
- }) => {
22
- const session = await authGuard(['Root'])
23
- if (!session) return notFound()
24
-
25
- let role: GetRoleFnDataType | undefined
26
-
27
- if (id !== 'new') {
28
- const x = await getRole(id)
29
- if (!x) return notFound()
30
- role = x
31
- }
32
-
33
- return <Render role={role} />
34
- }
35
-
36
- export default RolePage
@@ -1,266 +0,0 @@
1
- 'use client'
2
-
3
- import { zodResolver } from '@hookform/resolvers/zod'
4
- import { Permissions } from '@prisma/client'
5
- import Link from 'next/link'
6
- import { useRouter } from 'next/navigation'
7
- import { FC, useState } from 'react'
8
- import { useForm } from 'react-hook-form'
9
- import { z } from 'zod'
10
-
11
- import { Heading } from '@/components/heading'
12
- import { Icons } from '@/components/icons'
13
- import { Shell } from '@/components/shell'
14
- import { SystemInfo } from '@/components/system-info'
15
- import {
16
- AlertDialog,
17
- AlertDialogAction,
18
- AlertDialogCancel,
19
- AlertDialogContent,
20
- AlertDialogDescription,
21
- AlertDialogFooter,
22
- AlertDialogHeader,
23
- AlertDialogTitle,
24
- AlertDialogTrigger
25
- } from '@/components/ui/alert-dialog'
26
- import { Button } from '@/components/ui/button'
27
- import { Checkbox } from '@/components/ui/checkbox'
28
- import {
29
- Form,
30
- FormControl,
31
- FormField,
32
- FormItem,
33
- FormLabel,
34
- FormMessage
35
- } from '@/components/ui/form'
36
- import { Input } from '@/components/ui/input'
37
- import { toast } from '@/components/ui/use-toast'
38
- import { formatDateTime, timesAgo } from '@/lib/formatDate'
39
- import { generateLabel } from '@/lib/generateLabel'
40
- import {
41
- GetRoleFnDataType,
42
- createRole,
43
- deleteRole,
44
- updateRole
45
- } from './actions'
46
-
47
- const RoleSchema = z.object({
48
- name: z.string().nonempty(),
49
- permissions: z.array(z.nativeEnum(Permissions))
50
- })
51
-
52
- type FormData = z.infer<typeof RoleSchema>
53
-
54
- const permissions = Object.values(Permissions).map(x => ({
55
- label: generateLabel(x),
56
- value: x
57
- }))
58
-
59
- export const Render: FC<{
60
- role: GetRoleFnDataType | undefined
61
- }> = ({ role }) => {
62
- const form = useForm<FormData>({
63
- resolver: zodResolver(RoleSchema),
64
- defaultValues: {
65
- name: role?.name ?? '',
66
- permissions: role?.permissions.map(p => p.permission) ?? []
67
- }
68
- })
69
- const router = useRouter()
70
- const [isSaving, setIsSaving] = useState(false)
71
- const [isDeleting, setIsDeleting] = useState(false)
72
-
73
- async function onSubmit(data: FormData) {
74
- setIsSaving(true)
75
- try {
76
- if (!role) {
77
- const newId = await createRole(data)
78
- router.replace(`/roles/${newId}`)
79
- } else {
80
- await updateRole({
81
- id: role.id,
82
- ...data
83
- })
84
- }
85
- toast({
86
- title: 'Role saved'
87
- })
88
- } catch (err) {
89
- toast({
90
- title: 'Error saving role',
91
- variant: 'destructive'
92
- })
93
- }
94
- setIsSaving(false)
95
- }
96
-
97
- return (
98
- <Shell>
99
- <Heading heading={role ? role.name : 'New Role'} />
100
- <Form {...form}>
101
- <form
102
- className="grid grid-cols-1 gap-3 md:grid-cols-2"
103
- onSubmit={form.handleSubmit(onSubmit)}
104
- >
105
- <div className="col-span-1 mb-1 grid grid-cols-2 gap-2 sm:flex md:col-span-2">
106
- <Button type="button" onClick={() => router.back()} variant="ghost">
107
- <Icons.chevronLeft className="mr-2 h-4 w-4" />
108
- Back
109
- </Button>
110
- <Button type="submit" disabled={isSaving || isDeleting}>
111
- {isSaving ? (
112
- <Icons.spinner className="mr-2 h-4 w-4 animate-spin" />
113
- ) : (
114
- <Icons.save className="mr-2 h-4 w-4" />
115
- )}
116
- <span>Save</span>
117
- </Button>
118
- {role ? (
119
- <AlertDialog>
120
- <AlertDialogTrigger asChild>
121
- <Button
122
- type="button"
123
- variant="destructive"
124
- disabled={isSaving || isDeleting}
125
- >
126
- {isDeleting ? (
127
- <Icons.spinner className="mr-2 h-4 w-4 animate-spin" />
128
- ) : (
129
- <Icons.delete className="mr-2 h-4 w-4" />
130
- )}
131
- Delete
132
- </Button>
133
- </AlertDialogTrigger>
134
- <AlertDialogContent>
135
- <AlertDialogHeader>
136
- <AlertDialogTitle>
137
- Are you absolutely sure?
138
- </AlertDialogTitle>
139
- <AlertDialogDescription>
140
- This action cannot be undone.
141
- </AlertDialogDescription>
142
- </AlertDialogHeader>
143
- <AlertDialogFooter>
144
- <AlertDialogCancel>Cancel</AlertDialogCancel>
145
- <AlertDialogAction
146
- onClick={async () => {
147
- setIsDeleting(true)
148
- try {
149
- await deleteRole(role.id)
150
- toast({
151
- title: 'Role deleted'
152
- })
153
- router.push('/roles')
154
- } catch (err) {
155
- toast({
156
- title: 'Error deleting role',
157
- variant: 'destructive'
158
- })
159
- }
160
- setIsDeleting(false)
161
- }}
162
- >
163
- Continue
164
- </AlertDialogAction>
165
- </AlertDialogFooter>
166
- </AlertDialogContent>
167
- </AlertDialog>
168
- ) : undefined}
169
- {role ? (
170
- <Link href="/roles/new">
171
- <Button
172
- type="button"
173
- disabled={isSaving || isDeleting}
174
- variant="secondary"
175
- className="w-full"
176
- >
177
- <Icons.add className="mr-2 h-4 w-4" />
178
- New
179
- </Button>
180
- </Link>
181
- ) : undefined}
182
- </div>
183
-
184
- <FormField
185
- control={form.control}
186
- name="name"
187
- render={({ field }) => (
188
- <FormItem>
189
- <FormLabel>Name</FormLabel>
190
- <FormControl>
191
- <Input
192
- type="text"
193
- placeholder="Enter a name"
194
- disabled={isSaving}
195
- {...field}
196
- />
197
- </FormControl>
198
- <FormMessage />
199
- </FormItem>
200
- )}
201
- />
202
-
203
- <div></div>
204
-
205
- <FormField
206
- control={form.control}
207
- name="permissions"
208
- render={() => (
209
- <FormItem>
210
- <FormLabel className="text-base">Permissions</FormLabel>
211
- {permissions.map(item => (
212
- <FormField
213
- key={item.value}
214
- control={form.control}
215
- name="permissions"
216
- render={({ field }) => (
217
- <FormItem
218
- key={item.value}
219
- className="flex flex-row items-start space-x-3 space-y-0"
220
- >
221
- <FormControl>
222
- <Checkbox
223
- checked={field.value?.includes(item.value)}
224
- onCheckedChange={checked => {
225
- return checked
226
- ? field.onChange([...field.value, item.value])
227
- : field.onChange(
228
- field.value?.filter(
229
- value => value !== item.value
230
- )
231
- )
232
- }}
233
- />
234
- </FormControl>
235
- <FormLabel>{item.label}</FormLabel>
236
- </FormItem>
237
- )}
238
- />
239
- ))}
240
- <FormMessage />
241
- </FormItem>
242
- )}
243
- />
244
- </form>
245
- </Form>
246
- {role ? (
247
- <SystemInfo
248
- items={[
249
- {
250
- label: 'Id',
251
- value: role.id
252
- },
253
- {
254
- label: 'Created At',
255
- value: formatDateTime(role.createdAt)
256
- },
257
- {
258
- label: 'Updated At',
259
- value: timesAgo(role.updatedAt)
260
- }
261
- ]}
262
- />
263
- ) : undefined}
264
- </Shell>
265
- )
266
- }
@@ -1,67 +0,0 @@
1
- 'use server'
2
-
3
- import { Role } from '@prisma/client'
4
-
5
- import { authGuard } from '@/lib/auth'
6
- import { prisma } from '@/lib/db'
7
- import { UnwrapPromise } from '@/types/UnwrapPromise'
8
-
9
- export const getRoles = async ({
10
- page,
11
- limit,
12
- sortBy,
13
- sortOrder,
14
- name
15
- }: {
16
- page: number
17
- limit: number
18
- sortBy?: keyof Role
19
- sortOrder?: 'asc' | 'desc'
20
- name?: string
21
- }) => {
22
- const session = await authGuard(['Root'])
23
- if (!session) throw new Error('Unauthorized')
24
-
25
- const where = {
26
- name: name ? { contains: name, mode: 'insensitive' as const } : undefined
27
- }
28
- const [roles, total] = await Promise.all([
29
- prisma.role.findMany({
30
- where,
31
- select: {
32
- id: true,
33
- name: true,
34
- createdAt: true,
35
- updatedAt: true
36
- },
37
- skip: (page - 1) * limit,
38
- take: limit,
39
- orderBy: {
40
- [sortBy || 'createdAt']: sortOrder || 'desc'
41
- }
42
- }),
43
- prisma.role.count({
44
- where
45
- })
46
- ])
47
-
48
- return { roles, total }
49
- }
50
-
51
- export type GetRolesFnDataType = UnwrapPromise<ReturnType<typeof getRoles>>
52
-
53
- export const getRolesMini = async () => {
54
- return await prisma.role.findMany({
55
- select: {
56
- id: true,
57
- name: true
58
- },
59
- orderBy: {
60
- name: 'asc'
61
- }
62
- })
63
- }
64
-
65
- export type GetRolesMiniFnDataType = UnwrapPromise<
66
- ReturnType<typeof getRolesMini>
67
- >
@@ -1,51 +0,0 @@
1
- import { Role } from '@prisma/client'
2
- import { Metadata } from 'next'
3
- import { notFound } from 'next/navigation'
4
-
5
- import { authGuard } from '@/lib/auth'
6
- import { siteConfig } from '@/lib/siteConfig'
7
- import { getRoles } from './actions'
8
- import { Render } from './render'
9
-
10
- export const metadata: Metadata = {
11
- title: 'Roles' + ' | ' + siteConfig.name
12
- }
13
-
14
- const RolesPage = async ({
15
- searchParams
16
- }: {
17
- searchParams: {
18
- page?: string
19
- limit?: string
20
- sort?: string
21
- name?: string
22
- }
23
- }) => {
24
- const session = await authGuard(['Root'])
25
- if (!session) return notFound()
26
-
27
- const page = searchParams.page ? parseInt(searchParams.page) : 1
28
- const limit = searchParams.limit ? parseInt(searchParams.limit) : 10
29
-
30
- const [sortBy, sortOrder] =
31
- typeof searchParams.sort === 'string'
32
- ? (searchParams.sort.split('.') as [
33
- keyof Role | undefined,
34
- 'asc' | 'desc' | undefined
35
- ])
36
- : []
37
-
38
- const name = searchParams.name
39
-
40
- const data = await getRoles({
41
- page,
42
- limit,
43
- sortBy,
44
- sortOrder,
45
- name
46
- })
47
-
48
- return <Render data={data} />
49
- }
50
-
51
- export default RolesPage