Compare commits
13 Commits
feature/IO
...
feature/IO
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c68feef0b5 | ||
|
|
4a7bb07345 | ||
|
|
01fec9fa79 | ||
|
|
2f88d613c3 | ||
|
|
c9467b3982 | ||
|
|
ca4c48bd5c | ||
|
|
e5fd5c8bcb | ||
|
|
46945a24a7 | ||
|
|
be746500a6 | ||
|
|
71c6d9fa94 | ||
|
|
6d94ce7e5c | ||
|
|
182a8d59ab | ||
|
|
f1847ef650 |
@@ -9,10 +9,10 @@ import {
|
||||
WarningFilled
|
||||
} from "@ant-design/icons";
|
||||
import { PageHeader } from "@ant-design/pro-layout";
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { Button, Dropdown, Input, Space, Table, Tag } from "antd";
|
||||
import { gql, useMutation } from "@apollo/client";
|
||||
import { Button, Dropdown, Input, Modal, Select, Space, Table, Tag, Typography } from "antd";
|
||||
import axios from "axios";
|
||||
import { useState } from "react";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -47,6 +47,19 @@ import JobLinesExpander from "./job-lines-expander.component";
|
||||
import JobLinesPartPriceChange from "./job-lines-part-price-change.component";
|
||||
import JobLinesExpanderSimple from "./jobs-lines-expander-simple.component";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
|
||||
const UPDATE_JOB_LINES_LOCATION_BULK = gql`
|
||||
mutation UPDATE_JOB_LINES_LOCATION_BULK($ids: [uuid!]!, $location: String!) {
|
||||
update_joblines(where: { id: { _in: $ids } }, _set: { location: $location }) {
|
||||
affected_rows
|
||||
returning {
|
||||
id
|
||||
location
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -83,6 +96,9 @@ export function JobLinesComponent({
|
||||
isPartsEntry
|
||||
}) {
|
||||
const [deleteJobLine] = useMutation(DELETE_JOB_LINE_BY_PK);
|
||||
const [bulkUpdateLocations] = useMutation(UPDATE_JOB_LINES_LOCATION_BULK);
|
||||
const notification = useNotification();
|
||||
|
||||
const {
|
||||
treatments: { Enhanced_Payroll }
|
||||
} = useSplitTreatments({
|
||||
@@ -103,9 +119,83 @@ export function JobLinesComponent({
|
||||
}
|
||||
});
|
||||
|
||||
// Bulk location modal state
|
||||
const [bulkLocationOpen, setBulkLocationOpen] = useState(false);
|
||||
const [bulkLocation, setBulkLocation] = useState(null);
|
||||
const [bulkLocationSaving, setBulkLocationSaving] = useState(false);
|
||||
|
||||
const { t } = useTranslation();
|
||||
const jobIsPrivate = bodyshop.md_ins_cos.find((c) => c.name === job.ins_co_nm)?.private;
|
||||
|
||||
const selectedLineIds = useMemo(() => selectedLines.map((l) => l?.id).filter(Boolean), [selectedLines]);
|
||||
|
||||
const commonSelectedLocation = useMemo(() => {
|
||||
const locs = selectedLines
|
||||
.map((l) => (typeof l?.location === "string" ? l.location : ""))
|
||||
.map((x) => x.trim())
|
||||
.filter(Boolean);
|
||||
|
||||
if (locs.length === 0) return null;
|
||||
|
||||
const uniq = _.uniq(locs);
|
||||
return uniq.length === 1 ? uniq[0] : null;
|
||||
}, [selectedLines]);
|
||||
|
||||
const openBulkLocationModal = () => {
|
||||
setBulkLocation(commonSelectedLocation);
|
||||
setBulkLocationOpen(true);
|
||||
logImEXEvent("joblines_bulk_location_open", { count: selectedLineIds.length });
|
||||
};
|
||||
|
||||
const closeBulkLocationModal = () => {
|
||||
setBulkLocationOpen(false);
|
||||
setBulkLocation(null);
|
||||
};
|
||||
|
||||
const saveBulkLocation = async () => {
|
||||
if (selectedLineIds.length === 0) return;
|
||||
|
||||
setBulkLocationSaving(true);
|
||||
|
||||
try {
|
||||
const locationToSave = (bulkLocation ?? "").toString();
|
||||
|
||||
const result = await bulkUpdateLocations({
|
||||
variables: {
|
||||
ids: selectedLineIds,
|
||||
location: locationToSave
|
||||
}
|
||||
});
|
||||
|
||||
if (!result?.errors) {
|
||||
// Keep UI selection consistent without waiting for refetch
|
||||
setSelectedLines((prev) =>
|
||||
prev.map((l) => (l && selectedLineIds.includes(l.id) ? { ...l, location: locationToSave } : l))
|
||||
);
|
||||
|
||||
notification["success"]({ message: t("joblines.successes.saved") });
|
||||
|
||||
logImEXEvent("joblines_bulk_location_saved", {
|
||||
count: selectedLineIds.length,
|
||||
location: locationToSave
|
||||
});
|
||||
|
||||
closeBulkLocationModal();
|
||||
if (refetch) refetch();
|
||||
} else {
|
||||
notification["error"]({
|
||||
message: t("joblines.errors.saving", { error: JSON.stringify(result.errors) })
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
notification["error"]({
|
||||
message: t("joblines.errors.saving", { error: error?.message || String(error) })
|
||||
});
|
||||
} finally {
|
||||
setBulkLocationSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: "#",
|
||||
@@ -171,46 +261,16 @@ export function JobLinesComponent({
|
||||
? ["PAN", "PAC", "PAR", "PAL", "PAA", "PAM", "PAP", "PAS", "PASL", "PAG", "PAO"]
|
||||
: ["PAN", "PAC", "PAR", "PAL", "PAA", "PAM", "PAP", "PAS", "PASL", "PAG"]
|
||||
},
|
||||
{
|
||||
text: t("joblines.fields.part_types.PAN"),
|
||||
value: ["PAN"]
|
||||
},
|
||||
{
|
||||
text: t("joblines.fields.part_types.PAP"),
|
||||
value: ["PAP"]
|
||||
},
|
||||
{
|
||||
text: t("joblines.fields.part_types.PAL"),
|
||||
value: ["PAL"]
|
||||
},
|
||||
{
|
||||
text: t("joblines.fields.part_types.PAA"),
|
||||
value: ["PAA"]
|
||||
},
|
||||
{
|
||||
text: t("joblines.fields.part_types.PAG"),
|
||||
value: ["PAG"]
|
||||
},
|
||||
{
|
||||
text: t("joblines.fields.part_types.PAS"),
|
||||
value: ["PAS"]
|
||||
},
|
||||
{
|
||||
text: t("joblines.fields.part_types.PASL"),
|
||||
value: ["PASL"]
|
||||
},
|
||||
{
|
||||
text: t("joblines.fields.part_types.PAC"),
|
||||
value: ["PAC"]
|
||||
},
|
||||
{
|
||||
text: t("joblines.fields.part_types.PAR"),
|
||||
value: ["PAR"]
|
||||
},
|
||||
{
|
||||
text: t("joblines.fields.part_types.PAM"),
|
||||
value: ["PAM"]
|
||||
},
|
||||
{ text: t("joblines.fields.part_types.PAN"), value: ["PAN"] },
|
||||
{ text: t("joblines.fields.part_types.PAP"), value: ["PAP"] },
|
||||
{ text: t("joblines.fields.part_types.PAL"), value: ["PAL"] },
|
||||
{ text: t("joblines.fields.part_types.PAA"), value: ["PAA"] },
|
||||
{ text: t("joblines.fields.part_types.PAG"), value: ["PAG"] },
|
||||
{ text: t("joblines.fields.part_types.PAS"), value: ["PAS"] },
|
||||
{ text: t("joblines.fields.part_types.PASL"), value: ["PASL"] },
|
||||
{ text: t("joblines.fields.part_types.PAC"), value: ["PAC"] },
|
||||
{ text: t("joblines.fields.part_types.PAR"), value: ["PAR"] },
|
||||
{ text: t("joblines.fields.part_types.PAM"), value: ["PAM"] },
|
||||
...(isPartsEntry
|
||||
? [
|
||||
{
|
||||
@@ -220,7 +280,6 @@ export function JobLinesComponent({
|
||||
]
|
||||
: [])
|
||||
],
|
||||
|
||||
onFilter: (value, record) => value.includes(record.part_type),
|
||||
render: (text, record) => (record.part_type ? t(`joblines.fields.part_types.${record.part_type}`) : null)
|
||||
},
|
||||
@@ -246,7 +305,6 @@ export function JobLinesComponent({
|
||||
title: t("joblines.fields.mod_lbr_ty"),
|
||||
dataIndex: "mod_lbr_ty",
|
||||
key: "mod_lbr_ty",
|
||||
|
||||
sorter: (a, b) => alphaSort(a.mod_lbr_ty, b.mod_lbr_ty),
|
||||
sortOrder: state.sortedInfo.columnKey === "mod_lbr_ty" && state.sortedInfo.order,
|
||||
render: (text, record) => (record.mod_lbr_ty ? t(`joblines.fields.lbr_types.${record.mod_lbr_ty}`) : null)
|
||||
@@ -255,7 +313,6 @@ export function JobLinesComponent({
|
||||
title: t("joblines.fields.mod_lb_hrs"),
|
||||
dataIndex: "mod_lb_hrs",
|
||||
key: "mod_lb_hrs",
|
||||
|
||||
sorter: (a, b) => a.mod_lb_hrs - b.mod_lb_hrs,
|
||||
sortOrder: state.sortedInfo.columnKey === "mod_lb_hrs" && state.sortedInfo.order
|
||||
},
|
||||
@@ -310,18 +367,12 @@ export function JobLinesComponent({
|
||||
sorter: (a, b) => alphaSort(a.status, b.status),
|
||||
sortOrder: state.sortedInfo.columnKey === "status" && state.sortedInfo.order,
|
||||
filteredValue: state.filteredInfo.status || null,
|
||||
|
||||
filters:
|
||||
(jobLines &&
|
||||
jobLines
|
||||
.map((l) => l.status)
|
||||
.filter(onlyUnique)
|
||||
.map((s) => {
|
||||
return {
|
||||
text: s || t("dashboard.errors.status"),
|
||||
value: [s]
|
||||
};
|
||||
})) ||
|
||||
.map((s) => ({ text: s || t("dashboard.errors.status"), value: [s] }))) ||
|
||||
[],
|
||||
onFilter: (value, record) => value.includes(record.status),
|
||||
render: (text, record) => <JobLineStatusPopup jobline={record} disabled={jobRO} />
|
||||
@@ -376,9 +427,7 @@ export function JobLinesComponent({
|
||||
});
|
||||
}
|
||||
});
|
||||
await axios.post("/job/totalsssu", {
|
||||
id: job.id
|
||||
});
|
||||
await axios.post("/job/totalsssu", { id: job.id });
|
||||
if (refetch) refetch();
|
||||
}}
|
||||
>
|
||||
@@ -448,6 +497,36 @@ export function JobLinesComponent({
|
||||
return (
|
||||
<div>
|
||||
<PartsOrderModalContainer />
|
||||
|
||||
<Modal
|
||||
open={bulkLocationOpen}
|
||||
title={t("joblines.actions.updatelocation")}
|
||||
onCancel={closeBulkLocationModal}
|
||||
onOk={saveBulkLocation}
|
||||
okButtonProps={{
|
||||
disabled: jobRO || technician || selectedLineIds.length === 0,
|
||||
loading: bulkLocationSaving
|
||||
}}
|
||||
destroyOnHidden
|
||||
>
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
<Typography.Text type="secondary">
|
||||
{t("general.labels.selected")}: {selectedLineIds.length}
|
||||
</Typography.Text>
|
||||
|
||||
<Select
|
||||
allowClear
|
||||
placeholder={t("joblines.fields.location")}
|
||||
value={bulkLocation}
|
||||
style={{ width: "100%" }}
|
||||
popupMatchSelectWidth={false}
|
||||
onChange={(val) => setBulkLocation(val ?? null)}
|
||||
options={(bodyshop?.md_parts_locations || []).map((loc) => ({ label: loc, value: loc }))}
|
||||
/>
|
||||
<Typography.Text type="secondary">{t("joblines.labels.bulk_location_help")}</Typography.Text>
|
||||
</Space>
|
||||
</Modal>
|
||||
|
||||
{!technician && (
|
||||
<PartsOrderDrawer
|
||||
job={job}
|
||||
@@ -457,6 +536,7 @@ export function JobLinesComponent({
|
||||
setTaskUpsertContext={setTaskUpsertContext}
|
||||
/>
|
||||
)}
|
||||
|
||||
<PageHeader
|
||||
title={t("jobs.labels.estimatelines")}
|
||||
extra={
|
||||
@@ -465,6 +545,16 @@ export function JobLinesComponent({
|
||||
<SyncOutlined />
|
||||
</Button>
|
||||
|
||||
{/* Bulk Update Location */}
|
||||
<Button
|
||||
id="job-lines-bulk-update-location-button"
|
||||
disabled={jobRO || technician || selectedLineIds.length === 0}
|
||||
onClick={openBulkLocationModal}
|
||||
>
|
||||
{t("joblines.actions.updatelocation")}
|
||||
{selectedLineIds.length > 0 && ` (${selectedLineIds.length})`}
|
||||
</Button>
|
||||
|
||||
{job.special_coverage_policy && (
|
||||
<Tag color="tomato">
|
||||
<Space>
|
||||
@@ -473,6 +563,7 @@ export function JobLinesComponent({
|
||||
</Space>
|
||||
</Tag>
|
||||
)}
|
||||
|
||||
{!isPartsEntry && (
|
||||
<JobLineDispatchButton
|
||||
selectedLines={selectedLines}
|
||||
@@ -481,9 +572,11 @@ export function JobLinesComponent({
|
||||
disabled={technician}
|
||||
/>
|
||||
)}
|
||||
|
||||
{Enhanced_Payroll.treatment === "on" && (
|
||||
<JobLineBulkAssignComponent selectedLines={selectedLines} setSelectedLines={setSelectedLines} job={job} />
|
||||
)}
|
||||
|
||||
{!isPartsEntry && (
|
||||
<Button
|
||||
disabled={(job && !job.converted) || (selectedLines.length > 0 ? false : true) || jobRO || technician}
|
||||
@@ -499,27 +592,20 @@ export function JobLinesComponent({
|
||||
isinhouse: true,
|
||||
date: dayjs(),
|
||||
total: 0,
|
||||
billlines: selectedLines.map((p) => {
|
||||
return {
|
||||
joblineid: p.id,
|
||||
actual_price: p.act_price,
|
||||
actual_cost: 0, //p.act_price,
|
||||
line_desc: p.line_desc,
|
||||
line_remarks: p.line_remarks,
|
||||
part_type: p.part_type,
|
||||
quantity: p.quantity || 1,
|
||||
applicable_taxes: {
|
||||
local: false,
|
||||
state: false,
|
||||
federal: false
|
||||
}
|
||||
};
|
||||
})
|
||||
billlines: selectedLines.map((p) => ({
|
||||
joblineid: p.id,
|
||||
actual_price: p.act_price,
|
||||
actual_cost: 0,
|
||||
line_desc: p.line_desc,
|
||||
line_remarks: p.line_remarks,
|
||||
part_type: p.part_type,
|
||||
quantity: p.quantity || 1,
|
||||
applicable_taxes: { local: false, state: false, federal: false }
|
||||
}))
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//Clear out the selected lines. IO-785
|
||||
setSelectedLines([]);
|
||||
}}
|
||||
>
|
||||
@@ -528,6 +614,7 @@ export function JobLinesComponent({
|
||||
{selectedLines.length > 0 && ` (${selectedLines.length})`}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Button
|
||||
id="job-lines-order-parts-button"
|
||||
disabled={(job && !job.converted) || (selectedLines.length > 0 ? false : true) || jobRO || technician}
|
||||
@@ -544,13 +631,13 @@ export function JobLinesComponent({
|
||||
}
|
||||
});
|
||||
|
||||
//Clear out the selected lines. IO-785
|
||||
setSelectedLines([]);
|
||||
}}
|
||||
>
|
||||
{t("parts.actions.order")}
|
||||
{selectedLines.length > 0 && ` (${selectedLines.length})`}
|
||||
</Button>
|
||||
|
||||
{!isPartsEntry && (
|
||||
<Button
|
||||
id="job-lines-filter-parts-only-button"
|
||||
@@ -567,9 +654,11 @@ export function JobLinesComponent({
|
||||
<FilterFilled /> {t("jobs.actions.filterpartsonly")}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Dropdown menu={markMenu} trigger={["click"]}>
|
||||
<Button id="repair-data-mark-button">{t("jobs.actions.mark")}</Button>
|
||||
</Dropdown>
|
||||
|
||||
{!isPartsEntry && (
|
||||
<Button
|
||||
disabled={jobRO || technician}
|
||||
@@ -583,9 +672,12 @@ export function JobLinesComponent({
|
||||
{t("joblines.actions.new")}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{!isPartsEntry &&
|
||||
InstanceRenderManager({ rome: <JobSendPartPriceChangeComponent job={job} disabled={technician} /> })}
|
||||
|
||||
<JobCreateIOU job={job} selectedJobLines={selectedLines} />
|
||||
|
||||
<Input.Search
|
||||
placeholder={t("general.labels.search")}
|
||||
onChange={(e) => {
|
||||
@@ -596,6 +688,7 @@ export function JobLinesComponent({
|
||||
</Space>
|
||||
}
|
||||
/>
|
||||
|
||||
<Table
|
||||
columns={columns}
|
||||
rowKey="id"
|
||||
@@ -603,9 +696,7 @@ export function JobLinesComponent({
|
||||
pagination={false}
|
||||
dataSource={jobLines}
|
||||
onChange={handleTableChange}
|
||||
scroll={{
|
||||
x: true
|
||||
}}
|
||||
scroll={{ x: true }}
|
||||
expandable={{
|
||||
expandedRowRender: (record) =>
|
||||
isPartsEntry ? (
|
||||
@@ -614,7 +705,6 @@ export function JobLinesComponent({
|
||||
<JobLinesExpander jobline={record} jobid={job.id} />
|
||||
),
|
||||
rowExpandable: () => true,
|
||||
//expandRowByClick: true,
|
||||
expandIcon: ({ expanded, onExpand, record }) =>
|
||||
expanded ? (
|
||||
<MinusCircleTwoTone onClick={(e) => onExpand(record, e)} />
|
||||
@@ -627,17 +717,15 @@ export function JobLinesComponent({
|
||||
/>
|
||||
)
|
||||
}}
|
||||
onRow={(record) => {
|
||||
return {
|
||||
onDoubleClick: () => {
|
||||
logImEXEvent("joblines_double_click_select", {});
|
||||
const notMatchingLines = selectedLines.filter((i) => i.id !== record.id);
|
||||
notMatchingLines.length !== selectedLines.length
|
||||
? setSelectedLines(notMatchingLines)
|
||||
: setSelectedLines([...selectedLines, record]);
|
||||
} // double click row
|
||||
};
|
||||
}}
|
||||
onRow={(record) => ({
|
||||
onDoubleClick: () => {
|
||||
logImEXEvent("joblines_double_click_select", {});
|
||||
const notMatchingLines = selectedLines.filter((i) => i.id !== record.id);
|
||||
notMatchingLines.length !== selectedLines.length
|
||||
? setSelectedLines(notMatchingLines)
|
||||
: setSelectedLines([...selectedLines, record]);
|
||||
}
|
||||
})}
|
||||
rowSelection={{
|
||||
selectedRowKeys: selectedLines.map((item) => item && item.id),
|
||||
onSelectAll: (selected, selectedRows) => {
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { Select, Space } from "antd";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Select, Space, Tag } from "antd";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { UPDATE_JOB_LINE } from "../../graphql/jobs-lines.queries";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
const mapDispatchToProps = () => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
const mapDispatchToProps = () => ({});
|
||||
|
||||
const CLEAR_VALUE = "__CLEAR_LOCATION__";
|
||||
|
||||
export function JobLineLocationPopup({ bodyshop, jobline, disabled }) {
|
||||
const [editing, setEditing] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [location, setLocation] = useState(jobline.location);
|
||||
const [updateJob] = useMutation(UPDATE_JOB_LINE);
|
||||
const { t } = useTranslation();
|
||||
@@ -29,55 +27,78 @@ export function JobLineLocationPopup({ bodyshop, jobline, disabled }) {
|
||||
if (editing) setLocation(jobline.location);
|
||||
}, [editing, jobline.location]);
|
||||
|
||||
const handleChange = (e) => {
|
||||
setLocation(e);
|
||||
};
|
||||
const options = useMemo(() => {
|
||||
const locs = bodyshop?.md_parts_locations || [];
|
||||
return [
|
||||
{ label: t("general.labels.none", "No location"), value: CLEAR_VALUE },
|
||||
...locs.map((loc) => ({ label: loc, value: loc }))
|
||||
];
|
||||
}, [bodyshop?.md_parts_locations, t]);
|
||||
|
||||
const handleSave = async () => {
|
||||
setLoading(true);
|
||||
const result = await updateJob({
|
||||
variables: { lineId: jobline.id, line: { location: location || "" } }
|
||||
});
|
||||
const saveLocation = async (nextLocation) => {
|
||||
setSaving(true);
|
||||
|
||||
if (!result.errors) {
|
||||
notification["success"]({ message: t("joblines.successes.saved") });
|
||||
} else {
|
||||
notification["error"]({
|
||||
message: t("joblines.errors.saving", {
|
||||
error: JSON.stringify(result.errors)
|
||||
})
|
||||
try {
|
||||
const result = await updateJob({
|
||||
variables: { lineId: jobline.id, line: { location: nextLocation || "" } }
|
||||
});
|
||||
|
||||
if (!result.errors) {
|
||||
notification["success"]({ message: t("joblines.successes.saved") });
|
||||
} else {
|
||||
notification["error"]({
|
||||
message: t("joblines.errors.saving", {
|
||||
error: JSON.stringify(result.errors)
|
||||
})
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
notification["error"]({
|
||||
message: t("joblines.errors.saving", { error: error?.message || String(error) })
|
||||
});
|
||||
} finally {
|
||||
setSaving(false);
|
||||
setEditing(false);
|
||||
}
|
||||
setLoading(false);
|
||||
setEditing(false);
|
||||
};
|
||||
|
||||
if (editing)
|
||||
const handleChange = async (value) => {
|
||||
const next = value === CLEAR_VALUE ? null : value;
|
||||
setLocation(next);
|
||||
await saveLocation(next);
|
||||
};
|
||||
|
||||
if (editing) {
|
||||
return (
|
||||
<div>
|
||||
<LoadingSpinner loading={loading}>
|
||||
<Select
|
||||
autoFocus
|
||||
allowClear
|
||||
popupMatchSelectWidth={100}
|
||||
value={location}
|
||||
onClear={() => setLocation(null)}
|
||||
onSelect={handleChange}
|
||||
onBlur={handleSave}
|
||||
>
|
||||
{bodyshop.md_parts_locations.map((loc, idx) => (
|
||||
<Select.Option key={idx} value={loc}>
|
||||
{loc}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</LoadingSpinner>
|
||||
<div style={{ width: "100%", display: "flex", alignItems: "center" }}>
|
||||
<Select
|
||||
autoFocus
|
||||
size="small"
|
||||
value={location ?? undefined}
|
||||
loading={saving}
|
||||
disabled={saving}
|
||||
style={{ flex: 1, minWidth: 0 }}
|
||||
popupMatchSelectWidth={false}
|
||||
getPopupContainer={(triggerNode) => triggerNode.parentNode}
|
||||
onChange={handleChange}
|
||||
onBlur={() => !saving && setEditing(false)}
|
||||
options={options}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{ width: "100%", minHeight: "2rem", cursor: "pointer" }} onClick={() => !disabled && setEditing(true)}>
|
||||
<div
|
||||
style={{ width: "100%", minHeight: "2rem", cursor: disabled ? "default" : "pointer" }}
|
||||
onClick={() => !disabled && setEditing(true)}
|
||||
>
|
||||
<Space wrap>
|
||||
{jobline.location}
|
||||
{jobline.location ? (
|
||||
<Tag>{jobline.location}</Tag>
|
||||
) : (
|
||||
<span style={{ opacity: 0.6 }}>{t("general.labels.none")}</span>
|
||||
)}
|
||||
{jobline.parts_dispatch_lines?.length > 0 && "-Disp"}
|
||||
</Space>
|
||||
</div>
|
||||
|
||||
@@ -609,7 +609,7 @@ export function JobsDetailHeaderActions({
|
||||
<FormDateTimePickerComponent
|
||||
onBlur={() => {
|
||||
const start = form.getFieldValue("start");
|
||||
form.setFieldsValue({ end: start.add(30, "minutes") });
|
||||
form.setFieldsValue({ end: start?.add(30, "minutes") });
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
@@ -144,7 +144,7 @@ export function ProductionListEmpAssignment({ insertAuditTrail, bodyshop, record
|
||||
<Spin spinning={loading}>
|
||||
{record[type] ? (
|
||||
<div>
|
||||
<span>{`${theEmployee.first_name || ""} ${theEmployee.last_name || ""}`}</span>
|
||||
<span>{`${theEmployee?.first_name || ""} ${theEmployee?.last_name || ""}`}</span>
|
||||
<DeleteFilled style={iconStyle} onClick={() => handleRemove(type)} />
|
||||
</div>
|
||||
) : (
|
||||
|
||||
@@ -143,7 +143,7 @@ export function ReportCenterModalComponent({ reportCenterModal, bodyshop }) {
|
||||
|
||||
//TODO: Find a way to filter out / blur on demand.
|
||||
return (
|
||||
<div>
|
||||
<div className="report-center-modal">
|
||||
<Form onFinish={handleFinish} autoComplete={"off"} layout="vertical" form={form}>
|
||||
<Input.Search onChange={(e) => setSearch(e.target.value)} value={search} />
|
||||
<Form.Item name="defaultSorters" hidden />
|
||||
@@ -163,13 +163,14 @@ export function ReportCenterModalComponent({ reportCenterModal, bodyshop }) {
|
||||
{Object.keys(grouped)
|
||||
//.filter((key) => !groupExcludeKeyFilter.includes(key))
|
||||
.map((key) => (
|
||||
<Col md={8} sm={12} key={key}>
|
||||
<Col xs={24} sm={12} md={Object.keys(grouped).length === 1 ? 24 : 8} key={key}>
|
||||
<Card.Grid
|
||||
style={{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
maxHeight: "33vh",
|
||||
overflowY: "scroll"
|
||||
overflowY: "scroll",
|
||||
minWidth: "200px"
|
||||
}}
|
||||
>
|
||||
<Typography.Title level={4}>{t(`reportcenter.labels.groups.${key}`)}</Typography.Title>
|
||||
@@ -177,7 +178,7 @@ export function ReportCenterModalComponent({ reportCenterModal, bodyshop }) {
|
||||
<BlurWrapperComponent
|
||||
featureName={groupExcludeKeyFilter.find((g) => g.key === key).featureName}
|
||||
>
|
||||
<ul style={{ listStyleType: "none", columns: "2 auto" }}>
|
||||
<ul style={{ listStyleType: "none", columns: grouped[key].length > 4 ? "2 auto" : "1", padding: 0, margin: 0 }}>
|
||||
{grouped[key].map((item) => (
|
||||
<li key={item.key}>
|
||||
<Radio key={item.key} value={item.key}>
|
||||
@@ -188,7 +189,7 @@ export function ReportCenterModalComponent({ reportCenterModal, bodyshop }) {
|
||||
</ul>
|
||||
</BlurWrapperComponent>
|
||||
) : (
|
||||
<ul style={{ listStyleType: "none", columns: "2 auto" }}>
|
||||
<ul style={{ listStyleType: "none", columns: grouped[key].length > 4 ? "2 auto" : "1", padding: 0, margin: 0 }}>
|
||||
{grouped[key].map((item) =>
|
||||
item.featureNameRestricted ? (
|
||||
<li key={item.key}>
|
||||
|
||||
@@ -11,3 +11,38 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Report center modal fixes for column layout
|
||||
.report-center-modal {
|
||||
.ant-form-item .ant-radio-group {
|
||||
width: 100%;
|
||||
|
||||
.ant-card-grid {
|
||||
padding: 16px;
|
||||
box-sizing: border-box;
|
||||
|
||||
ul {
|
||||
width: 100%;
|
||||
|
||||
li {
|
||||
margin-bottom: 8px;
|
||||
break-inside: avoid;
|
||||
page-break-inside: avoid;
|
||||
|
||||
.ant-radio-wrapper {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
width: 100%;
|
||||
|
||||
span:not(.ant-radio) {
|
||||
word-break: break-word;
|
||||
overflow-wrap: break-word;
|
||||
hyphens: auto;
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { getFirestore } from "@firebase/firestore";
|
||||
import { getMessaging, getToken, onMessage } from "@firebase/messaging";
|
||||
import { store } from "../redux/store";
|
||||
//import * as amplitude from '@amplitude/analytics-browser';
|
||||
import posthog from 'posthog-js'
|
||||
// import posthog from 'posthog-js'
|
||||
|
||||
const config = JSON.parse(import.meta.env.VITE_APP_FIREBASE_CONFIG);
|
||||
initializeApp(config);
|
||||
@@ -74,7 +74,6 @@ onMessage(messaging, (payload) => {
|
||||
|
||||
export const logImEXEvent = (eventName, additionalParams, stateProp = null) => {
|
||||
try {
|
||||
|
||||
const state = stateProp || store.getState();
|
||||
|
||||
const eventParams = {
|
||||
@@ -99,8 +98,7 @@ export const logImEXEvent = (eventName, additionalParams, stateProp = null) => {
|
||||
// );
|
||||
logEvent(analytics, eventName, eventParams);
|
||||
//amplitude.track(eventName, eventParams);
|
||||
posthog.capture(eventName, eventParams);
|
||||
|
||||
//posthog.capture(eventName, eventParams);
|
||||
} finally {
|
||||
//If it fails, just keep going.
|
||||
}
|
||||
|
||||
@@ -1270,6 +1270,7 @@
|
||||
"vehicle": "Vehicle"
|
||||
},
|
||||
"labels": {
|
||||
"selected": "Selected",
|
||||
"settings": "Settings",
|
||||
"actions": "Actions",
|
||||
"areyousure": "Are you sure?",
|
||||
@@ -1491,7 +1492,8 @@
|
||||
"assign_team": "Assign Team",
|
||||
"converttolabor": "Convert amount to Labor.",
|
||||
"dispatchparts": "Dispatch Parts ({{count}})",
|
||||
"new": "New Line"
|
||||
"new": "New Line",
|
||||
"updatelocation": "Update Location"
|
||||
},
|
||||
"errors": {
|
||||
"creating": "Error encountered while creating job line. {{message}}",
|
||||
@@ -1572,7 +1574,8 @@
|
||||
"ioucreated": "IOU",
|
||||
"new": "New Line",
|
||||
"nostatus": "No Status",
|
||||
"presets": "Jobline Presets"
|
||||
"presets": "Jobline Presets",
|
||||
"bulk_location_help": "This will set the same location on all selected lines."
|
||||
},
|
||||
"successes": {
|
||||
"created": "Job line created successfully.",
|
||||
|
||||
@@ -1270,6 +1270,7 @@
|
||||
"vehicle": ""
|
||||
},
|
||||
"labels": {
|
||||
"selected": "",
|
||||
"actions": "Comportamiento",
|
||||
"settings": "",
|
||||
"areyousure": "",
|
||||
@@ -1491,7 +1492,8 @@
|
||||
"assign_team": "",
|
||||
"converttolabor": "",
|
||||
"dispatchparts": "",
|
||||
"new": ""
|
||||
"new": "",
|
||||
"updatelocation": ""
|
||||
},
|
||||
"errors": {
|
||||
"creating": "",
|
||||
@@ -1572,7 +1574,8 @@
|
||||
"ioucreated": "",
|
||||
"new": "Nueva línea",
|
||||
"nostatus": "",
|
||||
"presets": ""
|
||||
"presets": "",
|
||||
"bulk_location_help": ""
|
||||
},
|
||||
"successes": {
|
||||
"created": "",
|
||||
|
||||
@@ -1270,6 +1270,7 @@
|
||||
"vehicle": ""
|
||||
},
|
||||
"labels": {
|
||||
"selected": "",
|
||||
"settings": "",
|
||||
"actions": "actes",
|
||||
"areyousure": "",
|
||||
@@ -1491,7 +1492,8 @@
|
||||
"assign_team": "",
|
||||
"converttolabor": "",
|
||||
"dispatchparts": "",
|
||||
"new": ""
|
||||
"new": "",
|
||||
"updatelocation": ""
|
||||
},
|
||||
"errors": {
|
||||
"creating": "",
|
||||
@@ -1572,7 +1574,8 @@
|
||||
"ioucreated": "",
|
||||
"new": "Nouvelle ligne",
|
||||
"nostatus": "",
|
||||
"presets": ""
|
||||
"presets": "",
|
||||
"bulk_location_help": ""
|
||||
},
|
||||
"successes": {
|
||||
"created": "",
|
||||
|
||||
@@ -31,7 +31,8 @@ if (!import.meta.env.DEV) {
|
||||
"Module specifier, 'fs' does not start",
|
||||
"Module specifier, 'zlib' does not start with",
|
||||
"Messaging: This browser doesn't support the API's required to use the Firebase SDK.",
|
||||
"Failed to update a ServiceWorker for scope"
|
||||
"Failed to update a ServiceWorker for scope",
|
||||
"Network Error"
|
||||
],
|
||||
integrations: [
|
||||
// See docs for support of different versions of variation of react router
|
||||
|
||||
@@ -24,11 +24,13 @@ const lightningCssTargets = browserslistToTargets(
|
||||
})
|
||||
);
|
||||
|
||||
const currentDatePST = new Date()
|
||||
.toLocaleDateString("en-US", { timeZone: "America/Los_Angeles", year: "numeric", month: "2-digit", day: "2-digit" })
|
||||
.split("/")
|
||||
.reverse()
|
||||
.join("-");
|
||||
const pstFormatter = new Intl.DateTimeFormat("en-CA", {
|
||||
timeZone: "America/Los_Angeles",
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit"
|
||||
});
|
||||
const currentDatePST = pstFormatter.format(new Date());
|
||||
|
||||
const getFormattedTimestamp = () =>
|
||||
new Date().toLocaleTimeString("en-US", { hour12: true }).replace("AM", "a.m.").replace("PM", "p.m.");
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Could not auto-generate a down migration.
|
||||
-- Please write an appropriate down migration for the SQL below:
|
||||
-- alter table "public"."jobs" add column "dms_id" text
|
||||
-- null;
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table "public"."jobs" add column "dms_id" text
|
||||
null;
|
||||
@@ -77,9 +77,8 @@ const generateResetLink = async (email) => {
|
||||
*/
|
||||
const ensureExternalIdUnique = async (externalId) => {
|
||||
const resp = await client.request(CHECK_EXTERNAL_SHOP_ID, { key: externalId });
|
||||
if (resp.bodyshops.length) {
|
||||
throw { status: 400, message: `external_shop_id '${externalId}' is already in use.` };
|
||||
}
|
||||
|
||||
return !!resp.bodyshops.length;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -225,10 +224,25 @@ const patchPartsManagementProvisioning = async (req, res) => {
|
||||
*/
|
||||
const partsManagementProvisioning = async (req, res) => {
|
||||
const { logger } = req;
|
||||
const body = { ...req.body, userEmail: req.body.userEmail?.toLowerCase() };
|
||||
|
||||
// Trim and normalize email early
|
||||
const body = {
|
||||
...req.body,
|
||||
userEmail: req.body.userEmail?.trim().toLowerCase()
|
||||
};
|
||||
|
||||
const trim = (value) => (typeof value === "string" ? value.trim() : value);
|
||||
const trimIfString = (value) =>
|
||||
value !== null && value !== undefined && typeof value === "string" ? value.trim() : value;
|
||||
|
||||
try {
|
||||
// Ensure email is present and trimmed before checking registration
|
||||
if (!body.userEmail) {
|
||||
throw { status: 400, message: "userEmail is required" };
|
||||
}
|
||||
|
||||
await ensureEmailNotRegistered(body.userEmail);
|
||||
|
||||
requireFields(body, [
|
||||
"external_shop_id",
|
||||
"shopname",
|
||||
@@ -242,28 +256,68 @@ const partsManagementProvisioning = async (req, res) => {
|
||||
"userEmail"
|
||||
]);
|
||||
|
||||
// TODO add in check for early access
|
||||
await ensureExternalIdUnique(body.external_shop_id);
|
||||
// Trim all top-level string fields
|
||||
const trimmedBody = {
|
||||
...body,
|
||||
external_shop_id: trim(body.external_shop_id),
|
||||
shopname: trim(body.shopname),
|
||||
address1: trim(body.address1),
|
||||
address2: trimIfString(body.address2),
|
||||
city: trim(body.city),
|
||||
state: trim(body.state),
|
||||
zip_post: trim(body.zip_post),
|
||||
country: trim(body.country),
|
||||
email: trim(body.email),
|
||||
phone: trim(body.phone),
|
||||
timezone: trimIfString(body.timezone),
|
||||
logoUrl: trimIfString(body.logoUrl),
|
||||
userPassword: body.userPassword, // passwords should NOT be trimmed (preserves intentional spaces if any, though rare)
|
||||
vendors: Array.isArray(body.vendors)
|
||||
? body.vendors.map((v) => ({
|
||||
name: trim(v.name),
|
||||
street1: trimIfString(v.street1),
|
||||
street2: trimIfString(v.street2),
|
||||
city: trimIfString(v.city),
|
||||
state: trimIfString(v.state),
|
||||
zip: trimIfString(v.zip),
|
||||
country: trimIfString(v.country),
|
||||
email: trimIfString(v.email),
|
||||
cost_center: trimIfString(v.cost_center),
|
||||
phone: trimIfString(v.phone),
|
||||
dmsid: trimIfString(v.dmsid),
|
||||
discount: v.discount ?? 0,
|
||||
due_date: v.due_date ?? null,
|
||||
favorite: v.favorite ?? [],
|
||||
active: v.active ?? true
|
||||
}))
|
||||
: []
|
||||
};
|
||||
|
||||
logger.log("admin-create-shop-user", "debug", body.userEmail, null, {
|
||||
const duplicateCheck = await ensureExternalIdUnique(trimmedBody.external_shop_id);
|
||||
|
||||
if (duplicateCheck) {
|
||||
throw { status: 400, message: `external_shop_id '${trimmedBody.external_shop_id}' is already in use.` };
|
||||
}
|
||||
|
||||
logger.log("admin-create-shop-user", "debug", trimmedBody.userEmail, null, {
|
||||
request: req.body,
|
||||
ioadmin: true
|
||||
});
|
||||
|
||||
const shopInput = {
|
||||
shopname: body.shopname,
|
||||
address1: body.address1,
|
||||
address2: body.address2 || null,
|
||||
city: body.city,
|
||||
state: body.state,
|
||||
zip_post: body.zip_post,
|
||||
country: body.country,
|
||||
email: body.email,
|
||||
external_shop_id: body.external_shop_id,
|
||||
timezone: body.timezone || DefaultNewShop.timezone,
|
||||
phone: body.phone,
|
||||
shopname: trimmedBody.shopname,
|
||||
address1: trimmedBody.address1,
|
||||
address2: trimmedBody.address2,
|
||||
city: trimmedBody.city,
|
||||
state: trimmedBody.state,
|
||||
zip_post: trimmedBody.zip_post,
|
||||
country: trimmedBody.country,
|
||||
email: trimmedBody.email,
|
||||
external_shop_id: trimmedBody.external_shop_id,
|
||||
timezone: trimmedBody.timezone || DefaultNewShop.timezone,
|
||||
phone: trimmedBody.phone,
|
||||
logo_img_path: {
|
||||
src: body.logoUrl,
|
||||
src: trimmedBody.logoUrl || null, // allow empty logo
|
||||
width: "",
|
||||
height: "",
|
||||
headerMargin: DefaultNewShop.logo_img_path.headerMargin
|
||||
@@ -288,35 +342,37 @@ const partsManagementProvisioning = async (req, res) => {
|
||||
appt_alt_transport: DefaultNewShop.appt_alt_transport,
|
||||
md_jobline_presets: DefaultNewShop.md_jobline_presets,
|
||||
vendors: {
|
||||
data: body.vendors.map((v) => ({
|
||||
data: trimmedBody.vendors.map((v) => ({
|
||||
name: v.name,
|
||||
street1: v.street1 || null,
|
||||
street2: v.street2 || null,
|
||||
city: v.city || null,
|
||||
state: v.state || null,
|
||||
zip: v.zip || null,
|
||||
country: v.country || null,
|
||||
email: v.email || null,
|
||||
discount: v.discount ?? 0,
|
||||
due_date: v.due_date ?? null,
|
||||
cost_center: v.cost_center || null,
|
||||
favorite: v.favorite ?? [],
|
||||
phone: v.phone || null,
|
||||
active: v.active ?? true,
|
||||
dmsid: v.dmsid || null
|
||||
street1: v.street1,
|
||||
street2: v.street2,
|
||||
city: v.city,
|
||||
state: v.state,
|
||||
zip: v.zip,
|
||||
country: v.country,
|
||||
email: v.email,
|
||||
discount: v.discount,
|
||||
due_date: v.due_date,
|
||||
cost_center: v.cost_center,
|
||||
favorite: v.favorite,
|
||||
phone: v.phone,
|
||||
active: v.active,
|
||||
dmsid: v.dmsid
|
||||
}))
|
||||
}
|
||||
};
|
||||
|
||||
const newShopId = await insertBodyshop(shopInput);
|
||||
const userRecord = await createFirebaseUser(body.userEmail, body.userPassword);
|
||||
const userRecord = await createFirebaseUser(trimmedBody.userEmail, trimmedBody.userPassword);
|
||||
let resetLink = null;
|
||||
if (!body.userPassword) resetLink = await generateResetLink(body.userEmail);
|
||||
if (!trimmedBody.userPassword) {
|
||||
resetLink = await generateResetLink(trimmedBody.userEmail);
|
||||
}
|
||||
|
||||
const createdUser = await insertUserAssociation(userRecord.uid, body.userEmail, newShopId);
|
||||
const createdUser = await insertUserAssociation(userRecord.uid, trimmedBody.userEmail, newShopId);
|
||||
|
||||
return res.status(200).json({
|
||||
shop: { id: newShopId, shopname: body.shopname },
|
||||
shop: { id: newShopId, shopname: trimmedBody.shopname },
|
||||
user: {
|
||||
id: createdUser.id,
|
||||
email: createdUser.email,
|
||||
@@ -324,7 +380,7 @@ const partsManagementProvisioning = async (req, res) => {
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
logger.log("admin-create-shop-user-error", "error", body.userEmail, null, {
|
||||
logger.log("admin-create-shop-user-error", "error", body.userEmail || "unknown", null, {
|
||||
message: err.message,
|
||||
detail: err.detail || err
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user