diff --git a/client/src/components/profile-shops/profile-shops.container.jsx b/client/src/components/profile-shops/profile-shops.container.jsx index bc85033d6..cb08bb3a3 100644 --- a/client/src/components/profile-shops/profile-shops.container.jsx +++ b/client/src/components/profile-shops/profile-shops.container.jsx @@ -1,15 +1,27 @@ import React from "react"; -import { useQuery } from "react-apollo"; -import { QUERY_ALL_ASSOCIATIONS } from "../../graphql/associations.queries"; +import { useQuery, useMutation } from "react-apollo"; +import { + QUERY_ALL_ASSOCIATIONS, + UPDATE_ASSOCIATION +} from "../../graphql/associations.queries"; import AlertComponent from "../alert/alert.component"; import ProfileShopsComponent from "./profile-shops.component"; export default function ProfileShopsContainer() { - const { loading, error, data, refetch } = useQuery(QUERY_ALL_ASSOCIATIONS); + const [updateAssocation] = useMutation(UPDATE_ASSOCIATION); const updateActiveShop = activeShopId => { console.log("activeShopId", activeShopId); + + data.associations.map(record => { + updateAssocation({ + variables: { + assocId: record.id, + assocActive: record.id === activeShopId ? true : false + } + }); + }); refetch(); };