Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
208 changes: 80 additions & 128 deletions backend/graphql/resolvers/participantResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,136 +4,88 @@

const participantService: IParticipantService = new ParticipantService();
const participantResolvers = {
Query: {
getPastParticipants: async (): Promise<Participant[]> => {
return participantService.getPastParticipants();
Query: {

Check failure on line 7 in backend/graphql/resolvers/participantResolver.ts

View workflow job for this annotation

GitHub Actions / run-lint

Delete `··`
getPastParticipants: async (): Promise<Participant[]> => {

Check failure on line 8 in backend/graphql/resolvers/participantResolver.ts

View workflow job for this annotation

GitHub Actions / run-lint

Delete `····`
return participantService.getPastParticipants();

Check failure on line 9 in backend/graphql/resolvers/participantResolver.ts

View workflow job for this annotation

GitHub Actions / run-lint

Replace `············` with `······`
},

Check failure on line 10 in backend/graphql/resolvers/participantResolver.ts

View workflow job for this annotation

GitHub Actions / run-lint

Delete `····`
getCurrentParticipants: async (): Promise<Participant[]> => {
return participantService.getCurrentParticipants();
},
getParticipantById: async (
_parent: undefined,
{ participantId }: { participantId: string },
): Promise<Participant | null> => {
return participantService.getParticipantById(participantId);
},
getParticipantByRoom: async (
_parent: undefined,
{ roomNumber }: { roomNumber: number },
): Promise<Participant | null> => {
return participantService.getParticipantByRoom(roomNumber);
}
},
getCurrentParticipants: async (): Promise<Participant[]> => {
return participantService.getCurrentParticipants();
Mutation: {
createParticipant: async (
_parent: undefined,
{
participantId,
roomNumber,
arrival,
password,
}: {
participantId: string;
roomNumber: number;
arrival: string;
password: string;
},
): Promise<boolean> => {
return participantService.createParticipant(
participantId,
roomNumber,
arrival,
password,
);
},
updateParticipantById: async (
_parent: undefined,
{
participantId,
roomNumber,
arrival,
departure,
password,
}: {
participantId: string;
roomNumber?: number;
arrival?: string;
departure?: string;
password?: string;
},
): Promise<boolean> => {
return participantService.updateParticipantById(
participantId,
roomNumber,
arrival,
departure,
password,
);
},
editMarillacBucks: async (
_parent: undefined,
{
participantId,
credit
}: {
participantId: string;
credit: number;
},
): Promise<boolean> => {
return participantService.updateParticipantCredit(
participantId,
credit
);
},
},
getParticipantById: async (
_parent: undefined,
{ participantId }: { participantId: string },
): Promise<Participant | null> => {
return participantService.getParticipantById(participantId);
},
},
Mutation: {
createParticipant: async (
_parent: undefined,
{
participantId,
roomNumber,
arrival,
password,
}: {
participantId: string;
roomNumber: number;
arrival: string;
password: string;
},
): Promise<boolean> => {
return participantService.createParticipant(
participantId,
roomNumber,
arrival,
password,
);
},
updateParticipantById: async (
_parent: undefined,
{
participantId,
roomNumber,
arrival,
departure,
password,
}: {
participantId: string;
roomNumber?: number;
arrival?: string;
departure?: string;
password?: string;
},
): Promise<boolean> => {
return participantService.updateParticipantById(
participantId,
roomNumber,
arrival,
departure,
password,
);
},
},
};

export default participantResolvers;

// import IResidentService, {
// ResidentDTO,
// CreateResidentDTO,
// UpdateResidentDTO,
// RedeemCreditsResponse,
// } from "../../services/interface/residentService";

// const residentResolvers = {
// Query: {
// getResidentsByIds: async (
// _parent: undefined,
// { userIds }: { userIds: string[] },
// ): Promise<Array<ResidentDTO>> => {
// return residentService.getResidentsByIds(userIds.map(Number));
// },
// getAllResidents: async (): Promise<Array<ResidentDTO>> => {
// return residentService.getAllResidents();
// },
// getActiveResidents: async (): Promise<ResidentDTO[]> => {
// const activeResidents = await residentService.getActiveResidents();
// return activeResidents;
// },
// },
// Mutation: {
// addResident: async (
// _parent: undefined,
// {
// resident,
// }: {
// resident: CreateResidentDTO;
// },
// ): Promise<ResidentDTO> => {
// const newResident = await residentService.addResident(resident);
// return newResident;
// },
// updateResident: async (
// _parent: undefined,
// {
// userId,
// resident,
// }: {
// userId: string;
// resident: UpdateResidentDTO;
// },
// ): Promise<ResidentDTO> => {
// const newResident = await residentService.updateResident(
// parseInt(userId, 10),
// resident,
// );
// return newResident;
// },
// deleteResident: async (
// _parent: undefined,
// { userId }: { userId: string },
// ): Promise<ResidentDTO> => {
// const deletedResident = await residentService.deleteResident(
// parseInt(userId, 10),
// );
// return deletedResident;
// },
// redeemCredits: async (
// _parent: undefined,
// { userId, credits }: { userId: string; credits: number },
// ): Promise<RedeemCreditsResponse> => {
// return residentService.redeemCredits(parseInt(userId, 10), credits);
// },
// },
// };
14 changes: 14 additions & 0 deletions backend/graphql/types/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ const dataModels = gql`
type: String!
accessToken: String!
}
type AssignedTask {
assignedTaskId: Int!
userID: Int!
type: TaskType!
name: String!
recurrencePreference: RecurrenceFrequency!
repeatDays: [String]!
timePreference: TimeOption!
start: String
end: String
credit: Int!
deduction: Int!
comment: String
}
`;

export default dataModels;
19 changes: 19 additions & 0 deletions backend/graphql/types/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const resolverTypes = gql`
getPastParticipants: [Participant]
getCurrentParticipants: [Participant]
getParticipantById(participantId: String!): Participant
getParticipantByRoom(roomNumber: Int): Participant
getNotes: [Note]
getTaskById(taskId: Int!): Task!
getTasksByType(type: TaskType!): [Task!]
Expand Down Expand Up @@ -56,6 +57,24 @@ const resolverTypes = gql`
comment: String
): Task!
deleteTask(taskId: Int!): Task!
createAssignedTask(
assignedTaskId: Int
userID: Int
type: TaskType!
name: String!
recurrencePreference: RecurrenceFrequency
repeatDays: [String]
timePreference: TimeOption!
start: String
end: String
credit: Int!
deduction: Int
comment: String
): AssignedTask
editMarillacBucks(
participantId: String
credit: Int
): Boolean
}
`;

Expand Down
Loading
Loading