Skip to content

Commit

Permalink
fix: squads ssr when referring user is present (#3863)
Browse files Browse the repository at this point in the history
  • Loading branch information
sshanzel authored Nov 21, 2024
1 parent 08ef4e4 commit 4dfe785
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/webapp/pages/squads/[handle]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
import {
BasicSourceMember,
Squad,
Source,
} from '@dailydotdev/shared/src/graphql/sources';
import Unauthorized from '@dailydotdev/shared/src/components/errors/Unauthorized';
import { useQuery } from '@tanstack/react-query';
Expand Down Expand Up @@ -273,9 +274,9 @@ export async function getServerSideProps({
};

try {
const promises = [];

promises.push(getSquadStaticFields(handle));
const promises: [Promise<Source | Squad>, Promise<PublicProfile>?] = [
getSquadStaticFields(handle),
];

if (userId && campaign) {
promises.push(
Expand All @@ -286,6 +287,7 @@ export async function getServerSideProps({
id: userId,
},
)
.then((data) => data?.user)
.catch(() => undefined),
);
}
Expand Down Expand Up @@ -317,8 +319,8 @@ export async function getServerSideProps({
props: {
seo,
handle,
initialData: squad,
referringUser: referringUser?.user || null,
initialData: squad as Squad,
referringUser: referringUser || null,
},
};
} catch (err) {
Expand Down

0 comments on commit 4dfe785

Please sign in to comment.