diff --git a/src/hooks/Tokens.ts b/src/hooks/Tokens.ts index a9aeb3f..b4320eb 100644 --- a/src/hooks/Tokens.ts +++ b/src/hooks/Tokens.ts @@ -23,7 +23,6 @@ import { filterTokens } from '../components/SearchModal/filtering' function useTokensFromMap(tokenMap: TokenAddressMap, includeUserAdded: boolean): { [address: string]: Token } { const { chainId } = useActiveWeb3React() const userAddedTokens = useUserAddedTokens() - return useMemo(() => { if (!chainId) return {} @@ -32,7 +31,6 @@ function useTokensFromMap(tokenMap: TokenAddressMap, includeUserAdded: boolean): newMap[address] = tokenMap[chainId][address].token return newMap }, {}) - console.log(mapWithoutUrls) if (includeUserAdded) { return ( userAddedTokens diff --git a/src/types/bazaar.ts b/src/types/bazaar.ts new file mode 100644 index 0000000..aa619da --- /dev/null +++ b/src/types/bazaar.ts @@ -0,0 +1,17 @@ +export interface ListProps { + coverResource?: CoverResourceProps + grade?: string + id?: string + name?: string + price?: undefined + priceList?: PriceProps[] + type?: string +} +export interface CoverResourceProps { + path?: string + url?: string +} +export interface PriceProps { + label?: string + value?: string +} diff --git a/src/types/blindBox.ts b/src/types/blindBox.ts new file mode 100644 index 0000000..4d351de --- /dev/null +++ b/src/types/blindBox.ts @@ -0,0 +1,22 @@ +export interface ListProp { + beginTime?: string + coverResource: coverResourceProps + endTime?: string + id?: string + name?: string + priceList?: priceProps[] + price?: any + purchased?: string | number + total?: string | number + type?: string + num?: number +} + +export interface coverResourceProps { + path?: string + url?: string +} +export interface priceProps { + label?: string + value?: string | number +} diff --git a/src/views/Bazaar/components/Content.tsx b/src/views/Bazaar/components/Content.tsx index 040e26c..f8c400e 100644 --- a/src/views/Bazaar/components/Content.tsx +++ b/src/views/Bazaar/components/Content.tsx @@ -5,6 +5,7 @@ import Pagination from '@mui/material/Pagination' import { Flex, Text, Input, Image, Dropdown } from '@pancakeswap/uikit' import { useAccount } from 'state/userInfo/hooks' import useRefresh from 'hooks/useRefresh' +import { ListProps } from 'types/bazaar' import { useGetOfficialPage } from '../hooks' import HeaderOperation from './HeaderOperation' @@ -12,24 +13,6 @@ import ContentShop from './ContentShop' import Transaction from './Transaction' import ShopDetail from './ShopDetail' -interface ListProps { - coverResource?: CoverResourceProps - grade?: string - id?: string - name?: string - price?: undefined - priceList?: PriceProps[] - type?: string -} -interface CoverResourceProps { - path?: string - url?: string -} -interface PriceProps { - label?: string - value?: string -} - const HeaderFlex = styled(Flex)` width: 100%; justify-content: space-between; @@ -146,6 +129,7 @@ const FlexOption = styled(Flex)` const Content: React.FC = () => { const { t } = useTranslation() + const [detail, setDetail] = useState({}) const [detailVisible, setDetailVisible] = useState(false) const typeList = [ { label: t('All'), type: 1 }, @@ -159,26 +143,27 @@ const Content: React.FC = () => { ] const [auctionSelect, setAuctionSelect] = useState({ label: t('In the auction'), value: '0' }) const newPrice = [ - { label: t('The latest offer'), value: '0' }, - { label: t('latest release'), value: '1' }, - { label: t('end time'), value: '2' }, + // { label: t('The latest offer'), value: '0' }, + // { label: t('latest release'), value: '1' }, + // { label: t('end time'), value: '2' }, { label: t('Prices go from low to high'), value: '3' }, { label: t('Prices go from high to low'), value: '4' }, ] - const [priceSelect, setPriceSelect] = useState({ label: t('The latest offer'), value: '0' }) + const [priceSelect, setPriceSelect] = useState({ label: t('Prices go from low to high'), value: '3' }) const [searchTitle, setSearchTitle] = useState('') const [list, setList] = useState([]) const statusList = [ - { label: t('All'), id: '1' }, - { label: t('epic'), id: '2' }, - { label: t('legend'), id: '3' }, - { label: t('uncommon'), id: '4' }, - { label: t('common'), id: '5' }, + { label: t('All'), id: '1', grade: '' }, + { label: t('epic'), id: '2', grade: 'EPIC' }, + { label: t('legend'), id: '3', grade: 'LEGEND' }, + { label: t('uncommon'), id: '4', grade: 'RARE' }, + { label: t('common'), id: '5', grade: 'NORMAL' }, ] const [statusIndex, setStatusIndex] = useState(0) const [pageNum, setPage] = useState(1) + const [searchGrade, setGrade] = useState('') const [count, setCount] = useState(undefined) @@ -188,6 +173,7 @@ const Content: React.FC = () => { const params = { page: pageNum, size: 10, + grade: searchGrade, } const data = await getOfficialPage(params) const arr = [] @@ -206,7 +192,7 @@ const Content: React.FC = () => { useEffect(() => { getData() - }, [pageNum]) + }, [pageNum, searchGrade]) const handleChange = (evt: React.ChangeEvent) => { const { value } = evt.target @@ -214,8 +200,11 @@ const Content: React.FC = () => { } const searchList = () => { console.log('search') + setPage(1) } - const showDetail = () => { + const showDetail = (val) => { + console.log(val) + setDetail(val) setDetailVisible(!detailVisible) } const pageChange = (e, page) => { @@ -226,9 +215,15 @@ const Content: React.FC = () => { return parseInt(countTotal) } + const selectStatus = (index, grade) => { + setStatusIndex(index) + setGrade(grade) + setPage(1) + } + return ( <> - {detailVisible && } + {detailVisible && setDetailVisible(false)} />} {!detailVisible && ( <> @@ -256,7 +251,7 @@ const Content: React.FC = () => { return ( setStatusIndex(index)} + onClick={() => selectStatus(index, item.grade)} className={statusIndex === index ? 'statusActive' : ''} > {item.label} @@ -265,25 +260,27 @@ const Content: React.FC = () => { })} - - - - {auctionSelect.label} - - } - > - {auctionList.map((item) => { - return ( - setAuctionSelect(item)}> - {item.label} - - ) - })} - - + {typeIndex !== 0 && ( + + + + {auctionSelect.label} + + } + > + {auctionList.map((item) => { + return ( + setAuctionSelect(item)}> + {item.label} + + ) + })} + + + )} { - + showDetail(v)} /> diff --git a/src/views/Bazaar/components/ContentShop.tsx b/src/views/Bazaar/components/ContentShop.tsx index ea990d5..ad202bd 100644 --- a/src/views/Bazaar/components/ContentShop.tsx +++ b/src/views/Bazaar/components/ContentShop.tsx @@ -3,6 +3,7 @@ import styled, { keyframes } from 'styled-components' import { useTranslation } from 'contexts/Localization' import { formatTimeNumber } from 'utils/formatBalance' import { Flex, Text, Image } from '@pancakeswap/uikit' +import { ListProps } from 'types/bazaar' import { useAccount } from 'state/userInfo/hooks' import useRefresh from 'hooks/useRefresh' import { TOKEN_SYMBOL } from 'config/index' @@ -11,26 +12,9 @@ import ShopList from './ShopList' interface ContentShop { list?: ListProps[] - getDetail?: () => void + getDetail?: (v) => void } -interface ListProps { - coverResource?: CoverResourceProps - grade?: string - id?: string - name?: string - price?: undefined - priceList?: PriceProps[] - type?: string -} -interface CoverResourceProps { - path?: string - url?: string -} -interface PriceProps { - label?: string - value?: string -} const ShopMain = styled.div` width: 100%; display: grid; @@ -83,15 +67,15 @@ const FooterValue = styled(Text)` const ContentShop: React.FC = ({ list, getDetail }) => { const { t } = useTranslation() - const showDetail = () => { - getDetail() + const showDetail = (id) => { + getDetail(id) } return ( {list.map((item) => { return ( - + showDetail(item)}> void + detail: ListProps + typeIndex: number | string } const HeaderFlex = styled(Flex)` @@ -88,26 +92,48 @@ const PriceButton = styled(Button)` margin: 30px 0; ` -const ShopDetail: React.FC = ({ close }) => { +const ShopDetail: React.FC = ({ close, detail, typeIndex }) => { const { t } = useTranslation() + const [link, setLink] = useState('') - const [shopData, setShopData] = useState({ label: 'Cat goddess Emerald ', type: 1, id: 1 }) + const getLinkAddress = async () => { + const data = await getContract() + setLink(data) + } + useEffect(() => { + getLinkAddress() + }, []) return ( <> {t('Bazaar')} - > Crumb 1 + > {detail.name} - + - Cat goddess Emerald - + {detail.name} + {typeIndex !== 0 && ( + + )} = ({ close }) => { rightSize="30px" textColor="#1FC7D4" /> - {t('Fixed markup (%price% premium)', { price: '10%' })} - - - - - - + {typeIndex === 0 ? ( + {t('Buy It Now')} + ) : ( + {t('Fixed markup (%price% premium)', { price: '10%' })} + )} + {typeIndex !== 0 && } + {/* */} + + {typeIndex !== 0 && } + + diff --git a/src/views/BlindBox/component/Operation.tsx b/src/views/BlindBox/component/Operation.tsx index 606c166..2e5dc4d 100644 --- a/src/views/BlindBox/component/Operation.tsx +++ b/src/views/BlindBox/component/Operation.tsx @@ -5,31 +5,12 @@ import BigNumber from 'bignumber.js' import { useTranslation } from 'contexts/Localization' import { Flex, Text } from '@pancakeswap/uikit' import { TOKEN_SYMBOL } from 'config/index' +import { ListProp } from 'types/blindBox' import StepCom from './StepCom' -interface DetailProp { - beginTime?: string - coverResource: coverResourceProps - endTime?: string - id?: string - name?: string - priceList?: priceProps[] - price?: any - purchased?: string | number - total?: string | number - type?: string -} - interface OperationProp { - detail: DetailProp -} -interface coverResourceProps { - path?: string - url?: string -} -interface priceProps { - label?: string - value?: string | number + detail: ListProp + getNum?: (v) => void } const DetailDiv = styled.div` @@ -53,10 +34,12 @@ const HeaderText = styled(Text)` margin: 0 5px 0 10px; ` -const Operation: React.FC = ({ detail }) => { +const Operation: React.FC = ({ detail, getNum }) => { const { t } = useTranslation() - const [buyNum, setBuyNum] = useState(0) + const getStepValue = (v) => { + getNum(v) + } return ( @@ -80,7 +63,7 @@ const Operation: React.FC = ({ detail }) => { {t('quantity')} - setBuyNum(v)} /> + getStepValue(v)} /> ) diff --git a/src/views/BlindBox/component/SeriesDetail.tsx b/src/views/BlindBox/component/SeriesDetail.tsx index cdab1ed..da3a1c4 100644 --- a/src/views/BlindBox/component/SeriesDetail.tsx +++ b/src/views/BlindBox/component/SeriesDetail.tsx @@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react' import styled from 'styled-components' import { useTranslation } from 'contexts/Localization' import { Modal, Flex, Text, Image } from '@pancakeswap/uikit' +import { ListProp } from 'types/blindBox' import { useGetBoxDetail } from '../hooks' import ShopList from './ShopList' @@ -9,29 +10,7 @@ interface SeriesDetailProp { name?: string | number value?: string | number onDismiss?: () => void - detail: DetailProp -} - -interface DetailProp { - beginTime?: string - coverResource: coverResourceProps - endTime?: string - id?: string - name?: string - priceList?: priceProps[] - price?: any - purchased?: string | number - total?: string | number - type?: string -} - -interface coverResourceProps { - path?: string - url?: string -} -interface priceProps { - label?: string - value?: string | number + detail: ListProp } const Main = styled(Modal)` @@ -70,11 +49,9 @@ const TextNum = styled(Text)` color: #280d5f; ` const Detail = styled.div` - /* border: 1px solid red; */ height: calc(100vh - 320px); overflow: auto; padding-top: 30px; - /* border-left: 1px solid #d5d5d5; */ ` const ShopText = styled(Text)` font-size: 26px; @@ -111,9 +88,11 @@ const SeriesDetail: React.FC = ({ name, value, onDismiss, deta const { t } = useTranslation() const [list, setList] = useState([]) const [totalNum, setTotal] = useState(0) + const [size, setSize] = useState(0) const getDetail = useGetBoxDetail() const getData = async () => { const { contentList, total } = await getDetail(detail.id) + setSize(contentList.length) setTotal(total) const dataList = [] contentList.forEach((item, index) => { @@ -143,19 +122,19 @@ const SeriesDetail: React.FC = ({ name, value, onDismiss, deta {t('nft Smoking in the probability')} - {t('%num%kind nft', { num: 100 })} + {t('%num%kind nft', { num: size })}
{list.map((item) => { return ( - + {item.grade === 'EPIC' && {t('epic')}} {item.grade === 'LEGEND' && {t('legend')}} {item.grade === 'RARE' && {t('uncommon')}} {item.grade === 'NORMAL' && {t('common')}} {item.list.map((childItem) => { - return + return })} diff --git a/src/views/BlindBox/index.tsx b/src/views/BlindBox/index.tsx index 9bfa307..1a00043 100644 --- a/src/views/BlindBox/index.tsx +++ b/src/views/BlindBox/index.tsx @@ -7,6 +7,7 @@ import SwiperCore, { Keyboard, Mousewheel, Pagination } from 'swiper' import { Swiper, SwiperSlide } from 'swiper/react' import { Card, Text, Flex, Image, Button } from '@pancakeswap/uikit' import { UnOpenModel } from 'components/Modal' +import { ListProp } from 'types/blindBox' import Header from './component/Header' import Operation from './component/Operation' import { useGetList } from './hooks' @@ -16,27 +17,6 @@ import 'swiper/components/pagination/pagination.min.css' SwiperCore.use([Keyboard, Mousewheel, Pagination]) -interface listProps { - beginTime?: string - coverResource: coverResourceProps - endTime?: string - id?: string - name?: string - priceList?: priceProps[] - price?: any - purchased?: string | number - total?: string | number - type?: string -} -interface coverResourceProps { - path?: string - url?: string -} -interface priceProps { - label?: string - value?: string | number -} - const MainFlex = styled(Flex)` width: 100%; min-height: calc(100vh - 64px); @@ -163,7 +143,8 @@ const BuyButton = styled(Button)` const BlindBox: React.FC = () => { const { t } = useTranslation() const account = useAccount() - const [blindBoxList, setBlindBoxList] = useState() + const [blindBoxList, setBlindBoxList] = useState() + const [buyNum, setBuyNum] = useState(0) const getList = useGetList() @@ -172,6 +153,7 @@ const BlindBox: React.FC = () => { const arr = [] content.forEach((item) => { const obj = item + obj.num = 0 obj.priceList = [] Object.keys(obj.price).forEach((childItem) => { obj.priceList.push({ label: childItem, value: obj.price[childItem] }) @@ -186,6 +168,10 @@ const BlindBox: React.FC = () => { getData() }, []) + const handleBuy = () => { + console.log(buyNum) + } + return ( {/* */} @@ -210,9 +196,9 @@ const BlindBox: React.FC = () => {
- + setBuyNum(v)} /> - {account ? {t('Buy It Now')} : } + {account ? {t('Buy It Now')} : } )