BOD-6 #comment Additional build + layout for shop info screen.
This commit is contained in:
@@ -1,22 +1,35 @@
|
||||
import React, { useEffect } from "react";
|
||||
import ShopInfoComponent from "./shop-info.component";
|
||||
import { Form } from "antd";
|
||||
import { Form, notification } from "antd";
|
||||
import { useQuery, useMutation } from "react-apollo";
|
||||
import { QUERY_BODYSHOP, UPDATE_SHOP } from "../../graphql/bodyshop.queries";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
export default function ShopInfoContainer() {
|
||||
const [form] = Form.useForm();
|
||||
const { t } = useTranslation();
|
||||
const [updateBodyshop] = useMutation(UPDATE_SHOP);
|
||||
const { loading, error, data } = useQuery(QUERY_BODYSHOP, {
|
||||
const { loading, error, data, refetch } = useQuery(QUERY_BODYSHOP, {
|
||||
fetchPolicy: "network-only"
|
||||
});
|
||||
|
||||
const handleFinish = values => {
|
||||
console.log("values", values);
|
||||
|
||||
updateBodyshop({ variables: { id: data.bodyshops[0].id, shop: values } });
|
||||
updateBodyshop({
|
||||
variables: { id: data.bodyshops[0].id, shop: values }
|
||||
})
|
||||
.then(r => {
|
||||
notification["success"]({ message: t("bodyshop.successes.save") });
|
||||
refetch().then(_ => form.resetFields());
|
||||
})
|
||||
.catch(error => {
|
||||
notification["error"](
|
||||
{ message: t("bodyshop.errors.saving") },
|
||||
{ message: error }
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user