Merge branch 'rome/test-beta' into master-AIO. Initia
This commit is contained in:
@@ -1,88 +1,75 @@
|
||||
import {useMutation, useQuery} from "@apollo/client";
|
||||
//import {useMutation, useQuery } from "@apollo/client";
|
||||
import {Button, Form, Layout, Result, Typography} from "antd";
|
||||
import React, {useState} from "react";
|
||||
import axios from "axios";
|
||||
import React, {useCallback, useEffect, useState} from "react";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {connect} from "react-redux";
|
||||
import {useParams} from "react-router-dom";
|
||||
import {createStructuredSelector} from "reselect";
|
||||
import AlertComponent from "../../components/alert/alert.component";
|
||||
import ConfigFormComponents from "../../components/config-form-components/config-form-components.component";
|
||||
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
||||
import {COMPLETE_SURVEY, QUERY_SURVEY} from "../../graphql/csi.queries";
|
||||
import {connect} from "react-redux";
|
||||
import {createStructuredSelector} from "reselect";
|
||||
import {selectCurrentUser} from "../../redux/user/user.selectors";
|
||||
import {DateTimeFormat} from "./../../utils/DateFormatter";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(CsiContainerPage);
|
||||
|
||||
export function CsiContainerPage({currentUser}) {
|
||||
const {surveyId} = useParams();
|
||||
const [form] = Form.useForm();
|
||||
const [axiosResponse, setAxiosResponse] = useState(null);
|
||||
const [submitting, setSubmitting] = useState({
|
||||
loading: false,
|
||||
submitted: false,
|
||||
});
|
||||
|
||||
const {loading, error, data} = useQuery(QUERY_SURVEY, {
|
||||
variables: {surveyId},
|
||||
fetchPolicy: "network-only",
|
||||
nextFetchPolicy: "network-only",
|
||||
});
|
||||
|
||||
|
||||
const {t} = useTranslation();
|
||||
const [completeSurvey] = useMutation(COMPLETE_SURVEY);
|
||||
if (loading) return <LoadingSpinner/>;
|
||||
|
||||
if (error || !!!data.csi_by_pk)
|
||||
return (
|
||||
<div>
|
||||
<Result
|
||||
status="error"
|
||||
title={t("csi.errors.notfoundtitle")}
|
||||
subTitle={t("csi.errors.notfoundsubtitle")}
|
||||
>
|
||||
{error ? (
|
||||
<div>ERROR: {error.graphQLErrors.map((e) => e.message)}</div>
|
||||
) : null}
|
||||
</Result>
|
||||
</div>
|
||||
);
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
setSubmitting({...submitting, loading: true});
|
||||
const getAxiosData = useCallback(async () => {
|
||||
try {
|
||||
try {
|
||||
window.$crisp.push(["do", "chat:hide"]);
|
||||
} catch {
|
||||
console.log("Unable to attach to crisp instance. ");
|
||||
}
|
||||
setSubmitting((prevSubmitting) => ({...prevSubmitting, loading: true}));
|
||||
|
||||
const result = await completeSurvey({
|
||||
variables: {
|
||||
surveyId,
|
||||
survey: {
|
||||
response: values,
|
||||
valid: false,
|
||||
completedon: new Date(),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!!!result.errors) {
|
||||
setSubmitting({...submitting, loading: false, submitted: true});
|
||||
} else {
|
||||
setSubmitting({
|
||||
...submitting,
|
||||
const response = await axios.post("/csi/lookup", {
|
||||
surveyId
|
||||
});
|
||||
setSubmitting((prevSubmitting) => ({
|
||||
...prevSubmitting,
|
||||
loading: false,
|
||||
error: JSON.stringify(result.errors),
|
||||
}));
|
||||
setAxiosResponse(response.data);
|
||||
} catch (error) {
|
||||
console.error(`Something went wrong...: ${error.message}`);
|
||||
console.dir({
|
||||
stack: error?.stack,
|
||||
message:
|
||||
error?.message,
|
||||
});
|
||||
}
|
||||
};
|
||||
}, [setAxiosResponse, surveyId]);
|
||||
|
||||
const {
|
||||
relateddata: {bodyshop, job},
|
||||
csiquestion: {config: csiquestions},
|
||||
} = data.csi_by_pk;
|
||||
useEffect(() => {
|
||||
getAxiosData().catch((err) =>
|
||||
console.error(
|
||||
`Something went wrong fetching axios data: ${err.message || ""}`
|
||||
)
|
||||
);
|
||||
}, [getAxiosData]);
|
||||
|
||||
if (currentUser && currentUser.authorized)
|
||||
// Return if authorized
|
||||
if (currentUser && currentUser.authorized) {
|
||||
return (
|
||||
<Layout
|
||||
style={{height: "100vh", display: "flex", flexDirection: "column"}}
|
||||
@@ -94,11 +81,68 @@ export function CsiContainerPage({currentUser}) {
|
||||
/>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
if (submitting.loading) return <LoadingSpinner/>;
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
try {
|
||||
setSubmitting({...submitting, loading: true, submitting: true});
|
||||
const result = await axios.post("/csi/submit", {surveyId, values});
|
||||
console.log("result", result);
|
||||
if (!!!result.errors && result.data.update_csi.affected_rows > 0) {
|
||||
setSubmitting({...submitting, loading: false, submitted: true});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Something went wrong...: ${error.message}`);
|
||||
console.dir({
|
||||
stack: error?.stack,
|
||||
message: error?.message,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (!axiosResponse || axiosResponse.csi_by_pk === null) {
|
||||
// Do something here , this is where you would return a loading box or something
|
||||
return (
|
||||
<>
|
||||
<Layout style={{display: "flex", flexDirection: "column"}}>
|
||||
<Layout.Content
|
||||
style={{
|
||||
backgroundColor: "#fff",
|
||||
margin: "2em 4em",
|
||||
padding: "2em",
|
||||
overflowY: "auto",
|
||||
textAlign: "center",
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Form>
|
||||
<Result
|
||||
status="error"
|
||||
title={t("csi.errors.notfoundtitle")}
|
||||
subTitle={t("csi.errors.notfoundsubtitle")}
|
||||
/>
|
||||
</Form>
|
||||
</Layout.Content>
|
||||
<Layout.Footer>
|
||||
{t("csi.labels.copyright")}{" "}
|
||||
{t("csi.fields.surveyid", {surveyId: surveyId})}
|
||||
</Layout.Footer>
|
||||
</Layout>
|
||||
</>
|
||||
);
|
||||
} else {
|
||||
const {
|
||||
relateddata: {bodyshop, job},
|
||||
csiquestion: {config: csiquestions},
|
||||
} = axiosResponse.csi_by_pk;
|
||||
|
||||
return (
|
||||
<Layout
|
||||
style={{height: "100vh", display: "flex", flexDirection: "column"}}
|
||||
>
|
||||
<Layout style={{display: "flex", flexDirection: "column"}}>
|
||||
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
@@ -108,24 +152,35 @@ export function CsiContainerPage({currentUser}) {
|
||||
>
|
||||
<div style={{display: "flex", alignItems: "center", margin: "2em"}}>
|
||||
{bodyshop.logo_img_path && bodyshop.logo_img_path.src ? (
|
||||
<img src={bodyshop.logo_img_path.src} alt="Logo"/>
|
||||
) : null}
|
||||
<div style={{margin: "2em"}}>
|
||||
<strong>{bodyshop.shopname || ""}</strong>
|
||||
<div>{`${bodyshop.address1 || ""}`}</div>
|
||||
<div>{`${bodyshop.address2 || ""}`}</div>
|
||||
<div>{`${bodyshop.city || ""} ${bodyshop.state || ""} ${
|
||||
bodyshop.zip_post || ""
|
||||
}`}</div>
|
||||
<img src={bodyshop.logo_img_path.src} alt={bodyshop.shopname.concat("Logo")}
|
||||
height={bodyshop.logo_img_path.height}
|
||||
width={bodyshop.logo_img_path.width}
|
||||
/>) : null}
|
||||
<div style={{margin: "2em", verticalAlign: "middle"}}>
|
||||
<Typography.Title level={4} style={{margin: 0}}>
|
||||
{bodyshop.shopname || ""}
|
||||
</Typography.Title>
|
||||
<Typography.Paragraph style={{margin: 0}}>
|
||||
{`${bodyshop.address1 || ""}${bodyshop.address2 ? ", " : ""}${
|
||||
bodyshop.address2 || ""
|
||||
}`.trim()}
|
||||
</Typography.Paragraph>
|
||||
<Typography.Paragraph style={{margin: 0}}>
|
||||
{`${bodyshop.city || ""}${
|
||||
bodyshop.city && bodyshop.state ? ", " : ""
|
||||
}${bodyshop.state || ""} ${bodyshop.zip_post || ""}`.trim()}
|
||||
</Typography.Paragraph>
|
||||
</div>
|
||||
</div>
|
||||
<Typography.Title>{t("csi.labels.title")}</Typography.Title>
|
||||
<strong>{`Hi ${job.ownr_co_nm || job.ownr_fn || ""}!`}</strong>
|
||||
<strong>{t("csi.labels.greeting", {
|
||||
name: job.ownr_co_nm || job.ownr_fn || "",
|
||||
})}</strong>
|
||||
<Typography.Paragraph>
|
||||
{`At ${
|
||||
{t("csi.labels.intro", {
|
||||
shopname:
|
||||
bodyshop.shopname || ""
|
||||
}, we value your feedback. We would love to
|
||||
hear what you have to say. Please fill out the form below.`}
|
||||
})}
|
||||
</Typography.Paragraph>
|
||||
</div>
|
||||
|
||||
@@ -158,21 +213,42 @@ export function CsiContainerPage({currentUser}) {
|
||||
}}
|
||||
>
|
||||
<Form form={form} onFinish={handleFinish}>
|
||||
<ConfigFormComponents componentList={csiquestions}/>
|
||||
{axiosResponse.csi_by_pk.valid ? (
|
||||
<><ConfigFormComponents componentList={csiquestions}/>
|
||||
<Button
|
||||
loading={submitting.loading}
|
||||
type="primary"
|
||||
htmlType="submit"
|
||||
htmlType="submit" style={{float: "right"}}
|
||||
>
|
||||
{t("general.actions.submit")}
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Result
|
||||
title={t("csi.errors.surveycompletetitle")}
|
||||
status="warning"
|
||||
subTitle={t("csi.errors.surveycompletesubtitle", {
|
||||
date: DateTimeFormat(axiosResponse.csi_by_pk.completedon),
|
||||
})}
|
||||
/>
|
||||
<Typography.Paragraph
|
||||
type="secondary"
|
||||
style={{textAlign: "center"}}
|
||||
>
|
||||
{t("csi.successes.submittedsub")}
|
||||
</Typography.Paragraph>
|
||||
</>
|
||||
)}
|
||||
</Form>
|
||||
</Layout.Content>
|
||||
)}
|
||||
|
||||
)}
|
||||
<Layout.Footer>
|
||||
{`Survey ID: ${surveyId}`}
|
||||
{t("csi.labels.copyright")}{" "}
|
||||
{t("csi.fields.surveyid", {surveyId: surveyId})}
|
||||
</Layout.Footer>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,317 +0,0 @@
|
||||
import {SyncOutlined} from "@ant-design/icons";
|
||||
import {useQuery} from "@apollo/client";
|
||||
import {Button, Card, Input, Space, Table} from "antd";
|
||||
import _ from "lodash";
|
||||
import queryString from "query-string";
|
||||
import React, {useState} from "react";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {connect} from "react-redux";
|
||||
import {Link, useLocation, useNavigate} from "react-router-dom";
|
||||
import {createStructuredSelector} from "reselect";
|
||||
import AlertComponent from "../../components/alert/alert.component";
|
||||
import JobPartsQueueCount from "../../components/job-parts-queue-count/job-parts-queue-count.component";
|
||||
import JobRemoveFromPartsQueue
|
||||
from "../../components/job-remove-from-parst-queue/job-remove-from-parts-queue.component";
|
||||
import OwnerNameDisplay from "../../components/owner-name-display/owner-name-display.component";
|
||||
import ProductionListColumnComment
|
||||
from "../../components/production-list-columns/production-list-columns.comment.component";
|
||||
import {QUERY_PARTS_QUEUE} from "../../graphql/jobs.queries";
|
||||
import {selectBodyshop} from "../../redux/user/user.selectors";
|
||||
import {DateTimeFormatter, TimeAgoFormatter} from "../../utils/DateFormatter";
|
||||
import {alphaSort, dateSort} from "../../utils/sorters";
|
||||
import useLocalStorage from "../../utils/useLocalStorage";
|
||||
import {pageLimit} from "../../utils/config";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
|
||||
export function PartsQueuePageComponent({bodyshop}) {
|
||||
const searchParams = queryString.parse(useLocation().search);
|
||||
const {
|
||||
//page,
|
||||
sortcolumn,
|
||||
sortorder,
|
||||
statusFilters,
|
||||
} = searchParams;
|
||||
const history = useNavigate();
|
||||
const [filter, setFilter] = useLocalStorage("filter_parts_queue", null);
|
||||
|
||||
const {loading, error, data, refetch} = useQuery(QUERY_PARTS_QUEUE, {
|
||||
fetchPolicy: "network-only",
|
||||
nextFetchPolicy: "network-only",
|
||||
variables: {
|
||||
// offset: page ? (page - 1) * 25 : 0,
|
||||
// limit: 25,
|
||||
statuses: (statusFilters && JSON.parse(statusFilters)) ||
|
||||
bodyshop.md_ro_statuses.active_statuses || ["Open", "Open*"],
|
||||
order: [
|
||||
{
|
||||
[sortcolumn || "ro_number"]: sortorder
|
||||
? sortorder === "descend"
|
||||
? "desc"
|
||||
: "asc"
|
||||
: "desc",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const {t} = useTranslation();
|
||||
const [searchText, setSearchText] = useState("");
|
||||
|
||||
if (error) return <AlertComponent message={error.message} type="error"/>;
|
||||
|
||||
const jobs = data
|
||||
? searchText === ""
|
||||
? data.jobs
|
||||
: data.jobs.filter(
|
||||
(j) =>
|
||||
(j.ro_number || "")
|
||||
.toString()
|
||||
.toLowerCase()
|
||||
.includes(searchText.toLowerCase()) ||
|
||||
(j.ownr_co_nm || "")
|
||||
.toLowerCase()
|
||||
.includes(searchText.toLowerCase()) ||
|
||||
(j.ownr_fn || "")
|
||||
.toLowerCase()
|
||||
.includes(searchText.toLowerCase()) ||
|
||||
(j.ownr_ln || "")
|
||||
.toLowerCase()
|
||||
.includes(searchText.toLowerCase()) ||
|
||||
(j.clm_no || "").toLowerCase().includes(searchText.toLowerCase()) ||
|
||||
(j.plate_no || "")
|
||||
.toLowerCase()
|
||||
.includes(searchText.toLowerCase()) ||
|
||||
(j.v_model_desc || "")
|
||||
.toLowerCase()
|
||||
.includes(searchText.toLowerCase()) ||
|
||||
(j.v_make_desc || "")
|
||||
.toLowerCase()
|
||||
.includes(searchText.toLowerCase())
|
||||
)
|
||||
: [];
|
||||
|
||||
const handleTableChange = (pagination, filters, sorter) => {
|
||||
// searchParams.page = pagination.current;
|
||||
searchParams.sortcolumn = sorter.columnKey;
|
||||
searchParams.sortorder = sorter.order;
|
||||
|
||||
if (filters.status) {
|
||||
searchParams.statusFilters = JSON.stringify(
|
||||
_.flattenDeep(filters.status)
|
||||
);
|
||||
} else {
|
||||
delete searchParams.statusFilters;
|
||||
}
|
||||
setFilter(filters);
|
||||
history({search: queryString.stringify(searchParams)});
|
||||
};
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: t("jobs.fields.ro_number"),
|
||||
dataIndex: "ro_number",
|
||||
key: "ro_number",
|
||||
sorter: (a, b) => alphaSort(a.ro_number, b.ro_number),
|
||||
sortOrder: sortcolumn === "ro_number" && sortorder,
|
||||
|
||||
render: (text, record) => (
|
||||
<Link to={"/manage/jobs/" + record.id}>
|
||||
{record.ro_number || t("general.labels.na")}
|
||||
</Link>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("jobs.fields.owner"),
|
||||
dataIndex: "ownr_ln",
|
||||
key: "ownr_ln",
|
||||
sorter: (a, b) => alphaSort(a.ownr_ln, b.ownr_ln),
|
||||
sortOrder: sortcolumn === "ownr_ln" && sortorder,
|
||||
render: (text, record) => {
|
||||
return record.ownerid ? (
|
||||
<Link to={"/manage/owners/" + record.ownerid}>
|
||||
<OwnerNameDisplay ownerObject={record}/>
|
||||
</Link>
|
||||
) : (
|
||||
<span>
|
||||
<OwnerNameDisplay ownerObject={record}/>
|
||||
</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t("jobs.fields.status"),
|
||||
dataIndex: "status",
|
||||
key: "status",
|
||||
sorter: (a, b) => alphaSort(a.status, b.status),
|
||||
sortOrder: sortcolumn === "status" && sortorder,
|
||||
filteredValue: statusFilters ? JSON.parse(statusFilters) : null,
|
||||
filters:
|
||||
bodyshop.md_ro_statuses.active_statuses.map((s) => {
|
||||
return {
|
||||
text: s || "No Status*",
|
||||
value: [s],
|
||||
};
|
||||
}) || [],
|
||||
render: (text, record) => {
|
||||
return record.status || t("general.labels.na");
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
title: t("jobs.fields.scheduled_in"),
|
||||
dataIndex: "scheduled_in",
|
||||
key: "scheduled_in",
|
||||
ellipsis: true,
|
||||
sorter: (a, b) => dateSort(a.scheduled_in, b.scheduled_in),
|
||||
sortOrder: sortcolumn === "scheduled_in" && sortorder,
|
||||
render: (text, record) => (
|
||||
<DateTimeFormatter>{record.scheduled_in}</DateTimeFormatter>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("jobs.fields.vehicle"),
|
||||
dataIndex: "vehicle",
|
||||
key: "vehicle",
|
||||
ellipsis: true,
|
||||
render: (text, record) => {
|
||||
return record.vehicleid ? (
|
||||
<Link to={"/manage/vehicles/" + record.vehicleid}>
|
||||
{`${record.v_model_yr || ""} ${record.v_make_desc || ""} ${
|
||||
record.v_model_desc || ""
|
||||
}`}
|
||||
</Link>
|
||||
) : (
|
||||
<span>{`${record.v_model_yr || ""} ${record.v_make_desc || ""} ${
|
||||
record.v_model_desc || ""
|
||||
}`}</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
// {
|
||||
// title: t("vehicles.fields.plate_no"),
|
||||
// dataIndex: "plate_no",
|
||||
// key: "plate_no",
|
||||
// sorter: (a, b) => alphaSort(a.plate_no, b.plate_no),
|
||||
// sortOrder: sortcolumn === "plate_no" && sortorder,
|
||||
// render: (text, record) => {
|
||||
// return record.plate_no ? record.plate_no : "";
|
||||
// },
|
||||
// },
|
||||
{
|
||||
title: t("jobs.fields.clm_no"),
|
||||
dataIndex: "clm_no",
|
||||
key: "clm_no",
|
||||
ellipsis: true,
|
||||
sorter: (a, b) => alphaSort(a.clm_no, b.clm_no),
|
||||
sortOrder: sortcolumn === "clm_no" && sortorder,
|
||||
},
|
||||
// {
|
||||
// title: t("jobs.fields.clm_total"),
|
||||
// dataIndex: "clm_total",
|
||||
// key: "clm_total",
|
||||
// sorter: (a, b) => a.clm_total - b.clm_total,
|
||||
// sortOrder: sortcolumn === "clm_total" && sortorder,
|
||||
// render: (text, record) => {
|
||||
// return record.clm_total ? (
|
||||
// <CurrencyFormatter>{record.clm_total}</CurrencyFormatter>
|
||||
// ) : (
|
||||
// t("general.labels.unknown")
|
||||
// );
|
||||
// },
|
||||
// },
|
||||
{
|
||||
title: t("jobs.fields.updated_at"),
|
||||
dataIndex: "updated_at",
|
||||
key: "updated_at",
|
||||
sorter: (a, b) => dateSort(a.updated_at, b.updated_at),
|
||||
sortOrder: sortcolumn === "updated_at" && sortorder,
|
||||
render: (text, record) => (
|
||||
<TimeAgoFormatter>{record.updated_at}</TimeAgoFormatter>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("jobs.fields.partsstatus"),
|
||||
dataIndex: "partsstatus",
|
||||
key: "partsstatus",
|
||||
render: (text, record) => (
|
||||
<JobPartsQueueCount
|
||||
style={{minWidth: "10rem"}}
|
||||
parts={record.joblines_status}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("jobs.fields.comment"),
|
||||
dataIndex: "comment",
|
||||
key: "comment",
|
||||
render: (text, record) => <ProductionListColumnComment record={record}/>,
|
||||
},
|
||||
{
|
||||
title: t("jobs.fields.queued_for_parts"),
|
||||
dataIndex: "queued_for_parts",
|
||||
key: "queued_for_parts",
|
||||
sorter: (a, b) => a.queued_for_parts - b.queued_for_parts,
|
||||
sortOrder: sortcolumn === "queued_for_parts" && sortorder,
|
||||
filteredValue: filter?.queued_for_parts || null,
|
||||
filters: [
|
||||
{
|
||||
text: "Queued",
|
||||
value: true,
|
||||
},
|
||||
{
|
||||
text: "Unqueued",
|
||||
value: false,
|
||||
},
|
||||
],
|
||||
onFilter: (value, record) => record.queued_for_parts === value,
|
||||
render: (text, record) => (
|
||||
<JobRemoveFromPartsQueue
|
||||
checked={record.queued_for_parts}
|
||||
jobId={record.id}
|
||||
/>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<Card
|
||||
extra={
|
||||
<Space wrap>
|
||||
<Button onClick={() => refetch()}>
|
||||
<SyncOutlined/>
|
||||
</Button>
|
||||
<Input.Search
|
||||
className="imex-table-header__search"
|
||||
placeholder={t("general.labels.search")}
|
||||
onChange={(e) => {
|
||||
setSearchText(e.target.value);
|
||||
}}
|
||||
value={searchText}
|
||||
enterButton
|
||||
/>
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
<Table
|
||||
loading={loading}
|
||||
pagination={{
|
||||
position: "top",
|
||||
pageSize: pageLimit,
|
||||
// current: parseInt(page || 1),
|
||||
// total: data && data.jobs_aggregate.aggregate.count,
|
||||
}}
|
||||
columns={columns}
|
||||
rowKey="id"
|
||||
dataSource={jobs}
|
||||
style={{height: "100%"}}
|
||||
scroll={{x: true}}
|
||||
onChange={handleTableChange}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, null)(PartsQueuePageComponent);
|
||||
@@ -1,9 +1,10 @@
|
||||
import React, {useEffect} from "react";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {connect} from "react-redux";
|
||||
import PartsQueueDetailCard from "../../components/parts-queue-card/parts-queue-card.component";
|
||||
import PartsQueueList from "../../components/parts-queue-list/parts-queue.list.component";
|
||||
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
|
||||
import {setBreadcrumbs, setSelectedHeader,} from "../../redux/application/application.actions";
|
||||
import PartsQueuePage from "./parts-queue.page.component";
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
|
||||
@@ -23,7 +24,8 @@ export function PartsQueuePageContainer({setBreadcrumbs, setSelectedHeader}) {
|
||||
|
||||
return (
|
||||
<RbacWrapper action="jobs:partsqueue">
|
||||
<PartsQueuePage/>
|
||||
<PartsQueueList/>
|
||||
<PartsQueueDetailCard/>
|
||||
</RbacWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
import {Col, Row} from "antd";
|
||||
import {useQuery} from "@apollo/client";
|
||||
import {Col, Row} from "antd";
|
||||
import React, {useEffect} from "react";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {connect} from "react-redux";
|
||||
import {useLocation} from "react-router-dom";
|
||||
import {createStructuredSelector} from "reselect";
|
||||
import AlertComponent from "../../components/alert/alert.component";
|
||||
import CsiResponseFormContainer from "../../components/csi-response-form/csi-response-form.container";
|
||||
import CsiResponseListPaginated
|
||||
from "../../components/csi-response-list-paginated/csi-response-list-paginated.component";
|
||||
import {QUERY_CSI_RESPONSE_PAGINATED} from "../../graphql/csi.queries";
|
||||
import {setBreadcrumbs, setSelectedHeader} from "../../redux/application/application.actions";
|
||||
import {selectBodyshop} from "../../redux/user/user.selectors";
|
||||
from "../../components/csi-response-list-paginated/csi-response-list-paginated.component";
|
||||
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
|
||||
import {pageLimit} from "../../utils/config";
|
||||
import queryString from "query-string";
|
||||
import {QUERY_CSI_RESPONSE_PAGINATED} from "../../graphql/csi.queries";
|
||||
import {setBreadcrumbs, setSelectedHeader,} from "../../redux/application/application.actions";
|
||||
import {selectBodyshop} from "../../redux/user/user.selectors";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -25,29 +22,18 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
setSelectedHeader: (key) => dispatch(setSelectedHeader(key)),
|
||||
});
|
||||
|
||||
export function ShopCsiContainer({bodyshop, setBreadcrumbs, setSelectedHeader}) {
|
||||
export function ShopCsiContainer({
|
||||
bodyshop,
|
||||
setBreadcrumbs,
|
||||
setSelectedHeader,
|
||||
}) {
|
||||
const {t} = useTranslation();
|
||||
const searchParams = queryString.parse(useLocation().search);
|
||||
const {page, sortcolumn, sortorder} = searchParams;
|
||||
|
||||
const {loading, error, data, refetch} = useQuery(
|
||||
QUERY_CSI_RESPONSE_PAGINATED,
|
||||
{
|
||||
fetchPolicy: "network-only",
|
||||
nextFetchPolicy: "network-only",
|
||||
variables: {
|
||||
offset: page ? (page - 1) * pageLimit : 0,
|
||||
limit: pageLimit,
|
||||
order: [
|
||||
{
|
||||
[sortcolumn || "completedon"]: sortorder
|
||||
? sortorder === "descend"
|
||||
? "desc_nulls_last"
|
||||
: "asc"
|
||||
: "desc_nulls_last",
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user