From 61a74be0b01192041ad906a0f83e353ef4d7440e Mon Sep 17 00:00:00 2001 From: jfrye122 Date: Thu, 4 May 2023 13:47:22 -0400 Subject: [PATCH] added queries --- graphql/employees.queries.js | 54 ++++++++++++++++++++++++++++++++ graphql/timetickets.queries.js | 52 ++++++++++++++++++++++++++++++ redux/employee/employee.types.js | 3 ++ 3 files changed, 109 insertions(+) create mode 100644 graphql/employees.queries.js create mode 100644 graphql/timetickets.queries.js diff --git a/graphql/employees.queries.js b/graphql/employees.queries.js new file mode 100644 index 0000000..8cd59b7 --- /dev/null +++ b/graphql/employees.queries.js @@ -0,0 +1,54 @@ +import gql from "graphql-tag"; + +export const QUERY_EMPLOYEES = gql` + query QUERY_EMPLOYEES { + employees(order_by: { employee_number: asc }) { + last_name + id + first_name + flat_rate + employee_number + } + } +`; +export const QUERY_EMPLOYEE_BY_ID = gql` + query QUERY_EMPLOYEE_BY_ID($id: uuid!) { + employees_by_pk(id: $id) { + last_name + id + first_name + employee_number + active + termination_date + hire_date + flat_rate + rates + pin + user_email + external_id + employee_vacations(order_by: { start: desc }) { + id + start + end + } + } + } +`; + +export const QUERY_ACTIVE_EMPLOYEES = gql` + query QUERY_ACTIVE_EMPLOYEES { + employees(where: { active: { _eq: true } }) { + last_name + id + first_name + employee_number + active + termination_date + hire_date + flat_rate + rates + pin + user_email + } + } +`; \ No newline at end of file diff --git a/graphql/timetickets.queries.js b/graphql/timetickets.queries.js new file mode 100644 index 0000000..5fe94ae --- /dev/null +++ b/graphql/timetickets.queries.js @@ -0,0 +1,52 @@ +import gql from "graphql-tag"; + + + +export const INSERT_NEW_TIME_TICKET = gql` + mutation INSERT_NEW_TIME_TICKET( + $timeTicketInput: [timetickets_insert_input!]! + ) { + insert_timetickets(objects: $timeTicketInput) { + returning { + id + clockon + clockoff + employeeid + productivehrs + actualhrs + ciecacode + date + memo + flat_rate + } + } + } +`; + +export const UPDATE_TIME_TICKET = gql` + mutation UPDATE_TIME_TICKET( + $timeticketId: uuid! + $timeticket: timetickets_set_input! + ) { + update_timetickets( + where: { id: { _eq: $timeticketId } } + _set: $timeticket + ) { + returning { + id + clockon + clockoff + employeeid + productivehrs + actualhrs + ciecacode + created_at + updated_at + jobid + date + flat_rate + memo + } + } + } +`; \ No newline at end of file diff --git a/redux/employee/employee.types.js b/redux/employee/employee.types.js index cea3d6f..2c7b378 100644 --- a/redux/employee/employee.types.js +++ b/redux/employee/employee.types.js @@ -6,6 +6,9 @@ const EmployeeActionTypes = { EMPLOYEE_AUTHORIZING_SUCCESS: "EMPLOYEE_AUTHORIZING_SUCCESS", EMPLOYEE_AUTHORIZING_FAILURE: "EMPLOYEE_AUTHORIZING_FAILURE", EMPLOYEE_SIGN_OUT: "EMPLOYEE_SIGN_OUT", + EMPLOYEE_CREATE_TIME_TICKET_START: "EMPLOYEE_CREATE_TIME_TICKET_START", + EMPLOYEE_CREATE_TIME_TICKET_SUCCESS: "EMPLOYEE_CREATE_TIME_TICKET_SUCCESS", + EMPLOYEE_CREATE_TIME_TICKET_FAILURE: "EMPLOYEE_CREATE_TIME_TICKET_FAILURE", EMPLOYEE_CHECK_SESSION: "EMPLOYEE_CHECK_SESSION", EMPLOYEE_SET_CURRENT: "EMPLOYEE_SET_CURRENT"