Skip to content

Commit e4e1642

Browse files
fix: move USER_ROLE_LABELS/USER_MANAGER_ROLES to non-generated constants file
These constants were manually added to types.gen.ts which gets overwritten by generate-client.sh. Moved to frontend/src/lib/user-constants.ts and updated all imports. Also applied lint auto-fixes. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent a01bbf2 commit e4e1642

7 files changed

Lines changed: 60 additions & 22 deletions

File tree

frontend/src/client/types.gen.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,6 @@ export type UpdatePassword = {
216216

217217
export type UserRole = 'comercial' | 'juridico' | 'financeiro' | 'rh' | 'pj' | 'super_admin';
218218

219-
export const USER_MANAGER_ROLES: UserRole[] = ['comercial', 'juridico', 'financeiro', 'rh', 'super_admin'];
220-
221-
export const USER_ROLE_LABELS: Record<UserRole, string> = {
222-
comercial: 'Comercial',
223-
juridico: 'Jur\u00eddico',
224-
financeiro: 'Financeiro',
225-
rh: 'RH',
226-
pj: 'PJ',
227-
super_admin: 'Super Admin',
228-
};
229-
230219
export type AuditAction = 'created' | 'updated' | 'deactivated';
231220

232221
export type AuditLogPublic = {

frontend/src/components/Admin/AddUser.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useState } from "react"
55
import { useForm } from "react-hook-form"
66
import { z } from "zod"
77

8-
import { type UserCreate, type UserRole, USER_ROLE_LABELS, UsersService } from "@/client"
8+
import { type UserCreate, type UserRole, UsersService } from "@/client"
99
import { Button } from "@/components/ui/button"
1010
import {
1111
Dialog,
@@ -35,14 +35,29 @@ import {
3535
SelectValue,
3636
} from "@/components/ui/select"
3737
import useCustomToast from "@/hooks/useCustomToast"
38+
import { USER_ROLE_LABELS } from "@/lib/user-constants"
3839
import { handleError } from "@/utils"
3940

40-
const roleOptions: UserRole[] = ['comercial', 'juridico', 'financeiro', 'rh', 'pj', 'super_admin']
41+
const roleOptions: UserRole[] = [
42+
"comercial",
43+
"juridico",
44+
"financeiro",
45+
"rh",
46+
"pj",
47+
"super_admin",
48+
]
4149

4250
const formSchema = z.object({
4351
email: z.email({ message: "Invalid email address" }),
4452
full_name: z.string().optional(),
45-
role: z.enum(['comercial', 'juridico', 'financeiro', 'rh', 'pj', 'super_admin']),
53+
role: z.enum([
54+
"comercial",
55+
"juridico",
56+
"financeiro",
57+
"rh",
58+
"pj",
59+
"super_admin",
60+
]),
4661
})
4762

4863
type FormData = z.infer<typeof formSchema>

frontend/src/components/Admin/EditUser.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useState } from "react"
55
import { useForm } from "react-hook-form"
66
import { z } from "zod"
77

8-
import { type UserPublic, type UserRole, USER_ROLE_LABELS, UsersService } from "@/client"
8+
import { type UserPublic, type UserRole, UsersService } from "@/client"
99
import { Button } from "@/components/ui/button"
1010
import { Checkbox } from "@/components/ui/checkbox"
1111
import {
@@ -36,14 +36,29 @@ import {
3636
SelectValue,
3737
} from "@/components/ui/select"
3838
import useCustomToast from "@/hooks/useCustomToast"
39+
import { USER_ROLE_LABELS } from "@/lib/user-constants"
3940
import { handleError } from "@/utils"
4041

41-
const roleOptions: UserRole[] = ['comercial', 'juridico', 'financeiro', 'rh', 'pj', 'super_admin']
42+
const roleOptions: UserRole[] = [
43+
"comercial",
44+
"juridico",
45+
"financeiro",
46+
"rh",
47+
"pj",
48+
"super_admin",
49+
]
4250

4351
const formSchema = z.object({
4452
email: z.email({ message: "Invalid email address" }),
4553
full_name: z.string().optional(),
46-
role: z.enum(['comercial', 'juridico', 'financeiro', 'rh', 'pj', 'super_admin']),
54+
role: z.enum([
55+
"comercial",
56+
"juridico",
57+
"financeiro",
58+
"rh",
59+
"pj",
60+
"super_admin",
61+
]),
4762
is_active: z.boolean().optional(),
4863
})
4964

@@ -66,7 +81,7 @@ const EditUser = ({ user, onSuccess }: EditUserProps) => {
6681
defaultValues: {
6782
email: user.email,
6883
full_name: user.full_name ?? undefined,
69-
role: (user.role ?? 'comercial') as UserRole,
84+
role: (user.role ?? "comercial") as UserRole,
7085
is_active: user.is_active,
7186
},
7287
})
@@ -188,7 +203,6 @@ const EditUser = ({ user, onSuccess }: EditUserProps) => {
188203
</FormItem>
189204
)}
190205
/>
191-
192206
</div>
193207

