Skip to content

Commit 4b76b38

Browse files
committed
added conditional display logic
1 parent 6a572e7 commit 4b76b38

File tree

4 files changed

+39
-32
lines changed

4 files changed

+39
-32
lines changed

packages/grant-explorer/src/features/api/rounds.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ export const useRounds = (
3131
}),
3232
]);
3333

34-
rounds?.map((round) => {
35-
console.log("rounds.ts applications: " + round?.applications?.length);
36-
});
37-
3834
return rounds.filter(
3935
(round) =>
4036
!spamRounds[round.chainId]?.[round.id.toLowerCase()] &&

packages/grant-explorer/src/features/discovery/ExploreRoundsPage.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ const ExploreRoundsPage = () => {
4747
className="flex-wrap"
4848
action={<RoundsFilter />}
4949
>
50-
<div>
51-
{rounds?.data?.map((round) => {
52-
return <p>{"applications: " + round?.applications?.length}</p>;
53-
})}
54-
</div>
55-
5650
<RoundsGrid {...rounds} loadingCount={6} roundType="all" />
5751
</LandingSection>
5852
</GradientLayout>

packages/grant-explorer/src/features/discovery/RoundCard.tsx

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { RoundDaysDetails } from "./RoundDaysDetails";
1818
import { RoundMatchAmountBadge } from "./RoundMatchAmountBadge";
1919
import { RoundStrategyBadge } from "./RoundStrategyBadge";
2020
import { RoundTimeBadge } from "./RoundTimeBadge";
21+
import { RoundProjects } from "./RoundProjects";
2122
import { Application, RoundGetRound } from "data-layer";
2223
import { parseChainIdIntoResult, stringToBlobUrl } from "common/dist/chains";
2324

@@ -120,16 +121,6 @@ const RoundCard = ({ round, index, roundType }: RoundCardProps) => {
120121

121122
const trackEventValue = getTrackEventValue(roundType, index);
122123

123-
applications.map((application) => {
124-
console.log("applications: " + application.id);
125-
126-
const app = application as Application;
127-
console.log("casted: ", JSON.stringify(app));
128-
// return (
129-
// <p key={application.id}>{application.id}</p>
130-
// )
131-
});
132-
133124
return (
134125
<BasicCard className="w-full">
135126
<a
@@ -172,18 +163,11 @@ const RoundCard = ({ round, index, roundType }: RoundCardProps) => {
172163
<div className="border-t" />
173164
<div className="flex justify-between">
174165
<div className="flex gap-2">
175-
<Badge
176-
disabled={totalApplicationCount === 0}
177-
data-testid="approved-applications-count"
178-
>
179-
{totalApplicationCount} applications
180-
</Badge>
181-
<Badge
182-
disabled={approvedApplications === 0}
183-
data-testid="approved-applications-count"
184-
>
185-
{approvedApplications} projects
186-
</Badge>
166+
<RoundProjects
167+
roundStates={roundStates}
168+
totalApplicationCount={totalApplicationCount}
169+
approvedApplications={approvedApplications}
170+
/>
187171
{strategyName !== ROUND_PAYOUT_DIRECT && (
188172
<RoundMatchAmountBadge
189173
chainId={chainId}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Badge } from "../common/styles";
2+
3+
interface RoundProjectsProps {
4+
roundStates: Array<"active" | "accepting-applications" | "ended"> | undefined;
5+
totalApplicationCount: number;
6+
approvedApplications: number;
7+
}
8+
9+
export const RoundProjects: React.FC<RoundProjectsProps> = ({
10+
roundStates,
11+
totalApplicationCount,
12+
approvedApplications,
13+
}) => {
14+
if (roundStates?.includes("accepting-applications")) {
15+
return (
16+
<Badge
17+
disabled={totalApplicationCount === 0}
18+
data-testid="approved-applications-count"
19+
>
20+
{totalApplicationCount} applications
21+
</Badge>
22+
);
23+
} else {
24+
return (
25+
<Badge
26+
disabled={approvedApplications === 0}
27+
data-testid="approved-applications-count"
28+
>
29+
{approvedApplications} projects
30+
</Badge>
31+
);
32+
}
33+
};

0 commit comments

Comments
 (0)