Skip to content

Commit

Permalink
fix: lint & fix few bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaelVallenet committed Oct 17, 2024
1 parent ca02808 commit 54bb6a7
Show file tree
Hide file tree
Showing 18 changed files with 280 additions and 269 deletions.
218 changes: 109 additions & 109 deletions packages/components/NetworkSelector/NetworkSelectorMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,120 +38,120 @@ export const NetworkSelectorMenu: FC<{
onSelect,
optionsMenuwidth = 172,
}) => {
const { resetMediaPlayer } = useMediaPlayer();
const dispatch = useAppDispatch();
const { wallets } = useWallets();
const { setToastError } = useFeedbacks();
const selectedNetworkInfo = useSelectedNetworkInfo();
const [networksModalVisible, setNetworksModalVisible] = useState(false);
const enabledNetworks = useEnabledNetworks();
const isMobile = useIsMobile();
const { resetMediaPlayer } = useMediaPlayer();
const dispatch = useAppDispatch();
const { wallets } = useWallets();
const { setToastError } = useFeedbacks();
const selectedNetworkInfo = useSelectedNetworkInfo();
const [networksModalVisible, setNetworksModalVisible] = useState(false);
const enabledNetworks = useEnabledNetworks();
const isMobile = useIsMobile();

const onPressNetwork = (networkId: string) => {
onSelect();
let walletProvider: WalletProvider | null = null;
const onPressNetwork = (networkId: string) => {
onSelect();
let walletProvider: WalletProvider | null = null;

const network = getNetwork(networkId);
if (!network) {
setToastError({
title: "Error",
message: `unsupported network ${networkId}`,
});
return;
}
const network = getNetwork(networkId);
if (!network) {
setToastError({
title: "Error",
message: `unsupported network ${networkId}`,
});
return;
}

switch (network.kind) {
case NetworkKind.Ethereum:
walletProvider = WalletProvider.Metamask;
break;
case NetworkKind.Cosmos:
walletProvider = WalletProvider.Keplr;
break;
}
switch (network.kind) {
case NetworkKind.Ethereum:
walletProvider = WalletProvider.Metamask;
break;
case NetworkKind.Cosmos:
walletProvider = WalletProvider.Keplr;
break;
}

// Auto select the first connected wallet when switching network
dispatch(setSelectedNetworkId(networkId));
// Auto select the first connected wallet when switching network
dispatch(setSelectedNetworkId(networkId));

const selectedWallet = wallets.find(
(w) => w.connected && w.provider === walletProvider,
);

dispatch(setSelectedWalletId(selectedWallet?.id || ""));
const selectedWallet = wallets.find(
(w) => w.connected && w.provider === walletProvider,
);

resetMediaPlayer();
};
dispatch(setSelectedWalletId(selectedWallet?.id || ""));

return (
<LegacyTertiaryBox
width={optionsMenuwidth}
noBrokenCorners
style={style}
mainContainerStyle={[
{
paddingHorizontal: layout.spacing_x2,
paddingTop: layout.spacing_x2,
backgroundColor: neutral17,
alignItems: "flex-start",
},
isMobile && {
borderTopWidth: 0,
borderRightWidth: 0,
borderTopRightRadius: 0,
borderBottomRightRadius: 0,
},
]}
>
{enabledNetworks
.filter((network) => {
return (
(!forceNetworkId || network.id === forceNetworkId) && // check that it's the forced network id if forced to
(!forceNetworkKind || network.kind === forceNetworkKind) && // check that it's the correct network kind if forced to
(!forceNetworkFeatures ||
forceNetworkFeatures.every((feature) =>
network.features.includes(feature),
)) &&
selectedNetworkInfo?.id !== network.id // check that it's not already selected
);
})
.map((network, index) => {
const selectable = true;
return (
<TouchableOpacity
disabled={!selectable}
style={{
marginBottom: layout.spacing_x2,
opacity: selectable ? 1 : 0.5,
}}
key={index}
onPress={() => onPressNetwork(network.id)}
>
<View style={{ flexDirection: "row", alignItems: "center" }}>
<NetworkIcon networkId={network.id} size={16} />
<BrandText
style={[fontSemibold12, { marginLeft: layout.spacing_x1_5 }]}
>
{network?.displayName || "Unknown"}
</BrandText>
</View>
</TouchableOpacity>
);
})}
<TertiaryButton
text="Manage"
size="XS"
squaresBackgroundColor={neutral17}
style={{ marginBottom: layout.spacing_x2 }}
onPress={() => {
setNetworksModalVisible(true);
}}
fullWidth
/>
<NetworksListModal
isVisible={networksModalVisible}
onClose={() => {
setNetworksModalVisible(false);
}}
/>
</LegacyTertiaryBox>
);
resetMediaPlayer();
};

return (
<LegacyTertiaryBox
width={optionsMenuwidth}
noBrokenCorners
style={style}
mainContainerStyle={[
{
paddingHorizontal: layout.spacing_x2,
paddingTop: layout.spacing_x2,
backgroundColor: neutral17,
alignItems: "flex-start",
},
isMobile && {
borderTopWidth: 0,
borderRightWidth: 0,
borderTopRightRadius: 0,
borderBottomRightRadius: 0,
},
]}
>
{enabledNetworks
.filter((network) => {
return (
(!forceNetworkId || network.id === forceNetworkId) && // check that it's the forced network id if forced to
(!forceNetworkKind || network.kind === forceNetworkKind) && // check that it's the correct network kind if forced to
(!forceNetworkFeatures ||
forceNetworkFeatures.every((feature) =>
network.features.includes(feature),
)) &&
selectedNetworkInfo?.id !== network.id // check that it's not already selected
);
})
.map((network, index) => {
const selectable = true;
return (
<TouchableOpacity
disabled={!selectable}
style={{
marginBottom: layout.spacing_x2,
opacity: selectable ? 1 : 0.5,
}}
key={index}
onPress={() => onPressNetwork(network.id)}
>
<View style={{ flexDirection: "row", alignItems: "center" }}>
<NetworkIcon networkId={network.id} size={16} />
<BrandText
style={[fontSemibold12, { marginLeft: layout.spacing_x1_5 }]}
>
{network?.displayName || "Unknown"}
</BrandText>
</View>
</TouchableOpacity>
);
})}
<TertiaryButton
text="Manage"
size="XS"
squaresBackgroundColor={neutral17}
style={{ marginBottom: layout.spacing_x2 }}
onPress={() => {
setNetworksModalVisible(true);
}}
fullWidth
/>
<NetworksListModal
isVisible={networksModalVisible}
onClose={() => {
setNetworksModalVisible(false);
}}
/>
</LegacyTertiaryBox>
);
};
2 changes: 1 addition & 1 deletion packages/components/TopMenu/TopMenuMyWallets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { LinearGradient } from "expo-linear-gradient";
import React, { useMemo, useState } from "react";
import { StyleSheet, TouchableOpacity, View } from "react-native";

