Victor Pham 1 tahun lalu
induk
melakukan
b2f44653e2
2 mengubah file dengan 121 tambahan dan 26 penghapusan
  1. 117 22
      src/api/APIs.ts
  2. 4 4
      src/pages/Home.tsx

+ 117 - 22
src/api/APIs.ts

@@ -1,16 +1,16 @@
-import { get, patch, post } from '@src/api';
-import { ESNSType } from '@src/constants/Login';
-import { IFilter } from 'metarare';
-import { EItemType, ECurrencyType, ESaleType } from '@src/constants/Enums';
-import { isDev, isLocal, LOCAL_ENDPOINT } from '@src/constants/NodeEnv';
+import { get, patch, post } from "@src/api";
+import { ESNSType } from "@src/constants/Login";
+import { IFilter } from "metarare";
+import { EItemType, ECurrencyType, ESaleType } from "@src/constants/Enums";
+import { isDev, isLocal, LOCAL_ENDPOINT } from "@src/constants/NodeEnv";
 
 const getHost = () => {
   if (isLocal) {
     return LOCAL_ENDPOINT;
   } else if (isDev) {
-    return 'https://apibeta.meta-rare.net';
+    return "https://api.pepemomy.com";
   } else {
-    return 'https://api.meta-rare.net';
+    return "https://api.meta-rare.net";
   }
 };
 
@@ -41,7 +41,13 @@ const fetchCollectionActivity = (name: string) => {
   return post({ url });
 };
 
