Merged in feature/IO-2677-Tasks (pull request #1426)
IO-2667 Employee Tasks report Approved-by: Dave Richer
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
import { Select, Space, Tag } from "antd";
|
||||||
|
import React from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
const { Option } = Select;
|
||||||
|
//To be used as a form element only.
|
||||||
|
|
||||||
|
const EmployeeSearchSelectEmail = ({ options, ...props }) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Select
|
||||||
|
showSearch
|
||||||
|
// value={option}
|
||||||
|
style={{
|
||||||
|
width: 400
|
||||||
|
}}
|
||||||
|
optionFilterProp="search"
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{options
|
||||||
|
? options.map((o) => (
|
||||||
|
<Option key={o.id} value={o.user_email} search={`${o.employee_number} ${o.first_name} ${o.last_name}`}>
|
||||||
|
<Space>
|
||||||
|
{`${o.employee_number} ${o.first_name} ${o.last_name}`}
|
||||||
|
|
||||||
|
<Tag color="green">
|
||||||
|
{o.flat_rate ? t("timetickets.labels.flat_rate") : t("timetickets.labels.straight_time")}
|
||||||
|
</Tag>
|
||||||
|
</Space>
|
||||||
|
</Option>
|
||||||
|
))
|
||||||
|
: null}
|
||||||
|
</Select>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default EmployeeSearchSelectEmail;
|
||||||
@@ -2,23 +2,24 @@ import { useLazyQuery } from "@apollo/client";
|
|||||||
import { useSplitTreatments } from "@splitsoftware/splitio-react";
|
import { useSplitTreatments } from "@splitsoftware/splitio-react";
|
||||||
import { Button, Card, Col, DatePicker, Form, Input, Radio, Row, Typography } from "antd";
|
import { Button, Card, Col, DatePicker, Form, Input, Radio, Row, Typography } from "antd";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import dayjs from "../../utils/day";
|
|
||||||
import React, { useState } from "react";
|
import React, { 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_ACTIVE_EMPLOYEES } from "../../graphql/employees.queries";
|
import { QUERY_ACTIVE_EMPLOYEES, QUERY_ACTIVE_EMPLOYEES_WITH_EMAIL } from "../../graphql/employees.queries";
|
||||||
import { QUERY_ALL_VENDORS } from "../../graphql/vendors.queries";
|
import { QUERY_ALL_VENDORS } from "../../graphql/vendors.queries";
|
||||||
import { selectReportCenter } from "../../redux/modals/modals.selectors";
|
import { selectReportCenter } from "../../redux/modals/modals.selectors";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
import DatePickerRanges from "../../utils/DatePickerRanges";
|
import DatePickerRanges from "../../utils/DatePickerRanges";
|
||||||
import { GenerateDocument } from "../../utils/RenderTemplate";
|
import { GenerateDocument } from "../../utils/RenderTemplate";
|
||||||
import { TemplateList } from "../../utils/TemplateConstants";
|
import { TemplateList } from "../../utils/TemplateConstants";
|
||||||
|
import dayjs from "../../utils/day";
|
||||||
|
import EmployeeSearchSelectEmail from "../employee-search-select/employee-search-select-email.component";
|
||||||
import EmployeeSearchSelect from "../employee-search-select/employee-search-select.component";
|
import EmployeeSearchSelect from "../employee-search-select/employee-search-select.component";
|
||||||
import VendorSearchSelect from "../vendor-search-select/vendor-search-select.component";
|
|
||||||
import "./report-center-modal.styles.scss";
|
|
||||||
import ReportCenterModalFiltersSortersComponent from "./report-center-modal-filters-sorters-component";
|
|
||||||
import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component";
|
import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component";
|
||||||
|
import VendorSearchSelect from "../vendor-search-select/vendor-search-select.component";
|
||||||
|
import ReportCenterModalFiltersSortersComponent from "./report-center-modal-filters-sorters-component";
|
||||||
|
import "./report-center-modal.styles.scss";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
reportCenterModal: selectReportCenter,
|
reportCenterModal: selectReportCenter,
|
||||||
@@ -66,6 +67,13 @@ export function ReportCenterModalComponent({ reportCenterModal, bodyshop }) {
|
|||||||
skip: !(open && Templates[form.getFieldValue("key")] && Templates[form.getFieldValue("key")].idtype)
|
skip: !(open && Templates[form.getFieldValue("key")] && Templates[form.getFieldValue("key")].idtype)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const [callEmployeeWithEmailQuery, { data: employeeWithEmailData, called: employeeWithEmailCalled }] = useLazyQuery(
|
||||||
|
QUERY_ACTIVE_EMPLOYEES_WITH_EMAIL,
|
||||||
|
{
|
||||||
|
skip: !(open && Templates[form.getFieldValue("key")] && Templates[form.getFieldValue("key")].idtype)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const handleFinish = async (values) => {
|
const handleFinish = async (values) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const start = values.dates ? values.dates[0] : null;
|
const start = values.dates ? values.dates[0] : null;
|
||||||
@@ -197,6 +205,7 @@ export function ReportCenterModalComponent({ reportCenterModal, bodyshop }) {
|
|||||||
}
|
}
|
||||||
if (!vendorCalled && idtype === "vendor") callVendorQuery();
|
if (!vendorCalled && idtype === "vendor") callVendorQuery();
|
||||||
if (!employeeCalled && idtype === "employee") callEmployeeQuery();
|
if (!employeeCalled && idtype === "employee") callEmployeeQuery();
|
||||||
|
if (!employeeWithEmailCalled && idtype === "employeeWithEmail") callEmployeeWithEmailQuery();
|
||||||
if (idtype === "vendor")
|
if (idtype === "vendor")
|
||||||
return (
|
return (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
@@ -227,6 +236,21 @@ export function ReportCenterModalComponent({ reportCenterModal, bodyshop }) {
|
|||||||
<EmployeeSearchSelect options={employeeData ? employeeData.employees : []} />
|
<EmployeeSearchSelect options={employeeData ? employeeData.employees : []} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
);
|
);
|
||||||
|
if (idtype === "employeeWithEmail")
|
||||||
|
return (
|
||||||
|
<Form.Item
|
||||||
|
name="id"
|
||||||
|
label={t("reportcenter.labels.employee")}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<EmployeeSearchSelectEmail options={employeeWithEmailData ? employeeWithEmailData.employees : []} />
|
||||||
|
</Form.Item>
|
||||||
|
);
|
||||||
else return null;
|
else return null;
|
||||||
}}
|
}}
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|||||||
@@ -67,6 +67,24 @@ export const QUERY_ACTIVE_EMPLOYEES = gql`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const QUERY_ACTIVE_EMPLOYEES_WITH_EMAIL = gql`
|
||||||
|
query QUERY_ACTIVE_EMPLOYEES_WITH_EMAIL {
|
||||||
|
employees(where: {active: {_eq: true}, user_email: {_is_null: false}}) {
|
||||||
|
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) {
|
||||||
|
|||||||
@@ -2909,6 +2909,7 @@
|
|||||||
"parts_orders": "Parts Orders",
|
"parts_orders": "Parts Orders",
|
||||||
"payments": "Payments",
|
"payments": "Payments",
|
||||||
"scoreboard": "Scoreboard",
|
"scoreboard": "Scoreboard",
|
||||||
|
"tasks": "Tasks",
|
||||||
"timetickets": "Timetickets"
|
"timetickets": "Timetickets"
|
||||||
},
|
},
|
||||||
"vendor": "Vendor"
|
"vendor": "Vendor"
|
||||||
@@ -3025,6 +3026,7 @@
|
|||||||
"scoreboard_summary": "Scoreboard Summary",
|
"scoreboard_summary": "Scoreboard Summary",
|
||||||
"supplement_ratio_ins_co": "Supplement Ratio by Source",
|
"supplement_ratio_ins_co": "Supplement Ratio by Source",
|
||||||
"tasks_date": "Tasks by Date",
|
"tasks_date": "Tasks by Date",
|
||||||
|
"tasks_date_employee": "Employee Tasks by Date",
|
||||||
"thank_you_date": "Thank You Letters",
|
"thank_you_date": "Thank You Letters",
|
||||||
"timetickets": "Time Tickets",
|
"timetickets": "Time Tickets",
|
||||||
"timetickets_employee": "Employee Time Tickets",
|
"timetickets_employee": "Employee Time Tickets",
|
||||||
|
|||||||
@@ -2907,6 +2907,7 @@
|
|||||||
"parts_orders": "",
|
"parts_orders": "",
|
||||||
"payments": "",
|
"payments": "",
|
||||||
"scoreboard": "",
|
"scoreboard": "",
|
||||||
|
"tasks": "",
|
||||||
"timetickets": ""
|
"timetickets": ""
|
||||||
},
|
},
|
||||||
"vendor": ""
|
"vendor": ""
|
||||||
@@ -3023,6 +3024,7 @@
|
|||||||
"scoreboard_summary": "",
|
"scoreboard_summary": "",
|
||||||
"supplement_ratio_ins_co": "",
|
"supplement_ratio_ins_co": "",
|
||||||
"tasks_date": "",
|
"tasks_date": "",
|
||||||
|
"tasks_date_employee": "",
|
||||||
"thank_you_date": "",
|
"thank_you_date": "",
|
||||||
"timetickets": "",
|
"timetickets": "",
|
||||||
"timetickets_employee": "",
|
"timetickets_employee": "",
|
||||||
|
|||||||
@@ -2907,6 +2907,7 @@
|
|||||||
"parts_orders": "",
|
"parts_orders": "",
|
||||||
"payments": "",
|
"payments": "",
|
||||||
"scoreboard": "",
|
"scoreboard": "",
|
||||||
|
"tasks": "",
|
||||||
"timetickets": ""
|
"timetickets": ""
|
||||||
},
|
},
|
||||||
"vendor": ""
|
"vendor": ""
|
||||||
@@ -3023,6 +3024,7 @@
|
|||||||
"scoreboard_summary": "",
|
"scoreboard_summary": "",
|
||||||
"supplement_ratio_ins_co": "",
|
"supplement_ratio_ins_co": "",
|
||||||
"tasks_date": "",
|
"tasks_date": "",
|
||||||
|
"tasks_date_employee": "",
|
||||||
"thank_you_date": "",
|
"thank_you_date": "",
|
||||||
"timetickets": "",
|
"timetickets": "",
|
||||||
"timetickets_employee": "",
|
"timetickets_employee": "",
|
||||||
|
|||||||
@@ -2105,7 +2105,19 @@ export const TemplateList = (type, context) => {
|
|||||||
//idtype: "vendor",
|
//idtype: "vendor",
|
||||||
disabled: false,
|
disabled: false,
|
||||||
rangeFilter: {
|
rangeFilter: {
|
||||||
object: i18n.t("reportcenter.labels.objects.jobs"),
|
object: i18n.t("reportcenter.labels.objects.tasks"),
|
||||||
|
field: i18n.t("tasks.fields.created_at")
|
||||||
|
},
|
||||||
|
group: "jobs"
|
||||||
|
},
|
||||||
|
tasks_date_employee: {
|
||||||
|
title: i18n.t("reportcenter.templates.tasks_date_employee"),
|
||||||
|
subject: i18n.t("reportcenter.templates.tasks_date_employee"),
|
||||||
|
key: "tasks_date_employee",
|
||||||
|
idtype: "employeeWithEmail",
|
||||||
|
disabled: false,
|
||||||
|
rangeFilter: {
|
||||||
|
object: i18n.t("reportcenter.labels.objects.tasks"),
|
||||||
field: i18n.t("tasks.fields.created_at")
|
field: i18n.t("tasks.fields.created_at")
|
||||||
},
|
},
|
||||||
group: "jobs"
|
group: "jobs"
|
||||||
|
|||||||
Reference in New Issue
Block a user