- Merge client update into test-beta

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-01-18 19:20:08 -05:00
696 changed files with 92291 additions and 107075 deletions

View File

@@ -1,90 +1,91 @@
import { useMutation } from "@apollo/client";
import { notification, Select, Space } from "antd";
import React, { useEffect, 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 {useMutation} from "@apollo/client";
import {notification, Select, Space} from "antd";
import React, {useEffect, 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";
const mapStateToProps = createStructuredSelector({
//currentUser: selectCurrentUser
bodyshop: selectBodyshop,
//currentUser: selectCurrentUser
bodyshop: selectBodyshop,
});
const mapDispatchToProps = (dispatch) => ({
//setUserLanguage: language => dispatch(setUserLanguage(language))
//setUserLanguage: language => dispatch(setUserLanguage(language))
});
export function JobLineLocationPopup({ bodyshop, jobline, disabled }) {
const [editing, setEditing] = useState(false);
const [loading, setLoading] = useState(false);
const [location, setLocation] = useState(jobline.location);
const [updateJob] = useMutation(UPDATE_JOB_LINE);
const { t } = useTranslation();
export function JobLineLocationPopup({bodyshop, jobline, disabled}) {
const [editing, setEditing] = useState(false);
const [loading, setLoading] = useState(false);
const [location, setLocation] = useState(jobline.location);
const [updateJob] = useMutation(UPDATE_JOB_LINE);
const {t} = useTranslation();
useEffect(() => {
if (editing) setLocation(jobline.location);
}, [editing, jobline.location]);
useEffect(() => {
if (editing) setLocation(jobline.location);
}, [editing, jobline.location]);
const handleChange = (e) => {
setLocation(e);
};
const handleChange = (e) => {
setLocation(e);
};
const handleSave = async (e) => {
setLoading(true);
const result = await updateJob({
variables: { lineId: jobline.id, line: { location: location || "" } },
});
const handleSave = async (e) => {
setLoading(true);
const result = await updateJob({
variables: {lineId: jobline.id, line: {location: location || ""}},
});
if (!!!result.errors) {
notification["success"]({ message: t("joblines.successes.saved") });
} else {
notification["error"]({
message: t("joblines.errors.saving", {
error: JSON.stringify(result.errors),
}),
});
}
setLoading(false);
setEditing(false);
};
if (!!!result.errors) {
notification["success"]({message: t("joblines.successes.saved")});
} else {
notification["error"]({
message: t("joblines.errors.saving", {
error: JSON.stringify(result.errors),
}),
});
}
setLoading(false);
setEditing(false);
};
if (editing)
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>
);
return (
<div>
<LoadingSpinner loading={loading}>
<Select
autoFocus
allowClear
dropdownMatchSelectWidth={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>
<div
style={{width: "100%", minHeight: "2rem", cursor: "pointer"}}
onClick={() => !disabled && setEditing(true)}
>
<Space wrap>
{jobline.location}
{jobline.parts_dispatch_lines?.length > 0 && "-Disp"}
</Space>
</div>
);
return (
<div
style={{ width: "100%", minHeight: "2rem", cursor: "pointer" }}
onClick={() => !disabled && setEditing(true)}
>
<Space wrap>
{jobline.location}
{jobline.parts_dispatch_lines?.length > 0 && "-Disp"}
</Space>
</div>
);
}
export default connect(
mapStateToProps,
mapDispatchToProps
mapStateToProps,
mapDispatchToProps
)(JobLineLocationPopup);