import styles from './build.mss';

/*****************************************************************************/
/* Build: Event Handlers */
/*****************************************************************************/
Template.Build.events({
});

/*****************************************************************************/
/* Build: Helpers */
/*****************************************************************************/
Template.Build.helpers({
  styles: styles,
  links: function () {
    const build = this.build || {};
    const owningItemSets = build.itemSets;
    const itemSet = build.itemSet;
    const leftLinks = [], rightLinks = [];
    if (owningItemSets) {
      leftLinks.push({
        route: 'SetsId',
        name: `Back to ${owningItemSets.patchVersion} sets`,
        data: {
          _id: owningItemSets._id.valueOf()
        }
      });
    } else {
      // TODO: Show "Back to the sets" if the current item sets generation is the latest
      leftLinks.push({
        route: 'Sets',
        name: `Back to the sets`
      });
    }
    const latestSetsId = build.latestItemSetsId;
    const itemSetsId = owningItemSets && owningItemSets._id.valueOf();
    if (latestSetsId !== itemSetsId) {
      rightLinks.push({
        route: 'Build',
        name: `Latest ${itemSet.champion} build`,
        data: {
          _param1: itemSet.champion,
          _param2: itemSet.role
        }
      });
    }
    return {
      left: leftLinks,
      right: rightLinks
    };
  },
  routeItemSet: function () {
    return this.build || {};
  }
});

/*****************************************************************************/
/* Build: Lifecycle Hooks */
/*****************************************************************************/
Template.Build.onCreated(function () {
  this.subscribe('ItemSets');
});

Template.Build.onRendered(function () {
});

Template.Build.onDestroyed(function () {
});

@@ -1108,16 +1108,26 @@
 emSetsId
+.valueOf()
 ;%0A    co
@@ -1187,24 +1187,67 @@
 .valueOf();%0A
+    console.log(latestSetsId, itemSetsId);%0A
     if (late

Fix "Latest <champion> build" being shown no matter if the build is the latest.