Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kathleen megan/api constants tasks #113

Merged
merged 2 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
77 changes: 77 additions & 0 deletions frontend/src/APIClients/Mutations/TaskMutations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { gql } from "@apollo/client";

export const CREATE_TASK = gql`
mutation CreateTask($task: InputTaskDTO!) {
createTask(task: $task) {
id
type
title
description
creditValue
endDate
recurrenceFrequency
specificDay
repeatDays
}
}
`;

export const UPDATE_TASK = gql`
mutation UpdateTASK($taskId: Int!, $task: InputTaskDTO!) {
updateTask(taskId: $taskId, task: $task) {
id
type
title
description
creditValue
endDate
recurrenceFrequency
specificDay
repeatDays
}
}
`;

export const DELETE_TASK = gql`
mutation DeleteStaff($taskId: Int!) {
deleteTask(taskId: $taskId) {
id
type
title
description
creditValue
endDate
recurrenceFrequency
specificDay
repeatDays
}
}
`;

export const ASSIGN_TASK = gql`
mutation AssignTask($taskAssigned: InputTaskAssignedDTO!) {
assignTask(taskAssigned: $taskAssigned) {
id
taskId
assigneeId
assignerId
status
startDate
comments
}
}
`;

export const CHANGE_TASK_STATUS = gql`
mutation ChangeTaskStatus($taskAssignedId: Int!, $status: Status!) {
changeTaskStatus(taskAssignedId: $taskAssignedId, status: $status) {
id
taskId
assigneeId
assignerId
status
startDate
comments
}
}
`;
89 changes: 89 additions & 0 deletions frontend/src/APIClients/Queries/TaskQueries.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { gql } from "@apollo/client";

export const GET_TASK_BY_ID = gql`
query getTaskById($taskId: Int!) {
getTaskById(taskId: $taskId) {
id
type
title
description
creditValue
endDate
recurrenceFrequency
specificDay
repeatDays
}
}
`;

export const GET_TASKS_BY_TYPE = gql`
query getTaskById($type: TaskType!) {
getTasksByType(type: $type) {
id
type
title
description
creditValue
endDate
recurrenceFrequency
specificDay
repeatDays
}
}
`;

export const GET_TASKS_BY_ASSIGNEE_ID = gql`
query getTasksByAssigneeId($assigneeId: Int!) {
getTasksByAssigneeId(assigneeId: $assigneeId) {
id
taskId
assigneeId
assignerId
status
startDate
comments
}
}
`;

export const GET_TASKS_BY_ASSIGNER_ID = gql`
query GetTasksByAssignerId($assignerId: Int!) {
getTasksByAssignerId(assignerId: $assignerId) {
id
taskId
assigneeId
assignerId
status
startDate
comments
}
}
`;

export const GET_TASKS_BY_START_DATE = gql`
query GetTasksByStartDate($startDate: DateTime!) {
getTasksByStartDate(startDate: $startDate) {
id
taskId
assigneeId
assignerId
status
startDate
comments
}
}
`;

export const GET_TASKS_BY_STATUS = gql`
query GetTasksByStatus($status: Status!) {
getTasksByStatus(status: $status) {
id
taskId
assigneeId
assignerId
status
startDate
comments
}
}
`;
81 changes: 81 additions & 0 deletions frontend/src/APIClients/Types/TaskType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
export enum Status {
PENDING_APPROVAL = "PENDING_APPROVAL",
ASSIGNED = "ASSIGNED",
INCOMPLETE = "INCOMPLETE",
COMPLETE = "COMPLETE",
EXCUSED = "EXCUSED",
}

export enum RecurrenceFrequency {
ONE_TIME = "ONE_TIME",
REPEATS_PER_WEEK_SELECTED = "REPEATS_PER_WEEK_SELECTED",
REPEATS_PER_WEEK_ONCE = "REPEATS_PER_WEEK_ONCE",
}

export enum DaysOfWeek {
MONDAY = "MONDAY",
TUESDAY = "TUESDAY",
WEDNESDAY = "WEDNESDAY",
THURSDAY = "THURSDAY",
FRIDAY = "FRIDAY",
SATURDAY = "SATURDAY",
SUNDAY = "SUNDAY",
}

export enum TaskTypeEnum {
REQUIRED = "REQUIRED",
OPTIONAL = "OPTIONAL",
CHORE = "CHORE",
ACHIEVEMENT = "ACHIEVEMENT",
}

export type TaskLocation = {
id: number;
title: string;
description: string;
};

export type TaskResponse = {
id: number;
type: TaskTypeEnum;
title: string;
description: string;
creditValue: number;
location: TaskLocation;
tasksAssigned: TaskResponse[];
endDate?: Date;
recurrenceFrequency: RecurrenceFrequency;
specificDay?: DaysOfWeek;
repeatDays?: DaysOfWeek[];
};

export type TaskRequest = {
type: TaskTypeEnum;
title: string;
description: string;
creditValue: number;
locationId: number;
endDate?: Date;
recurrenceFrequency: RecurrenceFrequency;
specificDay?: DaysOfWeek;
repeatDays?: DaysOfWeek[];
};

export type TaskAssignedResponse = {
id: number;
taskId: number;
assigneeId: number;
assignerId: number;
status: Status;
startDate: Date;
comments?: string;
};

export type TaskAssignedRequest = {
taskId?: number;
assigneeId?: number;
assignerId?: number;
status?: Status;
startDate?: Date;
comments?: string;
};
Loading
Loading