- fix time input boxes with showSeconds deprecated prop

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-02-13 17:05:01 -05:00
parent a4a4d0b8f6
commit 9cc9bf20bd
4 changed files with 75 additions and 23 deletions

View File

@@ -4,12 +4,12 @@ import {fetchFilterData} from "../../utils/RenderTemplate";
import {DeleteFilled} from "@ant-design/icons"; import {DeleteFilled} from "@ant-design/icons";
import {useTranslation} from "react-i18next"; import {useTranslation} from "react-i18next";
export default function Test({form}) { export default function ReportCenterModalFiltersSortersComponent({form}) {
return ( return (
<Form.Item style={{margin: 0, padding: 0}} dependencies={["key"]}> <Form.Item style={{margin: 0, padding: 0}} dependencies={["key"]}>
{() => { {() => {
const key = form.getFieldValue("key"); const key = form.getFieldValue("key");
return <RenderFilters templateId={key}/>; return <RenderFilters form={form} templateId={key}/>;
}} }}
</Form.Item> </Form.Item>
); );
@@ -17,16 +17,20 @@ export default function Test({form}) {
function RenderFilters({templateId}) { function RenderFilters({templateId}) {
const [state, setState] = useState(null); const [state, setState] = useState(null);
console.log("state", state); console.log("state", state);
const {t} = useTranslation(); const {t} = useTranslation();
useEffect(() => { useEffect(() => {
const fetch = async () => { const fetch = async () => {
const data = await fetchFilterData({name: templateId}); const data = await fetchFilterData({name: templateId});
console.log("🚀 ~ fetch ~ data:", data); if (data?.success) {
setState(data.data); setState(data.data);
} else {
setState(null);
}
}; };
console.log("🚀 ~ useEffect ~ templateId:", templateId);
if (templateId) { if (templateId) {
fetch(); fetch();
} }
@@ -76,6 +80,7 @@ function RenderFilters({templateId}) {
key={`${index}operator`} key={`${index}operator`}
label="operator" label="operator"
name={[field.name, "operator"]} name={[field.name, "operator"]}
dependencies={[['filters', field.name, "field"]]}
rules={[ rules={[
{ {
required: true, required: true,
@@ -83,20 +88,28 @@ function RenderFilters({templateId}) {
}, },
]} ]}
> >
<Select {
options={[ () => {
{value: "_eq", label: "Equals"}, console.log('Dependencies fired')
{value: "_ne", label: "Not Equals"}, if (true) {
{value: "_gt", label: "Greater Than"}, return <Select
{value: "_lt", label: "Less Than"}, options={[
{value: "_gte", label: "Greater Than or Equal To"}, {value: "_eq", label: "Equals"},
{value: "_lte", label: "Less Than or Equal To"}, {value: "_ne", label: "Not Equals"},
{value: "_in", label: "In"}, {value: "_gt", label: "Greater Than"},
{value: "_nin", label: "Not In"}, {value: "_lt", label: "Less Than"},
{value: "_contains", label: "Contains"}, {value: "_gte", label: "Greater Than or Equal To"},
{value: "_ncontains", label: "Does Not Contain"}, {value: "_lte", label: "Less Than or Equal To"},
]} {value: "_in", label: "In"},
/> {value: "_nin", label: "Not In"},
{value: "_contains", label: "Contains"},
{value: "_ncontains", label: "Does Not Contain"},
]}
/>
}
}
}
</Form.Item> </Form.Item>
</Col> </Col>
<Col span={6}> <Col span={6}>

View File

@@ -15,7 +15,7 @@ import {TemplateList} from "../../utils/TemplateConstants";
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 VendorSearchSelect from "../vendor-search-select/vendor-search-select.component";
import "./report-center-modal.styles.scss"; import "./report-center-modal.styles.scss";
import Test from "./test"; import ReportCenterModalFiltersSortersComponent from "./report-center-modal-filters-sorters-component";
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
reportCenterModal: selectReportCenter, reportCenterModal: selectReportCenter,
@@ -182,7 +182,7 @@ export function ReportCenterModalComponent({reportCenterModal}) {
); );
}} }}
</Form.Item> </Form.Item>
<Test form={form} /> <ReportCenterModalFiltersSortersComponent form={form} />
<Form.Item style={{margin: 0, padding: 0}} dependencies={["key"]}> <Form.Item style={{margin: 0, padding: 0}} dependencies={["key"]}>
{() => { {() => {
const key = form.getFieldValue("key"); const key = form.getFieldValue("key");

View File

@@ -309,6 +309,7 @@ export const GenerateDocuments = async (templates) => {
}; };
export const fetchFilterData = async ({name}) => { export const fetchFilterData = async ({name}) => {
try {
const bodyshop = store.getState().user.bodyshop; const bodyshop = store.getState().user.bodyshop;
const jsrAuth = (await axios.post("/utils/jsr")).data; const jsrAuth = (await axios.post("/utils/jsr")).data;
jsreport.headers["FirebaseAuthorization"] = jsreport.headers["FirebaseAuthorization"] =
@@ -346,8 +347,17 @@ export const fetchFilterData = async ({name}) => {
useShopSpecificTemplate = false; useShopSpecificTemplate = false;
if (generalTemplate) parsedFilterData = atob(generalTemplate.content); if (generalTemplate) parsedFilterData = atob(generalTemplate.content);
} }
const data = JSON.parse(parsedFilterData);
return {data: JSON.parse(parsedFilterData), useShopSpecificTemplate}; return {
data,
useShopSpecificTemplate,
success: true,
}
} catch {
return {
success: false,
}
}
}; };
const fetchContextData = async (templateObject, jsrAuth) => { const fetchContextData = async (templateObject, jsrAuth) => {

View File

@@ -1,5 +1,34 @@
import {Kind, visit, parse, print} from "graphql"; import {Kind, visit, parse, print} from "graphql";
export const numberOperators = [
{value: "_eq", label: "Equals"},
{value: "_ne", label: "Not Equals"},
{value: "_gt", label: "Greater Than"},
{value: "_lt", label: "Less Than"},
{value: "_gte", label: "Greater Than or Equal To"},
{value: "_lte", label: "Less Than or Equal To"},
];
export const stringOperators = [
{value: "_eq", label: "Equals", type: 'string'},
{value: "_ne", label: "Not Equals", type: 'string'},
{value: "_in", label: "In", type: 'string'},
{value: "_nin", label: "Not In", type: 'string'},
{value: "_contains", label: "Contains", type: 'string'},
{value: "_ncontains", label: "Does Not Contain", type: 'string'},
];
export const numberSorters = [
{value: "asc", label: "Ascending"},
{value: "desc", label: "Descending"},
];
export const stringSorters = [
{value: "asc", label: "Alphabetically Ascending"},
{value: "desc", label: "Alphabetically Descending"},
];
/* eslint-disable no-loop-func */ /* eslint-disable no-loop-func */
/** /**