Skip to content

Commit

Permalink
🪲 Fix types broken by adding acronym to user groups.
Browse files Browse the repository at this point in the history
  • Loading branch information
klondikemarlen committed Jun 10, 2024
1 parent 17f40c5 commit 4e2c016
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/src/models/user-groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export enum UserGroupTypes {
}

export const UNASSIGNED_USER_GROUP_NAME = "Unassigned"
export const UNASSIGNED_USER_GROUP_ACRONYM = "U"
export const DEFAULT_ORDER = -1

export class UserGroup extends BaseModel<
Expand Down
7 changes: 6 additions & 1 deletion api/src/services/users/create-service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { isEmpty, isNil } from "lodash"

import db, { Role, User, UserGroup, UserGroupMembership } from "@/models"
import { DEFAULT_ORDER, UNASSIGNED_USER_GROUP_NAME } from "@/models/user-groups"
import {
DEFAULT_ORDER,
UNASSIGNED_USER_GROUP_ACRONYM,
UNASSIGNED_USER_GROUP_NAME,
} from "@/models/user-groups"

import { SyncService } from "@/services/users"
import BaseService from "@/services/base-service"
Expand Down Expand Up @@ -122,6 +126,7 @@ export class CreateService extends BaseService {
},
defaults: {
name: UNASSIGNED_USER_GROUP_NAME,
acronym: UNASSIGNED_USER_GROUP_ACRONYM,
type: UserGroup.Types.DEPARTMENT,
order: DEFAULT_ORDER,
},
Expand Down
3 changes: 3 additions & 0 deletions api/src/services/users/sync-service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isNil } from "lodash"

import acronymize from "@/utils/acronymize"
import { User } from "@/models"

import BaseService from "@/services/base-service"
Expand Down Expand Up @@ -34,10 +35,12 @@ export class SyncService extends BaseService {
let userGroup2: UserGroup | null = null
let userGroup3: UserGroup | null = null
let userGroup4: UserGroup | null = null
const departmentAcronym = acronymize(department)
const [userGroup1] = await UserGroup.findOrCreate({
where: { name: department, type: UserGroupTypes.DEPARTMENT },
defaults: {
name: department,
acronym: departmentAcronym,
type: UserGroupTypes.DEPARTMENT,
order: DEFAULT_ORDER,
},
Expand Down

0 comments on commit 4e2c016

Please sign in to comment.