diff --git a/Front/src/coinApi-types.ts b/Front/src/coinApi-types.ts
index 29312a1..0787aa9 100644
--- a/Front/src/coinApi-types.ts
+++ b/Front/src/coinApi-types.ts
@@ -1,3 +1,5 @@
+import { ReactNode } from "react";
+
export interface IGetGlobalResponse {
active_cryptocurrencies: number;
markets: number;
@@ -17,18 +19,37 @@ export interface IGetCoinsCountResponse {
}
export interface IGetCoinInfoResponse {
- [key: string]: any;
+ name: string;
+ id: string;
+ image: {
+ large: string;
+ };
+ description: {
+ en: string;
+ }
+ market_data: {
+ low_24h: { usd: number };
+ high_24h: { usd: number };
+ ath: { usd: number };
+ atl: { usd: number };
+ price_change_percentage_24h: number;
+ price_change_percentage_7d: number;
+ price_change_percentage_14d: number;
+ price_change_percentage_30d: number;
+ price_change_percentage_60d: number;
+ price_change_percentage_200d: number;
+ price_change_percentage_1y: number;
+ }
+}
+
+export interface IGetCoinInfoData {
+ data: IGetCoinInfoResponse
}
export interface IGetCoinInfoRequest {
id: string;
}
-// export interface IGetCoinChartRequest {
-// page: number;
-// per_page: number;
-// }
-
export interface IChartDataItem {
[index: number]: number,
}
diff --git a/Front/src/coinDetails/coinDetails.tsx b/Front/src/coinDetails/coinDetails.tsx
index e40275a..f1c40b1 100644
--- a/Front/src/coinDetails/coinDetails.tsx
+++ b/Front/src/coinDetails/coinDetails.tsx
@@ -1,3 +1,4 @@
+import React from 'react'
import { useParams } from 'react-router-dom';
import { useGetCoinInfoQuery } from '../coinApi';
@@ -12,22 +13,25 @@ import CoinInfo from './coinInfo';
const CoinDetails = (): JSX.Element => {
const { id } = useParams();
const {
- data: data,
- error: errorInfo,
- isLoading: isLoadingInfo,
- isSuccess: isSuccessInfo,
- refetch: refetchInfo
+ data,
+ error,
+ isLoading,
+ isSuccess,
} = useGetCoinInfoQuery(id ? id : '');
+ React.useEffect(() => {
+ console.log(data)
+ }, [])
+
return (
+ {isLoading &&
Loading...
}
{
- data && isSuccessInfo && <>
+ data && isSuccess && <>
{data.name}
-
@@ -39,8 +43,8 @@ const CoinDetails = (): JSX.Element => {
-
-
+
+
diff --git a/Front/src/coinDetails/coinInfo.tsx b/Front/src/coinDetails/coinInfo.tsx
index e7c8d99..53e1431 100644
--- a/Front/src/coinDetails/coinInfo.tsx
+++ b/Front/src/coinDetails/coinInfo.tsx
@@ -27,7 +27,7 @@ const CoinInfo = (props: ICoinInfoProps): JSX.Element => {
Current price: ${data.tickers[0].converted_last.usd}
- Homepage: {data.links.homepage}
+ Homepage: {data.links.homepage[0]}
Votes: {data.sentiment_votes_up_percentage}%
@@ -38,27 +38,35 @@ const CoinInfo = (props: ICoinInfoProps): JSX.Element => {
{data.links.subreddit_url &&
- } href={data.links.subreddit_url}>
+ } href={data.links.subreddit_url}>
Reddit
}
{data.links.twitter_screen_name &&
- } href={`https://twitter.com/${data.links.twitter_screen_name}`}>
+ } href={`https://twitter.com/${data.links.twitter_screen_name}`}>
Twitter
}
{
Object.entries(data.links.chat_url).map(
- ([key, value]) => Boolean(value)
- && }
+ ([key, value]) => {
+ if (Boolean(value)) {
+ console.log(value);
+ const domain = new URL(String(value));
+ const label = domain.hostname.split(".")[0]
+ return (
+ }
>
- Discord
+ {label}
+ )
+ }
+ }
)
}
diff --git a/Front/src/coinDetails/coinStats.tsx b/Front/src/coinDetails/coinStats.tsx
index 5fd2376..77d7686 100644
--- a/Front/src/coinDetails/coinStats.tsx
+++ b/Front/src/coinDetails/coinStats.tsx
@@ -5,12 +5,17 @@ import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
-export interface ICoinStatsProps {
- [key: string]: any;
+import { IGetCoinInfoResponse, IGetCoinInfoData } from '../coinApi-types'
+
+interface ICoinStatsProps {
+ data: IGetCoinInfoResponse;
}
const CoinStats = (props: ICoinStatsProps): JSX.Element => {
+ console.log("CoinStats props", props)
+
const { data } = props;
+
const tableData = [
{title: "24h Hight", value: `$${data.market_data.low_24h.usd}`},
{title: "24h Low", value: `$${data.market_data.high_24h.usd}`},
diff --git a/Front/src/coinList/coinList.tsx b/Front/src/coinList/coinList.tsx
index e7d55f7..4041c27 100644
--- a/Front/src/coinList/coinList.tsx
+++ b/Front/src/coinList/coinList.tsx
@@ -12,7 +12,17 @@ import { useGetCoinsListQuery, useGetGlobalQuery } from '../coinApi';
import Pager from './coinListPager';
-
+export interface IData {
+ id: string;
+ image: string;
+ name: string;
+ market_cap_rank: number;
+ symbol: string;
+ current_price: string;
+ high_24h: number;
+ low_24h: number;
+ price_change_percentage_24h: number;
+}
const CoinList = (): JSX.Element => {
@@ -74,7 +84,7 @@ const CoinList = (): JSX.Element => {
{
- data.map((row: any, index: any) => (
+ data.map((row: IData, index: number) => (
{
}
-
+
)
}
diff --git a/Front/src/coinList/coinListPager.tsx b/Front/src/coinList/coinListPager.tsx
index 98d2f81..854e94f 100644
--- a/Front/src/coinList/coinListPager.tsx
+++ b/Front/src/coinList/coinListPager.tsx
@@ -6,32 +6,37 @@ import ButtonGroup from '@mui/material/ButtonGroup';
import Typography from '@mui/material/Typography';
import Grid from '@mui/material/Grid';
-const Pager = (props:any): JSX.Element => {
- const { page, per_page, } = props;
- const { data, error, isLoading, isSuccess, refetch } = useGetCoinsCountQuery();
- const navigate = useNavigate();
- const lastPage = (data: number) => Math.ceil(data / per_page)
+export interface IPagerProps {
+ page: number;
+ per_page: number;
+}
- function handlePager(page: number) {
- const url = `/?page=${page}`
- navigate(url)
+const Pager = (props: IPagerProps): JSX.Element => {
+ const { page, per_page, } = props;
+ const { data, error, isLoading, isSuccess, refetch } = useGetCoinsCountQuery();
+ const navigate = useNavigate();
+ const lastPage = (data: number) => Math.ceil(data / per_page)
+
+ function handlePager(page: number) {
+ const url = `/?page=${page}`
+ navigate(url)
+ }
+
+ return (<>
+ {
+ data && isSuccess &&
+
+
+
+
+ Page {page} from {lastPage(data.count)}
+
+
+
+
}
-
- return (<>
- {
- data && isSuccess &&
-
-
-
-
- Page {page} from {lastPage(data.count)}
-
-
-
-
- }
- >
- )
+ >
+ )
}
export default Pager;
diff --git a/README.md b/README.md
index df56483..3817062 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
## What's inside
-- **Frontend:** Typescript using React, Redux-Toolkit, MaterialUI, react-charts-2
+- **Frontend:** Typescript using React, Redux-Toolkit, Material-UI, react-chartjs-2
- **Backend:** Javascript using Express
