From bdb0b56d688fabfac4e5645ef9bc234ab4e547c9 Mon Sep 17 00:00:00 2001 From: Lucian Date: Tue, 17 Dec 2024 12:57:00 -0700 Subject: [PATCH] fix(app): making distinction between technically possible points and points to tell the user about (#3148) * fix(app): making distinction between technically possible points and points to tell the user about * chore(platforms): updating holonym sidebar language --- app/__test-fixtures__/contextTestHelpers.tsx | 5 +++++ app/__tests__/components/CardList.test.tsx | 14 ++++++++++++++ app/components/CardList.tsx | 4 ++-- app/components/PlatformCard.tsx | 6 +++--- app/components/PlatformDetails.tsx | 2 +- app/context/scorerContext.tsx | 12 +++++++++++- platforms/src/Holonym/App-Bindings.tsx | 2 +- platforms/src/Holonym/Providers-config.ts | 5 ++++- 8 files changed, 41 insertions(+), 9 deletions(-) diff --git a/app/__test-fixtures__/contextTestHelpers.tsx b/app/__test-fixtures__/contextTestHelpers.tsx index 60f03efe0b..40b316416d 100644 --- a/app/__test-fixtures__/contextTestHelpers.tsx +++ b/app/__test-fixtures__/contextTestHelpers.tsx @@ -151,6 +151,7 @@ export const scorerContext = { connectMessage: "Verify amount", isEVM: true, possiblePoints: 7.4399999999999995, + displayPossiblePoints: 7.4399999999999995, earnedPoints: 0, }, { @@ -161,6 +162,7 @@ export const scorerContext = { connectMessage: "Connect Account", isEVM: true, possiblePoints: 12.93, + displayPossiblePoints: 12.93, earnedPoints: 0, }, { @@ -170,6 +172,7 @@ export const scorerContext = { description: "Connect your existing Twitter account to verify.", connectMessage: "Connect Account", possiblePoints: 3.63, + displayPossiblePoints: 3.63, earnedPoints: 3.63, }, { @@ -179,6 +182,7 @@ export const scorerContext = { description: "Connect your existing Discord account to verify.", connectMessage: "Connect Account", possiblePoints: 0.689, + displayPossiblePoints: 0.689, earnedPoints: 0, }, { @@ -188,6 +192,7 @@ export const scorerContext = { description: "Connect your existing Google Account to verify", connectMessage: "Connect Account", possiblePoints: 2.25, + displayPossiblePoints: 2.25, earnedPoints: 1, }, ], diff --git a/app/__tests__/components/CardList.test.tsx b/app/__tests__/components/CardList.test.tsx index 76907b6b5e..afccb840ed 100644 --- a/app/__tests__/components/CardList.test.tsx +++ b/app/__tests__/components/CardList.test.tsx @@ -55,6 +55,7 @@ let categoryProps: CategoryProps = { name: "Github", platform: "Github", possiblePoints: 7.0600000000000005, + displayPossiblePoints: 7.0600000000000005, website: "https://github.com", }, { @@ -65,6 +66,7 @@ let categoryProps: CategoryProps = { name: "Google", platform: "Google", possiblePoints: 0.525, + displayPossiblePoints: 0.525, website: "https://www.google.com/", }, { @@ -75,6 +77,7 @@ let categoryProps: CategoryProps = { name: "Discord", platform: "Discord", possiblePoints: 0.516, + displayPossiblePoints: 0.516, website: "https://discord.com/", }, ], @@ -147,6 +150,7 @@ describe("", () => { description: "ETH", connectMessage: "ETH", possiblePoints: 10, + displayPossiblePoints: 10, earnedPoints: 7, }} onOpen={mockOnOpen} @@ -187,6 +191,7 @@ describe("", () => { connectMessage: "Verify", isEVM: true, possiblePoints: 100, + displayPossiblePoints: 100, earnedPoints: 100, }, ] as PlatformScoreSpec[], @@ -241,6 +246,7 @@ describe("show/hide tests", () => { scoredPlatforms: [ { possiblePoints: 10, + displayPossiblePoints: 10, earnedPoints: 0, platform: "TestPlatform" as PLATFORM_ID, name: "Test Platform", @@ -285,6 +291,7 @@ describe("show/hide tests", () => { scoredPlatforms: [ { possiblePoints: 10, + displayPossiblePoints: 10, earnedPoints: 5, platform: "TestPlatform" as PLATFORM_ID, name: "Test Platform", @@ -340,6 +347,7 @@ describe("show/hide tests", () => { scoredPlatforms: [ { possiblePoints: 10, + displayPossiblePoints: 10, earnedPoints: 0, platform: "NFT" as PLATFORM_ID, name: "NFT", @@ -379,6 +387,7 @@ describe("show/hide tests", () => { scoredPlatforms: [ { possiblePoints: 10, + displayPossiblePoints: 10, earnedPoints: 10, platform: "AllowList", name: "Allow List Platform", @@ -421,6 +430,7 @@ describe("show/hide tests", () => { scoredPlatforms: [ { possiblePoints: 10, + displayPossiblePoints: 10, earnedPoints: 0, platform: "AllowList", name: "Allow List Platform", @@ -456,6 +466,7 @@ describe("show/hide tests", () => { scoredPlatforms: [ { possiblePoints: 10, + displayPossiblePoints: 10, earnedPoints: 2, ...platforms["GtcStaking"].PlatformDetails, }, @@ -484,6 +495,7 @@ describe("show/hide tests", () => { scoredPlatforms: [ { possiblePoints: 10, + displayPossiblePoints: 10, earnedPoints: 2, ...platforms["GtcStaking"].PlatformDetails, }, @@ -506,6 +518,7 @@ describe("show/hide tests", () => { scoredPlatforms: [ { possiblePoints: 10, + displayPossiblePoints: 10, earnedPoints: 2, ...platforms["GtcStaking"].PlatformDetails, }, @@ -528,6 +541,7 @@ describe("show/hide tests", () => { scoredPlatforms: [ { possiblePoints: 0, + displayPossiblePoints: 10, earnedPoints: 0, ...platforms["GtcStaking"].PlatformDetails, }, diff --git a/app/components/CardList.tsx b/app/components/CardList.tsx index 07ec81124f..913967319d 100644 --- a/app/components/CardList.tsx +++ b/app/components/CardList.tsx @@ -109,8 +109,8 @@ export const CardList = ({ className, isLoading = false, initialOpen = true }: C ); const sortedPlatforms = [ - ...unverified.sort((a, b) => b.possiblePoints - a.possiblePoints), - ...verified.sort((a, b) => b.possiblePoints - b.earnedPoints - (a.possiblePoints - a.earnedPoints)), + ...unverified.sort((a, b) => b.displayPossiblePoints - a.displayPossiblePoints), + ...verified.sort((a, b) => b.displayPossiblePoints - b.earnedPoints - (a.displayPossiblePoints - a.earnedPoints)), ]; const groupedPlatforms: { diff --git a/app/components/PlatformCard.tsx b/app/components/PlatformCard.tsx index c659136ddc..c8eb76535e 100644 --- a/app/components/PlatformCard.tsx +++ b/app/components/PlatformCard.tsx @@ -71,7 +71,7 @@ const DefaultStamp = ({ idx, platform, className, onClick, variant }: StampProps )}

- {+Math.max(platform.possiblePoints - platform.earnedPoints, 0).toFixed(1)} + {+Math.max(platform.displayPossiblePoints - platform.earnedPoints, 0).toFixed(1)}

Available Points

@@ -169,7 +169,7 @@ const VerifiedStamp = ({ idx, platform, daysUntilExpiration, className, onClick
{+platform.earnedPoints.toFixed(1)}
@@ -253,7 +253,7 @@ const ExpiredStamp = ({ idx, platform, daysUntilExpiration, className, onClick }
{+platform.earnedPoints.toFixed(1)}
diff --git a/app/components/PlatformDetails.tsx b/app/components/PlatformDetails.tsx index 05ed77ee9d..4a4c1d03dd 100644 --- a/app/components/PlatformDetails.tsx +++ b/app/components/PlatformDetails.tsx @@ -139,7 +139,7 @@ export const PlatformDetails = ({ const hasStamps = platformPassportData && !!platformPassportData.length; const earnedPoints = currentPlatformScoreSpec?.earnedPoints || 0; - const possiblePoints = currentPlatformScoreSpec?.possiblePoints || 0; + const possiblePoints = currentPlatformScoreSpec?.displayPossiblePoints || 0; const pointsGained = +earnedPoints.toFixed(1); const pointsAvailable = +Math.max(possiblePoints - earnedPoints, 0).toFixed(1); diff --git a/app/context/scorerContext.tsx b/app/context/scorerContext.tsx index 98b9ec4eb2..473487bb06 100644 --- a/app/context/scorerContext.tsx +++ b/app/context/scorerContext.tsx @@ -32,6 +32,9 @@ export type StampScores = { export type PlatformScoreSpec = PlatformSpec & { possiblePoints: number; + // Possible points that we want to tell the user + // about (i.e. excluding deprecated providers) + displayPossiblePoints: number; earnedPoints: number; }; @@ -214,6 +217,10 @@ export const ScorerContextProvider = ({ children }: { children: any }) => { const scoredPlatforms = [...platforms.keys()].map((platformId) => { const providers = platformProviders[platformId]; const possiblePoints = providers.reduce( + (acc, { name }) => acc + (parseFloat(stampWeights[name] || "0") || 0), + 0 + ); + const displayPossiblePoints = providers.reduce( (acc, { name, isDeprecated }) => acc + (isDeprecated ? 0 : parseFloat(stampWeights[name] || "0") || 0), 0 ); @@ -222,6 +229,7 @@ export const ScorerContextProvider = ({ children }: { children: any }) => { return { ...platformSpec, possiblePoints, + displayPossiblePoints, earnedPoints, }; }); @@ -231,7 +239,9 @@ export const ScorerContextProvider = ({ children }: { children: any }) => { useEffect(() => { if (!stampScores || !stampWeights) { - setScoredPlatforms(platformSpecs.map((platform) => ({ ...platform, possiblePoints: 0, earnedPoints: 0 }))); + setScoredPlatforms( + platformSpecs.map((platform) => ({ ...platform, possiblePoints: 0, earnedPoints: 0, displayPossiblePoints: 0 })) + ); return; } calculatePlatformScore(); diff --git a/platforms/src/Holonym/App-Bindings.tsx b/platforms/src/Holonym/App-Bindings.tsx index c515937fd9..5485f279dc 100644 --- a/platforms/src/Holonym/App-Bindings.tsx +++ b/platforms/src/Holonym/App-Bindings.tsx @@ -18,7 +18,7 @@ export class HolonymPlatform implements Platform {
  • Go to Holonym's page, verify your ID by connecting your - wallet, and follow prompts to obtain the Government ID, ePassport or Phone Proofs + wallet, and follow prompts to obtain the Government ID, ePassport or Phone Proofs.
  • After verification, mint the SBT to your wallet, then link it to your Passport by verifying it.
  • diff --git a/platforms/src/Holonym/Providers-config.ts b/platforms/src/Holonym/Providers-config.ts index ae454cba79..00e1d6c3ce 100644 --- a/platforms/src/Holonym/Providers-config.ts +++ b/platforms/src/Holonym/Providers-config.ts @@ -17,9 +17,12 @@ export const ProviderConfig: PlatformGroupSpec[] = [ platformGroup: "Holonym KYC", providers: [ { title: "Proven uniqueness using Holonym KYC with government ID or ePassport", name: "HolonymGovIdProvider" }, - { title: "Proven uniqueness using Holonym Phone Verification", name: "HolonymPhone" }, ], }, + { + platformGroup: "Phone Number", + providers: [{ title: "Proven uniqueness using Holonym Phone Verification", name: "HolonymPhone" }], + }, ]; export const providers: Provider[] = [new HolonymGovIdProvider(), new HolonymPhone()];