feature/IO-3255-simplified-parts-management - Checkpoint

This commit is contained in:
Dave
2025-08-13 15:48:09 -04:00
parent 898b97151f
commit 0d570d0323
8 changed files with 246 additions and 180 deletions

View File

@@ -1,4 +1,4 @@
import { SettingOutlined, SyncOutlined } from "@ant-design/icons";
import { CarOutlined, SettingOutlined, SyncOutlined } from "@ant-design/icons";
import { Button, Card, Input, Space, Table, Typography } from "antd";
import axios from "axios";
import _ from "lodash";
@@ -16,22 +16,23 @@ import useLocalStorage from "../../utils/useLocalStorage";
import OwnerNameDisplay from "../owner-name-display/owner-name-display.component";
import JobPartsQueueCount from "../job-parts-queue-count/job-parts-queue-count.component";
import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component";
import { selectIsPartsEntry } from "../../redux/application/application.selectors";
import * as Sentry from "@sentry/react";
const mapStateToProps = createStructuredSelector({
//currentUser: selectCurrentUser
bodyshop: selectBodyshop
});
const mapDispatchToProps = (dispatch) => ({
//setUserLanguage: language => dispatch(setUserLanguage(language))
bodyshop: selectBodyshop,
isPartsEntry: selectIsPartsEntry
});
export function SimplifiedPartsJobsListComponent({ bodyshop, refetch, loading, jobs, total }) {
export function SimplifiedPartsJobsListComponent({ bodyshop, refetch, loading, jobs, total, isPartsEntry }) {
const search = queryString.parse(useLocation().search);
const [openSearchResults, setOpenSearchResults] = useState([]);
const [searchLoading, setSearchLoading] = useState(false);
const [filter, setFilter] = useLocalStorage("filter_jobs_all", null);
const { page, sortcolumn, sortorder } = search;
const history = useNavigate();
const basePath = isPartsEntry ? "/parts" : "/manage";
const { t } = useTranslation();
const columns = [
@@ -92,7 +93,7 @@ export function SimplifiedPartsJobsListComponent({ bodyshop, refetch, loading, j
ellipsis: true,
render: (text, record) => {
return record.vehicleid ? (
<Link to={"/manage/vehicles/" + record.vehicleid}>
<Link to={`${basePath}/vehicles/` + record.vehicleid}>
{`${record.v_model_yr || ""} ${record.v_make_desc || ""} ${record.v_model_desc || ""}`}
</Link>
) : (
@@ -171,7 +172,6 @@ export function SimplifiedPartsJobsListComponent({ bodyshop, refetch, loading, j
if (search.search && search.search.trim() !== "") {
searchJobs();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
async function searchJobs(value) {
@@ -183,7 +183,7 @@ export function SimplifiedPartsJobsListComponent({ bodyshop, refetch, loading, j
});
setOpenSearchResults(searchData.data.hits.hits.map((s) => s._source));
} catch (error) {
console.log("Error while fetching search results", error);
Sentry.captureMessage(`Error while fetching search results: ${error.message}`, "warning");
} finally {
setSearchLoading(false);
}
@@ -193,6 +193,9 @@ export function SimplifiedPartsJobsListComponent({ bodyshop, refetch, loading, j
<Card
extra={
<Space wrap>
<Button icon={<CarOutlined />} onClick={() => history("/parts/vehicles")}>
{t("menus.header.vehicles")}
</Button>
<RbacWrapper action="shop:config">
<Button
icon={<SettingOutlined />}
@@ -258,4 +261,4 @@ export function SimplifiedPartsJobsListComponent({ bodyshop, refetch, loading, j
);
}
export default connect(mapStateToProps, mapDispatchToProps)(SimplifiedPartsJobsListComponent);
export default connect(mapStateToProps)(SimplifiedPartsJobsListComponent);