From ba4ce139c506065ceda545c39e6f42a8a9e05924 Mon Sep 17 00:00:00 2001 From: Abishek Bashyal Date: Wed, 11 Oct 2023 23:54:34 +0545 Subject: [PATCH] feat: token symbol display done --- .../components/chat/CreateGroup/AddCriteria.tsx | 12 +++++++++++- .../chat/CreateGroup/ConditionsComponent.tsx | 17 +++++++++++++++-- .../components/chat/helpers/tokenGatedGroup.ts | 9 +++------ .../chat/types/tokenGatedGroupCreationType.ts | 1 + 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/packages/uiweb/src/lib/components/chat/CreateGroup/AddCriteria.tsx b/packages/uiweb/src/lib/components/chat/CreateGroup/AddCriteria.tsx index a12bdfd32..959559ad5 100644 --- a/packages/uiweb/src/lib/components/chat/CreateGroup/AddCriteria.tsx +++ b/packages/uiweb/src/lib/components/chat/CreateGroup/AddCriteria.tsx @@ -329,7 +329,8 @@ const AddCriteria = ({ contract: `${selectedChain}:${contract}`, amount: quantity.value, comparison: dropdownQuantityRangeValues[quantity.range].value, - decimals: 18, + decimals: category === CATEGORY.ERC20 ? decimals : undefined, + token:unit }; } else if (category === CATEGORY.INVITE) { const _inviteRoles = []; @@ -410,6 +411,15 @@ const AddCriteria = ({ ) ); + if(pushData.token){ + setUnit(pushData.token) + } + + if(pushData.decimals){ + setDecimals(decimals) + } + + // TODO: make helper function for this const contractAndChain: string[] = ( pushData.contract || 'eip155:1:0x' ).split(':'); diff --git a/packages/uiweb/src/lib/components/chat/CreateGroup/ConditionsComponent.tsx b/packages/uiweb/src/lib/components/chat/CreateGroup/ConditionsComponent.tsx index 9ed370c2e..f8c4e3ecd 100644 --- a/packages/uiweb/src/lib/components/chat/CreateGroup/ConditionsComponent.tsx +++ b/packages/uiweb/src/lib/components/chat/CreateGroup/ConditionsComponent.tsx @@ -8,7 +8,7 @@ import { ThemeContext } from '../theme/ThemeProvider'; import Dropdown, { DropdownValueType } from '../reusables/DropDown'; import { ConditionArray, ConditionData, IChatTheme } from '../exportedTypes'; import { useClickAway } from '../../../hooks'; -import { CATEGORY, CRITERIA_TYPE, CriteriaType, TOKEN_NFT_COMPARISION, TokenNftComparision } from '../types'; +import { CATEGORY, CRITERIA_TYPE, CriteriaType, PushData, TOKEN_NFT_COMPARISION, TokenNftComparision } from '../types'; import EditSvg from '../../../icons/EditSvg.svg'; import RemoveSvg from '../../../icons/RemoveSvg.svg'; @@ -94,6 +94,19 @@ const CriteriaSection = ({ criteria }: { criteria: ConditionData }) => { return (GUILD_COMPARISON_OPTIONS.find(option => option.value === criteria?.data?.['comparison']))?.heading; } + + const getTokenSymbol = (conditionData:ConditionData)=>{ + if(conditionData.data){ + const data:PushData = conditionData.data; + if(data.token){ + // TODO truncate the token symbol + return data.token + } + } + + return conditionData.category + } + return (
{ {getTokenNftComparisionLabel()}{' '} {/* need to fetch token symbol */} - {criteria?.data?.['amount']} {criteria.category} + {criteria?.data?.['amount']} {getTokenSymbol(criteria)} )} {criteria.category === CATEGORY.INVITE && ( diff --git a/packages/uiweb/src/lib/components/chat/helpers/tokenGatedGroup.ts b/packages/uiweb/src/lib/components/chat/helpers/tokenGatedGroup.ts index e67e4fc15..971e3cf1f 100644 --- a/packages/uiweb/src/lib/components/chat/helpers/tokenGatedGroup.ts +++ b/packages/uiweb/src/lib/components/chat/helpers/tokenGatedGroup.ts @@ -75,7 +75,7 @@ const validateTokenData = async (condition:Rule):Promise