Skip to content

Commit

Permalink
Merge pull request #7614 from artsy/ivan-badyulya/PX-4098-RedirectFro…
Browse files Browse the repository at this point in the history
…mWorksWhenCMSoff

fix: add redirection logic for works page
  • Loading branch information
sweir27 authored May 28, 2021
2 parents 70b2037 + ed5f831 commit 6ee208b
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 40 deletions.
29 changes: 29 additions & 0 deletions src/v2/Apps/Partner/partnerRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,38 @@ export const partnerRoutes: AppRouteConfig[] = [
) {
partner(id: $partnerId) @principalField {
...Works_partner @arguments(input: $input)
displayWorksSection
counts {
eligibleArtworks
}
}
}
`,
render: ({ Component, props, match }) => {
if (!(Component && props)) {
return
}

const { partner } = props as any

if (!partner) {
return
}

const {
displayWorksSection,
counts: { eligibleArtworks },
} = partner

if (!displayWorksSection || eligibleArtworks <= 0) {
throw new RedirectException(
`/partner2/${match.params.partnerId}`,
302
)
}

return <Component {...props} />
},
},
{
getComponent: () => ArtistsRoute,
Expand Down
117 changes: 77 additions & 40 deletions src/v2/__generated__/partnerRoutes_WorksQuery.graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6ee208b

Please sign in to comment.