Skip to content

Commit

Permalink
Merge pull request #621 from reactioncommerce/fix-aldeed-tags-api-params
Browse files Browse the repository at this point in the history
[3.0.0] Fix params for withTag API query
  • Loading branch information
mikemurray committed Dec 3, 2019
2 parents 8a5f7c2 + 86fc8ed commit 2c7d663
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/components/CheckoutActions/CheckoutActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const MessageDiv = styled.div`

const NoPaymentMethodsMessage = () => <MessageDiv>No payment methods available</MessageDiv>;

NoPaymentMethodsMessage.renderComplete = () => "";

@withAddressValidation
@track()
@observer
Expand Down
4 changes: 2 additions & 2 deletions src/containers/tags/tag.gql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import "./tagFragment.gql"

query tagQuery($slugOrId: String) {
tag(slugOrId: $slugOrId) {
query tagQuery($shopId: ID!, $slugOrId: String!) {
tag(shopId: $shopId, slugOrId: $slugOrId) {
...TagInfo
}
}
10 changes: 8 additions & 2 deletions src/containers/tags/withTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import tagQuery from "./tag.gql";
* @returns {React.Component} - Component with `tag` prop
*/
export default function withTag(Component) {
@inject("routingStore")
@inject("primaryShopId", "routingStore")
@observer
class WithTag extends React.Component {
static propTypes = {
primaryShopId: PropTypes.string.isRequired,
/**
* slug used to obtain tag info
*/
Expand All @@ -27,14 +28,19 @@ export default function withTag(Component) {

render() {
const {
primaryShopId,
router: { query: { slug: slugFromQueryParam } },
routingStore: { tagId }
} = this.props;

const slugOrId = slugFromQueryParam || tagId;

if (!primaryShopId || !slugOrId) {
return <Component {...this.props} />;
}

return (
<Query query={tagQuery} variables={{ slugOrId }}>
<Query query={tagQuery} variables={{ shopId: primaryShopId, slugOrId }}>
{({ error, data }) => {
if (error) {
console.error("WithTag query error:", error); // eslint-disable-line no-console
Expand Down

0 comments on commit 2c7d663

Please sign in to comment.