Added class change admin functionality IO-521
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
import { useMutation } from "@apollo/react-hooks";
|
||||
import { Button, Form, notification, Popconfirm, Select } 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 } from "../../graphql/jobs.queries";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(JobsAdminClass);
|
||||
|
||||
export function JobsAdminClass({ bodyshop, job }) {
|
||||
const { t } = useTranslation();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [form] = Form.useForm();
|
||||
const [updateJob] = useMutation(UPDATE_JOB);
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
console.log(values);
|
||||
setLoading(true);
|
||||
const result = await updateJob({
|
||||
variables: { jobId: job.id, job: values },
|
||||
});
|
||||
|
||||
if (!!!result.errors) {
|
||||
notification["success"]({ message: t("jobs.successes.save") });
|
||||
} else {
|
||||
notification["error"]({
|
||||
message: t("jobs.errors.saving", {
|
||||
error: JSON.stringify(result.errors),
|
||||
}),
|
||||
});
|
||||
}
|
||||
setLoading(false);
|
||||
//Get the owner details, populate it all back into the job.
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
//form.resetFields();
|
||||
}, [form, job]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Form
|
||||
onFinish={handleFinish}
|
||||
autoComplete={"off"}
|
||||
form={form}
|
||||
layout="vertical"
|
||||
initialValues={job}
|
||||
>
|
||||
<LayoutFormRow>
|
||||
<Form.Item
|
||||
name={["class"]}
|
||||
label={t("jobs.fields.class")}
|
||||
rules={[
|
||||
{
|
||||
required: bodyshop.enforce_class,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Select>
|
||||
{bodyshop.md_classes.map((s) => (
|
||||
<Select.Option key={s} value={s}>
|
||||
{s}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
</Form>
|
||||
|
||||
<Popconfirm
|
||||
title={t("jobs.labels.changeclass")}
|
||||
onConfirm={() => form.submit()}
|
||||
>
|
||||
<Button loading={loading}>{t("general.actions.save")}</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ export function JobsConvertButton({ bodyshop, job, refetch, jobRO }) {
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name={["class"]}
|
||||
name={"class"}
|
||||
label={t("jobs.fields.class")}
|
||||
rules={[
|
||||
{
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import React from "react";
|
||||
|
||||
export default function JobsRatesComponent() {
|
||||
return <div>Jobs Rates Comp</div>;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import React from "react";
|
||||
import JobsRatesComponent from "./jobs-rates.component";
|
||||
|
||||
export default function JobsRatesContainer() {
|
||||
return <JobsRatesComponent />;
|
||||
}
|
||||
Reference in New Issue
Block a user