This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { map } from 'p-iteration'; | |
import _uniqBy from 'lodash/uniqBy'; | |
/* Array iteration with async/await */ | |
const getMultipleCategoryProducts = async productCategories => { | |
return map(productCategories, async category => { | |
const products = await getProductsByCategory(category); | |
return products; | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
import { graphql } from 'react-relay'; | |
import { createRefetchContainer, QueryRenderer } from 'react-relay'; | |
import { identifyDataKey, hasNextPage, createDataArray } from '../../../utils/RelayHelpers'; | |
const ProductReviewsList = ({ data, loading, containerWidth, role }) => { | |
const renderRow = () => ( | |
<Flex flexColumn id="ReviewComments"> | |
<Box className="ProductReviews__divider"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { PureComponent } from 'react' | |
const contextTypes = { | |
router: PropTypes.object.isRequired, | |
api: PropTypes.object.isRequired, | |
relay: PropTypes.shape({ | |
variables: PropTypes.shape({ | |
category: PropTypes.string.isRequired, | |
}).isRequired, | |
}).isRequired, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { PureComponent } from 'react' | |
const contextTypes = { | |
router: PropTypes.object.isRequired, | |
api: PropTypes.object.isRequired, | |
relay: PropTypes.shape({ | |
variables: PropTypes.shape({ | |
category: PropTypes.string.isRequired, | |
}).isRequired, | |
}).isRequired, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
class AsyncAwait extends React.Component { | |
constructor() { | |
super() | |
this.state = {} | |
} | |
async componentDidMount() { | |
const res = await this.context.api.fetch('/logout', { method: 'POST' }).then(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
class AsyncAwait extends React.Component { | |
constructor() { | |
super() | |
this.state = {} | |
} | |
async componentDidMount() { | |
const res = await this.context.api.fetch('/logout', { method: 'POST' }).then(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { PropTypes, Component } from 'react'; | |
import Relay from 'react-relay'; | |
import { Map } from 'immutable'; | |
import debounce from 'lodash/debounce'; | |
import AddToCartMutation from '../../mutations/AddToCartMutation'; | |
import RemoveFromCartMutation from '../../mutations/RemoveFromCartMutation'; | |
import CartEntry from '../cart/CartEntry'; | |
import InputQuantity from '../form/InputQuantity'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { PropTypes } from 'react'; | |
import Relay from 'react-relay'; | |
import { Map } from 'immutable'; | |
import debounce from 'lodash/debounce'; | |
import AddToCartMutation from '../../mutations/AddToCartMutation'; | |
import RemoveFromCartMutation from '../../mutations/RemoveFromCartMutation'; | |
import CartEntry from '../cart/CartEntry'; | |
import InputQuantity from '../form/InputQuantity'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' @param func = a site-by-species "functioning" matrix (cells are values of ecosystem function), | |
#' @param base = the row name or number of the baseline community; defaults to highest productivity community | |
#' @param standardize = TRUE, whether results are scaled by the maximum to units (-1, 1), | |
#' @param avg = TRUE, whether | |
#' @param avglvl = The top X% of sites that should be used as the baseline and then results averaged, default is top 90% | |
#' @return data.frame of Price components & summed effects | |
price = function(func, base = "best", standardize = TRUE, avg = FALSE, avglvl = 0.90) { | |
# Replace NAs with zeros |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* checks to see if item id arrangement in packages has changed */ | |
let compareItemIds = (oldIds, newIds) => { | |
return _.difference(newIds, oldIds).concat(_.difference(oldIds, newIds)); | |
}; | |
/* gets the item of ids of current packages and orignal packages | |
and compares them for changes */ | |
let haveItemsChanged = () => { | |
let curIds = []; |
NewerOlder