194208
<DialogFooter>

frontend/src/components/Admin/columns.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { ColumnDef } from "@tanstack/react-table"
22

33
import type { UserPublic, UserRole } from "@/client"
4-
import { USER_ROLE_LABELS } from "@/client"
54
import { Badge } from "@/components/ui/badge"
5+
import { USER_ROLE_LABELS } from "@/lib/user-constants"
66
import { cn } from "@/lib/utils"
77
import { UserActionsMenu } from "./UserActionsMenu"
88

frontend/src/components/Sidebar/AppSidebar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Briefcase, Building2, Home, Users } from "lucide-react"
22

3-
import { USER_MANAGER_ROLES, type UserRole } from "@/client"
3+
import type { UserRole } from "@/client"
44
import { SidebarAppearance } from "@/components/Common/Appearance"
55
import { Logo } from "@/components/Common/Logo"
66
import {
@@ -10,6 +10,7 @@ import {
1010
SidebarHeader,
1111
} from "@/components/ui/sidebar"
1212
import useAuth from "@/hooks/useAuth"
13+
import { USER_MANAGER_ROLES } from "@/lib/user-constants"
1314
import { type Item, Main } from "./Main"
1415
import { User } from "./User"
1516

frontend/src/lib/user-constants.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { UserRole } from "@/client"
2+
3+
export const USER_MANAGER_ROLES: UserRole[] = [
4+
"comercial",
5+
"juridico",
6+
"financeiro",
7+
"rh",
8+
"super_admin",
9+
]
10+
11+
export const USER_ROLE_LABELS: Record<UserRole, string> = {
12+
comercial: "Comercial",
13+
juridico: "Jur\u00eddico",
14+
financeiro: "Financeiro",
15+
rh: "RH",
16+
pj: "PJ",
17+
super_admin: "Super Admin",
18+
}

frontend/src/routes/_layout/admin.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { useSuspenseQuery } from "@tanstack/react-query"
22
import { createFileRoute, redirect } from "@tanstack/react-router"
33
import { Suspense } from "react"
44

5-
import { type UserPublic, USER_MANAGER_ROLES, type UserRole, UsersService } from "@/client"
5+
import { type UserPublic, type UserRole, UsersService } from "@/client"
66
import AddUser from "@/components/Admin/AddUser"
77
import { columns, type UserTableData } from "@/components/Admin/columns"
88
import { DataTable } from "@/components/Common/DataTable"
99
import PendingUsers from "@/components/Pending/PendingUsers"
1010
import useAuth from "@/hooks/useAuth"
11+
import { USER_MANAGER_ROLES } from "@/lib/user-constants"
1112

1213
function getUsersQueryOptions() {
1314
return {

0 commit comments

Comments
 (0)