* Get credits endpoint * Grant credit endpoint * Refactor Steps component * Onboarding update * lol * Format * Remove unusued * noidea * my ts is broken * Add SponsoredNetworkAlert * fix build * Claim credits flow * Update copy * More stuff * ok * x * Add frax * Can skip adding payment method * Skip title * Light mode * ts * Invalidate the right query * Update api change * Format * Formats button * Ship * Prioritize op grant until claimed * Should be good now * Ok * . * Fix * Fix logic * Add indicators to chainlist and chain selector * k * Also this ... * Better logic * fix API types * Small changes * Add to chain page * format * ok * ?? * Fix * chain page * big number * Main bug * format * format2 * Confetti * Add payment method modal to flow * No need * A lot of stuff * Form working * pretty pretty * :) * Update banner * A lotta stuff * All can apply * kk * Update billing page * Remove unused * Fix * Improve these * Disable if already applied * Format * Only show on sponsored chains * Stuff * Format * Fatter * Changes * Stuff * Format * yep * format * Refetch account when payment method is added * Apply now * Remove apply now button when already applied * cool * Fix * Multiple options for chains * Conditional logic * Format * Industry * Link for contact us * Industry categories * No lisk * format * Not required * yep * Remove upgrade upsell for pro * Sponsored tag on chain page * New image * New banner images * Only show in dashboard on op chains * Fix build --------- Co-authored-by: Joaquim Verges <[email protected]>
144 lines
4.2 KiB
TypeScript
144 lines
4.2 KiB
TypeScript
import { Box, Flex, IconButton, Spinner } from "@chakra-ui/react";
|
|
import { NetworkSelectorProps } from "@thirdweb-dev/react";
|
|
import { ChainIcon } from "components/icons/ChainIcon";
|
|
import { useAddRecentlyUsedChainId } from "hooks/chains/recentlyUsedChains";
|
|
import {
|
|
useSetEditChain,
|
|
useSetIsNetworkConfigModalOpen,
|
|
} from "hooks/networkConfigModal";
|
|
import { OPSponsoredChains } from "pages/chainlist";
|
|
import { RxGear } from "react-icons/rx";
|
|
import { Heading, Text } from "tw-components";
|
|
|
|
export const CustomChainRenderer: NetworkSelectorProps["renderChain"] = ({
|
|
chain,
|
|
switchChain,
|
|
switching,
|
|
switchFailed,
|
|
close,
|
|
}) => {
|
|
const setIsOpenNetworkConfigModal = useSetIsNetworkConfigModalOpen();
|
|
const addRecentlyUsedChain = useAddRecentlyUsedChainId();
|
|
const setEditChain = useSetEditChain();
|
|
|
|
const isDeprecated = chain.status === "deprecated";
|
|
const isSponsored = OPSponsoredChains.includes(chain?.chainId);
|
|
|
|
return (
|
|
<Flex
|
|
w="100%"
|
|
justifyContent="start"
|
|
_hover={{
|
|
bg: "inputBg",
|
|
}}
|
|
borderRadius="md"
|
|
p="4px 12px"
|
|
cursor="pointer"
|
|
h="auto"
|
|
>
|
|
<Flex role="group" flexGrow={1} alignItems="center">
|
|
<Flex
|
|
onClick={() => {
|
|
if (!isDeprecated) {
|
|
switchChain();
|
|
}
|
|
}}
|
|
flexGrow={1}
|
|
gap={4}
|
|
alignItems="center"
|
|
cursor={isDeprecated ? "not-allowed" : "pointer"}
|
|
>
|
|
<ChainIcon ipfsSrc={chain.icon?.url} size={32} />
|
|
<Flex gap={1} flexDir="column" alignItems="start">
|
|
<Flex gap={2}>
|
|
<Text fontWeight={500} color={isDeprecated ? "faded" : "bgBlack"}>
|
|
{chain.name}
|
|
</Text>
|
|
{isDeprecated && (
|
|
<Flex alignItems="center">
|
|
<Flex
|
|
borderRadius="full"
|
|
align="center"
|
|
border="1px solid"
|
|
borderColor="borderColor"
|
|
overflow="hidden"
|
|
flexShrink={0}
|
|
py={{ base: 1.5, md: 1 }}
|
|
px={{ base: 1.5, md: 2 }}
|
|
gap={3}
|
|
cursor="not-allowed"
|
|
>
|
|
<Heading size="label.sm" as="label" cursor="not-allowed">
|
|
Deprecated
|
|
</Heading>
|
|
</Flex>
|
|
</Flex>
|
|
)}
|
|
{isSponsored && (
|
|
<Flex
|
|
borderRadius="full"
|
|
align="center"
|
|
overflow="hidden"
|
|
flexShrink={0}
|
|
py={{ base: 1.5, md: 1 }}
|
|
px={{ base: 1.5, md: 2 }}
|
|
gap={3}
|
|
bgGradient="linear(to-r, #701953, #5454B2)"
|
|
>
|
|
<Heading size="label.sm" as="label" color="#fff">
|
|
Sponsored
|
|
</Heading>
|
|
</Flex>
|
|
)}
|
|
</Flex>
|
|
{switching && (
|
|
<Flex
|
|
color="blue.500"
|
|
fontSize={12}
|
|
fontWeight={500}
|
|
alignItems="center"
|
|
gap={2}
|
|
>
|
|
Confirm in your wallet
|
|
<Spinner size="xs" />
|
|
</Flex>
|
|
)}
|
|
|
|
{switchFailed && (
|
|
<Box color="red.500" fontSize={12} fontWeight={500}>
|
|
Error switching network
|
|
</Box>
|
|
)}
|
|
</Flex>
|
|
</Flex>
|
|
|
|
<IconButton
|
|
aria-label="Configure Network"
|
|
ml="auto"
|
|
p={0}
|
|
variant="ghost"
|
|
_hover={{
|
|
bg: "inputBg",
|
|
}}
|
|
lineHeight={1}
|
|
opacity={0}
|
|
_groupHover={{
|
|
opacity: 1,
|
|
}}
|
|
icon={<RxGear width={4} height={4} />}
|
|
onClick={() => {
|
|
setEditChain(chain);
|
|
addRecentlyUsedChain(chain.chainId);
|
|
setIsOpenNetworkConfigModal(true);
|
|
if (close) {
|
|
close();
|
|
} else {
|
|
console.error("close is undefined");
|
|
}
|
|
}}
|
|
/>
|
|
</Flex>
|
|
</Flex>
|
|
);
|
|
};
|