Skip to content

Commit

Permalink
add select as props
Browse files Browse the repository at this point in the history
  • Loading branch information
pivilartisant committed Jun 18, 2024
1 parent ee093c5 commit c50540b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
24 changes: 16 additions & 8 deletions src/components/inputAmount/InputHead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ChainStatus } from '../Status/ChainStatus';
import { useConnectorName } from '@/custom/bridge/useConnectorName';
import { ChainContext } from '@/custom/bridge/useNetworkValidation';
import Intl from '@/i18n/i18n';
import { useAccountStore, useOperationStore } from '@/store/store';
import { useAccountStore } from '@/store/store';
import { maskAddress } from '@/utils/massaFormat';

interface InputHeadProps {
Expand All @@ -13,14 +13,20 @@ interface InputHeadProps {
dropdownOptions: IOption[];
isMassaChain: boolean;
isConnected: boolean;
select: number | undefined;
}

export function InputHead(props: InputHeadProps) {
const { address, context, dropdownOptions, isMassaChain, isConnected } =
props;
const {
address,
context,
dropdownOptions,
isMassaChain,
isConnected,
select,
} = props;

const { currentProvider } = useAccountStore();
const { selectedEvm, availableEvmNetworks } = useOperationStore();

const walletName = useConnectorName();
const isReadyOnly = dropdownOptions.length <= 1;
Expand All @@ -39,7 +45,11 @@ export function InputHead(props: InputHeadProps) {
: Intl.t('connect-wallet.card-destination.to')}
</>
) : (
<> {walletName} </>
<>
{isConnected
? walletName
: Intl.t('connect-wallet.card-destination.from')}{' '}
</>
)}
</div>
<ChainStatus context={context} isMassaChain={isMassaChain} />
Expand All @@ -49,9 +59,7 @@ export function InputHead(props: InputHeadProps) {
<Dropdown
readOnly={isReadyOnly}
options={dropdownOptions}
select={
isMassaChain ? undefined : availableEvmNetworks.indexOf(selectedEvm)
}
select={select}
/>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/pages/DaoPage/DaoInit/DaoHead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export function DaoHead(props: DaoHeadProps) {
context={ChainContext.DAO}
dropdownOptions={options}
isConnected={isConnected}
select={undefined}
/>

<div className="flex items-center justify-between gap-4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import {
export function EVMHeader() {
const { isConnected, address } = useAccount();
const { currentMode, isMainnet: getIsMainnet } = useBridgeModeStore();
const { setSelectedEvm, setAmounts } = useOperationStore();
const { setSelectedEvm, setAmounts, selectedEvm, availableEvmNetworks } =
useOperationStore();

const { resetSelectedToken } = useTokenStore();
const isMainnet = getIsMainnet();

Expand Down Expand Up @@ -52,6 +54,7 @@ export function EVMHeader() {
isMassaChain={false}
isConnected={isConnected}
dropdownOptions={options}
select={availableEvmNetworks.indexOf(selectedEvm)}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function MassaHeader() {
isMassaChain={true}
context={ChainContext.BRIDGE}
isConnected={isConnected}
select={undefined}
/>
</div>
);
Expand Down

0 comments on commit c50540b

Please sign in to comment.