diff --git a/src/AppContext.js b/src/AppContext.js index 5022611..156feae 100644 --- a/src/AppContext.js +++ b/src/AppContext.js @@ -1,7 +1,5 @@ -import { useSafeLayoutEffect } from "@chakra-ui/react" -import axios from "axios" -import { config } from "./config" import React from "react" +import { config } from "./config" import { get_settings } from './api' import { ImTwitter, ImTelegram, ImFacebook } from "react-icons/im"; @@ -23,6 +21,7 @@ export const AppContextProvider = ({ children }) => { const [title, setTitle] = React.useState('') const [logo, setLogo] = React.useState('') const [banners, setBanners] = React.useState([]) + const [lockImg, setLockImg] = React.useState('') const [socials, setSocials] = React.useState(SOCIALS) @@ -49,6 +48,8 @@ export const AppContextProvider = ({ children }) => { setBanners(banr) setLogo(config.ENDPOINT + 'upload/' + o.logo_url) + setLockImg(config.ENDPOINT + 'upload/' + o.lock_url) + setBannerLink(s.pic_url) SOCIALS[0].path = s.telegram @@ -71,6 +72,7 @@ export const AppContextProvider = ({ children }) => { address, setAddress, logo, + lockImg, title, banners, bannerLink, diff --git a/src/api/api.js b/src/api/api.js index cadbe6e..478be22 100644 --- a/src/api/api.js +++ b/src/api/api.js @@ -1,10 +1,14 @@ import axios from 'axios' import { config } from '../config' -const get = (path, onSuccess, onFailed) => { +const get = (path) => { return axios.get(config.ENDPOINT + path) } +const getWith = (path, data) => { + return axios.get(config.ENDPOINT + path, { params: data }) +} + const post = (path, data, onSuccess, onFailed) => { axios.post(config.ENDPOINT + path, data).then(res => { onSuccess && onSuccess(res.data) @@ -21,4 +25,15 @@ export const get_coins_platform = () => { return get('v1/coins/platform') } +export const get_coins_platform_all = () => { + return get('/v1/coins/platform/all') +} +export const get_lockup = (address) => { + return getWith('/lockup', { + address: address, + type: 1, + }) +} + + // export const \ No newline at end of file diff --git a/src/components/AppBar.js b/src/components/AppBar.js index ba9ce10..aa04623 100644 --- a/src/components/AppBar.js +++ b/src/components/AppBar.js @@ -6,8 +6,10 @@ import { FiBell, FiArrowRight, FiChevronDown, FiCompass, FiHome, FiMenu, FiSetti import { ImTwitter, ImTelegram, ImFacebook } from "react-icons/im"; import { Logo } from './Logo' import { Link } from 'react-router-dom'; +import { useApp } from '../AppContext'; export const AppBar = ({ onOpen, ...rest }) => { + const app = useApp() const bg = useColorModeValue('white', 'gray.900') const borderBottomColor = useColorModeValue('gray.200', 'gray.700') @@ -32,8 +34,11 @@ export const AppBar = ({ onOpen, ...rest }) => { + { +const Row = ({ children }) => { return ( - + + {children} + + ) +} - +const CardRow = ({ title, value, compond = false }) => { + + return ( + + + + {title} + + { + compond && (Compound Interest) + } + + { + compond + ? {value} + : {value} + } + + + ) +} + +export const FarmCoinCard = ({ index, icon, symbol, apy, deposited, vl, remaining, isNew = false }) => { + return ( + + + + {symbol} + {symbol} + + + Harvest {symbol} + + { + isNew && new + } + + + + + + + + + + + + + + + + + + + + + + ) } \ No newline at end of file diff --git a/src/components/Layout.js b/src/components/Layout.js index b9de32f..ce96088 100644 --- a/src/components/Layout.js +++ b/src/components/Layout.js @@ -39,7 +39,12 @@ export const Layout = ({ children }) => { - + {children} diff --git a/src/components/MiningListCard.js b/src/components/MiningListCard.js index 64fb060..f6d06f3 100644 --- a/src/components/MiningListCard.js +++ b/src/components/MiningListCard.js @@ -2,13 +2,13 @@ import React from 'react' import { HStack, Stack, Flex, Box, Slider, Image, Text, Button, VStack, Icon, AspectRatio, useCallbackRef } from '@chakra-ui/react' import { ImArrowRight2 } from 'react-icons/im' import { config } from '../config' -import { Link } from 'react-router-dom' +import { Link, useNavigate } from 'react-router-dom' const FarmListItem = ({ id, img, symbol, percentage, ...rest }) => { - + const navigateTo = useNavigate() const onBtnMining = () => { - console.log('press ' + id) + navigateTo('/farm') } return ( diff --git a/src/data.js b/src/data.js index 4e6b3dc..74ebcf5 100644 --- a/src/data.js +++ b/src/data.js @@ -20,5 +20,6 @@ export const Images = { config.ENDPOINT + '/static/media/aolink.55778d9b.svg', config.ENDPOINT + '/static/media/codebank.db7917c8.svg', ], - more: config.ENDPOINT + '/static/media/icon-more.c502d302.svg' + more: config.ENDPOINT + '/static/media/icon-more.c502d302.svg', + new: config.ENDPOINT + '/static/media/jiaobiao-eth.4b55fb16.svg', } \ No newline at end of file diff --git a/src/pages/Farm.js b/src/pages/Farm.js index 69f8ac1..7779569 100644 --- a/src/pages/Farm.js +++ b/src/pages/Farm.js @@ -1,13 +1,83 @@ -import { Box } from "@chakra-ui/react"; -import React from "react"; +import React from "react" +import { Box, VStack, Stack, Image, Text, HStack, Flex, AspectRatio, Center, Slider, ButtonGroup, SliderTrack, SliderFilledTrack } from "@chakra-ui/react" +import { StateCard, MiningListCard, FarmCoinCard } from "../components" +import { useApp } from "../AppContext" +import { config } from "../config" +import { get_lockup, get_coins_platform_all } from "../api" +let DEF_LOCK = { + count: 0, + income: 0, +} export const Farm = () => { + const [lock, setLock] = React.useState(DEF_LOCK) + const [coins, setCoins] = React.useState([]) + const app = useApp() + + React.useEffect(() => { + get_lockup(app.address).then(res => { + DEF_LOCK.count = res.data?.count ?? 0 + DEF_LOCK.income = res.data?.income ?? 0 + setLock(DEF_LOCK) + }).catch(err => { + console.error('get_lockup() error:' + err.message) + }) + + get_coins_platform_all().then(res => { + setCoins(res.data) + }).catch(err => { + console.error('get_coins_platform_all() error:' + err.message) + }) + }, [app.address]) return ( - - {/* pool list */} - - + <> + + + lock + + + + + + + + + + + + + + + { + + coins && coins.map((coin, index) => ( + + + + )) + } + ) } \ No newline at end of file