Skip to content

Commit

Permalink
Co-authored-by: Shelley Chen <[email protected]>
Browse files Browse the repository at this point in the history
  • Loading branch information
jeessh committed Nov 22, 2023
1 parent 125723c commit f0b017b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 65 deletions.
60 changes: 7 additions & 53 deletions backend/typescript/graphql/resolvers/taskResolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ const taskResolvers = {
_parent: undefined,
{ id }: { id: string },
): Promise<TaskDTO> => {
const task = await taskService.getTaskById(id);
const task = await taskService.getTaskById(Number(id));
return task;
},
getTasksByCategoryId: async (
_parent: undefined,
{ id }: { id: string },
): Promise<TaskDTO[]> => {
const tasks = await taskService.getTasksByCategoryId(id);
): Promise<Array<TaskDTO>> => {
const tasks = await taskService.getTasksByCategoryId(Number(id));
return tasks;
},
getTasksByAssigneeId: async (
_parent: undefined,
{ id }: { id: string },
): Promise<TaskDTO[]> => {
const tasks = await taskService.getTasksByAssigneeId(id);
const tasks = await taskService.getTasksByAssigneeId(Number(id));
return tasks;
},
getTasksByAssignerId: async (
_parent: undefined,
{ id }: { id: string },
): Promise<TaskDTO[]> => {
const tasks = await taskService.getTasksByAssignerId(id);
const tasks = await taskService.getTasksByAssignerId(Number(id));
return tasks;
},
},
Expand All @@ -52,63 +52,17 @@ const taskResolvers = {
{ id }: { id: string },
{ task }: { task: InputTaskDTO },
): Promise<TaskDTO> => {
const updatedTask = await taskService.updateTaskById(id, task);
const updatedTask = await taskService.updateTaskById(Number(id), task);
return updatedTask;
},
deleteTask: async (
_parent: undefined,
{ id }: { id: string },
): Promise<TaskDTO> => {
const deletedTask = await taskService.deleteTaskById(id);
const deletedTask = await taskService.deleteTaskById(Number(id));
return deletedTask;
},
},
};

// import ResidentService from "../../services/implementations/residentService";
// import type IResidentService from "../../services/interfaces/residentService";
// import type { ResidentDTO, CreateResidentDTO, UpdateResidentDTO } from "../../services/interfaces/residentService";

// const residentService: IResidentService = new ResidentService();
// //const authService: IAuthService = new AuthService(userService, emailService);

// const residentResolvers = {
// Query: {
// residentsById: async (
// _parent: undefined,
// { id }: { id: string[] },
// ): Promise<Array<ResidentDTO>> => {
// return residentService.get_residents_by_id(id.map(Number));
// },
// allResidents: async (): Promise<Array<ResidentDTO>> => {
// return residentService.get_all_residents();
// }
// },
// Mutation: {
// addResident: async (
// _parent: undefined,
// { resident }: { resident: CreateResidentDTO },
// ): Promise<ResidentDTO> => {
// const newResident = await residentService.add_resident(resident);
// return newResident;
// },
// updateResident: async (
// _parent: undefined,
// { id, resident }: { id: string, resident: UpdateResidentDTO },
// ): Promise<ResidentDTO> => {
// const newResident = await residentService.update_resident(parseInt(id), resident);
// return newResident;
// },
// deleteResident: async (
// _parent: undefined,
// { id }: { id: string },
// ): Promise<ResidentDTO> => {
// const deletedResident = await residentService.delete_resident(parseInt(id));
// return deletedResident;
// },
// },
// };

// export default residentResolvers;

export default taskResolvers;
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const up: Migration = async ({ context: sequelize }) => {
primaryKey: true,
autoIncrement: true,
},
first_name: {
firstName: {
type: DataType.STRING,
allowNull: false,
},
Expand Down
16 changes: 8 additions & 8 deletions backend/typescript/services/implementations/taskService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ class TaskService implements ITaskService {
title: task.title,
status: task.status,
description: task.description,
credit_value: task.creditValue,
start_date: task.startDate,
end_date: task.endDate,
creditValue: task.creditValue,
startDate: task.startDate,
endDate: task.endDate,
comments: task.comments,
recurrence_frequency: task.recurrenceFrequency,
recurrenceFrequency: task.recurrenceFrequency,
category: {
connect: {
id: task.categoryId,
Expand Down Expand Up @@ -200,11 +200,11 @@ class TaskService implements ITaskService {
title: task.title,
status: task.status,
description: task.description,
credit_value: task.creditValue,
start_date: task.startDate,
end_date: task.endDate,
creditValue: task.creditValue,
startDate: task.startDate,
endDate: task.endDate,
comments: task.comments,
recurrence_frequency: task.recurrenceFrequency,
recurrenceFrequency: task.recurrenceFrequency,
category: {
connect: {
id: task.categoryId,
Expand Down
6 changes: 3 additions & 3 deletions backend/typescript/services/interfaces/taskService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export interface InputTaskDTO {

export interface TaskDTO {
id: number;
categoryName?: string;
category_name?: string;
title: string;
status: Status;
description: string;
assigneeName?: string;
assignerName?: string;
assignee_name?: string;
assigner_name?: string;
creditValue: number;
startDate: Date;
endDate?: Date | null;
Expand Down

0 comments on commit f0b017b

Please sign in to comment.