Skip to content

Commit

Permalink
decorate revalidated campaign with isYesNo
Browse files Browse the repository at this point in the history
  • Loading branch information
ogous committed Jan 27, 2025
1 parent 4e4453b commit a620dcb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions web/src/components/detail/detailWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ export default function DetailWrapper({
const { data } = useQuery({
queryKey: ["campaign", initialData.identifier],
queryFn: async () => {
const res = await requestCampaignById(initialData.identifier);
return res as CampaignDetail;
const res = (await requestCampaignById(initialData.identifier))!;
const campaign = Object.assign(res, {
isYesNo:
res.outcomes.length === 2 &&
res.outcomes.findIndex((outcome) => outcome.name === "Yes") !== -1 &&
res.outcomes.findIndex((outcome) => outcome.name === "No") !== -1,
});
return campaign as CampaignDetail;
},
initialData,
});
Expand Down

0 comments on commit a620dcb

Please sign in to comment.