Added messaging presets BOD-107

This commit is contained in:
Patrick Fic
2020-07-21 16:12:32 -07:00
parent 0ef4d77275
commit 7b99a2e612
21 changed files with 526 additions and 18 deletions

View File

@@ -8,6 +8,7 @@ import {
Radio,
Select,
} from "antd";
import { DeleteFilled } from "@ant-design/icons";
import { useTranslation } from "react-i18next";
import ShopInfoROStatusComponent from "./shop-info.rostatus.component";
import ShopInfoOrderStatusComponent from "./shop-info.orderstatus.component";
@@ -188,6 +189,68 @@ export default function ShopInfoComponent({ form }) {
}}
</Form.Item>
<Form.List name={["md_messaging_presets"]}>
{(fields, { add, remove }) => {
return (
<div>
{fields.map((field, index) => (
<Form.Item
key={field.key}
style={{ padding: 0, margin: 2 }}
>
<div style={{ display: "flex" }}>
<Form.Item
style={{ padding: 0, margin: 2 }}
label={t("bodyshop.fields.messaginglabel")}
key={`${index}label`}
name={[field.name, "label"]}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<Input />
</Form.Item>
<Form.Item
style={{ padding: 0, margin: 2 }}
label={t("bodyshop.fields.messagingtext")}
key={`${index}text`}
name={[field.name, "text"]}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<Input />
</Form.Item>
<DeleteFilled
onClick={() => {
remove(field.name);
}}
/>
</div>
</Form.Item>
))}
<Form.Item>
<Button
type="dashed"
onClick={() => {
add();
}}
style={{ width: "100%" }}
>
{t("general.actions.add")}
</Button>
</Form.Item>
</div>
);
}}
</Form.List>
<Form.Item
name={["md_referral_sources"]}
label={t("bodyshop.fields.md_referral_sources")}

View File

@@ -13,25 +13,24 @@ export default function ShopInfoContainer() {
const { t } = useTranslation();
const [updateBodyshop] = useMutation(UPDATE_SHOP);
const { loading, error, data, refetch } = useQuery(QUERY_BODYSHOP, {
fetchPolicy: "network-only"
fetchPolicy: "network-only",
});
const handleFinish = values => {
const handleFinish = (values) => {
console.log("values", values);
logImEXEvent("shop_update");
updateBodyshop({
variables: { id: data.bodyshops[0].id, shop: values }
variables: { id: data.bodyshops[0].id, shop: values },
})
.then(r => {
.then((r) => {
notification["success"]({ message: t("bodyshop.successes.save") });
refetch().then(_ => form.resetFields());
refetch().then((_) => form.resetFields());
})
.catch(error => {
notification["error"](
{ message: t("bodyshop.errors.saving") },
{ message: error }
);
.catch((error) => {
notification["error"]({
message: t("bodyshop.errors.saving", { message: error }),
});
});
};