Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.0.0] Fix params for withTag API query #621

Merged
merged 2 commits into from
Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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