Skip to content

Commit

Permalink
Add redirection logic if no artworks or cms field is false
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Badyulya committed May 24, 2021
1 parent 4e7ef2f commit ed5f831
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 @@ -180,9 +180,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 ed5f831

Please sign in to comment.