Added first round of analytics and event tracking BOD-190
This commit is contained in:
@@ -2,28 +2,31 @@ import React from "react";
|
||||
import { useQuery, useMutation } from "@apollo/react-hooks";
|
||||
import {
|
||||
QUERY_ALL_ASSOCIATIONS,
|
||||
UPDATE_ASSOCIATION
|
||||
UPDATE_ASSOCIATION,
|
||||
} from "../../graphql/associations.queries";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import ProfileShopsComponent from "./profile-shops.component";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
|
||||
export default function ProfileShopsContainer() {
|
||||
const { loading, error, data, refetch } = useQuery(QUERY_ALL_ASSOCIATIONS);
|
||||
const [updateAssocation] = useMutation(UPDATE_ASSOCIATION);
|
||||
|
||||
const updateActiveShop = activeShopId => {
|
||||
data.associations.forEach(record => {
|
||||
const updateActiveShop = (activeShopId) => {
|
||||
logImEXEvent("profile_change_active_shop");
|
||||
|
||||
data.associations.forEach((record) => {
|
||||
updateAssocation({
|
||||
variables: {
|
||||
assocId: record.id,
|
||||
assocActive: record.id === activeShopId ? true : false
|
||||
}
|
||||
assocActive: record.id === activeShopId ? true : false,
|
||||
},
|
||||
});
|
||||
});
|
||||
refetch();
|
||||
};
|
||||
|
||||
if (error) return <AlertComponent type="error" message={error.message} />;
|
||||
if (error) return <AlertComponent type='error' message={error.message} />;
|
||||
return (
|
||||
<ProfileShopsComponent
|
||||
loading={loading}
|
||||
|
||||
Reference in New Issue
Block a user