Skip to content

Commit

Permalink
fixes cart in profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
davelandry committed Mar 15, 2019
1 parent d26b343 commit 0d41c63
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion api/mortarRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ module.exports = function(app) {
returnObject.image = image;
returnObject.sections.forEach(section => {
section.topics.forEach(topic => {
topic.profile = section.profile.slug;
topic.profile = profile.slug;
topic.section = section.slug;
});
});
Expand Down
9 changes: 4 additions & 5 deletions app/components/Viz/Options.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,13 @@ class Options extends Component {

async onCart() {

const {addToCart, cart, removeFromCart, slug, topic} = this.props;
const {addToCart, cart, removeFromCart, slug, topic, variables} = this.props;
const inCart = cart.data.find(c => c.slug === slug);

if (!inCart) {

const {config, data, dataFormat, title} = this.props;
const {list, stripHTML} = this.context.formatters;
console.log(topic);
console.log(slug);
console.log(data);
console.log(config);
Expand All @@ -126,9 +125,9 @@ class Options extends Component {
let slices = [];
if (!params.drilldowns) params.drilldowns = [];

if (params[slugMap[topic.profile]] && topic.variables.hierarchy) {
if (params[slugMap[topic.profile]] && variables.hierarchy) {
delete params[slugMap[topic.profile]];
params.drilldowns.push(topic.variables.hierarchy);
params.drilldowns.push(variables.hierarchy);
}

// params.drilldowns = params.drilldowns
Expand Down Expand Up @@ -197,7 +196,7 @@ class Options extends Component {
const cartTitle = `${stripHTML(title)}${drilldowns ? ` by ${list(drilldowns)}` : ""}`;
console.log(cartTitle);

// addToCart({urls, format, slug, title: cartTitle});
addToCart({urls, format, slug, title: cartTitle});

}
else {
Expand Down
3 changes: 2 additions & 1 deletion app/components/Viz/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class Viz extends Component {
dataFormat={ vizProps.dataFormat }
slug={ slug }
title={ formatters.stripHTML(title || "Data USA Visualization") }
topic={ topic } /> : null }
topic={ topic }
variables={ variables } /> : null }
<Visualization
ref={ comp => this.viz = comp }
className="d3plus"
Expand Down

0 comments on commit 0d41c63

Please sign in to comment.