Skip to content

Commit

Permalink
Hide token must be wrapped message untill we actually resolve whether…
Browse files Browse the repository at this point in the history
… imported token is votes token or not. Disable token name and symbol inputs if imported token is votes token
  • Loading branch information
mudrila committed Aug 14, 2024
1 parent cebd389 commit e5aa164
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
15 changes: 10 additions & 5 deletions src/components/DaoCreator/formComponents/AzoriusTokenDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
import { erc20Abi, getContract, isAddress, zeroAddress } from 'viem';
import { usePublicClient, useWalletClient } from 'wagmi';
import { createAccountSubstring } from '../../../hooks/utils/useDisplayName';
import { TokenCreationType, ICreationStepProps } from '../../../types';
import { ICreationStepProps, TokenCreationType } from '../../../types';
import SupportTooltip from '../../ui/badges/SupportTooltip';
import ContentBoxTitle from '../../ui/containers/ContentBox/ContentBoxTitle';
import { LabelComponent } from '../../ui/forms/InputComponent';
Expand All @@ -19,7 +19,9 @@ import { AzoriusTokenAllocations } from './AzoriusTokenAllocations';
import { VotesTokenImport } from './VotesTokenImport';
import { VotesTokenNew } from './VotesTokenNew';

function TokenConfigDisplay(props: ICreationStepProps) {
function TokenConfigDisplay(
props: ICreationStepProps & { isImportedVotesToken: boolean | undefined },
) {
switch (props.values.erc20Token.tokenCreationType) {
case TokenCreationType.NEW:
return <VotesTokenNew {...props} />;
Expand Down Expand Up @@ -47,7 +49,7 @@ export function AzoriusTokenDetails(props: ICreationStepProps) {
const publicClient = usePublicClient();

const { checkVotesToken } = usePrepareFormData();
const [isImportedVotesToken, setIsImportedVotesToken] = useState(false);
const [isImportedVotesToken, setIsImportedVotesToken] = useState<boolean>();

useStepRedirect({ values });
const updateImportFields = useCallback(async () => {
Expand Down Expand Up @@ -177,7 +179,7 @@ export function AzoriusTokenDetails(props: ICreationStepProps) {
isRequired
/>
</LabelWrapper>
{!isImportedVotesToken && !errors.erc20Token?.tokenImportAddress && (
{isImportedVotesToken === false && !errors.erc20Token?.tokenImportAddress && (
<Flex
gap={4}
alignItems="center"
Expand Down Expand Up @@ -208,7 +210,10 @@ export function AzoriusTokenDetails(props: ICreationStepProps) {
bg="neutral-2"
borderRadius="0.25rem"
>
<TokenConfigDisplay {...props} />
<TokenConfigDisplay
{...props}
isImportedVotesToken={isImportedVotesToken}
/>
</Box>
{values.erc20Token.tokenCreationType === TokenCreationType.NEW && (
<Box
Expand Down
9 changes: 7 additions & 2 deletions src/components/DaoCreator/formComponents/VotesTokenImport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { ICreationStepProps } from '../../../types';
import ContentBoxTitle from '../../ui/containers/ContentBox/ContentBoxTitle';
import { LabelComponent } from '../../ui/forms/InputComponent';

export function VotesTokenImport(props: ICreationStepProps) {
const { values, handleChange } = props;
export function VotesTokenImport({
values,
handleChange,
isImportedVotesToken,
}: ICreationStepProps & { isImportedVotesToken: boolean | undefined }) {
const { t } = useTranslation('daoCreate');
return (
<Flex
Expand All @@ -26,6 +29,7 @@ export function VotesTokenImport(props: ICreationStepProps) {
data-testid="tokenVoting-tokenNameInput"
minWidth="50%"
placeholder="Name"
disabled={isImportedVotesToken}
/>
)}
</Field>
Expand All @@ -41,6 +45,7 @@ export function VotesTokenImport(props: ICreationStepProps) {
onChange={handleChange}
data-testid="tokenVoting-tokenSymbolInput"
placeholder="TKN"
disabled={isImportedVotesToken}
/>
</LabelComponent>
<LabelComponent
Expand Down

0 comments on commit e5aa164

Please sign in to comment.