IO-777 Added employee select to report center.
This commit is contained in:
@@ -27410,6 +27410,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>employee</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>generateasemail</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useLazyQuery } from "@apollo/client";
|
||||
import { Button, DatePicker, Form, Select, Switch } from "antd";
|
||||
import moment from "moment";
|
||||
import React from "react";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -11,6 +11,8 @@ import { GenerateDocument } from "../../utils/RenderTemplate";
|
||||
import { TemplateList } from "../../utils/TemplateConstants";
|
||||
import VendorSearchSelect from "../vendor-search-select/vendor-search-select.component";
|
||||
import DatePIckerRanges from "../../utils/DatePickerRanges";
|
||||
import EmployeeSearchSelect from "../employee-search-select/employee-search-select.component";
|
||||
import { QUERY_ACTIVE_EMPLOYEES } from "../../graphql/employees.queries";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
reportCenterModal: selectReportCenter,
|
||||
@@ -25,11 +27,15 @@ export default connect(
|
||||
|
||||
export function ReportCenterModalComponent({ reportCenterModal }) {
|
||||
const [form] = Form.useForm();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const { t } = useTranslation();
|
||||
const Templates = TemplateList("report_center");
|
||||
const { visible } = reportCenterModal;
|
||||
|
||||
const [callVendorQuery, { data, called }] = useLazyQuery(QUERY_ALL_VENDORS, {
|
||||
const [
|
||||
callVendorQuery,
|
||||
{ data: vendorData, called: vendorCalled },
|
||||
] = useLazyQuery(QUERY_ALL_VENDORS, {
|
||||
skip: !(
|
||||
visible &&
|
||||
Templates[form.getFieldValue("key")] &&
|
||||
@@ -37,12 +43,24 @@ export function ReportCenterModalComponent({ reportCenterModal }) {
|
||||
),
|
||||
});
|
||||
|
||||
const handleFinish = (values) => {
|
||||
const [
|
||||
callEmployeeQuery,
|
||||
{ data: employeeData, called: employeeCalled },
|
||||
] = useLazyQuery(QUERY_ACTIVE_EMPLOYEES, {
|
||||
skip: !(
|
||||
visible &&
|
||||
Templates[form.getFieldValue("key")] &&
|
||||
Templates[form.getFieldValue("key")].idtype
|
||||
),
|
||||
});
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
setLoading(true);
|
||||
const start = values.dates[0];
|
||||
const end = values.dates[1];
|
||||
const { id } = values;
|
||||
console.log("values", values);
|
||||
GenerateDocument(
|
||||
await GenerateDocument(
|
||||
{
|
||||
name: values.key,
|
||||
variables: {
|
||||
@@ -56,6 +74,7 @@ export function ReportCenterModalComponent({ reportCenterModal }) {
|
||||
},
|
||||
values.email ? "e" : "p"
|
||||
);
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -89,7 +108,8 @@ export function ReportCenterModalComponent({ reportCenterModal }) {
|
||||
//Kind of Id
|
||||
const idtype = Templates[key] && Templates[key].idtype;
|
||||
if (!idtype) return null;
|
||||
if (!called && idtype === "vendor") callVendorQuery();
|
||||
if (!vendorCalled && idtype === "vendor") callVendorQuery();
|
||||
if (!employeeCalled && idtype === "employee") callEmployeeQuery();
|
||||
if (idtype === "vendor")
|
||||
return (
|
||||
<Form.Item
|
||||
@@ -102,7 +122,26 @@ export function ReportCenterModalComponent({ reportCenterModal }) {
|
||||
},
|
||||
]}
|
||||
>
|
||||
<VendorSearchSelect options={data ? data.vendors : []} />
|
||||
<VendorSearchSelect
|
||||
options={vendorData ? vendorData.vendors : []}
|
||||
/>
|
||||
</Form.Item>
|
||||
);
|
||||
if (idtype === "employee")
|
||||
return (
|
||||
<Form.Item
|
||||
name="id"
|
||||
label={t("reportcenter.labels.employee")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<EmployeeSearchSelect
|
||||
options={employeeData ? employeeData.employees : []}
|
||||
/>
|
||||
</Form.Item>
|
||||
);
|
||||
else return null;
|
||||
@@ -138,7 +177,7 @@ export function ReportCenterModalComponent({ reportCenterModal }) {
|
||||
marginTop: "1rem",
|
||||
}}
|
||||
>
|
||||
<Button onClick={() => form.submit()} style={{}}>
|
||||
<Button onClick={() => form.submit()} style={{}} loading={loading}>
|
||||
{t("reportcenter.actions.generate")}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -1662,6 +1662,7 @@
|
||||
},
|
||||
"labels": {
|
||||
"dates": "Dates",
|
||||
"employee": "Employee",
|
||||
"generateasemail": "Generate as Email?",
|
||||
"key": "Report",
|
||||
"vendor": "Vendor"
|
||||
|
||||
@@ -1662,6 +1662,7 @@
|
||||
},
|
||||
"labels": {
|
||||
"dates": "",
|
||||
"employee": "",
|
||||
"generateasemail": "",
|
||||
"key": "",
|
||||
"vendor": ""
|
||||
|
||||
@@ -1662,6 +1662,7 @@
|
||||
},
|
||||
"labels": {
|
||||
"dates": "",
|
||||
"employee": "",
|
||||
"generateasemail": "",
|
||||
"key": "",
|
||||
"vendor": ""
|
||||
|
||||
@@ -326,13 +326,7 @@ export const TemplateList = (type, context) => {
|
||||
key: "schedule",
|
||||
disabled: false,
|
||||
},
|
||||
timetickets: {
|
||||
title: i18n.t("reportcenter.templates.timetickets"),
|
||||
description: "Est Detail",
|
||||
subject: i18n.t("reportcenter.templates.timetickets"),
|
||||
key: "timetickets",
|
||||
disabled: false,
|
||||
},
|
||||
|
||||
purchases_by_vendor_detailed_date_range: {
|
||||
title: i18n.t(
|
||||
"reportcenter.templates.purchases_by_vendor_detailed_date_range"
|
||||
@@ -357,12 +351,19 @@ export const TemplateList = (type, context) => {
|
||||
idtype: "vendor",
|
||||
disabled: false,
|
||||
},
|
||||
timetickets: {
|
||||
title: i18n.t("reportcenter.templates.timetickets"),
|
||||
description: "Est Detail",
|
||||
subject: i18n.t("reportcenter.templates.timetickets"),
|
||||
key: "timetickets",
|
||||
disabled: false,
|
||||
},
|
||||
timetickets_employee: {
|
||||
title: i18n.t("reportcenter.templates.timetickets_employee"),
|
||||
description: "Est Detail",
|
||||
subject: i18n.t("reportcenter.templates.timetickets_employee"),
|
||||
key: "timetickets_employee",
|
||||
idtype: "vendor",
|
||||
idtype: "employee",
|
||||
disabled: false,
|
||||
},
|
||||
timetickets_summary: {
|
||||
@@ -370,7 +371,7 @@ export const TemplateList = (type, context) => {
|
||||
description: "Est Detail",
|
||||
subject: i18n.t("reportcenter.templates.timetickets_summary"),
|
||||
key: "timetickets_summary",
|
||||
idtype: "vendor",
|
||||
//idtype: "vendor",
|
||||
disabled: false,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user