Change shop association.

This commit is contained in:
Patrick Fic
2020-02-05 08:52:12 -08:00
parent 02578bda2a
commit ba9e91d0c8

View File

@@ -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();
};