From bef1da2ab69c4d02498966f069b5f0bbe8a49515 Mon Sep 17 00:00:00 2001 From: Maija Grudule <34912439+MGrudule@users.noreply.github.com> Date: Mon, 14 Oct 2024 10:31:35 +0200 Subject: [PATCH] Evolution Limit Configuration (#1880) - Evolution LIMITED state - translations for LIMITED state - evolution Feature flag --- .../src/lib/features/MultipassStates.ts | 14 +++++++++-- .../src/lib/shared/i18n/en/index.ts | 5 ++++ .../src/lib/shared/i18n/i18n-types.ts | 24 +++++++++++++++++++ .../src/lib/shared/multipassConfig.ts | 5 ++-- .../src/lib/shared/siteConfigs.ts | 1 + .../DOTphin/Steps/CardEvolution.svelte | 9 +++++++ 6 files changed, 54 insertions(+), 4 deletions(-) diff --git a/apps/verification-portal/src/lib/features/MultipassStates.ts b/apps/verification-portal/src/lib/features/MultipassStates.ts index 96a8cba6f..3a4166794 100644 --- a/apps/verification-portal/src/lib/features/MultipassStates.ts +++ b/apps/verification-portal/src/lib/features/MultipassStates.ts @@ -1,8 +1,13 @@ import { writable, derived } from 'svelte/store'; import type { DeepAsset } from '@sni/types'; +import { isFeatureEnabled } from '$lib/shared/utils'; + +const canEvolve = isFeatureEnabled('dotphinEvolution'); + import { MAX_EVOLUTION_LEVEL, + EVOLUTION_LIMIT, initialStepConfig, STATUS, } from '$lib/shared/multipassConfig'; @@ -107,6 +112,8 @@ export const evolveStepState = derived( return 'INITIAL'; } else if ($multipassData.evolution.level >= MAX_EVOLUTION_LEVEL) { return 'COMPLETE'; + } else if ($multipassData.evolution.level >= EVOLUTION_LIMIT) { + return 'LIMITED'; } else { return 'EVOLVING'; } @@ -132,7 +139,8 @@ export const multipassStepConfig = derived( // Retrieve the disabled status from the initial configuration const nftDisabled = initialStepConfig.nft.disabled; - const evolutionDisabled = initialStepConfig.evolution.disabled; + const evolutionDisabled = + initialStepConfig.evolution.disabled && !canEvolve; // NFT step is locked if the user is logged out or disabled; otherwise, check other conditions const nftStatus = @@ -151,7 +159,9 @@ export const multipassStepConfig = derived( : proofsStatus === STATUS.COMPLETE && nftStatus === STATUS.COMPLETE ? $multipassData.evolution.level >= MAX_EVOLUTION_LEVEL ? STATUS.COMPLETE - : STATUS.ACTIVE + : $multipassData.evolution.level >= EVOLUTION_LIMIT + ? STATUS.LOCKED + : STATUS.ACTIVE : STATUS.LOCKED; // Simplified MultipassStepConfig with proper disabled checks diff --git a/apps/verification-portal/src/lib/shared/i18n/en/index.ts b/apps/verification-portal/src/lib/shared/i18n/en/index.ts index c9c63b219..f4a5b48e4 100644 --- a/apps/verification-portal/src/lib/shared/i18n/en/index.ts +++ b/apps/verification-portal/src/lib/shared/i18n/en/index.ts @@ -207,6 +207,11 @@ const en: BaseTranslation = { EVOLVING: { subtitle: 'Evolution level {level}/{maxLevel}', }, + LIMITED: { + title: 'Come back later to complete the evolution', + subtitle: + 'Evolution level {level}/{maxLevel}.\n(Full evolution coming soon!)', + }, COMPLETE: { title: 'Congratulation, you have completed your DOTphin', subtitle: 'Your NFT has reached its maximum evolution level', diff --git a/apps/verification-portal/src/lib/shared/i18n/i18n-types.ts b/apps/verification-portal/src/lib/shared/i18n/i18n-types.ts index c8efd58a1..ea66d817e 100644 --- a/apps/verification-portal/src/lib/shared/i18n/i18n-types.ts +++ b/apps/verification-portal/src/lib/shared/i18n/i18n-types.ts @@ -585,6 +585,19 @@ type RootTranslation = { */ subtitle: RequiredParams<'level' | 'maxLevel'> } + LIMITED: { + /** + * C​o​m​e​ ​b​a​c​k​ ​l​a​t​e​r​ ​t​o​ ​c​o​m​p​l​e​t​e​ ​t​h​e​ ​e​v​o​l​u​t​i​o​n + */ + title: string + /** + * E​v​o​l​u​t​i​o​n​ ​l​e​v​e​l​ ​{​l​e​v​e​l​}​/​{​m​a​x​L​e​v​e​l​}​.​ + ​(​F​u​l​l​ ​e​v​o​l​u​t​i​o​n​ ​c​o​m​i​n​g​ ​s​o​o​n​!​) + * @param {unknown} level + * @param {unknown} maxLevel + */ + subtitle: RequiredParams<'level' | 'maxLevel'> + } COMPLETE: { /** * C​o​n​g​r​a​t​u​l​a​t​i​o​n​,​ ​y​o​u​ ​h​a​v​e​ ​c​o​m​p​l​e​t​e​d​ ​y​o​u​r​ ​D​O​T​p​h​i​n @@ -1288,6 +1301,17 @@ export type TranslationFunctions = { */ subtitle: (arg: { level: unknown, maxLevel: unknown }) => LocalizedString } + LIMITED: { + /** + * Come back later to complete the evolution + */ + title: () => LocalizedString + /** + * Evolution level {level}/{maxLevel}. + (Full evolution coming soon!) + */ + subtitle: (arg: { level: unknown, maxLevel: unknown }) => LocalizedString + } COMPLETE: { /** * Congratulation, you have completed your DOTphin diff --git a/apps/verification-portal/src/lib/shared/multipassConfig.ts b/apps/verification-portal/src/lib/shared/multipassConfig.ts index dd5c31bbe..fa2daefcb 100644 --- a/apps/verification-portal/src/lib/shared/multipassConfig.ts +++ b/apps/verification-portal/src/lib/shared/multipassConfig.ts @@ -1,4 +1,5 @@ -export const MAX_EVOLUTION_LEVEL = 7; +export const MAX_EVOLUTION_LEVEL = 4; +export const EVOLUTION_LIMIT = 3; // Multipass step states, derived from API data. Used for dynamic UI/UX and translation based on API Data points export type ProofStepState = @@ -7,7 +8,7 @@ export type ProofStepState = | 'HAS_AVAILABLE_PROOFS' | 'NO_AVAILABLE_PROOFS'; export type NftStepState = 'CLAIMED' | 'UNCLAIMED'; -export type EvolveStepState = 'INITIAL' | 'EVOLVING' | 'COMPLETE'; +export type EvolveStepState = 'INITIAL' | 'EVOLVING' | 'LIMITED' | 'COMPLETE'; export type MultipassStepConfig = { proofs: { diff --git a/apps/verification-portal/src/lib/shared/siteConfigs.ts b/apps/verification-portal/src/lib/shared/siteConfigs.ts index c5e39d913..dd3815026 100644 --- a/apps/verification-portal/src/lib/shared/siteConfigs.ts +++ b/apps/verification-portal/src/lib/shared/siteConfigs.ts @@ -6,6 +6,7 @@ export default { collectionsTest: false, multipassTest: false, dotphinWidget: true, + dotphinEvolution: false, }, social: { discord: 'discord:https://discord.gg/ZXyC3tN87K', diff --git a/apps/verification-portal/src/lib/widgets/DOTphin/Steps/CardEvolution.svelte b/apps/verification-portal/src/lib/widgets/DOTphin/Steps/CardEvolution.svelte index 3b9c94e53..868c4a244 100644 --- a/apps/verification-portal/src/lib/widgets/DOTphin/Steps/CardEvolution.svelte +++ b/apps/verification-portal/src/lib/widgets/DOTphin/Steps/CardEvolution.svelte @@ -28,6 +28,8 @@ {#if $evolveStepState === 'COMPLETE'} + {:else if $evolveStepState === 'LIMITED'} + {:else} + {:else if $evolveStepState === 'LIMITED'} + {:else} {$LL.multipass.state.evolveStep.EVOLVING.subtitle({