create-ej-app 6.0.0 → 7.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.
- package/cli.js +88 -14
- package/cli.ts +100 -17
- package/package.json +2 -2
- package/template/base/.env.example +11 -15
- package/template/base/Dockerfile +15 -0
- package/template/base/components.json +10 -5
- package/template/base/drizzle.config.ts +4 -5
- package/template/{new → base}/eslint.config.mjs +6 -1
- package/template/base/package.json +58 -75
- package/template/base/postcss.config.mjs +1 -4
- package/template/base/src/app/(admin)/layout.tsx +20 -0
- package/template/base/src/app/(app)/layout.tsx +13 -118
- package/template/base/src/app/(auth)/login/page.tsx +65 -42
- package/template/base/src/app/(marketing)/layout.tsx +7 -35
- package/template/base/src/app/(marketing)/page.tsx +2 -96
- package/template/base/src/app/(marketing)/privacy/page.tsx +3 -0
- package/template/base/src/app/(marketing)/terms/page.tsx +3 -0
- package/template/base/src/app/globals.css +118 -66
- package/template/base/src/app/layout.tsx +27 -12
- package/template/base/src/app/not-found.tsx +27 -0
- package/template/base/src/components/site-footer.tsx +16 -24
- package/template/base/src/components/ui/button.tsx +31 -27
- package/template/base/src/components/ui/card.tsx +83 -70
- package/template/base/src/components/ui/form.tsx +38 -47
- package/template/base/src/components/ui/input.tsx +16 -20
- package/template/base/src/components/ui/label.tsx +16 -18
- package/template/base/src/components/ui/separator.tsx +11 -14
- package/template/base/src/components/ui/sonner.tsx +22 -13
- package/template/base/src/db/index.ts +4 -11
- package/template/base/src/db/schema.ts +60 -268
- package/template/{new → base}/src/env.ts +2 -2
- package/template/{new → base}/src/lib/auth-client.ts +2 -0
- package/template/base/src/lib/auth.ts +64 -80
- package/template/base/src/lib/safe-action.ts +30 -6
- package/template/base/tsconfig.json +9 -7
- package/template/{prisma-advanced → old}/.env.example +10 -9
- package/template/{prisma → old}/components.json +1 -1
- package/template/old/drizzle.config.ts +11 -0
- package/template/old/package.json +87 -0
- package/template/old/postcss.config.mjs +8 -0
- package/template/{prisma-advanced → old}/src/app/(app)/layout.tsx +11 -3
- package/template/{prisma-advanced → old}/src/app/(auth)/login/page.tsx +2 -2
- package/template/{prisma → old}/src/app/(marketing)/page.tsx +8 -7
- package/template/old/src/app/layout.tsx +31 -0
- package/template/old/src/components/ui/sonner.tsx +31 -0
- package/template/old/src/db/index.ts +14 -0
- package/template/old/src/db/schema.ts +287 -0
- package/template/old/src/lib/auth.ts +89 -0
- package/template/old/src/lib/safe-action.ts +19 -0
- package/template/{prisma-advanced → old}/tsconfig.json +3 -2
- package/template/new/.env.example +0 -13
- package/template/new/components.json +0 -22
- package/template/new/drizzle.config.ts +0 -10
- package/template/new/package.json +0 -81
- package/template/new/postcss.config.mjs +0 -5
- package/template/new/src/app/(auth)/login/page.tsx +0 -72
- package/template/new/src/app/globals.css +0 -128
- package/template/new/src/app/layout.tsx +0 -50
- package/template/new/src/app/page.tsx +0 -3
- package/template/new/src/components/ui/button.tsx +0 -60
- package/template/new/src/components/ui/card.tsx +0 -92
- package/template/new/src/components/ui/form.tsx +0 -167
- package/template/new/src/components/ui/input.tsx +0 -21
- package/template/new/src/components/ui/label.tsx +0 -24
- package/template/new/src/components/ui/separator.tsx +0 -28
- package/template/new/src/components/ui/sonner.tsx +0 -40
- package/template/new/src/db/index.ts +0 -7
- package/template/new/src/db/schema.ts +0 -74
- package/template/new/src/lib/auth.ts +0 -67
- package/template/new/src/lib/safe-action.ts +0 -15
- package/template/new/tsconfig.json +0 -49
- package/template/prisma/.env.example +0 -16
- package/template/prisma/.eslintrc.cjs +0 -24
- package/template/prisma/next.config.mjs +0 -15
- package/template/prisma/package.json +0 -80
- package/template/prisma/postcss.config.cjs +0 -6
- package/template/prisma/prettier.config.ts +0 -11
- package/template/prisma/prisma/schema.prisma +0 -115
- package/template/prisma/public/next.svg +0 -1
- package/template/prisma/src/app/(app)/dashboard/page.tsx +0 -19
- package/template/prisma/src/app/(app)/layout.tsx +0 -90
- package/template/prisma/src/app/(app)/settings/actions.ts +0 -18
- package/template/prisma/src/app/(app)/settings/loading.tsx +0 -28
- package/template/prisma/src/app/(app)/settings/page.tsx +0 -28
- package/template/prisma/src/app/(app)/settings/render.tsx +0 -113
- package/template/prisma/src/app/(app)/tasks/[id]/actions.ts +0 -147
- package/template/prisma/src/app/(app)/tasks/[id]/page.tsx +0 -25
- package/template/prisma/src/app/(app)/tasks/[id]/render.tsx +0 -413
- package/template/prisma/src/app/(app)/tasks/actions.ts +0 -69
- package/template/prisma/src/app/(app)/tasks/page.tsx +0 -53
- package/template/prisma/src/app/(app)/tasks/render.tsx +0 -107
- package/template/prisma/src/app/(app)/users/[id]/actions.ts +0 -83
- package/template/prisma/src/app/(app)/users/[id]/page.tsx +0 -32
- package/template/prisma/src/app/(app)/users/[id]/render.tsx +0 -240
- package/template/prisma/src/app/(app)/users/actions.ts +0 -55
- package/template/prisma/src/app/(app)/users/page.tsx +0 -49
- package/template/prisma/src/app/(app)/users/render.tsx +0 -80
- package/template/prisma/src/app/(auth)/layout.tsx +0 -20
- package/template/prisma/src/app/(auth)/login/page.tsx +0 -49
- package/template/prisma/src/app/(auth)/login/user-auth-form.tsx +0 -152
- package/template/prisma/src/app/api/auth/[...nextauth]/route.ts +0 -7
- package/template/prisma/src/app/api/upload/route.ts +0 -36
- package/template/prisma/src/app/favicon.ico +0 -0
- package/template/prisma/src/app/layout.tsx +0 -34
- package/template/prisma/src/components/app-nav-command.tsx +0 -160
- package/template/prisma/src/components/dark-mode-toggle.tsx +0 -43
- package/template/prisma/src/components/data-table/data-table-column-header.tsx +0 -91
- package/template/prisma/src/components/data-table/data-table-faceted-filter.tsx +0 -149
- package/template/prisma/src/components/data-table/data-table-loading.tsx +0 -77
- package/template/prisma/src/components/data-table/data-table-pagination.tsx +0 -94
- package/template/prisma/src/components/data-table/data-table-toolbar.tsx +0 -78
- package/template/prisma/src/components/data-table/data-table-types.ts +0 -17
- package/template/prisma/src/components/data-table/data-table-view-options.tsx +0 -59
- package/template/prisma/src/components/data-table/data-table.tsx +0 -301
- package/template/prisma/src/components/data-table/simple-data-table.tsx +0 -109
- package/template/prisma/src/components/empty-placeholder.tsx +0 -78
- package/template/prisma/src/components/heading.tsx +0 -17
- package/template/prisma/src/components/icons.tsx +0 -85
- package/template/prisma/src/components/main-nav.tsx +0 -64
- package/template/prisma/src/components/mobile-nav.tsx +0 -50
- package/template/prisma/src/components/shell.tsx +0 -13
- package/template/prisma/src/components/side-nav.tsx +0 -51
- package/template/prisma/src/components/site-footer.tsx +0 -31
- package/template/prisma/src/components/system-info.tsx +0 -36
- package/template/prisma/src/components/theme-provider.tsx +0 -13
- package/template/prisma/src/components/ui/alert-dialog.tsx +0 -141
- package/template/prisma/src/components/ui/avatar.tsx +0 -50
- package/template/prisma/src/components/ui/badge.tsx +0 -36
- package/template/prisma/src/components/ui/button.tsx +0 -56
- package/template/prisma/src/components/ui/card.tsx +0 -79
- package/template/prisma/src/components/ui/checkbox.tsx +0 -30
- package/template/prisma/src/components/ui/command.tsx +0 -155
- package/template/prisma/src/components/ui/dialog.tsx +0 -122
- package/template/prisma/src/components/ui/dropdown-menu.tsx +0 -200
- package/template/prisma/src/components/ui/form.tsx +0 -176
- package/template/prisma/src/components/ui/input.tsx +0 -25
- package/template/prisma/src/components/ui/label.tsx +0 -26
- package/template/prisma/src/components/ui/popover.tsx +0 -31
- package/template/prisma/src/components/ui/select.tsx +0 -160
- package/template/prisma/src/components/ui/separator.tsx +0 -31
- package/template/prisma/src/components/ui/skeleton.tsx +0 -15
- package/template/prisma/src/components/ui/table.tsx +0 -117
- package/template/prisma/src/components/ui/textarea.tsx +0 -24
- package/template/prisma/src/components/ui/toast.tsx +0 -127
- package/template/prisma/src/components/ui/toaster.tsx +0 -35
- package/template/prisma/src/components/ui/use-toast.ts +0 -189
- package/template/prisma/src/components/user-account-nav.tsx +0 -60
- package/template/prisma/src/components/user-avatar.tsx +0 -25
- package/template/prisma/src/env.mjs +0 -78
- package/template/prisma/src/hooks/use-debounce.ts +0 -17
- package/template/prisma/src/hooks/use-lock-body.tsx +0 -12
- package/template/prisma/src/lib/auth.ts +0 -80
- package/template/prisma/src/lib/cn.ts +0 -4
- package/template/prisma/src/lib/db.ts +0 -20
- package/template/prisma/src/lib/delay.ts +0 -2
- package/template/prisma/src/lib/formatDate.ts +0 -11
- package/template/prisma/src/lib/generateLabel.ts +0 -5
- package/template/prisma/src/lib/siteConfig.ts +0 -4
- package/template/prisma/src/lib/storageClient.ts +0 -11
- package/template/prisma/src/styles/editor.css +0 -61
- package/template/prisma/src/styles/globals.css +0 -76
- package/template/prisma/src/types/UnwrapPromise.ts +0 -1
- package/template/prisma/tailwind.config.ts +0 -80
- package/template/prisma/tsconfig.json +0 -46
- package/template/prisma-advanced/.eslintrc.cjs +0 -24
- package/template/prisma-advanced/components.json +0 -17
- package/template/prisma-advanced/next.config.mjs +0 -15
- package/template/prisma-advanced/package.json +0 -80
- package/template/prisma-advanced/postcss.config.cjs +0 -6
- package/template/prisma-advanced/prettier.config.ts +0 -11
- package/template/prisma-advanced/prisma/schema.prisma +0 -154
- package/template/prisma-advanced/public/next.svg +0 -1
- package/template/prisma-advanced/src/app/(app)/dashboard/page.tsx +0 -19
- package/template/prisma-advanced/src/app/(app)/roles/[id]/actions.ts +0 -100
- package/template/prisma-advanced/src/app/(app)/roles/[id]/page.tsx +0 -36
- package/template/prisma-advanced/src/app/(app)/roles/[id]/render.tsx +0 -266
- package/template/prisma-advanced/src/app/(app)/roles/actions.ts +0 -67
- package/template/prisma-advanced/src/app/(app)/roles/page.tsx +0 -51
- package/template/prisma-advanced/src/app/(app)/roles/render.tsx +0 -70
- package/template/prisma-advanced/src/app/(app)/settings/actions.ts +0 -18
- package/template/prisma-advanced/src/app/(app)/settings/loading.tsx +0 -28
- package/template/prisma-advanced/src/app/(app)/settings/page.tsx +0 -28
- package/template/prisma-advanced/src/app/(app)/settings/render.tsx +0 -113
- package/template/prisma-advanced/src/app/(app)/tasks/[id]/actions.ts +0 -147
- package/template/prisma-advanced/src/app/(app)/tasks/[id]/page.tsx +0 -55
- package/template/prisma-advanced/src/app/(app)/tasks/[id]/render.tsx +0 -418
- package/template/prisma-advanced/src/app/(app)/tasks/actions.ts +0 -69
- package/template/prisma-advanced/src/app/(app)/tasks/page.tsx +0 -63
- package/template/prisma-advanced/src/app/(app)/tasks/render.tsx +0 -114
- package/template/prisma-advanced/src/app/(app)/users/[id]/actions.ts +0 -104
- package/template/prisma-advanced/src/app/(app)/users/[id]/page.tsx +0 -39
- package/template/prisma-advanced/src/app/(app)/users/[id]/render.tsx +0 -320
- package/template/prisma-advanced/src/app/(app)/users/actions.ts +0 -67
- package/template/prisma-advanced/src/app/(app)/users/page.tsx +0 -61
- package/template/prisma-advanced/src/app/(app)/users/render.tsx +0 -108
- package/template/prisma-advanced/src/app/(auth)/layout.tsx +0 -20
- package/template/prisma-advanced/src/app/(auth)/login/user-auth-form.tsx +0 -152
- package/template/prisma-advanced/src/app/(marketing)/layout.tsx +0 -42
- package/template/prisma-advanced/src/app/(marketing)/page.tsx +0 -96
- package/template/prisma-advanced/src/app/api/auth/[...nextauth]/route.ts +0 -7
- package/template/prisma-advanced/src/app/api/upload/route.ts +0 -36
- package/template/prisma-advanced/src/app/favicon.ico +0 -0
- package/template/prisma-advanced/src/app/layout.tsx +0 -34
- package/template/prisma-advanced/src/components/app-nav-command.tsx +0 -160
- package/template/prisma-advanced/src/components/dark-mode-toggle.tsx +0 -43
- package/template/prisma-advanced/src/components/data-table/data-table-column-header.tsx +0 -91
- package/template/prisma-advanced/src/components/data-table/data-table-faceted-filter.tsx +0 -149
- package/template/prisma-advanced/src/components/data-table/data-table-loading.tsx +0 -77
- package/template/prisma-advanced/src/components/data-table/data-table-pagination.tsx +0 -94
- package/template/prisma-advanced/src/components/data-table/data-table-toolbar.tsx +0 -78
- package/template/prisma-advanced/src/components/data-table/data-table-types.ts +0 -17
- package/template/prisma-advanced/src/components/data-table/data-table-view-options.tsx +0 -59
- package/template/prisma-advanced/src/components/data-table/data-table.tsx +0 -301
- package/template/prisma-advanced/src/components/data-table/simple-data-table.tsx +0 -109
- package/template/prisma-advanced/src/components/empty-placeholder.tsx +0 -78
- package/template/prisma-advanced/src/components/heading.tsx +0 -17
- package/template/prisma-advanced/src/components/icons.tsx +0 -85
- package/template/prisma-advanced/src/components/main-nav.tsx +0 -64
- package/template/prisma-advanced/src/components/shell.tsx +0 -13
- package/template/prisma-advanced/src/components/side-nav.tsx +0 -51
- package/template/prisma-advanced/src/components/system-info.tsx +0 -36
- package/template/prisma-advanced/src/components/theme-provider.tsx +0 -13
- package/template/prisma-advanced/src/components/ui/alert-dialog.tsx +0 -141
- package/template/prisma-advanced/src/components/ui/avatar.tsx +0 -50
- package/template/prisma-advanced/src/components/ui/badge.tsx +0 -36
- package/template/prisma-advanced/src/components/ui/checkbox.tsx +0 -30
- package/template/prisma-advanced/src/components/ui/command.tsx +0 -155
- package/template/prisma-advanced/src/components/ui/dialog.tsx +0 -122
- package/template/prisma-advanced/src/components/ui/dropdown-menu.tsx +0 -200
- package/template/prisma-advanced/src/components/ui/popover.tsx +0 -31
- package/template/prisma-advanced/src/components/ui/select.tsx +0 -160
- package/template/prisma-advanced/src/components/ui/skeleton.tsx +0 -15
- package/template/prisma-advanced/src/components/ui/table.tsx +0 -117
- package/template/prisma-advanced/src/components/ui/textarea.tsx +0 -24
- package/template/prisma-advanced/src/components/ui/toast.tsx +0 -127
- package/template/prisma-advanced/src/components/ui/toaster.tsx +0 -35
- package/template/prisma-advanced/src/components/ui/use-toast.ts +0 -189
- package/template/prisma-advanced/src/components/user-account-nav.tsx +0 -60
- package/template/prisma-advanced/src/components/user-avatar.tsx +0 -25
- package/template/prisma-advanced/src/env.mjs +0 -78
- package/template/prisma-advanced/src/hooks/use-debounce.ts +0 -17
- package/template/prisma-advanced/src/hooks/use-lock-body.tsx +0 -12
- package/template/prisma-advanced/src/lib/auth.ts +0 -180
- package/template/prisma-advanced/src/lib/cn.ts +0 -4
- package/template/prisma-advanced/src/lib/db.ts +0 -20
- package/template/prisma-advanced/src/lib/delay.ts +0 -2
- package/template/prisma-advanced/src/lib/formatDate.ts +0 -11
- package/template/prisma-advanced/src/lib/generateLabel.ts +0 -5
- package/template/prisma-advanced/src/lib/siteConfig.ts +0 -4
- package/template/prisma-advanced/src/lib/storageClient.ts +0 -11
- package/template/prisma-advanced/src/styles/editor.css +0 -61
- package/template/prisma-advanced/src/types/UnwrapPromise.ts +0 -1
- package/template/prisma-advanced/tailwind.config.ts +0 -80
- package/template/{new → base}/next.config.ts +0 -0
- package/template/{new → base}/public/placeholder.svg +0 -0
- package/template/{new → base}/src/app/(auth)/login/email-login-form.tsx +0 -0
- package/template/{new → base}/src/app/(auth)/login/social-login-buttons.tsx +0 -0
- package/template/{new → base}/src/app/api/auth/[...all]/route.ts +0 -0
- package/template/{new → base}/src/components/loader.tsx +0 -0
- package/template/{new → base}/src/components/react-query-provider.tsx +0 -0
- package/template/{new → base}/src/components/screen-size.tsx +0 -0
- package/template/{new → base}/src/components/theme-toggle.tsx +0 -0
- package/template/{new → base}/src/lib/toast-message.ts +0 -0
- package/template/{base → old}/.eslintrc.cjs +0 -0
- package/template/{base → old}/next.config.mjs +0 -0
- package/template/{new → old}/prettier.config.mjs +0 -0
- package/template/{base → old}/public/next.svg +0 -0
- package/template/{base → old}/public/vercel.svg +0 -0
- package/template/{base → old}/src/app/(app)/dashboard/layout.tsx +0 -0
- package/template/{base → old}/src/app/(app)/dashboard/page.tsx +0 -0
- package/template/{base → old}/src/app/(app)/roles/[id]/actions.ts +0 -0
- package/template/{base → old}/src/app/(app)/roles/[id]/page.tsx +0 -0
- package/template/{base → old}/src/app/(app)/roles/[id]/render.tsx +0 -0
- package/template/{base → old}/src/app/(app)/roles/[id]/validation.ts +0 -0
- package/template/{base → old}/src/app/(app)/roles/actions.ts +0 -0
- package/template/{base → old}/src/app/(app)/roles/page.tsx +0 -0
- package/template/{base → old}/src/app/(app)/roles/render.tsx +0 -0
- package/template/{base → old}/src/app/(app)/settings/actions.ts +0 -0
- package/template/{base → old}/src/app/(app)/settings/layout.tsx +0 -0
- package/template/{base → old}/src/app/(app)/settings/loading.tsx +0 -0
- package/template/{base → old}/src/app/(app)/settings/page.tsx +0 -0
- package/template/{base → old}/src/app/(app)/settings/render.tsx +0 -0
- package/template/{base → old}/src/app/(app)/settings/validation.ts +0 -0
- package/template/{base → old}/src/app/(app)/tasks/[id]/actions.ts +0 -0
- package/template/{base → old}/src/app/(app)/tasks/[id]/page.tsx +0 -0
- package/template/{base → old}/src/app/(app)/tasks/[id]/render.tsx +0 -0
- package/template/{base → old}/src/app/(app)/tasks/[id]/validation.ts +0 -0
- package/template/{base → old}/src/app/(app)/tasks/actions.ts +0 -0
- package/template/{base → old}/src/app/(app)/tasks/page.tsx +0 -0
- package/template/{base → old}/src/app/(app)/tasks/render.tsx +0 -0
- package/template/{base → old}/src/app/(app)/tasks/statusEnum.ts +0 -0
- package/template/{base → old}/src/app/(app)/users/[id]/actions.ts +0 -0
- package/template/{base → old}/src/app/(app)/users/[id]/page.tsx +0 -0
- package/template/{base → old}/src/app/(app)/users/[id]/render.tsx +0 -0
- package/template/{base → old}/src/app/(app)/users/[id]/validation.ts +0 -0
- package/template/{base → old}/src/app/(app)/users/actions.ts +0 -0
- package/template/{base → old}/src/app/(app)/users/page.tsx +0 -0
- package/template/{base → old}/src/app/(app)/users/render.tsx +0 -0
- package/template/{base → old}/src/app/(auth)/layout.tsx +0 -0
- package/template/{base → old}/src/app/(auth)/login/render.tsx +0 -0
- package/template/{prisma → old}/src/app/(marketing)/layout.tsx +1 -1
- /package/template/{base → old}/src/app/api/auth/[...nextauth]/route.ts +0 -0
- /package/template/{new → old}/src/app/favicon.ico +0 -0
- /package/template/{prisma-advanced/src/styles → old/src/app}/globals.css +0 -0
- /package/template/{base → old}/src/components/app-nav-command.tsx +0 -0
- /package/template/{base → old}/src/components/dark-mode-toggle.tsx +0 -0
- /package/template/{base → old}/src/components/data-table/data-table-column-header.tsx +0 -0
- /package/template/{base → old}/src/components/data-table/data-table-faceted-filter.tsx +0 -0
- /package/template/{base → old}/src/components/data-table/data-table-loading.tsx +0 -0
- /package/template/{base → old}/src/components/data-table/data-table-pagination.tsx +0 -0
- /package/template/{base → old}/src/components/data-table/data-table-toolbar.tsx +0 -0
- /package/template/{base → old}/src/components/data-table/data-table-types.ts +0 -0
- /package/template/{base → old}/src/components/data-table/data-table-view-options.tsx +0 -0
- /package/template/{base → old}/src/components/data-table/data-table.tsx +0 -0
- /package/template/{base → old}/src/components/data-table/simple-data-table.tsx +0 -0
- /package/template/{base → old}/src/components/empty-placeholder.tsx +0 -0
- /package/template/{base → old}/src/components/heading.tsx +0 -0
- /package/template/{base → old}/src/components/icons.tsx +0 -0
- /package/template/{base → old}/src/components/main-nav.tsx +0 -0
- /package/template/{base → old}/src/components/mobile-nav.tsx +0 -0
- /package/template/{base → old}/src/components/shell.tsx +0 -0
- /package/template/{base → old}/src/components/side-nav.tsx +0 -0
- /package/template/{prisma-advanced → old}/src/components/site-footer.tsx +0 -0
- /package/template/{base → old}/src/components/system-info.tsx +0 -0
- /package/template/{base → old}/src/components/ui/alert-dialog.tsx +0 -0
- /package/template/{base → old}/src/components/ui/avatar.tsx +0 -0
- /package/template/{base → old}/src/components/ui/badge.tsx +0 -0
- /package/template/{prisma-advanced → old}/src/components/ui/button.tsx +0 -0
- /package/template/{prisma-advanced → old}/src/components/ui/card.tsx +0 -0
- /package/template/{base → old}/src/components/ui/checkbox.tsx +0 -0
- /package/template/{base → old}/src/components/ui/command.tsx +0 -0
- /package/template/{base → old}/src/components/ui/dialog.tsx +0 -0
- /package/template/{base → old}/src/components/ui/dropdown-menu.tsx +0 -0
- /package/template/{prisma-advanced → old}/src/components/ui/form.tsx +0 -0
- /package/template/{prisma-advanced → old}/src/components/ui/input.tsx +0 -0
- /package/template/{prisma-advanced → old}/src/components/ui/label.tsx +0 -0
- /package/template/{base → old}/src/components/ui/popover.tsx +0 -0
- /package/template/{base → old}/src/components/ui/select.tsx +0 -0
- /package/template/{prisma-advanced → old}/src/components/ui/separator.tsx +0 -0
- /package/template/{base → old}/src/components/ui/skeleton.tsx +0 -0
- /package/template/{base → old}/src/components/ui/table.tsx +0 -0
- /package/template/{base → old}/src/components/user-account-nav.tsx +0 -0
- /package/template/{base → old}/src/components/user-avatar.tsx +0 -0
- /package/template/{base → old}/src/data-access/resource.ts +0 -0
- /package/template/{base → old}/src/data-access/role-permission.ts +0 -0
- /package/template/{base → old}/src/data-access/role.ts +0 -0
- /package/template/{base → old}/src/data-access/task.ts +0 -0
- /package/template/{base → old}/src/data-access/user.ts +0 -0
- /package/template/{base → old}/src/env.mjs +0 -0
- /package/template/{base → old}/src/hooks/use-debounce.tsx +0 -0
- /package/template/{base → old}/src/hooks/use-lock-body.tsx +0 -0
- /package/template/{new → old}/src/lib/cn.ts +0 -0
- /package/template/{base → old}/src/lib/currentUser.ts +0 -0
- /package/template/{new → old}/src/lib/delay.ts +0 -0
- /package/template/{base → old}/src/lib/formatDate.ts +0 -0
- /package/template/{base → old}/src/lib/generateLabel.ts +0 -0
- /package/template/{base → old}/src/lib/s3Client.ts +0 -0
- /package/template/{new → old}/src/lib/siteConfig.ts +0 -0
- /package/template/{base → old}/src/lib/sortOrderEnum.ts +0 -0
- /package/template/{base → old}/src/use-case/role-permission.ts +0 -0
- /package/template/{base → old}/src/use-case/role.ts +0 -0
- /package/template/{base → old}/src/use-case/task.ts +0 -0
- /package/template/{base → old}/src/use-case/user.ts +0 -0
- /package/template/{base → old}/tailwind.config.ts +0 -0
|
@@ -1,413 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import EditorJS from '@editorjs/editorjs'
|
|
4
|
-
import { zodResolver } from '@hookform/resolvers/zod'
|
|
5
|
-
import { TaskStatus } from '@prisma/client'
|
|
6
|
-
import edjsHTML from 'editorjs-html'
|
|
7
|
-
import Link from 'next/link'
|
|
8
|
-
import { useRouter } from 'next/navigation'
|
|
9
|
-
import { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
10
|
-
import { useForm } from 'react-hook-form'
|
|
11
|
-
import { z } from 'zod'
|
|
12
|
-
|
|
13
|
-
import { Heading } from '@/components/heading'
|
|
14
|
-
import { Icons } from '@/components/icons'
|
|
15
|
-
import { Shell } from '@/components/shell'
|
|
16
|
-
import { SystemInfo } from '@/components/system-info'
|
|
17
|
-
import {
|
|
18
|
-
AlertDialog,
|
|
19
|
-
AlertDialogAction,
|
|
20
|
-
AlertDialogCancel,
|
|
21
|
-
AlertDialogContent,
|
|
22
|
-
AlertDialogDescription,
|
|
23
|
-
AlertDialogFooter,
|
|
24
|
-
AlertDialogHeader,
|
|
25
|
-
AlertDialogTitle,
|
|
26
|
-
AlertDialogTrigger
|
|
27
|
-
} from '@/components/ui/alert-dialog'
|
|
28
|
-
import { Button } from '@/components/ui/button'
|
|
29
|
-
import {
|
|
30
|
-
Form,
|
|
31
|
-
FormControl,
|
|
32
|
-
FormField,
|
|
33
|
-
FormItem,
|
|
34
|
-
FormLabel,
|
|
35
|
-
FormMessage
|
|
36
|
-
} from '@/components/ui/form'
|
|
37
|
-
import { Input } from '@/components/ui/input'
|
|
38
|
-
import {
|
|
39
|
-
Select,
|
|
40
|
-
SelectContent,
|
|
41
|
-
SelectItem,
|
|
42
|
-
SelectTrigger,
|
|
43
|
-
SelectValue
|
|
44
|
-
} from '@/components/ui/select'
|
|
45
|
-
import { toast } from '@/components/ui/use-toast'
|
|
46
|
-
import { formatDateTime, timesAgo } from '@/lib/formatDate'
|
|
47
|
-
import { generateLabel } from '@/lib/generateLabel'
|
|
48
|
-
import '@/styles/editor.css'
|
|
49
|
-
import {
|
|
50
|
-
GetTaskFnDataType,
|
|
51
|
-
createTask,
|
|
52
|
-
deleteTask,
|
|
53
|
-
updateTask
|
|
54
|
-
} from './actions'
|
|
55
|
-
|
|
56
|
-
const TaskSchema = z.object({
|
|
57
|
-
title: z.string().nonempty(),
|
|
58
|
-
status: z.nativeEnum(TaskStatus)
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
type FormData = z.infer<typeof TaskSchema>
|
|
62
|
-
|
|
63
|
-
const statuses = Object.values(TaskStatus).map(x => ({
|
|
64
|
-
label: generateLabel(x),
|
|
65
|
-
value: x
|
|
66
|
-
}))
|
|
67
|
-
|
|
68
|
-
const edjsParser = edjsHTML()
|
|
69
|
-
|
|
70
|
-
export const Render: FC<{
|
|
71
|
-
task: GetTaskFnDataType | undefined
|
|
72
|
-
}> = ({ task }) => {
|
|
73
|
-
const form = useForm<FormData>({
|
|
74
|
-
resolver: zodResolver(TaskSchema),
|
|
75
|
-
defaultValues: {
|
|
76
|
-
title: task?.title ?? '',
|
|
77
|
-
status: task?.status || 'Todo'
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
const router = useRouter()
|
|
81
|
-
const [isSaving, setIsSaving] = useState(false)
|
|
82
|
-
const [isDeleting, setIsDeleting] = useState(false)
|
|
83
|
-
const [isEditorMounted, setIsMounted] = useState<boolean>(false)
|
|
84
|
-
|
|
85
|
-
const editorRef = useRef<EditorJS>()
|
|
86
|
-
|
|
87
|
-
const initializeEditor = useCallback(async () => {
|
|
88
|
-
const EditorJS = (await import('@editorjs/editorjs')).default
|
|
89
|
-
|
|
90
|
-
// @ts-ignore
|
|
91
|
-
const Table = (await import('@editorjs/table')).default
|
|
92
|
-
// @ts-ignore
|
|
93
|
-
const List = (await import('@editorjs/list')).default
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
const Image = (await import('@editorjs/image')).default
|
|
96
|
-
// @ts-ignore
|
|
97
|
-
const Header = (await import('@editorjs/header')).default
|
|
98
|
-
// @ts-ignore
|
|
99
|
-
const Quote = (await import('@editorjs/quote')).default
|
|
100
|
-
// @ts-ignore
|
|
101
|
-
const CheckList = (await import('@editorjs/checklist')).default
|
|
102
|
-
// @ts-ignore
|
|
103
|
-
const Delimiter = (await import('@editorjs/delimiter')).default
|
|
104
|
-
|
|
105
|
-
if (!editorRef.current) {
|
|
106
|
-
const editor = new EditorJS({
|
|
107
|
-
holder: 'editor',
|
|
108
|
-
onReady() {
|
|
109
|
-
editorRef.current = editor
|
|
110
|
-
},
|
|
111
|
-
placeholder: 'Type here to write...',
|
|
112
|
-
inlineToolbar: true,
|
|
113
|
-
data: task?.description as any,
|
|
114
|
-
tools: {
|
|
115
|
-
header: Header,
|
|
116
|
-
list: List,
|
|
117
|
-
image: {
|
|
118
|
-
class: Image,
|
|
119
|
-
config: {
|
|
120
|
-
uploader: {
|
|
121
|
-
async uploadByFile(file: any) {
|
|
122
|
-
const formData = new FormData()
|
|
123
|
-
formData.append('file', file)
|
|
124
|
-
const res = await fetch('/api/upload', {
|
|
125
|
-
method: 'POST',
|
|
126
|
-
body: formData
|
|
127
|
-
})
|
|
128
|
-
const json = await res.json()
|
|
129
|
-
if (json.success && json.id && json.url) {
|
|
130
|
-
return {
|
|
131
|
-
success: true,
|
|
132
|
-
file: {
|
|
133
|
-
id: json.id,
|
|
134
|
-
url: json.url
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
} else {
|
|
138
|
-
return {
|
|
139
|
-
success: false
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
table: Table,
|
|
147
|
-
checklist: CheckList,
|
|
148
|
-
quote: Quote,
|
|
149
|
-
delimiter: Delimiter
|
|
150
|
-
}
|
|
151
|
-
})
|
|
152
|
-
}
|
|
153
|
-
}, [task?.description])
|
|
154
|
-
|
|
155
|
-
useEffect(() => {
|
|
156
|
-
if (typeof window !== 'undefined') setIsMounted(true)
|
|
157
|
-
}, [])
|
|
158
|
-
|
|
159
|
-
useEffect(() => {
|
|
160
|
-
if (!isEditorMounted) return
|
|
161
|
-
|
|
162
|
-
initializeEditor()
|
|
163
|
-
|
|
164
|
-
return () => {
|
|
165
|
-
editorRef.current?.destroy()
|
|
166
|
-
editorRef.current = undefined
|
|
167
|
-
}
|
|
168
|
-
}, [isEditorMounted, initializeEditor])
|
|
169
|
-
|
|
170
|
-
const editorHTML = useMemo(() => {
|
|
171
|
-
if (!task?.description) return ''
|
|
172
|
-
return edjsParser.parse(task.description as any).join('')
|
|
173
|
-
}, [task?.description])
|
|
174
|
-
console.log(editorHTML)
|
|
175
|
-
|
|
176
|
-
async function onSubmit(data: FormData) {
|
|
177
|
-
setIsSaving(true)
|
|
178
|
-
try {
|
|
179
|
-
const editorData = await editorRef.current?.save()
|
|
180
|
-
const imageIds: string[] = []
|
|
181
|
-
if (editorData?.blocks)
|
|
182
|
-
for (const b of editorData.blocks)
|
|
183
|
-
if (
|
|
184
|
-
b.type === 'image' &&
|
|
185
|
-
b.data &&
|
|
186
|
-
b.data.file &&
|
|
187
|
-
b.data.file.id &&
|
|
188
|
-
b.data.file.url
|
|
189
|
-
)
|
|
190
|
-
imageIds.push(b.data.file.id)
|
|
191
|
-
|
|
192
|
-
if (!task) {
|
|
193
|
-
const newId = await createTask({
|
|
194
|
-
...data,
|
|
195
|
-
description: editorData,
|
|
196
|
-
imageIds
|
|
197
|
-
})
|
|
198
|
-
router.replace(`/tasks/${newId}`)
|
|
199
|
-
} else {
|
|
200
|
-
await updateTask({
|
|
201
|
-
id: task.id,
|
|
202
|
-
...data,
|
|
203
|
-
description: editorData,
|
|
204
|
-
imageIds
|
|
205
|
-
})
|
|
206
|
-
}
|
|
207
|
-
toast({
|
|
208
|
-
title: 'Task saved'
|
|
209
|
-
})
|
|
210
|
-
} catch (err) {
|
|
211
|
-
toast({
|
|
212
|
-
title: 'Error saving task',
|
|
213
|
-
variant: 'destructive'
|
|
214
|
-
})
|
|
215
|
-
}
|
|
216
|
-
setIsSaving(false)
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return (
|
|
220
|
-
<Shell>
|
|
221
|
-
<Heading heading={task ? task.title : 'New Task'} />
|
|
222
|
-
<Form {...form}>
|
|
223
|
-
<form
|
|
224
|
-
className="grid grid-cols-1 gap-3 md:grid-cols-2"
|
|
225
|
-
onSubmit={form.handleSubmit(onSubmit)}
|
|
226
|
-
>
|
|
227
|
-
<div className="col-span-1 mb-1 grid grid-cols-2 gap-2 sm:flex md:col-span-2">
|
|
228
|
-
<Button type="button" onClick={() => router.back()} variant="ghost">
|
|
229
|
-
<Icons.chevronLeft className="mr-2 h-4 w-4" />
|
|
230
|
-
Back
|
|
231
|
-
</Button>
|
|
232
|
-
<Button type="submit" disabled={isSaving || isDeleting}>
|
|
233
|
-
{isSaving ? (
|
|
234
|
-
<Icons.spinner className="mr-2 h-4 w-4 animate-spin" />
|
|
235
|
-
) : (
|
|
236
|
-
<Icons.save className="mr-2 h-4 w-4" />
|
|
237
|
-
)}
|
|
238
|
-
<span>Save</span>
|
|
239
|
-
</Button>
|
|
240
|
-
{task ? (
|
|
241
|
-
<AlertDialog>
|
|
242
|
-
<AlertDialogTrigger asChild>
|
|
243
|
-
<Button
|
|
244
|
-
type="button"
|
|
245
|
-
variant="destructive"
|
|
246
|
-
disabled={isSaving || isDeleting}
|
|
247
|
-
>
|
|
248
|
-
{isDeleting ? (
|
|
249
|
-
<Icons.spinner className="mr-2 h-4 w-4 animate-spin" />
|
|
250
|
-
) : (
|
|
251
|
-
<Icons.delete className="mr-2 h-4 w-4" />
|
|
252
|
-
)}
|
|
253
|
-
Delete
|
|
254
|
-
</Button>
|
|
255
|
-
</AlertDialogTrigger>
|
|
256
|
-
<AlertDialogContent>
|
|
257
|
-
<AlertDialogHeader>
|
|
258
|
-
<AlertDialogTitle>
|
|
259
|
-
Are you absolutely sure?
|
|
260
|
-
</AlertDialogTitle>
|
|
261
|
-
<AlertDialogDescription>
|
|
262
|
-
This action cannot be undone.
|
|
263
|
-
</AlertDialogDescription>
|
|
264
|
-
</AlertDialogHeader>
|
|
265
|
-
<AlertDialogFooter>
|
|
266
|
-
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
267
|
-
<AlertDialogAction
|
|
268
|
-
onClick={async () => {
|
|
269
|
-
setIsDeleting(true)
|
|
270
|
-
try {
|
|
271
|
-
await deleteTask(task.id)
|
|
272
|
-
toast({
|
|
273
|
-
title: 'Task deleted'
|
|
274
|
-
})
|
|
275
|
-
router.push('/tasks')
|
|
276
|
-
} catch (err) {
|
|
277
|
-
toast({
|
|
278
|
-
title: 'Error deleting task',
|
|
279
|
-
variant: 'destructive'
|
|
280
|
-
})
|
|
281
|
-
}
|
|
282
|
-
setIsDeleting(false)
|
|
283
|
-
}}
|
|
284
|
-
>
|
|
285
|
-
Continue
|
|
286
|
-
</AlertDialogAction>
|
|
287
|
-
</AlertDialogFooter>
|
|
288
|
-
</AlertDialogContent>
|
|
289
|
-
</AlertDialog>
|
|
290
|
-
) : undefined}
|
|
291
|
-
{task ? (
|
|
292
|
-
<Link href="/tasks/new">
|
|
293
|
-
<Button
|
|
294
|
-
type="button"
|
|
295
|
-
disabled={isSaving || isDeleting}
|
|
296
|
-
variant="secondary"
|
|
297
|
-
className="w-full"
|
|
298
|
-
>
|
|
299
|
-
<Icons.add className="mr-2 h-4 w-4" />
|
|
300
|
-
New
|
|
301
|
-
</Button>
|
|
302
|
-
</Link>
|
|
303
|
-
) : undefined}
|
|
304
|
-
</div>
|
|
305
|
-
|
|
306
|
-
<FormField
|
|
307
|
-
control={form.control}
|
|
308
|
-
name="title"
|
|
309
|
-
render={({ field }) => (
|
|
310
|
-
<FormItem>
|
|
311
|
-
<FormLabel>Title</FormLabel>
|
|
312
|
-
<FormControl>
|
|
313
|
-
<Input
|
|
314
|
-
type="text"
|
|
315
|
-
placeholder="Enter a title"
|
|
316
|
-
disabled={isSaving}
|
|
317
|
-
{...field}
|
|
318
|
-
/>
|
|
319
|
-
</FormControl>
|
|
320
|
-
<FormMessage />
|
|
321
|
-
</FormItem>
|
|
322
|
-
)}
|
|
323
|
-
/>
|
|
324
|
-
|
|
325
|
-
<FormField
|
|
326
|
-
control={form.control}
|
|
327
|
-
name="status"
|
|
328
|
-
render={({ field }) => (
|
|
329
|
-
<FormItem>
|
|
330
|
-
<FormLabel>Status</FormLabel>
|
|
331
|
-
<Select
|
|
332
|
-
onValueChange={field.onChange}
|
|
333
|
-
defaultValue={field.value}
|
|
334
|
-
disabled={isSaving}
|
|
335
|
-
>
|
|
336
|
-
<FormControl>
|
|
337
|
-
<SelectTrigger>
|
|
338
|
-
<SelectValue placeholder="Select status" />
|
|
339
|
-
</SelectTrigger>
|
|
340
|
-
</FormControl>
|
|
341
|
-
<SelectContent>
|
|
342
|
-
{statuses.map(({ label, value }) => (
|
|
343
|
-
<SelectItem key={value} value={value}>
|
|
344
|
-
{label}
|
|
345
|
-
</SelectItem>
|
|
346
|
-
))}
|
|
347
|
-
</SelectContent>
|
|
348
|
-
</Select>
|
|
349
|
-
<FormMessage />
|
|
350
|
-
</FormItem>
|
|
351
|
-
)}
|
|
352
|
-
/>
|
|
353
|
-
|
|
354
|
-
{isEditorMounted ? (
|
|
355
|
-
<div className="col-span-1 md:col-span-2 w-full mt-5 prose prose-neutral mx-auto dark:prose-invert">
|
|
356
|
-
<h3 className="w-full bg-transparent text-3xl font-bold">
|
|
357
|
-
Description
|
|
358
|
-
</h3>
|
|
359
|
-
<div id="editor" className="min-h-[360px] w-full" />
|
|
360
|
-
<p className="text-sm text-gray-500">
|
|
361
|
-
Use{' '}
|
|
362
|
-
<kbd className="rounded-md border bg-muted px-1 text-xs uppercase">
|
|
363
|
-
Tab
|
|
364
|
-
</kbd>{' '}
|
|
365
|
-
to open the command menu.
|
|
366
|
-
</p>
|
|
367
|
-
</div>
|
|
368
|
-
) : undefined}
|
|
369
|
-
</form>
|
|
370
|
-
</Form>
|
|
371
|
-
{task ? (
|
|
372
|
-
<SystemInfo
|
|
373
|
-
items={[
|
|
374
|
-
{
|
|
375
|
-
label: 'Id',
|
|
376
|
-
value: task.id
|
|
377
|
-
},
|
|
378
|
-
{
|
|
379
|
-
label: 'Created At',
|
|
380
|
-
value: formatDateTime(task.createdAt)
|
|
381
|
-
},
|
|
382
|
-
{
|
|
383
|
-
label: 'Updated At',
|
|
384
|
-
value: timesAgo(task.updatedAt)
|
|
385
|
-
},
|
|
386
|
-
{
|
|
387
|
-
label: 'Created By',
|
|
388
|
-
value: (
|
|
389
|
-
<Link
|
|
390
|
-
href={`/users/${task.createdBy.id}`}
|
|
391
|
-
className="underline underline-offset-4 transition-all hover:text-foreground"
|
|
392
|
-
>
|
|
393
|
-
{task.createdBy.name ?? 'Unknown'}
|
|
394
|
-
</Link>
|
|
395
|
-
)
|
|
396
|
-
},
|
|
397
|
-
{
|
|
398
|
-
label: 'Updated By',
|
|
399
|
-
value: (
|
|
400
|
-
<Link
|
|
401
|
-
href={`/users/${task.updatedBy.id}`}
|
|
402
|
-
className="underline underline-offset-4 transition-all hover:text-foreground"
|
|
403
|
-
>
|
|
404
|
-
{task.updatedBy.name ?? 'Unknown'}
|
|
405
|
-
</Link>
|
|
406
|
-
)
|
|
407
|
-
}
|
|
408
|
-
]}
|
|
409
|
-
/>
|
|
410
|
-
) : undefined}
|
|
411
|
-
</Shell>
|
|
412
|
-
)
|
|
413
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
'use server'
|
|
2
|
-
|
|
3
|
-
import { Task, TaskStatus } from '@prisma/client'
|
|
4
|
-
|
|
5
|
-
import { getAuthSession } from '@/lib/auth'
|
|
6
|
-
import { prisma } from '@/lib/db'
|
|
7
|
-
import { UnwrapPromise } from '@/types/UnwrapPromise'
|
|
8
|
-
|
|
9
|
-
export const getTasks = async ({
|
|
10
|
-
page,
|
|
11
|
-
limit,
|
|
12
|
-
sortBy,
|
|
13
|
-
sortOrder,
|
|
14
|
-
title,
|
|
15
|
-
status
|
|
16
|
-
}: {
|
|
17
|
-
page: number
|
|
18
|
-
limit: number
|
|
19
|
-
sortBy?: keyof Task
|
|
20
|
-
sortOrder?: 'asc' | 'desc'
|
|
21
|
-
title?: string
|
|
22
|
-
status?: TaskStatus[]
|
|
23
|
-
}) => {
|
|
24
|
-
const session = await getAuthSession()
|
|
25
|
-
if (!session) throw new Error('Unauthorized')
|
|
26
|
-
|
|
27
|
-
const where = {
|
|
28
|
-
title: title
|
|
29
|
-
? { contains: title, mode: 'insensitive' as const }
|
|
30
|
-
: undefined,
|
|
31
|
-
status: status?.length ? { in: status } : undefined
|
|
32
|
-
}
|
|
33
|
-
const [tasks, total] = await Promise.all([
|
|
34
|
-
prisma.task.findMany({
|
|
35
|
-
where,
|
|
36
|
-
select: {
|
|
37
|
-
id: true,
|
|
38
|
-
title: true,
|
|
39
|
-
status: true,
|
|
40
|
-
createdAt: true,
|
|
41
|
-
updatedAt: true,
|
|
42
|
-
createdBy: {
|
|
43
|
-
select: {
|
|
44
|
-
id: true,
|
|
45
|
-
name: true
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
updatedBy: {
|
|
49
|
-
select: {
|
|
50
|
-
id: true,
|
|
51
|
-
name: true
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
skip: (page - 1) * limit,
|
|
56
|
-
take: limit,
|
|
57
|
-
orderBy: {
|
|
58
|
-
[sortBy || 'createdAt']: sortOrder || 'desc'
|
|
59
|
-
}
|
|
60
|
-
}),
|
|
61
|
-
prisma.task.count({
|
|
62
|
-
where
|
|
63
|
-
})
|
|
64
|
-
])
|
|
65
|
-
|
|
66
|
-
return { tasks, total }
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export type GetTasksFnDataType = UnwrapPromise<ReturnType<typeof getTasks>>
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Task, TaskStatus } from '@prisma/client'
|
|
2
|
-
import { Metadata } from 'next'
|
|
3
|
-
|
|
4
|
-
import { siteConfig } from '@/lib/siteConfig'
|
|
5
|
-
import { getTasks } from './actions'
|
|
6
|
-
import { Render } from './render'
|
|
7
|
-
|
|
8
|
-
export const metadata: Metadata = {
|
|
9
|
-
title: 'Tasks' + ' | ' + siteConfig.name
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const TasksPage = async ({
|
|
13
|
-
searchParams
|
|
14
|
-
}: {
|
|
15
|
-
searchParams: {
|
|
16
|
-
page?: string
|
|
17
|
-
limit?: string
|
|
18
|
-
sort?: string
|
|
19
|
-
title?: string
|
|
20
|
-
status?: string
|
|
21
|
-
}
|
|
22
|
-
}) => {
|
|
23
|
-
const page = searchParams.page ? parseInt(searchParams.page) : 1
|
|
24
|
-
const limit = searchParams.limit ? parseInt(searchParams.limit) : 10
|
|
25
|
-
|
|
26
|
-
const [sortBy, sortOrder] =
|
|
27
|
-
typeof searchParams.sort === 'string'
|
|
28
|
-
? (searchParams.sort.split('.') as [
|
|
29
|
-
keyof Task | undefined,
|
|
30
|
-
'asc' | 'desc' | undefined
|
|
31
|
-
])
|
|
32
|
-
: []
|
|
33
|
-
|
|
34
|
-
const title = searchParams.title
|
|
35
|
-
|
|
36
|
-
const status =
|
|
37
|
-
typeof searchParams.status === 'string'
|
|
38
|
-
? (searchParams.status.split('.') as TaskStatus[])
|
|
39
|
-
: undefined
|
|
40
|
-
|
|
41
|
-
const data = await getTasks({
|
|
42
|
-
page,
|
|
43
|
-
limit,
|
|
44
|
-
sortBy,
|
|
45
|
-
sortOrder,
|
|
46
|
-
title,
|
|
47
|
-
status
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
return <Render data={data} />
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export default TasksPage
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { TaskStatus } from '@prisma/client'
|
|
4
|
-
import Link from 'next/link'
|
|
5
|
-
import { FC } from 'react'
|
|
6
|
-
|
|
7
|
-
import { DataTable } from '@/components/data-table/data-table'
|
|
8
|
-
import { DataTableColumnHeader } from '@/components/data-table/data-table-column-header'
|
|
9
|
-
import { Heading } from '@/components/heading'
|
|
10
|
-
import { Icons } from '@/components/icons'
|
|
11
|
-
import { Shell } from '@/components/shell'
|
|
12
|
-
import { Button } from '@/components/ui/button'
|
|
13
|
-
import { formatDateTime, timesAgo } from '@/lib/formatDate'
|
|
14
|
-
import { generateLabel } from '@/lib/generateLabel'
|
|
15
|
-
import { GetTasksFnDataType } from './actions'
|
|
16
|
-
|
|
17
|
-
const statuses = Object.values(TaskStatus).map(x => ({
|
|
18
|
-
label: generateLabel(x),
|
|
19
|
-
value: x
|
|
20
|
-
}))
|
|
21
|
-
|
|
22
|
-
export const Render: FC<{
|
|
23
|
-
data: GetTasksFnDataType
|
|
24
|
-
}> = ({ data }) => {
|
|
25
|
-
return (
|
|
26
|
-
<Shell>
|
|
27
|
-
<Heading heading="Tasks" text="List of all the tasks">
|
|
28
|
-
<Link href="/tasks/new">
|
|
29
|
-
<Button>
|
|
30
|
-
<Icons.add className="mr-2 h-4 w-4" />
|
|
31
|
-
New
|
|
32
|
-
</Button>
|
|
33
|
-
</Link>
|
|
34
|
-
</Heading>
|
|
35
|
-
<DataTable
|
|
36
|
-
columns={[
|
|
37
|
-
{
|
|
38
|
-
accessorKey: 'title',
|
|
39
|
-
header: ({ column }) => (
|
|
40
|
-
<DataTableColumnHeader column={column} title="Title" />
|
|
41
|
-
),
|
|
42
|
-
cell: ({ row }) => (
|
|
43
|
-
<Link
|
|
44
|
-
className="underline underline-offset-4"
|
|
45
|
-
href={`/tasks/${row.original.id}`}
|
|
46
|
-
>
|
|
47
|
-
{row.original.title}
|
|
48
|
-
</Link>
|
|
49
|
-
)
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
accessorKey: 'status',
|
|
53
|
-
header: ({ column }) => (
|
|
54
|
-
<DataTableColumnHeader column={column} title="Status" />
|
|
55
|
-
),
|
|
56
|
-
cell: ({ row }) => row.original.status.replace('_', ' ')
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
accessorKey: 'createdBy',
|
|
60
|
-
header: ({ column }) => (
|
|
61
|
-
<DataTableColumnHeader column={column} title="Created By" />
|
|
62
|
-
),
|
|
63
|
-
cell: ({ row }) => row.original.createdBy.name,
|
|
64
|
-
enableSorting: false
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
accessorKey: 'updatedBy',
|
|
68
|
-
header: ({ column }) => (
|
|
69
|
-
<DataTableColumnHeader column={column} title="Updated By" />
|
|
70
|
-
),
|
|
71
|
-
cell: ({ row }) => row.original.updatedBy.name,
|
|
72
|
-
enableSorting: false
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
accessorKey: 'createdAt',
|
|
76
|
-
header: ({ column }) => (
|
|
77
|
-
<DataTableColumnHeader column={column} title="Created At" />
|
|
78
|
-
),
|
|
79
|
-
cell: ({ row }) => formatDateTime(row.original.createdAt)
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
accessorKey: 'updatedAt',
|
|
83
|
-
header: ({ column }) => (
|
|
84
|
-
<DataTableColumnHeader column={column} title="Updated At" />
|
|
85
|
-
),
|
|
86
|
-
cell: ({ row }) => timesAgo(row.original.updatedAt)
|
|
87
|
-
}
|
|
88
|
-
]}
|
|
89
|
-
data={data.tasks}
|
|
90
|
-
total={data.total}
|
|
91
|
-
searchableColumns={[
|
|
92
|
-
{
|
|
93
|
-
id: 'title',
|
|
94
|
-
title: 'Title'
|
|
95
|
-
}
|
|
96
|
-
]}
|
|
97
|
-
filterableColumns={[
|
|
98
|
-
{
|
|
99
|
-
id: 'status',
|
|
100
|
-
title: 'Status',
|
|
101
|
-
options: statuses
|
|
102
|
-
}
|
|
103
|
-
]}
|
|
104
|
-
/>
|
|
105
|
-
</Shell>
|
|
106
|
-
)
|
|
107
|
-
}
|