Skip to content

Commit

Permalink
removed user isActive field
Browse files Browse the repository at this point in the history
  • Loading branch information
jeessh committed Dec 4, 2024
1 parent e0da20f commit 2af3eb9
Show file tree
Hide file tree
Showing 13 changed files with 5 additions and 51 deletions.
1 change: 0 additions & 1 deletion backend/graphql/types/residentType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const residentType = gql`
type ResidentDTO {
userId: Int!
residentId: Int!
isActive: Boolean!
roomNumber: Int!
credits: Float!
dateJoined: Date!
Expand Down
5 changes: 2 additions & 3 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ model User {
authId String @unique @map("auth_id")
displayName String? @map("display_name")
profilePictureURL String? @map("profile_picture_url")
isActive Boolean @default(true) @map("is_active")
@@map("users")
}
Expand Down Expand Up @@ -148,9 +147,9 @@ model Warning {

model NotificationGroup {
id Int @id @default(autoincrement())
recipients Resident[]
recipients Resident[]
notifications Notification[]
announcementGroup Boolean
announcementGroup Boolean
}

model Notification {
Expand Down
4 changes: 3 additions & 1 deletion backend/services/implementations/notificationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ class NotificationService implements INotificationService {

async createAnnouncementGroup(): Promise<NotificationGroupDTO> {
try {
const residents = await prisma.resident.findMany();
const residents = await prisma.resident.findMany({
where: { dateLeft: null },
});
const residentIds = residents.map((resident) => resident.userId);

const newNotificationGroup = await prisma.notificationGroup.create({
Expand Down
14 changes: 0 additions & 14 deletions backend/services/implementations/residentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class ResidentService implements IResidentService {
create: {
authId: firebaseUser.uid,
type: UserType.RESIDENT,
isActive: true,
},
},
notificationGroup: {
Expand All @@ -64,7 +63,6 @@ class ResidentService implements IResidentService {
credits: newResident.credits,
dateJoined: newResident.dateJoined,
dateLeft: newResident.dateLeft,
isActive: newResident.user.isActive,
};
} catch (postgresError) {
try {
Expand Down Expand Up @@ -126,13 +124,6 @@ class ResidentService implements IResidentService {
credits: resident.credits || undefined,
dateJoined: resident.dateJoined || undefined,
dateLeft: resident.dateLeft || undefined,
user: {
update: {
data: {
isActive: resident.isActive || undefined,
},
},
},
},
include: { user: true },
});
Expand All @@ -144,7 +135,6 @@ class ResidentService implements IResidentService {
credits: updatedResident.credits,
dateJoined: updatedResident.dateJoined,
dateLeft: updatedResident.dateLeft,
isActive: updatedResident.user.isActive,
};
} catch (error) {
Logger.error(
Expand Down Expand Up @@ -188,7 +178,6 @@ class ResidentService implements IResidentService {
credits: deletedResident.credits,
dateJoined: deletedResident.dateJoined,
dateLeft: deletedResident.dateLeft,
isActive: deletedResident.user.isActive,
};
} catch (error) {
Logger.error(
Expand All @@ -213,7 +202,6 @@ class ResidentService implements IResidentService {
credits: resident.credits,
dateJoined: resident.dateJoined,
dateLeft: resident.dateLeft,
isActive: resident.user.isActive,
};
});
} catch (error: unknown) {
Expand All @@ -238,7 +226,6 @@ class ResidentService implements IResidentService {
credits: resident.credits,
dateJoined: resident.dateJoined,
dateLeft: resident.dateLeft,
isActive: resident.user.isActive,
};
});
} catch (error: unknown) {
Expand Down Expand Up @@ -270,7 +257,6 @@ class ResidentService implements IResidentService {
credits: resident.credits,
dateJoined: resident.dateJoined,
dateLeft: resident.dateLeft,
isActive: resident.user.isActive,
};
});
} catch (error: unknown) {
Expand Down
12 changes: 0 additions & 12 deletions backend/services/implementations/staffService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class StaffService implements IStaffService {
phoneNumber: newStaff.phoneNumber,
firstName: newStaff.firstName,
lastName: newStaff.lastName,
isActive: newStaff.user.isActive,
};
} catch (postgresError) {
try {
Expand Down Expand Up @@ -98,13 +97,6 @@ class StaffService implements IStaffService {
phoneNumber: staff.phoneNumber,
firstName: staff.firstName,
lastName: staff.lastName,
user: {
update: {
data: {
isActive: staff.isActive,
},
},
},
},
include: {
user: true,
Expand All @@ -118,7 +110,6 @@ class StaffService implements IStaffService {
phoneNumber: updatedStaff.phoneNumber,
firstName: updatedStaff.firstName,
lastName: updatedStaff.lastName,
isActive: updatedStaff.user.isActive,
};
} catch (error) {
Logger.error(
Expand Down Expand Up @@ -158,7 +149,6 @@ class StaffService implements IStaffService {
phoneNumber: deletedStaff.phoneNumber,
firstName: deletedStaff.firstName,
lastName: deletedStaff.lastName,
isActive: deletedUser.isActive,
};
} catch (error) {
Logger.error(
Expand All @@ -184,7 +174,6 @@ class StaffService implements IStaffService {
phoneNumber: staff.phoneNumber,
firstName: staff.firstName,
lastName: staff.lastName,
isActive: staff.user.isActive,
};
});
} catch (error: unknown) {
Expand All @@ -208,7 +197,6 @@ class StaffService implements IStaffService {
phoneNumber: staff.phoneNumber,
firstName: staff.firstName,
lastName: staff.lastName,
isActive: staff.user.isActive,
};
});
} catch (error: unknown) {
Expand Down
2 changes: 0 additions & 2 deletions backend/services/interfaces/userService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export type UserDTO = {
type: UserType;
displayName?: string | null;
profilePictureURL?: string | null;
isActive: boolean;
};

export type SimplifiedUserDTO = Pick<UserDTO, "id" | "type">;
Expand All @@ -20,7 +19,6 @@ export interface UpdateUserDTO {
password?: string;
displayName?: string;
profilePictureURL?: string;
isActive?: boolean;
}

interface IUserService {
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/APIClients/Mutations/ResidentsMutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const ADD_RESIDENT = gql`
residentId
displayName
profilePictureURL
isActive
roomNumber
credits
dateJoined
Expand All @@ -23,7 +22,6 @@ export const UPDATE_RESIDENT = gql`
residentId
displayName
profilePictureURL
isActive
roomNumber
credits
dateJoined
Expand All @@ -39,7 +37,6 @@ export const DELETE_RESIDENT = gql`
residentId
displayName
profilePictureURL
isActive
roomNumber
credits
dateJoined
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/APIClients/Mutations/StaffMutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const ADD_STAFF = gql`
lastName
displayName
profilePictureURL
isActive
isAdmin
}
}
Expand All @@ -26,7 +25,6 @@ export const UPDATE_STAFF = gql`
lastName
displayName
profilePictureURL
isActive
isAdmin
}
}
Expand All @@ -42,7 +40,6 @@ export const DELETE_STAFF = gql`
lastName
displayName
profilePictureURL
isActive
isAdmin
}
}
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/APIClients/Queries/ResidentsQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const GET_RESIDENTS_BY_ID = gql`
lastName
displayName
profilePictureURL
isActive
birthDate
roomNumber
credits
Expand All @@ -33,7 +32,6 @@ export const GET_ALL_RESIDENTS = gql`
lastName
displayName
profilePictureURL
isActive
birthDate
roomNumber
credits
Expand All @@ -55,7 +53,6 @@ export const GET_ACTIVE_RESIDENTS = gql`
lastName
displayName
profilePictureURL
isActive
birthDate
roomNumber
credits
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/APIClients/Queries/StaffQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const GET_ALL_STAFF = gql`
lastName
displayName
profilePictureURL
isActive
isAdmin
}
}
Expand All @@ -26,7 +25,6 @@ export const GET_STAFF_BY_IDS = gql`
lastName
displayName
profilePictureURL
isActive
isAdmin
}
}
Expand Down
1 change: 0 additions & 1 deletion frontend/src/APIClients/Types/ResidentsType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export type UserResponse = {
lastName: string;
displayName?: string;
profilePictureURL?: string;
isActive: boolean;
birthDate: string;
roomNumber: number;
credits: number;
Expand Down
5 changes: 0 additions & 5 deletions frontend/src/APIClients/Types/StaffTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export type UserRequest = {
isAdmin: boolean;
displayName?: string;
profilePictureURL?: string;
isActive: boolean;
};

export type UserRequestID = {
Expand All @@ -21,7 +20,6 @@ export type UserRequestID = {
isAdmin: boolean;
displayName?: string;
profilePictureURL?: string;
isActive: boolean;
};

export type UserRequestAdd = {
Expand All @@ -32,7 +30,6 @@ export type UserRequestAdd = {
lastName: string;
displayName: string;
profilePictureURL?: string;
isActive: boolean;
isAdmin: boolean;
};

Expand All @@ -44,7 +41,6 @@ export type UserRequestUpdate = {
lastName?: string;
displayName?: string;
profilePictureURL?: string;
isActive?: boolean;
isAdmin?: boolean;
};

Expand All @@ -56,6 +52,5 @@ export type UserRequestDelete = {
lastName?: string;
displayName?: string;
profilePictureURL?: string;
isActive?: boolean;
isAdmin?: boolean;
};
1 change: 0 additions & 1 deletion frontend/src/types/UserTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export interface User {
lastName: string;
displayName: string | null;
profilePictureURL: string | null;
isActive: boolean;
}

export interface Resident extends User {
Expand Down

0 comments on commit 2af3eb9

Please sign in to comment.