Skip to content

Commit 1e65ea2

Browse files
committed
Improve network eligibility status
1 parent 8c854a4 commit 1e65ea2

3 files changed

Lines changed: 44 additions & 34 deletions

File tree

apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/program-status-badge.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export const ProgramNetworkStatusBadges = {
2121
};
2222

2323
const notEligibleBadge = {
24-
variant: "new" as const,
25-
className: "text-blue-600 bg-blue-100",
24+
variant: "neutral" as const,
25+
className: "text-neutral-600 bg-neutral-100",
2626
icon: Lock,
2727
label: "Not eligible",
2828
};
@@ -49,7 +49,9 @@ export function ProgramStatusBadge({
4949

5050
const statusBadge = programEnrollmentStatus
5151
? ProgramNetworkStatusBadges[programEnrollmentStatus]
52-
: reason === "requirementsNotMet"
52+
: (partner?.networkStatus &&
53+
!["approved", "trusted"].includes(partner.networkStatus)) ||
54+
reason === "requirementsNotMet"
5355
? notEligibleBadge
5456
: null;
5557

apps/web/ui/partners/partner-network/network-status-badges.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export const NetworkStatusBadges = {
3131
},
3232
rejected: {
3333
partnerTooltip: {
34-
content: "Your Dub Partner Network application was rejected.",
34+
content:
35+
"Your Dub Partner Network application was not approved. You are not eligible to apply to this program.",
3536
cta: "Rejected",
3637
},
3738
label: "Rejected",

apps/web/ui/partners/program-eligibility-card.tsx

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,43 @@ import { evaluateCondition } from "@/lib/partners/evaluate-application-requireme
44
import usePartnerProfile from "@/lib/swr/use-partner-profile";
55
import useProgramEnrollment from "@/lib/swr/use-program-enrollment";
66
import { EligibilityConditionDB } from "@/lib/types";
7+
import { CountryFlag } from "@/ui/shared/country-flag";
78
import { Lock } from "@dub/ui/icons";
89
import { COUNTRIES } from "@dub/utils";
10+
import { ReactNode } from "react";
911

10-
function oxfordJoin(items: string[]): string {
11-
if (items.length === 0) return "";
12-
if (items.length === 1) return items[0];
13-
if (items.length === 2) return `${items[0]} or ${items[1]}`;
14-
return `${items.slice(0, -1).join(", ")}, or ${items[items.length - 1]}`;
15-
}
16-
17-
function formatConditionText(condition: EligibilityConditionDB): string {
12+
function formatConditionContent(
13+
condition: EligibilityConditionDB,
14+
): ReactNode | null {
1815
if (condition.key === "country") {
19-
const countryNames = condition.value.map((code) => COUNTRIES[code] ?? code);
20-
const joined = oxfordJoin(countryNames);
16+
const intro =
17+
condition.operator === "is"
18+
? "You can only apply to this program if you are from the following countries:"
19+
: "You cannot apply to this program if you are from the following countries:";
2120

22-
if (condition.operator === "is") {
23-
return `Your country is ${joined}`;
24-
} else {
25-
return `Your country is not ${joined}`;
26-
}
21+
return (
22+
<div className="space-y-2 text-sm text-blue-800">
23+
<p>{intro}</p>
24+
<div className="flex flex-wrap gap-1.5">
25+
{condition.value.map((code) => (
26+
<span
27+
key={code}
28+
className="inline-flex h-7 items-center gap-1.5 rounded-full bg-blue-100 px-2.5 text-xs font-medium text-blue-900"
29+
>
30+
<CountryFlag countryCode={code} className="size-3.5 rounded-full" />
31+
{COUNTRIES[code] ?? code}
32+
</span>
33+
))}
34+
</div>
35+
</div>
36+
);
2737
}
2838

2939
// emailDomain — commented out, preserved for future use
3040
// if (condition.key === "emailDomain") {
31-
// const joined = oxfordJoin(condition.value);
32-
// if (condition.operator === "is") {
33-
// return `Your email domain is ${joined}`;
34-
// } else {
35-
// return `Your email domain is not ${joined}`;
36-
// }
37-
// }
41+
// ...
3842

39-
return "";
43+
return null;
4044
}
4145

4246
export function ProgramEligibilityCard({
@@ -67,9 +71,14 @@ export function ProgramEligibilityCard({
6771
}),
6872
);
6973

70-
const unmetWithText = unmet.map(formatConditionText).filter(Boolean);
74+
const unmetConditions = unmet
75+
.map((condition) => ({
76+
condition,
77+
content: formatConditionContent(condition),
78+
}))
79+
.filter(({ content }) => content !== null);
7180

72-
if (unmetWithText.length === 0) return null;
81+
if (unmetConditions.length === 0) return null;
7382

7483
return (
7584
<div className="mt-4 space-y-3 rounded-[10px] border border-blue-200 bg-blue-50 p-4">
@@ -78,11 +87,9 @@ export function ProgramEligibilityCard({
7887
Program eligibility
7988
</div>
8089

81-
<ul className="list-disc space-y-1 pl-5 text-sm text-blue-800">
82-
{unmetWithText.map((text, i) => (
83-
<li key={i}>{text}</li>
84-
))}
85-
</ul>
90+
{unmetConditions.map(({ condition, content }) => (
91+
<div key={`${condition.key}-${condition.operator}`}>{content}</div>
92+
))}
8693
</div>
8794
);
8895
}

0 commit comments

Comments
 (0)