diff --git a/src/v2/Apps/Partner/partnerRoutes.tsx b/src/v2/Apps/Partner/partnerRoutes.tsx index ff4c58eaf03..f04848643db 100644 --- a/src/v2/Apps/Partner/partnerRoutes.tsx +++ b/src/v2/Apps/Partner/partnerRoutes.tsx @@ -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 + }, }, { getComponent: () => ArtistsRoute, diff --git a/src/v2/__generated__/partnerRoutes_WorksQuery.graphql.ts b/src/v2/__generated__/partnerRoutes_WorksQuery.graphql.ts index 155873d41a2..9753497e409 100644 --- a/src/v2/__generated__/partnerRoutes_WorksQuery.graphql.ts +++ b/src/v2/__generated__/partnerRoutes_WorksQuery.graphql.ts @@ -60,6 +60,10 @@ export type partnerRoutes_WorksQueryVariables = { }; export type partnerRoutes_WorksQueryResponse = { readonly partner: { + readonly displayWorksSection: boolean | null; + readonly counts: { + readonly eligibleArtworks: number | null; + } | null; readonly " $fragmentRefs": FragmentRefs<"Works_partner">; } | null; }; @@ -77,6 +81,10 @@ query partnerRoutes_WorksQuery( ) { partner(id: $partnerId) @principalField { ...Works_partner_2VV6jB + displayWorksSection + counts { + eligibleArtworks + } id } } @@ -275,48 +283,73 @@ v1 = [ } ], v2 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "displayWorksSection", + "storageKey": null +}, +v3 = { + "alias": null, + "args": null, + "concreteType": "PartnerCounts", + "kind": "LinkedField", + "name": "counts", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "eligibleArtworks", + "storageKey": null + } + ], + "storageKey": null +}, +v4 = { "kind": "Variable", "name": "input", "variableName": "input" }, -v3 = { +v5 = { "alias": null, "args": null, "kind": "ScalarField", "name": "slug", "storageKey": null }, -v4 = { +v6 = { "alias": null, "args": null, "kind": "ScalarField", "name": "internalID", "storageKey": null }, -v5 = { +v7 = { "alias": null, "args": null, "kind": "ScalarField", "name": "id", "storageKey": null }, -v6 = { +v8 = { "alias": null, "args": null, "kind": "ScalarField", "name": "cursor", "storageKey": null }, -v7 = { +v9 = { "alias": null, "args": null, "kind": "ScalarField", "name": "page", "storageKey": null }, -v8 = [ - (v6/*: any*/), - (v7/*: any*/), +v10 = [ + (v8/*: any*/), + (v9/*: any*/), { "alias": null, "args": null, @@ -325,28 +358,28 @@ v8 = [ "storageKey": null } ], -v9 = { +v11 = { "alias": null, "args": null, "kind": "ScalarField", "name": "href", "storageKey": null }, -v10 = [ +v12 = [ { "kind": "Literal", "name": "shallow", "value": true } ], -v11 = { +v13 = { "alias": null, "args": null, "kind": "ScalarField", "name": "name", "storageKey": null }, -v12 = [ +v14 = [ { "alias": null, "args": null, @@ -370,9 +403,11 @@ return { "name": "partner", "plural": false, "selections": [ + (v2/*: any*/), + (v3/*: any*/), { "args": [ - (v2/*: any*/) + (v4/*: any*/) ], "kind": "FragmentSpread", "name": "Works_partner" @@ -397,8 +432,8 @@ return { "name": "partner", "plural": false, "selections": [ - (v3/*: any*/), - (v4/*: any*/), + (v5/*: any*/), + (v6/*: any*/), { "alias": "filtered_artworks", "args": [ @@ -407,14 +442,14 @@ return { "name": "first", "value": 30 }, - (v2/*: any*/) + (v4/*: any*/) ], "concreteType": "FilterArtworksConnection", "kind": "LinkedField", "name": "filterArtworksConnection", "plural": false, "selections": [ - (v5/*: any*/), + (v7/*: any*/), { "alias": null, "args": null, @@ -455,7 +490,7 @@ return { "kind": "LinkedField", "name": "around", "plural": true, - "selections": (v8/*: any*/), + "selections": (v10/*: any*/), "storageKey": null }, { @@ -465,7 +500,7 @@ return { "kind": "LinkedField", "name": "first", "plural": false, - "selections": (v8/*: any*/), + "selections": (v10/*: any*/), "storageKey": null }, { @@ -475,7 +510,7 @@ return { "kind": "LinkedField", "name": "last", "plural": false, - "selections": (v8/*: any*/), + "selections": (v10/*: any*/), "storageKey": null }, { @@ -486,8 +521,8 @@ return { "name": "previous", "plural": false, "selections": [ - (v6/*: any*/), - (v7/*: any*/) + (v8/*: any*/), + (v9/*: any*/) ], "storageKey": null } @@ -510,10 +545,10 @@ return { "name": "node", "plural": false, "selections": [ + (v7/*: any*/), (v5/*: any*/), - (v3/*: any*/), - (v9/*: any*/), - (v4/*: any*/), + (v11/*: any*/), + (v6/*: any*/), { "alias": null, "args": null, @@ -589,15 +624,15 @@ return { }, { "alias": null, - "args": (v10/*: any*/), + "args": (v12/*: any*/), "concreteType": "Artist", "kind": "LinkedField", "name": "artists", "plural": true, "selections": [ - (v5/*: any*/), - (v9/*: any*/), - (v11/*: any*/) + (v7/*: any*/), + (v11/*: any*/), + (v13/*: any*/) ], "storageKey": "artists(shallow:true)" }, @@ -610,15 +645,15 @@ return { }, { "alias": null, - "args": (v10/*: any*/), + "args": (v12/*: any*/), "concreteType": "Partner", "kind": "LinkedField", "name": "partner", "plural": false, "selections": [ + (v13/*: any*/), (v11/*: any*/), - (v9/*: any*/), - (v5/*: any*/), + (v7/*: any*/), { "alias": null, "args": null, @@ -651,7 +686,7 @@ return { "name": "isClosed", "storageKey": null }, - (v5/*: any*/), + (v7/*: any*/), { "alias": "is_live_open", "args": null, @@ -716,7 +751,7 @@ return { "kind": "LinkedField", "name": "highestBid", "plural": false, - "selections": (v12/*: any*/), + "selections": (v14/*: any*/), "storageKey": null }, { @@ -726,10 +761,10 @@ return { "kind": "LinkedField", "name": "openingBid", "plural": false, - "selections": (v12/*: any*/), + "selections": (v14/*: any*/), "storageKey": null }, - (v5/*: any*/) + (v7/*: any*/) ], "storageKey": null }, @@ -757,14 +792,16 @@ return { ], "storageKey": null }, - (v5/*: any*/) + (v7/*: any*/) ], "storageKey": null } ], "storageKey": null }, - (v5/*: any*/) + (v2/*: any*/), + (v3/*: any*/), + (v7/*: any*/) ], "storageKey": null } @@ -775,9 +812,9 @@ return { "metadata": {}, "name": "partnerRoutes_WorksQuery", "operationKind": "query", - "text": "query partnerRoutes_WorksQuery(\n $partnerId: String!\n $input: FilterArtworksInput\n) {\n partner(id: $partnerId) @principalField {\n ...Works_partner_2VV6jB\n id\n }\n}\n\nfragment ArtworkFilterArtworkGrid_filtered_artworks on FilterArtworksConnection {\n id\n pageInfo {\n hasNextPage\n endCursor\n }\n pageCursors {\n ...Pagination_pageCursors\n }\n edges {\n node {\n id\n }\n }\n ...ArtworkGrid_artworks\n}\n\nfragment ArtworkGrid_artworks on ArtworkConnectionInterface {\n edges {\n __typename\n node {\n id\n slug\n href\n internalID\n image {\n aspect_ratio: aspectRatio\n }\n ...GridItem_artwork\n }\n ... on Node {\n id\n }\n }\n}\n\nfragment Badge_artwork on Artwork {\n is_biddable: isBiddable\n href\n sale {\n is_preview: isPreview\n display_timely_at: displayTimelyAt\n id\n }\n}\n\nfragment Contact_artwork on Artwork {\n href\n is_inquireable: isInquireable\n sale {\n is_auction: isAuction\n is_live_open: isLiveOpen\n is_open: isOpen\n is_closed: isClosed\n id\n }\n partner(shallow: true) {\n type\n id\n }\n sale_artwork: saleArtwork {\n highest_bid: highestBid {\n display\n }\n opening_bid: openingBid {\n display\n }\n counts {\n bidder_positions: bidderPositions\n }\n id\n }\n}\n\nfragment Details_artwork on Artwork {\n href\n title\n date\n sale_message: saleMessage\n cultural_maker: culturalMaker\n artists(shallow: true) {\n id\n href\n name\n }\n collecting_institution: collectingInstitution\n partner(shallow: true) {\n name\n href\n id\n }\n sale {\n is_auction: isAuction\n is_closed: isClosed\n id\n }\n sale_artwork: saleArtwork {\n counts {\n bidder_positions: bidderPositions\n }\n highest_bid: highestBid {\n display\n }\n opening_bid: openingBid {\n display\n }\n id\n }\n}\n\nfragment GridItem_artwork on Artwork {\n internalID\n title\n image_title: imageTitle\n image {\n placeholder\n url(version: \"large\")\n aspect_ratio: aspectRatio\n }\n href\n ...Metadata_artwork\n ...SaveButton_artwork\n ...Badge_artwork\n}\n\nfragment Metadata_artwork on Artwork {\n ...Details_artwork\n ...Contact_artwork\n href\n}\n\nfragment Pagination_pageCursors on PageCursors {\n around {\n cursor\n page\n isCurrent\n }\n first {\n cursor\n page\n isCurrent\n }\n last {\n cursor\n page\n isCurrent\n }\n previous {\n cursor\n page\n }\n}\n\nfragment SaveButton_artwork on Artwork {\n id\n internalID\n slug\n is_saved: isSaved\n title\n}\n\nfragment Works_partner_2VV6jB on Partner {\n slug\n internalID\n filtered_artworks: filterArtworksConnection(first: 30, input: $input) {\n id\n ...ArtworkFilterArtworkGrid_filtered_artworks\n }\n}\n" + "text": "query partnerRoutes_WorksQuery(\n $partnerId: String!\n $input: FilterArtworksInput\n) {\n partner(id: $partnerId) @principalField {\n ...Works_partner_2VV6jB\n displayWorksSection\n counts {\n eligibleArtworks\n }\n id\n }\n}\n\nfragment ArtworkFilterArtworkGrid_filtered_artworks on FilterArtworksConnection {\n id\n pageInfo {\n hasNextPage\n endCursor\n }\n pageCursors {\n ...Pagination_pageCursors\n }\n edges {\n node {\n id\n }\n }\n ...ArtworkGrid_artworks\n}\n\nfragment ArtworkGrid_artworks on ArtworkConnectionInterface {\n edges {\n __typename\n node {\n id\n slug\n href\n internalID\n image {\n aspect_ratio: aspectRatio\n }\n ...GridItem_artwork\n }\n ... on Node {\n id\n }\n }\n}\n\nfragment Badge_artwork on Artwork {\n is_biddable: isBiddable\n href\n sale {\n is_preview: isPreview\n display_timely_at: displayTimelyAt\n id\n }\n}\n\nfragment Contact_artwork on Artwork {\n href\n is_inquireable: isInquireable\n sale {\n is_auction: isAuction\n is_live_open: isLiveOpen\n is_open: isOpen\n is_closed: isClosed\n id\n }\n partner(shallow: true) {\n type\n id\n }\n sale_artwork: saleArtwork {\n highest_bid: highestBid {\n display\n }\n opening_bid: openingBid {\n display\n }\n counts {\n bidder_positions: bidderPositions\n }\n id\n }\n}\n\nfragment Details_artwork on Artwork {\n href\n title\n date\n sale_message: saleMessage\n cultural_maker: culturalMaker\n artists(shallow: true) {\n id\n href\n name\n }\n collecting_institution: collectingInstitution\n partner(shallow: true) {\n name\n href\n id\n }\n sale {\n is_auction: isAuction\n is_closed: isClosed\n id\n }\n sale_artwork: saleArtwork {\n counts {\n bidder_positions: bidderPositions\n }\n highest_bid: highestBid {\n display\n }\n opening_bid: openingBid {\n display\n }\n id\n }\n}\n\nfragment GridItem_artwork on Artwork {\n internalID\n title\n image_title: imageTitle\n image {\n placeholder\n url(version: \"large\")\n aspect_ratio: aspectRatio\n }\n href\n ...Metadata_artwork\n ...SaveButton_artwork\n ...Badge_artwork\n}\n\nfragment Metadata_artwork on Artwork {\n ...Details_artwork\n ...Contact_artwork\n href\n}\n\nfragment Pagination_pageCursors on PageCursors {\n around {\n cursor\n page\n isCurrent\n }\n first {\n cursor\n page\n isCurrent\n }\n last {\n cursor\n page\n isCurrent\n }\n previous {\n cursor\n page\n }\n}\n\nfragment SaveButton_artwork on Artwork {\n id\n internalID\n slug\n is_saved: isSaved\n title\n}\n\nfragment Works_partner_2VV6jB on Partner {\n slug\n internalID\n filtered_artworks: filterArtworksConnection(first: 30, input: $input) {\n id\n ...ArtworkFilterArtworkGrid_filtered_artworks\n }\n}\n" } }; })(); -(node as any).hash = '44662cbc0ebd9b017296e5798e142c86'; +(node as any).hash = '12a6ff8ed103c7b7e65f770e2857c726'; export default node;