({
handle,
initialSquad,
feature,
children,
}: SquadRouteComponentProps)
| 45 | // Loads the squad for a squad route and hands every surface the same page |
| 46 | // context: the private wall, not found, and the skeleton live here once. |
| 47 | export const SquadRoute = ({ |
| 48 | handle, |
| 49 | initialSquad, |
| 50 | feature, |
| 51 | children, |
| 52 | }: SquadRouteComponentProps): ReactElement => { |
| 53 | const { isLoggedIn } = useAuthContext(); |
| 54 | const { squad, isFetched, isForbidden } = useSquad({ handle }); |
| 55 | const current = squad ?? initialSquad; |
| 56 | // Admins and moderators setting up a company page get no achievement or |
| 57 | // other boot pop-ups over it; they open on the next page instead. Held |
| 58 | // until the viewer's own copy of the squad says who they are. |
| 59 | const isSettled = !!squad || isFetched || isForbidden; |
| 60 | const isSettingUpCompany = |
| 61 | !!squad && |
| 62 | isCompanyPage(squad) && |
| 63 | isStaffViewer(getSquadViewer(squad, isLoggedIn)); |
| 64 | usePauseBootPopups(!isSettled || isSettingUpCompany); |
| 65 | |
| 66 | if (isForbidden) { |
| 67 | return <SquadPrivateWall />; |
| 68 | } |
| 69 | |
| 70 | if (!current) { |
| 71 | return isFetched ? <Custom404 /> : <SquadPageSkeleton />; |
| 72 | } |
| 73 | |
| 74 | if (feature && !hasSquadFeature(current, feature)) { |
| 75 | return <Custom404 />; |
| 76 | } |
| 77 | |
| 78 | return ( |
| 79 | <SquadPageContextProvider squad={current} isViewerReady={!!squad}> |
| 80 | {children} |
| 81 | {isSettingUpCompany && <CompanyPageHotjarEvents squad={squad} />} |
| 82 | </SquadPageContextProvider> |
| 83 | ); |
| 84 | }; |
| 85 | |
| 86 | interface SquadRouteParams extends ParsedUrlQuery { |
| 87 | handle: string; |
nothing calls this directly
no test coverage detected