diff --git a/backend/src/controllers/UserController.ts b/backend/src/controllers/UserController.ts index 20dc4ee..c435c8e 100644 --- a/backend/src/controllers/UserController.ts +++ b/backend/src/controllers/UserController.ts @@ -142,8 +142,7 @@ export const store = async (req: Request, res: Response): Promise => { email, password, name, - profile, - positionCompany, + profile, positionId, queueIds, transferToOtherQueues @@ -169,8 +168,7 @@ export const store = async (req: Request, res: Response): Promise => { const user = await CreateUserService({ email, password, - name, - positionCompany, + name, positionId, profile, queueIds, diff --git a/backend/src/database/migrations/20240503175233-remove-column-positionCompany-from-users.ts b/backend/src/database/migrations/20240503175233-remove-column-positionCompany-from-users.ts new file mode 100644 index 0000000..38e711b --- /dev/null +++ b/backend/src/database/migrations/20240503175233-remove-column-positionCompany-from-users.ts @@ -0,0 +1,14 @@ +import { QueryInterface, DataTypes } from "sequelize"; + +module.exports = { + up: (queryInterface: QueryInterface) => { + return queryInterface.removeColumn("Users", "positionCompany"); + }, + + down: (queryInterface: QueryInterface) => { + return queryInterface.addColumn("Users", "positionCompany", { + type: DataTypes.STRING, + allowNull: true + }); + } +}; diff --git a/backend/src/helpers/SerializeUser.ts b/backend/src/helpers/SerializeUser.ts index 03f70b0..cbe7c20 100644 --- a/backend/src/helpers/SerializeUser.ts +++ b/backend/src/helpers/SerializeUser.ts @@ -3,8 +3,7 @@ import User from "../models/User"; interface SerializedUser { id: number; - name: string; - positionCompany: string; + name: string; positionId: string | number; position: object; email: string; @@ -15,8 +14,7 @@ interface SerializedUser { export const SerializeUser = (user: User): SerializedUser => { return { id: user.id, - name: user.name, - positionCompany: user.positionCompany, + name: user.name, positionId: user.positionId, position: user.position, email: user.email, diff --git a/backend/src/models/User.ts b/backend/src/models/User.ts index f4db2f7..a7e3d47 100644 --- a/backend/src/models/User.ts +++ b/backend/src/models/User.ts @@ -43,10 +43,7 @@ class User extends Model { @Default(0) @Column - tokenVersion: number; - - @Column - positionCompany: string; + tokenVersion: number; @Column secondaryId: string; diff --git a/backend/src/services/UserServices/AuthUserService.ts b/backend/src/services/UserServices/AuthUserService.ts index b1cac22..9abf4cf 100644 --- a/backend/src/services/UserServices/AuthUserService.ts +++ b/backend/src/services/UserServices/AuthUserService.ts @@ -9,8 +9,7 @@ import Queue from "../../models/Queue"; interface SerializedUser { id: number; - name: string; - positionCompany: string; + name: string; email: string; profile: string; queues: Queue[]; diff --git a/backend/src/services/UserServices/CreateUserService.ts b/backend/src/services/UserServices/CreateUserService.ts index 9e4117c..ab2e948 100644 --- a/backend/src/services/UserServices/CreateUserService.ts +++ b/backend/src/services/UserServices/CreateUserService.ts @@ -8,8 +8,7 @@ import ShowUserService from "./ShowUserService"; interface Request { email: string; password: string; - name: string; - positionCompany?: string; + name: string; positionId?: string; queueIds?: number[]; profile?: string; @@ -19,8 +18,7 @@ interface Request { interface Response { email: string; - name: string; - positionCompany: string; + name: string; positionId: string; id: number; profile: string; @@ -30,8 +28,7 @@ interface Response { const CreateUserService = async ({ email, password, - name, - positionCompany, + name, positionId, queueIds = [], profile = "master", @@ -84,8 +81,7 @@ const CreateUserService = async ({ { email, password, - name, - positionCompany, + name, positionId: !positionId ? null : positionId, profile, transferToOtherQueues: transferToOtherQueues? transferToOtherQueues : false diff --git a/backend/src/services/UserServices/ListUserParamiterService.ts b/backend/src/services/UserServices/ListUserParamiterService.ts index de476cd..c9faccf 100644 --- a/backend/src/services/UserServices/ListUserParamiterService.ts +++ b/backend/src/services/UserServices/ListUserParamiterService.ts @@ -75,7 +75,7 @@ const ListUser = async ({ const users = await User.findAll({ where: where_clause, raw, - attributes: ["id", "name", "email", "positionCompany", "transferToOtherQueues"], + attributes: ["id", "name", "email", "transferToOtherQueues"], include: [ { model: Queue, as: "queues", attributes: ["id", "name", "color"] } diff --git a/backend/src/services/UserServices/ListUsersService.ts b/backend/src/services/UserServices/ListUsersService.ts index bfcb4d3..e2fb993 100644 --- a/backend/src/services/UserServices/ListUsersService.ts +++ b/backend/src/services/UserServices/ListUsersService.ts @@ -63,8 +63,7 @@ const ListUsersService = async ({ attributes: [ "name", "id", - "email", - "positionCompany", + "email", "profile", "createdAt", "transferToOtherQueues" diff --git a/backend/src/services/UserServices/ShowUserService.ts b/backend/src/services/UserServices/ShowUserService.ts index 8b9d6c8..d0d22ec 100644 --- a/backend/src/services/UserServices/ShowUserService.ts +++ b/backend/src/services/UserServices/ShowUserService.ts @@ -9,8 +9,7 @@ const ShowUserService = async (id: string | number): Promise => { "name", "id", "email", - "profile", - "positionCompany", + "profile", "positionId", "tokenVersion", "transferToOtherQueues" diff --git a/backend/src/services/UserServices/UpdateUserService.ts b/backend/src/services/UserServices/UpdateUserService.ts index 2f721bb..3cdad6d 100644 --- a/backend/src/services/UserServices/UpdateUserService.ts +++ b/backend/src/services/UserServices/UpdateUserService.ts @@ -7,8 +7,7 @@ import User from "../../models/User"; interface UserData { email?: string; password?: string; - name?: string; - positionCompany?: string; + name?: string; positionId?: string; profile?: string; queueIds?: number[]; @@ -73,8 +72,7 @@ const UpdateUserService = async ({ email, password, profile, - name, - positionCompany, + name, positionId, queueIds = [], transferToOtherQueues @@ -89,8 +87,7 @@ const UpdateUserService = async ({ await user.update({ email, password, - profile, - positionCompany, + profile, positionId: !positionId ? null : positionId, name, transferToOtherQueues diff --git a/frontend/src/components/UserModal/index.js b/frontend/src/components/UserModal/index.js index 976fc8c..6520545 100644 --- a/frontend/src/components/UserModal/index.js +++ b/frontend/src/components/UserModal/index.js @@ -84,8 +84,7 @@ const UserModal = ({ open, onClose, userId, }) => { const initialState = { name: "", email: "", - password: "", - positionCompany: "", + password: "", profile: "user", } @@ -261,17 +260,7 @@ const UserModal = ({ open, onClose, userId, }) => { margin="dense" fullWidth /> -
- {/* */} +