IO-849 Remove class when not enforced.
This commit is contained in:
@@ -27,10 +27,13 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
|
|
||||||
export function JobsConvertButton({ bodyshop, job, refetch, jobRO }) {
|
export function JobsConvertButton({ bodyshop, job, refetch, jobRO }) {
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
const [mutationConvertJob] = useMutation(CONVERT_JOB_TO_RO);
|
const [mutationConvertJob] = useMutation(CONVERT_JOB_TO_RO);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
|
||||||
const handleConvert = async (values) => {
|
const handleConvert = async (values) => {
|
||||||
|
setLoading(true);
|
||||||
const res = await mutationConvertJob({
|
const res = await mutationConvertJob({
|
||||||
variables: { jobId: job.id, ...values },
|
variables: { jobId: job.id, ...values },
|
||||||
});
|
});
|
||||||
@@ -42,12 +45,14 @@ export function JobsConvertButton({ bodyshop, job, refetch, jobRO }) {
|
|||||||
});
|
});
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
}
|
}
|
||||||
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const popMenu = (
|
const popMenu = (
|
||||||
<div>
|
<div>
|
||||||
<Form
|
<Form
|
||||||
layout="vertical"
|
layout="vertical"
|
||||||
|
form={form}
|
||||||
onFinish={handleConvert}
|
onFinish={handleConvert}
|
||||||
initialValues={{ driveable: true, towin: false }}
|
initialValues={{ driveable: true, towin: false }}
|
||||||
>
|
>
|
||||||
@@ -69,24 +74,26 @@ export function JobsConvertButton({ bodyshop, job, refetch, jobRO }) {
|
|||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
{bodyshop.enforce_class && (
|
||||||
name={"class"}
|
<Form.Item
|
||||||
label={t("jobs.fields.class")}
|
name={"class"}
|
||||||
rules={[
|
label={t("jobs.fields.class")}
|
||||||
{
|
rules={[
|
||||||
required: bodyshop.enforce_class,
|
{
|
||||||
message: t("general.validation.required"),
|
required: bodyshop.enforce_class,
|
||||||
},
|
message: t("general.validation.required"),
|
||||||
]}
|
},
|
||||||
>
|
]}
|
||||||
<Select>
|
>
|
||||||
{bodyshop.md_classes.map((s) => (
|
<Select>
|
||||||
<Select.Option key={s} value={s}>
|
{bodyshop.md_classes.map((s) => (
|
||||||
{s}
|
<Select.Option key={s} value={s}>
|
||||||
</Select.Option>
|
{s}
|
||||||
))}
|
</Select.Option>
|
||||||
</Select>
|
))}
|
||||||
</Form.Item>
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("jobs.fields.ca_gst_registrant")}
|
label={t("jobs.fields.ca_gst_registrant")}
|
||||||
name="ca_gst_registrant"
|
name="ca_gst_registrant"
|
||||||
@@ -109,7 +116,7 @@ export function JobsConvertButton({ bodyshop, job, refetch, jobRO }) {
|
|||||||
<Switch />
|
<Switch />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Space wrap>
|
<Space wrap>
|
||||||
<Button type="danger" htmlType="submit">
|
<Button type="danger" onClick={() => form.submit()} loading={loading}>
|
||||||
{t("jobs.actions.convert")}
|
{t("jobs.actions.convert")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={() => setVisible(false)}>
|
<Button onClick={() => setVisible(false)}>
|
||||||
@@ -129,6 +136,7 @@ export function JobsConvertButton({ bodyshop, job, refetch, jobRO }) {
|
|||||||
type="danger"
|
type="danger"
|
||||||
// style={{ display: job.converted ? "none" : "" }}
|
// style={{ display: job.converted ? "none" : "" }}
|
||||||
disabled={job.converted || jobRO}
|
disabled={job.converted || jobRO}
|
||||||
|
loading={loading}
|
||||||
onClick={() => setVisible(true)}
|
onClick={() => setVisible(true)}
|
||||||
>
|
>
|
||||||
{t("jobs.actions.convert")}
|
{t("jobs.actions.convert")}
|
||||||
|
|||||||
Reference in New Issue
Block a user