-const fetchCollectionItem = ({ name, filter }: { name: string; filter: IFilter }) => {
+const fetchCollectionItem = ({
+  name,
+  filter
+}: {
+  name: string;
+  filter: IFilter;
+}) => {
   const url = `${host}/v1/collection/item/${name}`;
 
   return post({ url, body: filter });
@@ -72,8 +78,6 @@ const fetchExploreHint = (filter: IFilter) => {
   return post({ url, body: filter });
 };
 
-
-
 const fetchExploreKeyword = (collectionName: string) => {
   const url = `${host}/v1/explore/keyword`;
 
@@ -94,13 +98,29 @@ const fetchHomeArtists = (filter: IFilter) => {
 };
 
 // sale
-const saleHighestPrice = ({ bid_price, currency, sale_id }: { bid_price: number; currency: ECurrencyType; sale_id: number }) => {
+const saleHighestPrice = ({
+  bid_price,
+  currency,
+  sale_id
+}: {
+  bid_price: number;
+  currency: ECurrencyType;
+  sale_id: number;
+}) => {
   const url = `${host}/v1/sale/auction`;
 
   return post({ url, body: { bid_price, currency, sale_id } });
 };
 
-const saleBid = ({ bid_price, currency, sale_id }: { bid_price: number; currency: ECurrencyType; sale_id: number }) => {
+const saleBid = ({
+  bid_price,
+  currency,
+  sale_id
+}: {
+  bid_price: number;
+  currency: ECurrencyType;
+  sale_id: number;
+}) => {
   const url = `${host}/v1/sale/bid`;
 
   return post({ url, body: { bid_price, currency, sale_id } });
@@ -118,16 +138,51 @@ const fetchBid = (id: number) => {
   return get({ url });
 };
 
-const saleBuy = ({ bid_price, currency, sale_id }: { bid_price: number; currency: ECurrencyType; sale_id: number }) => {
+const saleBuy = ({
+  bid_price,
+  currency,
+  sale_id
+}: {
+  bid_price: number;
+  currency: ECurrencyType;
+  sale_id: number;
+}) => {
   const url = `${host}/v1/sale/buy`;
 
   return post({ url, body: { bid_price, currency, sale_id } });
 };
 
-const resale = ({ currency, end_at, price, sale_type, start_at, start_price, token_id }: { currency: ECurrencyType; end_at?: string; price?: number; sale_type: ESaleType; start_at?: string; start_price?: number; token_id: number }) => {
+const resale = ({
+  currency,
+  end_at,
+  price,
+  sale_type,
+  start_at,
+  start_price,
+  token_id
+}: {
+  currency: ECurrencyType;
+  end_at?: string;
+  price?: number;
+  sale_type: ESaleType;
+  start_at?: string;
+  start_price?: number;
+  token_id: number;
+}) => {
   const url = `${host}/v1/sale/resale`;
 
-  return post({ url, body: { currency, end_at, price, sale_type, start_at, start_price, token_id } });
+  return post({
+    url,
+    body: {
+      currency,
+      end_at,
+      price,
+      sale_type,
+      start_at,
+      start_price,
+      token_id
+    }
+  });
 };
 
 const changeSaleStatus = (id: number) => {
@@ -146,7 +201,7 @@ const fetchSaleRanking = (filter: IFilter) => {
   const url = `${host}/v1/sale/ranking`;
 
   return get({ url, params: filter });
-}
+};
 
 // token
 const fetchToken = (id: number) => {
@@ -167,7 +222,13 @@ const fetchBaseInfo = (type: EItemType) => {
   return get({ url });
 };
 
-const changeLike = ({ tokenId, isLike }: { tokenId: number; isLike: boolean }) => {
+const changeLike = ({
+  tokenId,
+  isLike
+}: {
+  tokenId: number;
+  isLike: boolean;
+}) => {
   const url = `${host}/v1/token/like`;
 
   return patch({ url, body: { token_id: tokenId, is_like: isLike } });
@@ -204,7 +265,13 @@ const fetchUserBid = (filter: IFilter) => {
   return post({ url, body: filter });
 };
 
-const fetchUserCollection = ({ name, filter }: { name: string; filter: IFilter }) => {
+const fetchUserCollection = ({
+  name,
+  filter
+}: {
+  name: string;
+  filter: IFilter;
+}) => {
   const url = `${host}/v1/user/collection/${name}`;
 
   return post({ url, body: filter });
@@ -222,13 +289,25 @@ const fetchUserLike = ({ name, filter }: { name: string; filter: IFilter }) => {
   return post({ url, body: filter });
 };
 
-const fetchUserOwned = ({ name, filter }: { name: string; filter: IFilter }) => {
+const fetchUserOwned = ({
+  name,
+  filter
+}: {
+  name: string;
+  filter: IFilter;
+}) => {
   const url = `${host}/v1/user/owned/${name}`;
 
   return post({ url, body: filter });
 };
 
-const fetchUserOnSale = ({ name, filter }: { name: string; filter: IFilter }) => {
+const fetchUserOnSale = ({
+  name,
+  filter
+}: {
+  name: string;
+  filter: IFilter;
+}) => {
   const url = `${host}/v1/user/onsale/${name}`;
 
   return post({ url, body: filter });
@@ -252,7 +331,17 @@ const changeUserProfile = (formData: FormData) => {
   return patch({ url, body: formData });
 };
 
-const transfer = ({ amount, currency, to_address, code }: { amount: number; currency: ECurrencyType; to_address: string; code: string }) => {
+const transfer = ({
+  amount,
+  currency,
+  to_address,
+  code
+}: {
+  amount: number;
+  currency: ECurrencyType;
+  to_address: string;
+  code: string;
+}) => {
   const url = `${host}/v1/user/transfer`;
 
   return post({ url, body: { amount, currency, to_address, code } });
@@ -270,7 +359,13 @@ const signIn = (code: string, type: ESNSType) => {
   return post({ url, body: { code, type } });
 };
 
-const sendEmail = ({ amount, currency }: { amount: number; currency: ECurrencyType }) => {
+const sendEmail = ({
+  amount,
+  currency
+}: {
+  amount: number;
+  currency: ECurrencyType;
+}) => {
   const url = `${host}/v1/user/certification/code`;
 
   return post({ url, body: { amount, currency } });

+ 4 - 4
src/pages/Home.tsx

@@ -90,25 +90,25 @@ const Home: React.FC = () => {
               <BannerScrollList list={data.curating_list} />
             </div>
           )}
-          {!!data?.special_bids.length && (
+          {!!data?.special_bids?.length && (
             <div className={cx("home_group")}>
               <strong className={cx("home_title")}>Special Bids 🌟</strong>
               <NFTScrollList list={data.special_bids} />
             </div>
           )}
-          {!!data?.hot_bids.length && (
+          {!!data?.hot_bids?.length && (
             <div className={cx("home_group")}>
               <strong className={cx("home_title")}>지금 뜨는 Bids 🚀</strong>
               <NFTScrollList list={data.hot_bids} />
             </div>
           )}
-          {!!data?.time_auctions.length && (
+          {!!data?.time_auctions?.length && (
             <div className={cx("home_group")}>
               <strong className={cx("home_title")}>타임옥션 🔥</strong>
               <NFTScrollList list={data.time_auctions} />
             </div>
           )}
-          {!!data?.collections.length && (
+          {!!data?.collections?.length && (
             <div className={cx("home_group")}>
               <strong className={cx("home_title")}>인기 콜렉션 🎉</strong>
               <CollectionScrollList list={data.collections} />