create-ej-app 12.0.0 → 15.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 +5 -4
- package/cli.ts +9 -4
- package/package.json +3 -3
- package/template/base/package.json +23 -29
- package/template/base/src/lib/auth.ts +15 -6
- package/template/base/terraform/artifact-registry.tf +5 -0
- package/template/base/terraform/backend-service.tf +13 -0
- package/template/base/terraform/cleanup.sh +9 -0
- package/template/base/terraform/cloudbuild.tf +70 -0
- package/template/base/terraform/cloudrun.tf +68 -0
- package/template/base/terraform/database.tf +60 -0
- package/template/base/terraform/forwarding-rule.tf +43 -0
- package/template/base/terraform/ip-address.tf +11 -0
- package/template/base/terraform/network-endpoint-group.tf +11 -0
- package/template/base/terraform/network.tf +21 -0
- package/template/base/terraform/pre.sh +3 -0
- package/template/base/terraform/providers.tf +18 -0
- package/template/base/terraform/secret.txt +11 -0
- package/template/base/terraform/setup.sh +25 -0
- package/template/base/terraform/ssl-certs.tf +32 -0
- package/template/base/terraform/target-https-proxy copy.tf +14 -0
- package/template/base/terraform/target-https-proxy.tf +14 -0
- package/template/base/terraform/terraform.tfvars +4 -0
- package/template/base/terraform/url-map.tf +23 -0
- package/template/base/terraform/variables.tf +21 -0
- package/template/old/.env.example +0 -17
- package/template/old/.eslintrc.cjs +0 -26
- package/template/old/components.json +0 -17
- package/template/old/drizzle.config.ts +0 -11
- package/template/old/next.config.mjs +0 -4
- package/template/old/package.json +0 -87
- package/template/old/postcss.config.mjs +0 -8
- package/template/old/prettier.config.mjs +0 -11
- package/template/old/public/next.svg +0 -1
- package/template/old/public/vercel.svg +0 -1
- package/template/old/src/app/(app)/dashboard/layout.tsx +0 -14
- package/template/old/src/app/(app)/dashboard/page.tsx +0 -12
- package/template/old/src/app/(app)/layout.tsx +0 -125
- package/template/old/src/app/(app)/roles/[id]/actions.ts +0 -59
- package/template/old/src/app/(app)/roles/[id]/page.tsx +0 -46
- package/template/old/src/app/(app)/roles/[id]/render.tsx +0 -264
- package/template/old/src/app/(app)/roles/[id]/validation.ts +0 -22
- package/template/old/src/app/(app)/roles/actions.ts +0 -33
- package/template/old/src/app/(app)/roles/page.tsx +0 -52
- package/template/old/src/app/(app)/roles/render.tsx +0 -80
- package/template/old/src/app/(app)/settings/actions.ts +0 -17
- package/template/old/src/app/(app)/settings/layout.tsx +0 -14
- package/template/old/src/app/(app)/settings/loading.tsx +0 -28
- package/template/old/src/app/(app)/settings/page.tsx +0 -19
- package/template/old/src/app/(app)/settings/render.tsx +0 -107
- package/template/old/src/app/(app)/settings/validation.ts +0 -5
- package/template/old/src/app/(app)/tasks/[id]/actions.ts +0 -92
- package/template/old/src/app/(app)/tasks/[id]/page.tsx +0 -59
- package/template/old/src/app/(app)/tasks/[id]/render.tsx +0 -482
- package/template/old/src/app/(app)/tasks/[id]/validation.ts +0 -18
- package/template/old/src/app/(app)/tasks/actions.ts +0 -39
- package/template/old/src/app/(app)/tasks/page.tsx +0 -59
- package/template/old/src/app/(app)/tasks/render.tsx +0 -129
- package/template/old/src/app/(app)/tasks/statusEnum.ts +0 -3
- package/template/old/src/app/(app)/users/[id]/actions.ts +0 -68
- package/template/old/src/app/(app)/users/[id]/page.tsx +0 -39
- package/template/old/src/app/(app)/users/[id]/render.tsx +0 -325
- package/template/old/src/app/(app)/users/[id]/validation.ts +0 -18
- package/template/old/src/app/(app)/users/actions.ts +0 -34
- package/template/old/src/app/(app)/users/page.tsx +0 -62
- package/template/old/src/app/(app)/users/render.tsx +0 -124
- package/template/old/src/app/(auth)/layout.tsx +0 -27
- package/template/old/src/app/(auth)/login/page.tsx +0 -49
- package/template/old/src/app/(auth)/login/render.tsx +0 -146
- package/template/old/src/app/(marketing)/layout.tsx +0 -42
- package/template/old/src/app/(marketing)/page.tsx +0 -97
- package/template/old/src/app/api/auth/[...nextauth]/route.ts +0 -7
- package/template/old/src/app/favicon.ico +0 -0
- package/template/old/src/app/globals.css +0 -76
- package/template/old/src/app/layout.tsx +0 -31
- package/template/old/src/components/app-nav-command.tsx +0 -178
- package/template/old/src/components/dark-mode-toggle.tsx +0 -43
- package/template/old/src/components/data-table/data-table-column-header.tsx +0 -91
- package/template/old/src/components/data-table/data-table-faceted-filter.tsx +0 -149
- package/template/old/src/components/data-table/data-table-loading.tsx +0 -77
- package/template/old/src/components/data-table/data-table-pagination.tsx +0 -94
- package/template/old/src/components/data-table/data-table-toolbar.tsx +0 -78
- package/template/old/src/components/data-table/data-table-types.ts +0 -17
- package/template/old/src/components/data-table/data-table-view-options.tsx +0 -59
- package/template/old/src/components/data-table/data-table.tsx +0 -301
- package/template/old/src/components/data-table/simple-data-table.tsx +0 -109
- package/template/old/src/components/empty-placeholder.tsx +0 -78
- package/template/old/src/components/heading.tsx +0 -17
- package/template/old/src/components/icons.tsx +0 -101
- package/template/old/src/components/main-nav.tsx +0 -64
- package/template/old/src/components/mobile-nav.tsx +0 -50
- package/template/old/src/components/shell.tsx +0 -13
- package/template/old/src/components/side-nav.tsx +0 -51
- package/template/old/src/components/site-footer.tsx +0 -31
- package/template/old/src/components/system-info.tsx +0 -36
- package/template/old/src/components/ui/alert-dialog.tsx +0 -141
- package/template/old/src/components/ui/avatar.tsx +0 -50
- package/template/old/src/components/ui/badge.tsx +0 -36
- package/template/old/src/components/ui/button.tsx +0 -56
- package/template/old/src/components/ui/card.tsx +0 -79
- package/template/old/src/components/ui/checkbox.tsx +0 -30
- package/template/old/src/components/ui/command.tsx +0 -155
- package/template/old/src/components/ui/dialog.tsx +0 -122
- package/template/old/src/components/ui/dropdown-menu.tsx +0 -200
- package/template/old/src/components/ui/form.tsx +0 -176
- package/template/old/src/components/ui/input.tsx +0 -25
- package/template/old/src/components/ui/label.tsx +0 -26
- package/template/old/src/components/ui/popover.tsx +0 -31
- package/template/old/src/components/ui/select.tsx +0 -160
- package/template/old/src/components/ui/separator.tsx +0 -31
- package/template/old/src/components/ui/skeleton.tsx +0 -15
- package/template/old/src/components/ui/sonner.tsx +0 -31
- package/template/old/src/components/ui/table.tsx +0 -117
- package/template/old/src/components/user-account-nav.tsx +0 -60
- package/template/old/src/components/user-avatar.tsx +0 -27
- package/template/old/src/data-access/resource.ts +0 -85
- package/template/old/src/data-access/role-permission.ts +0 -45
- package/template/old/src/data-access/role.ts +0 -105
- package/template/old/src/data-access/task.ts +0 -141
- package/template/old/src/data-access/user.ts +0 -141
- package/template/old/src/db/index.ts +0 -14
- package/template/old/src/db/schema.ts +0 -287
- package/template/old/src/env.mjs +0 -58
- package/template/old/src/hooks/use-debounce.tsx +0 -17
- package/template/old/src/hooks/use-lock-body.tsx +0 -13
- package/template/old/src/lib/auth.ts +0 -89
- package/template/old/src/lib/cn.ts +0 -4
- package/template/old/src/lib/currentUser.ts +0 -8
- package/template/old/src/lib/delay.ts +0 -2
- package/template/old/src/lib/formatDate.ts +0 -11
- package/template/old/src/lib/generateLabel.ts +0 -5
- package/template/old/src/lib/s3Client.ts +0 -156
- package/template/old/src/lib/safe-action.ts +0 -19
- package/template/old/src/lib/siteConfig.ts +0 -4
- package/template/old/src/lib/sortOrderEnum.ts +0 -2
- package/template/old/src/use-case/role-permission.ts +0 -19
- package/template/old/src/use-case/role.ts +0 -110
- package/template/old/src/use-case/task.ts +0 -166
- package/template/old/src/use-case/user.ts +0 -121
- package/template/old/tailwind.config.ts +0 -81
- package/template/old/tsconfig.json +0 -47
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
checkForRolePermission,
|
|
3
|
-
type RolePermissionType
|
|
4
|
-
} from '@/data-access/role-permission'
|
|
5
|
-
import { type UserType } from '@/data-access/user'
|
|
6
|
-
|
|
7
|
-
export const checkForRolePermissionUseCase = async (
|
|
8
|
-
userType: UserType['type'],
|
|
9
|
-
roleId?: string | null,
|
|
10
|
-
permission?: RolePermissionType['permission']
|
|
11
|
-
) => {
|
|
12
|
-
if (userType === 'Root') return true
|
|
13
|
-
|
|
14
|
-
if (!roleId) return false
|
|
15
|
-
|
|
16
|
-
if (!permission) return true
|
|
17
|
-
|
|
18
|
-
return await checkForRolePermission(roleId, permission)
|
|
19
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createRole,
|
|
3
|
-
deleteRole,
|
|
4
|
-
getRoleByIdWithPermissions,
|
|
5
|
-
getRoles,
|
|
6
|
-
getRolesMini,
|
|
7
|
-
updateRole,
|
|
8
|
-
type RoleType
|
|
9
|
-
} from '@/data-access/role'
|
|
10
|
-
import {
|
|
11
|
-
RolePermissionType,
|
|
12
|
-
createRolePermissions,
|
|
13
|
-
deleteRolePermissionsByRoleId
|
|
14
|
-
} from '@/data-access/role-permission'
|
|
15
|
-
import { type UserType } from '@/data-access/user'
|
|
16
|
-
import { type SortOrderEnum } from '@/lib/sortOrderEnum'
|
|
17
|
-
|
|
18
|
-
type getRolesUseCaseInput = {
|
|
19
|
-
page: number
|
|
20
|
-
limit: number
|
|
21
|
-
sortBy?: keyof RoleType
|
|
22
|
-
sortOrder?: SortOrderEnum
|
|
23
|
-
filters?: {
|
|
24
|
-
name?: string
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const getRolesUseCase = async (
|
|
29
|
-
currentUserType: UserType['type'],
|
|
30
|
-
{ page, limit, sortBy, sortOrder, filters }: getRolesUseCaseInput
|
|
31
|
-
) => {
|
|
32
|
-
if (currentUserType !== 'Root') throw new Error('Unauthorized')
|
|
33
|
-
|
|
34
|
-
if (limit < 1 || limit > 1000) throw new Error('Invalid limit')
|
|
35
|
-
if (page < 1) throw new Error('Invalid page')
|
|
36
|
-
|
|
37
|
-
return await getRoles({
|
|
38
|
-
page,
|
|
39
|
-
limit,
|
|
40
|
-
sortBy,
|
|
41
|
-
sortOrder,
|
|
42
|
-
filters
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const getRolesMiniUseCase = async (
|
|
47
|
-
currentUserType: UserType['type']
|
|
48
|
-
) => {
|
|
49
|
-
if (currentUserType !== 'Root') throw new Error('Unauthorized')
|
|
50
|
-
return await getRolesMini()
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export const getRoleByIdWithPermissionsUseCase = async (
|
|
54
|
-
currentUserType: UserType['type'],
|
|
55
|
-
id: string
|
|
56
|
-
) => {
|
|
57
|
-
if (currentUserType !== 'Root') throw new Error('Unauthorized')
|
|
58
|
-
return await getRoleByIdWithPermissions(id)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
type createRoleUseCaseInput = {
|
|
62
|
-
name: string
|
|
63
|
-
permissions: RolePermissionType['permission'][]
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export const createRoleUseCase = async (
|
|
67
|
-
currentUserType: UserType['type'],
|
|
68
|
-
data: createRoleUseCaseInput
|
|
69
|
-
) => {
|
|
70
|
-
if (currentUserType !== 'Root') throw new Error('Unauthorized')
|
|
71
|
-
const roleId = await createRole({
|
|
72
|
-
name: data.name
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
if (data.permissions.length)
|
|
76
|
-
await createRolePermissions({
|
|
77
|
-
roleId,
|
|
78
|
-
permissions: data.permissions
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
return roleId
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
type updateRoleUseCaseInput = createRoleUseCaseInput & {
|
|
85
|
-
id: string
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export const updateRoleUseCase = async (
|
|
89
|
-
currentUserType: UserType['type'],
|
|
90
|
-
data: updateRoleUseCaseInput
|
|
91
|
-
) => {
|
|
92
|
-
if (currentUserType !== 'Root') throw new Error('Unauthorized')
|
|
93
|
-
await updateRole({
|
|
94
|
-
id: data.id,
|
|
95
|
-
name: data.name
|
|
96
|
-
})
|
|
97
|
-
await deleteRolePermissionsByRoleId(data.id)
|
|
98
|
-
await createRolePermissions({
|
|
99
|
-
roleId: data.id,
|
|
100
|
-
permissions: data.permissions
|
|
101
|
-
})
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export const deleteRoleUseCase = async (
|
|
105
|
-
currentUserType: UserType['type'],
|
|
106
|
-
id: string
|
|
107
|
-
) => {
|
|
108
|
-
if (currentUserType !== 'Root') throw new Error('Unauthorized')
|
|
109
|
-
return await deleteRole(id)
|
|
110
|
-
}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getResourcesByTaskId,
|
|
3
|
-
updateResourceByIds
|
|
4
|
-
} from '@/data-access/resource'
|
|
5
|
-
import {
|
|
6
|
-
TaskType,
|
|
7
|
-
createTask,
|
|
8
|
-
deleteTask,
|
|
9
|
-
getTaskByIdWithUser,
|
|
10
|
-
getTasksWithUser,
|
|
11
|
-
updateTask
|
|
12
|
-
} from '@/data-access/task'
|
|
13
|
-
import { CurrentUser } from '@/lib/currentUser'
|
|
14
|
-
import { deleteFile } from '@/lib/s3Client'
|
|
15
|
-
import { type SortOrderEnum } from '@/lib/sortOrderEnum'
|
|
16
|
-
import { checkForRolePermissionUseCase } from './role-permission'
|
|
17
|
-
|
|
18
|
-
const handleTaskImages = async (
|
|
19
|
-
imageIds: string[],
|
|
20
|
-
taskId: string,
|
|
21
|
-
updatedById: string
|
|
22
|
-
) => {
|
|
23
|
-
const prevImages = await getResourcesByTaskId(taskId)
|
|
24
|
-
|
|
25
|
-
for (const p of prevImages) {
|
|
26
|
-
if (imageIds.includes(p.id)) continue
|
|
27
|
-
await deleteFile(p.id)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (imageIds.length)
|
|
31
|
-
await updateResourceByIds({
|
|
32
|
-
ids: imageIds,
|
|
33
|
-
taskId,
|
|
34
|
-
updatedById
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
type getUsersUseCaseInput = {
|
|
39
|
-
page: number
|
|
40
|
-
limit: number
|
|
41
|
-
sortBy?: keyof TaskType
|
|
42
|
-
sortOrder?: SortOrderEnum
|
|
43
|
-
filters?: {
|
|
44
|
-
title?: string
|
|
45
|
-
status?: TaskType['status'][]
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const getTasksWithUserUseCase = async (
|
|
50
|
-
currentUser: CurrentUser,
|
|
51
|
-
{ page, limit, sortBy, sortOrder, filters }: getUsersUseCaseInput
|
|
52
|
-
) => {
|
|
53
|
-
const c = await checkForRolePermissionUseCase(
|
|
54
|
-
currentUser.type,
|
|
55
|
-
currentUser.roleId,
|
|
56
|
-
'TaskList'
|
|
57
|
-
)
|
|
58
|
-
if (!c) throw new Error('Unauthorized')
|
|
59
|
-
|
|
60
|
-
if (limit < 1 || limit > 1000) throw new Error('Invalid limit')
|
|
61
|
-
if (page < 1) throw new Error('Invalid page')
|
|
62
|
-
|
|
63
|
-
return await getTasksWithUser({
|
|
64
|
-
page,
|
|
65
|
-
limit,
|
|
66
|
-
sortBy,
|
|
67
|
-
sortOrder,
|
|
68
|
-
filters: filters
|
|
69
|
-
? {
|
|
70
|
-
title: filters.title,
|
|
71
|
-
status: filters.status
|
|
72
|
-
}
|
|
73
|
-
: undefined
|
|
74
|
-
})
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export const getTaskByIdWithUserUseCase = async (
|
|
78
|
-
currentUser: CurrentUser,
|
|
79
|
-
id: string
|
|
80
|
-
) => {
|
|
81
|
-
const c = await checkForRolePermissionUseCase(
|
|
82
|
-
currentUser.type,
|
|
83
|
-
currentUser.roleId,
|
|
84
|
-
'TaskView'
|
|
85
|
-
)
|
|
86
|
-
if (!c) throw new Error('Unauthorized')
|
|
87
|
-
|
|
88
|
-
return await getTaskByIdWithUser(id)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
type createTaskUseCaseInput = {
|
|
92
|
-
title: string
|
|
93
|
-
description?: string | null
|
|
94
|
-
status: TaskType['status']
|
|
95
|
-
imageIds?: string[] | null
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export const createTaskUseCase = async (
|
|
99
|
-
currentUser: CurrentUser,
|
|
100
|
-
data: createTaskUseCaseInput
|
|
101
|
-
) => {
|
|
102
|
-
const c = await checkForRolePermissionUseCase(
|
|
103
|
-
currentUser.type,
|
|
104
|
-
currentUser.roleId,
|
|
105
|
-
'TaskCreate'
|
|
106
|
-
)
|
|
107
|
-
if (!c) throw new Error('Unauthorized')
|
|
108
|
-
|
|
109
|
-
const taskId = await createTask({
|
|
110
|
-
title: data.title,
|
|
111
|
-
description: data.description,
|
|
112
|
-
status: data.status,
|
|
113
|
-
createdById: currentUser.id
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
if (taskId)
|
|
117
|
-
await handleTaskImages(data.imageIds || [], taskId, currentUser.id)
|
|
118
|
-
|
|
119
|
-
return taskId
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
type updateTaskUseCaseInput = {
|
|
123
|
-
id: string
|
|
124
|
-
title?: string
|
|
125
|
-
description?: string | null
|
|
126
|
-
status?: TaskType['status']
|
|
127
|
-
imageIds?: string[] | null
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export const updateTaskUseCase = async (
|
|
131
|
-
currentUser: CurrentUser,
|
|
132
|
-
data: updateTaskUseCaseInput
|
|
133
|
-
) => {
|
|
134
|
-
const c = await checkForRolePermissionUseCase(
|
|
135
|
-
currentUser.type,
|
|
136
|
-
currentUser.roleId,
|
|
137
|
-
'TaskUpdate'
|
|
138
|
-
)
|
|
139
|
-
if (!c) throw new Error('Unauthorized')
|
|
140
|
-
|
|
141
|
-
const result = await updateTask({
|
|
142
|
-
id: data.id,
|
|
143
|
-
title: data.title,
|
|
144
|
-
description: data.description,
|
|
145
|
-
status: data.status,
|
|
146
|
-
updatedById: currentUser.id
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
await handleTaskImages(data.imageIds || [], data.id, currentUser.id)
|
|
150
|
-
|
|
151
|
-
return result
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export const deleteTaskUseCase = async (
|
|
155
|
-
currentUser: CurrentUser,
|
|
156
|
-
id: string
|
|
157
|
-
) => {
|
|
158
|
-
const c = await checkForRolePermissionUseCase(
|
|
159
|
-
currentUser.type,
|
|
160
|
-
currentUser.roleId,
|
|
161
|
-
'TaskDelete'
|
|
162
|
-
)
|
|
163
|
-
if (!c) throw new Error('Unauthorized')
|
|
164
|
-
|
|
165
|
-
return await deleteTask(id)
|
|
166
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
UserType,
|
|
3
|
-
createUser,
|
|
4
|
-
deleteUser,
|
|
5
|
-
getUserById,
|
|
6
|
-
getUsersWithRole,
|
|
7
|
-
updateUser
|
|
8
|
-
} from '@/data-access/user'
|
|
9
|
-
import { type SortOrderEnum } from '@/lib/sortOrderEnum'
|
|
10
|
-
|
|
11
|
-
type UpdateUserNameUseCaseInput = {
|
|
12
|
-
name: string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const updateCurrentUserNameUseCase = async (
|
|
16
|
-
currentUserId: string,
|
|
17
|
-
data: UpdateUserNameUseCaseInput
|
|
18
|
-
) => {
|
|
19
|
-
await updateUser(currentUserId, {
|
|
20
|
-
name: data.name
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type getUsersUseCaseInput = {
|
|
25
|
-
page: number
|
|
26
|
-
limit: number
|
|
27
|
-
sortBy?: keyof UserType
|
|
28
|
-
sortOrder?: SortOrderEnum
|
|
29
|
-
filters?: {
|
|
30
|
-
name?: string
|
|
31
|
-
email?: string
|
|
32
|
-
type?: UserType['type'][]
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const getUsersWithRoleUseCase = async (
|
|
37
|
-
currentUserType: UserType['type'],
|
|
38
|
-
{ page, limit, sortBy, sortOrder, filters }: getUsersUseCaseInput
|
|
39
|
-
) => {
|
|
40
|
-
if (currentUserType !== 'Root') throw new Error('Unauthorized')
|
|
41
|
-
|
|
42
|
-
if (limit < 1 || limit > 1000) throw new Error('Invalid limit')
|
|
43
|
-
if (page < 1) throw new Error('Invalid page')
|
|
44
|
-
|
|
45
|
-
return await getUsersWithRole({
|
|
46
|
-
page,
|
|
47
|
-
limit,
|
|
48
|
-
sortBy,
|
|
49
|
-
sortOrder,
|
|
50
|
-
filters: filters
|
|
51
|
-
? {
|
|
52
|
-
name: filters.name,
|
|
53
|
-
email: filters.email,
|
|
54
|
-
type: filters.type
|
|
55
|
-
}
|
|
56
|
-
: undefined
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export const getUserByIdUseCase = async (
|
|
61
|
-
currentUserType: UserType['type'],
|
|
62
|
-
id: string
|
|
63
|
-
) => {
|
|
64
|
-
if (currentUserType !== 'Root') throw new Error('Unauthorized')
|
|
65
|
-
|
|
66
|
-
return await getUserById(id)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
type createUserUseCaseInput = {
|
|
70
|
-
name?: string | null
|
|
71
|
-
email: string
|
|
72
|
-
type: UserType['type']
|
|
73
|
-
roleId?: string | null
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export const createUserUseCase = async (
|
|
77
|
-
currentUserType: UserType['type'],
|
|
78
|
-
data: createUserUseCaseInput
|
|
79
|
-
) => {
|
|
80
|
-
if (currentUserType !== 'Root') throw new Error('Unauthorized')
|
|
81
|
-
|
|
82
|
-
if (data.type === 'Root') data.roleId = null
|
|
83
|
-
|
|
84
|
-
data.email = data.email.trim().toLowerCase()
|
|
85
|
-
|
|
86
|
-
return await createUser({
|
|
87
|
-
name: data.name,
|
|
88
|
-
email: data.email,
|
|
89
|
-
type: data.type,
|
|
90
|
-
roleId: data.roleId
|
|
91
|
-
})
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
type updateUserUseCaseInput = {
|
|
95
|
-
name: string
|
|
96
|
-
type: UserType['type']
|
|
97
|
-
roleId?: string | null
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export const updateUserUseCase = async (
|
|
101
|
-
currentUserType: UserType['type'],
|
|
102
|
-
id: string,
|
|
103
|
-
data: updateUserUseCaseInput
|
|
104
|
-
) => {
|
|
105
|
-
if (currentUserType !== 'Root') throw new Error('Unauthorized')
|
|
106
|
-
|
|
107
|
-
await updateUser(id, {
|
|
108
|
-
name: data.name,
|
|
109
|
-
type: data.type,
|
|
110
|
-
roleId: data.roleId
|
|
111
|
-
})
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export const deleteUserUseCase = async (
|
|
115
|
-
currentUserType: UserType['type'],
|
|
116
|
-
id: string
|
|
117
|
-
) => {
|
|
118
|
-
if (currentUserType !== 'Root') throw new Error('Unauthorized')
|
|
119
|
-
|
|
120
|
-
await deleteUser(id)
|
|
121
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type { Config } from 'tailwindcss'
|
|
2
|
-
import { fontFamily } from 'tailwindcss/defaultTheme'
|
|
3
|
-
|
|
4
|
-
const config = {
|
|
5
|
-
darkMode: ['class'],
|
|
6
|
-
content: ['./src/**/*.{js,ts,jsx,tsx,mdx}'],
|
|
7
|
-
prefix: '',
|
|
8
|
-
theme: {
|
|
9
|
-
container: {
|
|
10
|
-
center: true,
|
|
11
|
-
padding: '2rem',
|
|
12
|
-
screens: {
|
|
13
|
-
'2xl': '1400px'
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
extend: {
|
|
17
|
-
extend: {
|
|
18
|
-
fontFamily: {
|
|
19
|
-
sans: ['var(--font-geist-sans)', ...fontFamily.sans]
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
colors: {
|
|
23
|
-
border: 'hsl(var(--border))',
|
|
24
|
-
input: 'hsl(var(--input))',
|
|
25
|
-
ring: 'hsl(var(--ring))',
|
|
26
|
-
background: 'hsl(var(--background))',
|
|
27
|
-
foreground: 'hsl(var(--foreground))',
|
|
28
|
-
primary: {
|
|
29
|
-
DEFAULT: 'hsl(var(--primary))',
|
|
30
|
-
foreground: 'hsl(var(--primary-foreground))'
|
|
31
|
-
},
|
|
32
|
-
secondary: {
|
|
33
|
-
DEFAULT: 'hsl(var(--secondary))',
|
|
34
|
-
foreground: 'hsl(var(--secondary-foreground))'
|
|
35
|
-
},
|
|
36
|
-
destructive: {
|
|
37
|
-
DEFAULT: 'hsl(var(--destructive))',
|
|
38
|
-
foreground: 'hsl(var(--destructive-foreground))'
|
|
39
|
-
},
|
|
40
|
-
muted: {
|
|
41
|
-
DEFAULT: 'hsl(var(--muted))',
|
|
42
|
-
foreground: 'hsl(var(--muted-foreground))'
|
|
43
|
-
},
|
|
44
|
-
accent: {
|
|
45
|
-
DEFAULT: 'hsl(var(--accent))',
|
|
46
|
-
foreground: 'hsl(var(--accent-foreground))'
|
|
47
|
-
},
|
|
48
|
-
popover: {
|
|
49
|
-
DEFAULT: 'hsl(var(--popover))',
|
|
50
|
-
foreground: 'hsl(var(--popover-foreground))'
|
|
51
|
-
},
|
|
52
|
-
card: {
|
|
53
|
-
DEFAULT: 'hsl(var(--card))',
|
|
54
|
-
foreground: 'hsl(var(--card-foreground))'
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
borderRadius: {
|
|
58
|
-
lg: 'var(--radius)',
|
|
59
|
-
md: 'calc(var(--radius) - 2px)',
|
|
60
|
-
sm: 'calc(var(--radius) - 4px)'
|
|
61
|
-
},
|
|
62
|
-
keyframes: {
|
|
63
|
-
'accordion-down': {
|
|
64
|
-
from: { height: '0' },
|
|
65
|
-
to: { height: 'var(--radix-accordion-content-height)' }
|
|
66
|
-
},
|
|
67
|
-
'accordion-up': {
|
|
68
|
-
from: { height: 'var(--radix-accordion-content-height)' },
|
|
69
|
-
to: { height: '0' }
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
animation: {
|
|
73
|
-
'accordion-down': 'accordion-down 0.2s ease-out',
|
|
74
|
-
'accordion-up': 'accordion-up 0.2s ease-out'
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
plugins: [require('tailwindcss-animate'), require('@tailwindcss/typography')]
|
|
79
|
-
} satisfies Config
|
|
80
|
-
|
|
81
|
-
export default config
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
|
5
|
-
"allowJs": true,
|
|
6
|
-
"checkJs": true,
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
"strict": true,
|
|
9
|
-
"noImplicitAny": true,
|
|
10
|
-
"strictNullChecks": true,
|
|
11
|
-
"strictFunctionTypes": true,
|
|
12
|
-
"noImplicitThis": true,
|
|
13
|
-
"noUncheckedIndexedAccess": true,
|
|
14
|
-
"noUnusedLocals": true,
|
|
15
|
-
"noUnusedParameters": true,
|
|
16
|
-
"noImplicitReturns": true,
|
|
17
|
-
"noFallthroughCasesInSwitch": true,
|
|
18
|
-
"forceConsistentCasingInFileNames": true,
|
|
19
|
-
"noEmit": true,
|
|
20
|
-
"esModuleInterop": true,
|
|
21
|
-
"module": "ESNext",
|
|
22
|
-
"moduleResolution": "bundler",
|
|
23
|
-
"resolveJsonModule": true,
|
|
24
|
-
"isolatedModules": true,
|
|
25
|
-
"jsx": "preserve",
|
|
26
|
-
"incremental": true,
|
|
27
|
-
"plugins": [
|
|
28
|
-
{
|
|
29
|
-
"name": "next"
|
|
30
|
-
}
|
|
31
|
-
],
|
|
32
|
-
"paths": {
|
|
33
|
-
"@/*": ["./src/*"]
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"include": [
|
|
37
|
-
".eslintrc.cjs",
|
|
38
|
-
"next-env.d.ts",
|
|
39
|
-
"**/*.ts",
|
|
40
|
-
"**/*.tsx",
|
|
41
|
-
"**/*.js",
|
|
42
|
-
"**/*.cjs",
|
|
43
|
-
"**/*.mjs",
|
|
44
|
-
".next/types/**/*.ts"
|
|
45
|
-
],
|
|
46
|
-
"exclude": ["node_modules"]
|
|
47
|
-
}
|