Skip to content

Commit 4fcd4c2

Browse files
committed
fix: par-799
1 parent 1cc8ce2 commit 4fcd4c2

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

packages/data-layer/src/data-layer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,8 @@ export class DataLayer {
770770
id: round.strategyAddress,
771771
strategyName: round.strategyName,
772772
},
773+
applicationQuestions:
774+
round.applicationMetadata?.applicationSchema?.questions,
773775
approvedProjects: projects,
774776
uniqueDonorsCount: round.uniqueDonorsCount,
775777
},

packages/data-layer/src/data.types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { VerifiableCredential } from "@gitcoinco/passport-sdk-types";
22
import { Address } from "viem";
3-
import { RoundApplicationMetadata } from "./roundApplication.types";
3+
import {
4+
RoundApplicationMetadata,
5+
RoundApplicationQuestion,
6+
} from "./roundApplication.types";
47
export type RoundPayoutType =
58
| "allov1.Direct"
69
| "allov1.QF"
@@ -256,6 +259,7 @@ export type RoundWithApplications = Omit<RoundGetRound, "applications"> & {
256259
export type RoundForExplorer = Omit<RoundGetRound, "applications"> & {
257260
applications: (Application & { anchorAddress: Address })[];
258261
uniqueDonorsCount?: number;
262+
applicationMetadata?: RoundApplicationMetadata;
259263
};
260264

261265
export type BaseDonorValues = {
@@ -471,6 +475,8 @@ export interface Round {
471475
info: string;
472476
};
473477
};
478+
479+
applicationQuestions?: RoundApplicationQuestion[];
474480
/**
475481
* Pointer to round metadata in a decentralized storage e.g IPFS, Ceramic etc.
476482
*/

packages/grant-explorer/src/features/round/ViewProjectDetails.tsx

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,16 @@ import { useGap } from "../api/gap";
4242
import { StatList } from "./OSO/ImpactStats";
4343
import { useOSO } from "../api/oso";
4444
import { CheckIcon, ShoppingCartIcon } from "@heroicons/react/24/outline";
45-
import { Application, useDataLayer } from "data-layer";
45+
import {
46+
Application,
47+
BaseQuestion,
48+
Round,
49+
RoundApplicationQuestion,
50+
useDataLayer,
51+
} from "data-layer";
4652
import { DefaultLayout } from "../common/DefaultLayout";
4753
import {
4854
mapApplicationToProject,
49-
mapApplicationToRound,
5055
useApplication,
5156
} from "../projects/hooks/useApplication";
5257
import { PassportWidget } from "../common/PassportWidget";
@@ -114,9 +119,9 @@ export default function ViewProjectDetails() {
114119
},
115120
dataLayer
116121
);
122+
const { round } = useRoundById(Number(chainId), roundId);
117123

118124
const projectToRender = application && mapApplicationToProject(application);
119-
const round = application && mapApplicationToRound(application);
120125
round && (round.chainId = Number(chainId));
121126
const isSybilDefenseEnabled =
122127
round?.roundMetadata?.quadraticFundingConfig?.sybilDefense === true ||
@@ -207,6 +212,7 @@ export default function ViewProjectDetails() {
207212
<Detail text={description} testID="project-metadata" />
208213
<ApplicationFormAnswers
209214
answers={projectToRender.grantApplicationFormAnswers}
215+
round={round}
210216
/>
211217
</>
212218
) : (
@@ -234,7 +240,7 @@ export default function ViewProjectDetails() {
234240
),
235241
},
236242
],
237-
[stats, grants, projectToRender, description, isLoading]
243+
[stats, grants, projectToRender, description, round, impacts]
238244
);
239245

240246
const handleTabChange = (tabIndex: number) => {
@@ -460,9 +466,27 @@ function Detail(props: { text: string; testID: string }) {
460466

461467
function ApplicationFormAnswers(props: {
462468
answers: GrantApplicationFormAnswer[];
469+
round: Round | undefined;
463470
}) {
464-
// only show answers that are not empty and are not marked as hidden
465-
const answers = props.answers.filter((a) => !!a.answer && !a.hidden);
471+
const roundQuestions = props.round?.applicationQuestions as (BaseQuestion &
472+
RoundApplicationQuestion)[];
473+
if (!roundQuestions) {
474+
return null;
475+
}
476+
let answers = roundQuestions
477+
.filter((q) => !q.hidden && !q.encrypted)
478+
.map((q) => ({
479+
...props.answers.find(
480+
(a) =>
481+
a.questionId === q.id && a.question === q.title && a.type === q.type
482+
),
483+
question: q.title,
484+
}))
485+
.filter((a): a is GrantApplicationFormAnswer => !!a.answer);
486+
487+
if (answers.length === 0) {
488+
answers = props.answers.filter((a) => !!a.answer && !a.hidden);
489+
}
466490

467491
if (answers.length === 0) {
468492
return null;

0 commit comments

Comments
 (0)