import { TopMenuSection } from "./TopMenuSection";
import walletsSVG from "../../../assets/icons/wallets.svg";
import { useBalances } from "../../hooks/useBalances";
import { useDelegations } from "../../hooks/useDelegations";
Expand Down Expand Up @@ -37,7 +38,6 @@ import FlexRow from "../FlexRow";
import { SVG } from "../SVG";
import { SecondaryButton } from "../buttons/SecondaryButton";
import { SendModal } from "../modals/SendModal";
import { TopMenuSection } from "./TopMenuSection";

import { DepositWithdrawModal } from "@/components/modals/DepositWithdrawModal";
import { useAppNavigation } from "@/hooks/navigation/useAppNavigation";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
import React from "react";


import { BrandText } from "@/components/BrandText";
import { ScreenContainer } from "@/components/ScreenContainer";
import { useForceNetworkSelection } from "@/hooks/useForceNetworkSelection";
import { NetworkFeature, NetworkKind } from "@/networks";
import { ScreenFC, useAppNavigation } from "@/utils/navigation";

export const LaunchpadERC20ManageTokenScreen: ScreenFC<"LaunchpadERC20ManageToken"> = ({
route: { params },
}) => {
const network = params?.network;
useForceNetworkSelection(network);
const navigation = useAppNavigation();

return (
<ScreenContainer
headerChildren={<BrandText>Launchpad ERC 20</BrandText>}
forceNetworkFeatures={[NetworkFeature.LaunchpadERC20]}
forceNetworkKind={NetworkKind.Gno}
isLarge
responsive
onBackPress={() => navigation.navigate("LaunchpadERC20Tokens")}
>
export const LaunchpadERC20ManageTokenScreen: ScreenFC<
"LaunchpadERC20ManageToken"
> = ({ route: { params } }) => {
const network = params?.network;
useForceNetworkSelection(network);
const navigation = useAppNavigation();

</ScreenContainer>
);
return (
<ScreenContainer
headerChildren={<BrandText>Launchpad ERC 20</BrandText>}
forceNetworkFeatures={[NetworkFeature.LaunchpadERC20]}
forceNetworkKind={NetworkKind.Gno}
isLarge
responsive
onBackPress={() => navigation.navigate("LaunchpadERC20Tokens")}
/>
);
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from "react";
import { useState } from "react";
import { useWindowDimensions, View } from "react-native";

import exploreSVG from "../../../../assets/icons/explore-neutral77.svg";
import penSVG from "../../../../assets/icons/pen-neutral77.svg";
import registerSVG from "../../../../assets/icons/register-neutral77.svg";
import { SelectUserTokenModal } from "../component/LaunchpadERC20SelectUserTokenModal";
import { TokensTable } from "../component/LaunchpadERC20TokensTable";
import { useUserTokens } from "../hooks/useUserTokens";
import { breakpoints } from "../utils/breakpoints";

import { BrandText } from "@/components/BrandText";
Expand All @@ -16,8 +18,6 @@ import { useSelectedNetworkId } from "@/hooks/useSelectedNetwork";
import useSelectedWallet from "@/hooks/useSelectedWallet";
import { NetworkFeature, NetworkKind } from "@/networks";
import { ScreenFC, useAppNavigation } from "@/utils/navigation";
import { SelectUserTokenModal } from "../component/LaunchpadERC20SelectUserTokenModal";
import { useUserTokens } from "../hooks/useUserTokens";

export const LaunchpadERC20TokensScreen: ScreenFC<"LaunchpadERC20Tokens"> = ({
route: { params },
Expand All @@ -27,17 +27,15 @@ export const LaunchpadERC20TokensScreen: ScreenFC<"LaunchpadERC20Tokens"> = ({
const networkId = useSelectedNetworkId();
const { width } = useWindowDimensions();
const navigation = useAppNavigation();
const [isModalVisible, setIsModalVisible] = React.useState(false);
const [isModalVisible, setIsModalVisible] = useState(false);
const selectedWallet = useSelectedWallet();
const caller = selectedWallet?.address;
const { data: tokens } = useUserTokens(networkId, caller || "");
const dropdownItems = tokens?.map((token) =>
token.name
);
const dropdownItems = tokens?.map((token) => token.name);

const toggleModal = () => {
setIsModalVisible(!isModalVisible);
}
};

return (
<ScreenContainer
Expand Down Expand Up @@ -65,7 +63,9 @@ export const LaunchpadERC20TokensScreen: ScreenFC<"LaunchpadERC20Tokens"> = ({
label="Manage"
description="Mint, burn, or transfer the tokens you own"
iconSVG={penSVG}
onPress={() => { setIsModalVisible(true) }}
onPress={() => {
setIsModalVisible(true);
}}
style={{
marginHorizontal: width >= breakpoints.MD_BREAKPOINT ? 12 : 0,
marginVertical: width >= breakpoints.LG_BREAKPOINT ? 0 : 12,
Expand All @@ -75,11 +75,15 @@ export const LaunchpadERC20TokensScreen: ScreenFC<"LaunchpadERC20Tokens"> = ({
label="Explore"
description="Lookup tokens and explore their details"
iconSVG={exploreSVG}
onPress={() => { }}
onPress={() => {}}
disabled
/>
</View>
<SelectUserTokenModal isVisible={isModalVisible} onClose={toggleModal} items={dropdownItems} />
<SelectUserTokenModal
isVisible={isModalVisible}
onClose={toggleModal}
items={dropdownItems}
/>
<SpacerColumn size={2} />
<TokensTable networkId={networkId} />
</ScreenContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { TableRow } from "@/components/table/TableRow";
import { TableTextCell } from "@/components/table/TableTextCell";
import { TableWrapper } from "@/components/table/TableWrapper";
import { TableColumns } from "@/components/table/utils";
import { Airdrop } from "@/utils/launchpadERC20/types";
import { screenContentMaxWidthLarge } from "@/utils/style/layout";
import { Airdrop } from "@/utils/types/types";

const columns: TableColumns = {
id: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { TableRow } from "@/components/table/TableRow";
import { TableTextCell } from "@/components/table/TableTextCell";
import { TableWrapper } from "@/components/table/TableWrapper";
import { TableColumns } from "@/components/table/utils";
import { Sale } from "@/utils/launchpadERC20/types";
import { screenContentMaxWidthLarge } from "@/utils/style/layout";
import { Sale } from "@/utils/types/types";

const columns: TableColumns = {
id: {
Expand Down
Loading

0 comments on commit 54bb6a7

Please sign in to comment.