From 2a0ad46eeaa8d3648787133321702fa6366c8569 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Thu, 20 Apr 2023 09:46:21 -0700 Subject: [PATCH] IO-2235 Changes in Prettier --- .../report-center-modal.component.jsx | 526 +++++++++--------- 1 file changed, 263 insertions(+), 263 deletions(-) diff --git a/client/src/components/report-center-modal/report-center-modal.component.jsx b/client/src/components/report-center-modal/report-center-modal.component.jsx index f2906c338..255273419 100644 --- a/client/src/components/report-center-modal/report-center-modal.component.jsx +++ b/client/src/components/report-center-modal/report-center-modal.component.jsx @@ -1,14 +1,14 @@ import { useLazyQuery } from "@apollo/client"; import { - Button, - Card, - Col, - DatePicker, - Form, - Input, - Radio, - Row, - Typography, + Button, + Card, + Col, + DatePicker, + Form, + Input, + Radio, + Row, + Typography, } from "antd"; import _ from "lodash"; import moment from "moment"; @@ -26,281 +26,281 @@ import EmployeeSearchSelect from "../employee-search-select/employee-search-sele import VendorSearchSelect from "../vendor-search-select/vendor-search-select.component"; import "./report-center-modal.styles.scss"; const mapStateToProps = createStructuredSelector({ - reportCenterModal: selectReportCenter, + reportCenterModal: selectReportCenter, }); const mapDispatchToProps = (dispatch) => ({ - //setUserLanguage: language => dispatch(setUserLanguage(language)) + //setUserLanguage: language => dispatch(setUserLanguage(language)) }); export default connect( - mapStateToProps, - mapDispatchToProps + mapStateToProps, + mapDispatchToProps )(ReportCenterModalComponent); export function ReportCenterModalComponent({ reportCenterModal }) { - const [form] = Form.useForm(); - const [search, setSearch] = useState(""); + const [form] = Form.useForm(); + const [search, setSearch] = useState(""); - const [loading, setLoading] = useState(false); - const { t } = useTranslation(); - const Templates = TemplateList("report_center"); - const ReportsList = Object.keys(Templates).map((key) => { - return Templates[key]; - }); - const { visible } = reportCenterModal; + const [loading, setLoading] = useState(false); + const { t } = useTranslation(); + const Templates = TemplateList("report_center"); + const ReportsList = Object.keys(Templates).map((key) => { + return Templates[key]; + }); + const { visible } = reportCenterModal; - const [callVendorQuery, { data: vendorData, called: vendorCalled }] = - useLazyQuery(QUERY_ALL_VENDORS, { - skip: !( - visible && - Templates[form.getFieldValue("key")] && - Templates[form.getFieldValue("key")].idtype - ), - }); + const [callVendorQuery, { data: vendorData, called: vendorCalled }] = + useLazyQuery(QUERY_ALL_VENDORS, { + skip: !( + visible && + Templates[form.getFieldValue("key")] && + Templates[form.getFieldValue("key")].idtype + ), + }); - const [callEmployeeQuery, { data: employeeData, called: employeeCalled }] = - useLazyQuery(QUERY_ACTIVE_EMPLOYEES, { - skip: !( - visible && - Templates[form.getFieldValue("key")] && - Templates[form.getFieldValue("key")].idtype - ), - }); + 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; + const handleFinish = async (values) => { + setLoading(true); + const start = values.dates[0]; + const end = values.dates[1]; + const { id } = values; - await GenerateDocument( - { - name: values.key, - variables: { - ...(start - ? { start: moment(start).startOf("day").format("YYYY-MM-DD") } - : {}), - ...(end - ? { end: moment(end).endOf("day").format("YYYY-MM-DD") } - : {}), - ...(start ? { starttz: moment(start).startOf("day") } : {}), - ...(end ? { endtz: moment(end).endOf("day") } : {}), + await GenerateDocument( + { + name: values.key, + variables: { + ...(start + ? { start: moment(start).startOf("day").format("YYYY-MM-DD") } + : {}), + ...(end + ? { end: moment(end).endOf("day").format("YYYY-MM-DD") } + : {}), + ...(start ? { starttz: moment(start).startOf("day") } : {}), + ...(end ? { endtz: moment(end).endOf("day") } : {}), - ...(id ? { id: id } : {}), - }, - }, - { - to: values.to, - subject: Templates[values.key]?.subject, - }, - values.sendby === "excel" ? "x" : values.sendby === "email" ? "e" : "p", - id - ); - setLoading(false); - }; + ...(id ? { id: id } : {}), + }, + }, + { + to: values.to, + subject: Templates[values.key]?.subject, + }, + values.sendby === "excel" ? "x" : values.sendby === "email" ? "e" : "p", + id + ); + setLoading(false); + }; - const FilteredReportsList = - search !== "" - ? ReportsList.filter((r) => - r.title.toLowerCase().includes(search.toLowerCase()) - ) - : ReportsList; + const FilteredReportsList = + search !== "" + ? ReportsList.filter((r) => + r.title.toLowerCase().includes(search.toLowerCase()) + ) + : ReportsList; - //Group it, create cards, and then filter out. + //Group it, create cards, and then filter out. - const grouped = _.groupBy(FilteredReportsList, "group"); + const grouped = _.groupBy(FilteredReportsList, "group"); - return ( -
-
- setSearch(e.target.value)} - value={search} - /> - - - {/* {Object.keys(Templates).map((key) => ( + return ( +
+ + setSearch(e.target.value)} + value={search} + /> + + + {/* {Object.keys(Templates).map((key) => ( {Templates[key].title} ))} */} - - {Object.keys(grouped).map((key) => ( - - - - {t(`reportcenter.labels.groups.${key}`)} - -
    - {grouped[key].map((item) => ( -
  • - - {item.title} - -
  • - ))} -
-
- - ))} -
-
-
- - {() => { - const key = form.getFieldValue("key"); - if (!key) return null; - //Kind of Id - const rangeFilter = Templates[key] && Templates[key].rangeFilter; - if (!rangeFilter) return null; - return ( -
- {t("reportcenter.labels.filterson", { - object: rangeFilter.object, - field: rangeFilter.field, - })} -
- ); - }} -
- - {() => { - const key = form.getFieldValue("key"); - const currentId = form.getFieldValue("id"); - if (!key) return null; - //Kind of Id - const idtype = Templates[key] && Templates[key].idtype; - if (!idtype && currentId) { - form.setFieldsValue({ id: null }); - return null; - } - if (!vendorCalled && idtype === "vendor") callVendorQuery(); - if (!employeeCalled && idtype === "employee") callEmployeeQuery(); - if (idtype === "vendor") - return ( - - - - ); - if (idtype === "employee") - return ( - - - - ); - else return null; - }} - - - - - - {() => { - const key = form.getFieldValue("key"); - const currentId = form.getFieldValue("id"); - if (!key) return null; - //Kind of Id - const idtype = Templates[key] && Templates[key].idtype; - if (!idtype && currentId) { - form.setFieldsValue({ id: null }); - return null; - } - if (idtype === "excel") - return ( - - - {t("general.labels.excel")} - - - ); - if (idtype !== "excel") - return ( - - - {t("general.labels.email")} - {t("general.labels.print")} - - - ); - }} - + + {Object.keys(grouped).map((key) => ( + + + + {t(`reportcenter.labels.groups.${key}`)} + +
    + {grouped[key].map((item) => ( +
  • + + {item.title} + +
  • + ))} +
+
+ + ))} +
+ + + + {() => { + const key = form.getFieldValue("key"); + if (!key) return null; + //Kind of Id + const rangeFilter = Templates[key] && Templates[key].rangeFilter; + if (!rangeFilter) return null; + return ( +
+ {t("reportcenter.labels.filterson", { + object: rangeFilter.object, + field: rangeFilter.field, + })} +
+ ); + }} +
+ + {() => { + const key = form.getFieldValue("key"); + const currentId = form.getFieldValue("id"); + if (!key) return null; + //Kind of Id + const idtype = Templates[key] && Templates[key].idtype; + if (!idtype && currentId) { + form.setFieldsValue({ id: null }); + return null; + } + if (!vendorCalled && idtype === "vendor") callVendorQuery(); + if (!employeeCalled && idtype === "employee") callEmployeeQuery(); + if (idtype === "vendor") + return ( + + + + ); + if (idtype === "employee") + return ( + + + + ); + else return null; + }} + + + + + + {() => { + const key = form.getFieldValue("key"); + const currentId = form.getFieldValue("id"); + if (!key) return null; + //Kind of Id + const idtype = Templates[key] && Templates[key].idtype; + if (!idtype && currentId) { + form.setFieldsValue({ id: null }); + return null; + } + if (idtype === "excel") + return ( + + + {t("general.labels.excel")} + + + ); + if (idtype !== "excel") + return ( + + + {t("general.labels.email")} + {t("general.labels.print")} + + + ); + }} + -
- -
- -
- ); +
+ +
+ +
+ ); }