Remove active employees from dropdowns IO-677

This commit is contained in:
Patrick Fic
2021-02-16 10:49:32 -08:00
parent 1201d78d99
commit 5b5cf579b8
3 changed files with 21 additions and 3 deletions

View File

@@ -30,7 +30,7 @@ export function ProductionBoardFilters({ bodyshop, filter, setFilter }) {
}} }}
/> />
<EmployeeSearchSelectComponent <EmployeeSearchSelectComponent
options={bodyshop.employees} options={bodyshop.employees.filter((e) => e.active)}
value={filter.employeeId} value={filter.employeeId}
placeholder={t("production.labels.employeesearch")} placeholder={t("production.labels.employeesearch")}
onChange={(emp) => setFilter({ ...filter, employeeId: emp })} onChange={(emp) => setFilter({ ...filter, employeeId: emp })}

View File

@@ -5,7 +5,7 @@ import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { createStructuredSelector } from "reselect"; import { createStructuredSelector } from "reselect";
import { QUERY_EMPLOYEES } from "../../graphql/employees.queries"; import { QUERY_ACTIVE_EMPLOYEES } from "../../graphql/employees.queries";
import { GET_LINE_TICKET_BY_PK } from "../../graphql/jobs-lines.queries"; import { GET_LINE_TICKET_BY_PK } from "../../graphql/jobs-lines.queries";
import { import {
INSERT_NEW_TIME_TICKET, INSERT_NEW_TIME_TICKET,
@@ -35,7 +35,7 @@ export function TimeTicketModalContainer({
const [insertTicket] = useMutation(INSERT_NEW_TIME_TICKET); const [insertTicket] = useMutation(INSERT_NEW_TIME_TICKET);
const [updateTicket] = useMutation(UPDATE_TIME_TICKET); const [updateTicket] = useMutation(UPDATE_TIME_TICKET);
const { data: EmployeeAutoCompleteData } = useQuery(QUERY_EMPLOYEES, { const { data: EmployeeAutoCompleteData } = useQuery(QUERY_ACTIVE_EMPLOYEES, {
skip: !timeTicketModal.visible, skip: !timeTicketModal.visible,
}); });

View File

@@ -18,6 +18,24 @@ export const QUERY_EMPLOYEES = gql`
} }
`; `;
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
}
}
`;
export const INSERT_EMPLOYEES = gql` export const INSERT_EMPLOYEES = gql`
mutation INSERT_EMPLOYEES($employees: [employees_insert_input!]!) { mutation INSERT_EMPLOYEES($employees: [employees_insert_input!]!) {
insert_employees(objects: $employees) { insert_employees(objects: $employees) {