MCPcopy Create free account
hub / github.com/dailydotdev/apps / SquadRoute

Function SquadRoute

packages/webapp/components/squads/SquadRoute.tsx:47–84  ·  view source on GitHub ↗
({
  handle,
  initialSquad,
  feature,
  children,
}: SquadRouteComponentProps)

Source from the content-addressed store, hash-verified

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.
47export 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
86interface SquadRouteParams extends ParsedUrlQuery {
87 handle: string;

Callers

nothing calls this directly

Calls 7

useAuthContextFunction · 0.90
useSquadFunction · 0.90
isCompanyPageFunction · 0.90
isStaffViewerFunction · 0.90
getSquadViewerFunction · 0.90
usePauseBootPopupsFunction · 0.90
hasSquadFeatureFunction · 0.90

Tested by

no test coverage detected