Final updates to admin script and refactor warning.
This commit is contained in:
@@ -186,7 +186,7 @@
|
||||
},
|
||||
"1.3.5": {
|
||||
"title": "Release Notes for 1.3.5",
|
||||
"date": "TBD",
|
||||
"notes": "Bug Fix\n*Fix typos on application labels."
|
||||
"date": "10/17/2024",
|
||||
"notes": "Improvements:\r\n* Improved group detection for latest RPS rule sets.\r\n* Audit functionality will now rely on header names instead of order."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"productName": "ImEX RPS",
|
||||
"author": "ImEX Systems Inc. <support@thinkimex.com>",
|
||||
"description": "ImEX RPS",
|
||||
"version": "1.3.5-alpha.1",
|
||||
"version": "1.3.5",
|
||||
"main": "electron/main.js",
|
||||
"homepage": "./",
|
||||
"dependencies": {
|
||||
|
||||
13
src/components/atoms/no-date-set/no-date-set.atom.jsx
Normal file
13
src/components/atoms/no-date-set/no-date-set.atom.jsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import React from "react";
|
||||
import { WarningOutlined } from "@ant-design/icons";
|
||||
export default function NoDateSetWarning({ job }) {
|
||||
return (
|
||||
!job.close_date && (
|
||||
<WarningOutlined
|
||||
title="No Ready for Payment Date has been set for this job."
|
||||
className="blink_me"
|
||||
style={{ marginLeft: ".5rem", color: "tomato" }}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import React from "react";
|
||||
import { CloudUploadOutlined } from "@ant-design/icons";
|
||||
|
||||
export default function RequiresReimportDisplay({ job }) {
|
||||
return (
|
||||
job.requires_reimport && (
|
||||
<CloudUploadOutlined
|
||||
title="A change in R4P date changed the applicable rules. Import this job again for accurate scoring."
|
||||
style={{ marginLeft: ".5rem", color: "tomato" }}
|
||||
className="blink_me"
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -39,7 +39,7 @@ export default function JobsDetailDescriptionMolecule({ loading, job }) {
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="A change in R4P date changed the applicable rules. Reimport this job for accurate scoring."
|
||||
message="RPS has detected this job may have inaccurate grouping/targets. Reimport this job for accurate scoring."
|
||||
/>
|
||||
</Tooltip>
|
||||
),
|
||||
|
||||
@@ -7,6 +7,7 @@ import { setSelectedJobId } from "../../../redux/application/application.actions
|
||||
import { selectSelectedJobId } from "../../../redux/application/application.selectors";
|
||||
import TimeAgoFormatter from "../../atoms/time-ago-formatter/time-ago-formatter.atom";
|
||||
import "./jobs-list-item.styles.scss";
|
||||
import RequiresReimportDisplay from "../../atoms/requires-reimport/requires-reimport.atom";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
selectedJobId: selectSelectedJobId
|
||||
@@ -51,12 +52,7 @@ export function JobsListItemMolecule({ selectedJobId, setSelectedJobId, item, re
|
||||
style={{ marginLeft: ".5rem", color: "tomato" }}
|
||||
/>
|
||||
)}
|
||||
{item.requires_reimport && (
|
||||
<CloudUploadOutlined
|
||||
title="A change in R4P date changed the applicable rules. Import this job again for accurate scoring."
|
||||
style={{ marginLeft: ".5rem", color: "tomato" }}
|
||||
/>
|
||||
)}
|
||||
<RequiresReimportDisplay job={item} />
|
||||
</strong>
|
||||
<span style={{ fontStyle: "italic" }}>
|
||||
<TimeAgoFormatter>{item.updated_at}</TimeAgoFormatter>
|
||||
|
||||
@@ -11,6 +11,7 @@ import dayjs from "../../../util/day.js";
|
||||
import { alphaSort } from "../../../util/sorters";
|
||||
import VehicleGroupAlertAtom from "../../atoms/vehicle-group-alert/vehicle-group-alert.atom";
|
||||
import GroupVerifySwitch from "../group-verify-switch/group-verify-switch.component";
|
||||
import RequiresReimportDisplay from "../../atoms/requires-reimport/requires-reimport.atom.jsx";
|
||||
|
||||
const { ipcRenderer } = window;
|
||||
|
||||
@@ -35,12 +36,7 @@ export function ReportingJobsListMolecule({ scoreCard, reportingLoading, reportD
|
||||
<Link onClick={() => setSelectedJobId(record.id)} to={"/"}>
|
||||
<Space>
|
||||
{text}
|
||||
{record.requires_reimport && (
|
||||
<CloudUploadOutlined
|
||||
title="A change in R4P date changed the applicable rules. Import this job again for accurate scoring."
|
||||
style={{ marginLeft: ".5rem", color: "tomato" }}
|
||||
/>
|
||||
)}
|
||||
<RequiresReimportDisplay job={record} />
|
||||
</Space>
|
||||
</Link>
|
||||
),
|
||||
|
||||
@@ -2,13 +2,14 @@ import { Card, Col, Divider, Empty, Result, Space, Table, Tooltip } from "antd";
|
||||
import Dinero from "dinero.js";
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { Link } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { setSelectedJobId, setSelectedJobTargetPc } from "../../../redux/application/application.actions";
|
||||
import { selectAuditData, selectAuditLoading } from "../../../redux/reporting/reporting.selectors";
|
||||
import { DateFormat } from "../../../util/constants";
|
||||
import dayjs from "../../../util/day";
|
||||
import { alphaSort, dateSort } from "../../../util/sorters";
|
||||
import { Link } from "react-router-dom";
|
||||
import RequiresReimportDisplay from "../../atoms/requires-reimport/requires-reimport.atom";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
selectAuditData: selectAuditData,
|
||||
@@ -81,7 +82,10 @@ export function AuditResultsOrganism({ auditLoading, setSelectedJobId, selectAud
|
||||
render: (text, record) =>
|
||||
record.rps?.id ? (
|
||||
<Link onClick={() => setSelectedJobId(record.rps.id)} to={"/"}>
|
||||
{text}
|
||||
<Space size="small">
|
||||
{text}
|
||||
<RequiresReimportDisplay job={record.rps} />
|
||||
</Space>
|
||||
</Link>
|
||||
) : (
|
||||
text
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ApolloClient, gql, InMemoryCache, useApolloClient } from "@apollo/client";
|
||||
import { HttpLink } from "@apollo/client/link/http"; //"apollo-link-http";
|
||||
import { Button, Table } from "antd";
|
||||
import { Button, Space, Table } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { LOCAL_DOESNOTUpsertEstimate } from "../../../ipc/ipc-estimate-utils";
|
||||
import _ from "lodash";
|
||||
@@ -10,11 +10,14 @@ import { dateSort } from "../../../util/sorters";
|
||||
const httpLink = new HttpLink({
|
||||
uri: import.meta.env.VITE_APP_GRAPHQL_ENDPOINT,
|
||||
headers: {
|
||||
"x-hasura-admin-secret": `ImEXRPSDataBase`
|
||||
"x-hasura-admin-secret": `TOBEPOPULATED`
|
||||
}
|
||||
});
|
||||
|
||||
const localCLient = new ApolloClient({ link: httpLink, cache: new InMemoryCache({}) });
|
||||
|
||||
const startingDate = "2024-01-01";
|
||||
|
||||
export default function AdminPage() {
|
||||
const client = useApolloClient();
|
||||
const clientToUse = client;
|
||||
@@ -26,13 +29,18 @@ export default function AdminPage() {
|
||||
const {
|
||||
data: { jobs }
|
||||
} = await clientToUse.query({
|
||||
variables: { createdAt: "2024-01-01" },
|
||||
variables: {
|
||||
createdAtStart: startingDate,
|
||||
createdAtEnd: moment(startingDate).add(365, "days").format("YYYY-MM-DD")
|
||||
},
|
||||
query: gql`
|
||||
query ADMIN_GET_JOBS($createdAt: timestamptz) {
|
||||
query ADMIN_GET_JOBS($createdAtStart: timestamptz, $createdAtEnd: timestamptz) {
|
||||
jobs(
|
||||
where: {
|
||||
_and: [
|
||||
{ created_at: { _gte: $createdAt } }
|
||||
{ requires_reimport: { _eq: false } }
|
||||
{ created_at: { _gte: $createdAtStart } }
|
||||
{ created_at: { _lte: $createdAtEnd } }
|
||||
{ _or: [{ close_date: { _is_null: true } }, { close_date: { _gte: "2024-09-01" } }] }
|
||||
]
|
||||
}
|
||||
@@ -57,23 +65,6 @@ export default function AdminPage() {
|
||||
v_type
|
||||
requires_reimport
|
||||
v_mileage
|
||||
joblines {
|
||||
act_price
|
||||
db_price
|
||||
part_qty
|
||||
part_type
|
||||
price_diff
|
||||
price_diff_pc
|
||||
updated_at
|
||||
oem_partno
|
||||
line_no
|
||||
line_ind
|
||||
line_desc
|
||||
ignore
|
||||
id
|
||||
db_ref
|
||||
unq_seq
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
@@ -88,7 +79,6 @@ export default function AdminPage() {
|
||||
const initialJob = { ...job };
|
||||
|
||||
const calcedGroup = await LOCAL_DOESNOTUpsertEstimate(initialJob);
|
||||
console.log("🚀 ~ handleQuery ~ calcedGroup:", calcedGroup);
|
||||
AllJobResults.push({
|
||||
close_date: job.close_date,
|
||||
make: initialJob.v_makedesc,
|
||||
@@ -111,9 +101,31 @@ export default function AdminPage() {
|
||||
const jobsToMarkForReimport = [...NoDateSetJobs, ...JobsInWrongGroup];
|
||||
};
|
||||
|
||||
const handleUpdate = async () => {
|
||||
//TODO: MAKE SURE THIS USES THE ADMIN SECRET INSTEAD.
|
||||
const data = await clientToUse.mutate({
|
||||
variables: {
|
||||
jobs: wrongGroups.map((j) => j.id)
|
||||
},
|
||||
mutation: gql`
|
||||
mutation ADMIN_UPDATE_JOBS($jobs: [uuid!]!) {
|
||||
update_jobs(where: { id: { _in: $jobs } }, _set: { requires_reimport: true }) {
|
||||
affected_rows
|
||||
}
|
||||
}
|
||||
`
|
||||
});
|
||||
|
||||
console.log("Updated Rows", data);
|
||||
};
|
||||
return (
|
||||
<div style={{ height: "100%" }}>
|
||||
<Button onClick={handleQuery}>Run the query</Button>
|
||||
<Space>
|
||||
<Button onClick={handleQuery}>Run the query</Button>
|
||||
<Button danger onClick={handleUpdate}>
|
||||
UPDATE THE GROUPS {wrongGroups.length}
|
||||
</Button>
|
||||
</Space>
|
||||
<Table
|
||||
title={() => "Jobs with the wrong group set."}
|
||||
dataSource={wrongGroups}
|
||||
@@ -125,7 +137,12 @@ export default function AdminPage() {
|
||||
sorter: (a, b) => dateSort(a.created_at, b.created_at),
|
||||
render: (record) => moment(record).format("YYYY-MM-DD")
|
||||
},
|
||||
{ key: "close_date", dataIndex: "close_date", title: "Close Date" },
|
||||
{
|
||||
key: "close_date",
|
||||
dataIndex: "close_date",
|
||||
title: "Close Date",
|
||||
sorter: (a, b) => dateSort(a.close_date, b.close_date)
|
||||
},
|
||||
{ key: "clm_no", dataIndex: "clm_no", title: "Claim" },
|
||||
{ key: "v_makedesc", dataIndex: "v_makedesc", title: "Make" },
|
||||
{ key: "v_model", dataIndex: "v_model", title: "Model" },
|
||||
|
||||
Reference in New Issue
Block a user