Change shop association.
This commit is contained in:
@@ -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();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user