diff --git a/src/components/WalletManagement/History/History.tsx b/src/components/WalletManagement/History/History.tsx index 7e8e0a9ac5e6c93c2698edfadc48886a5a8cae14..0b2ab5aed2a9ecc7be42cc9b00947f33b7488e18 100644 --- a/src/components/WalletManagement/History/History.tsx +++ b/src/components/WalletManagement/History/History.tsx @@ -1,9 +1,11 @@ -import React from "react"; +import React, { FC, useEffect, useState } from "react"; import { ToastContainer } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; import { FaWallet, FaPlus } from 'react-icons/fa6'; import HistorySingle from './HistorySingle'; import { useNavigate } from 'react-router-dom'; +import axios from "axios"; +import { REST_BASE_URL } from "@/constant/constants"; const History = () => { const navigate = useNavigate(); @@ -13,6 +15,26 @@ const History = () => { navigate(yourRoute); }; + const [userHistory, setUserHistory] = useState<any>(); + + useEffect(() => { + + const userID = 1; + + const fetchData = async () => { + const userHistoryData = await axios.get( + REST_BASE_URL + '/history/get/' + userID + ); + setUserHistory(userHistoryData.data); + } + + fetchData(); + console.log(userHistory); + + }, []); + + + return ( <> <ToastContainer /> @@ -44,6 +66,16 @@ const History = () => { </div> </div> <div className="relative top-16 mb-4"> + {userHistory && userHistory.map((element, index: number) => ( + <HistorySingle + key={index} + status={element.status} + title={element.info} + subtitle={element.reciever} + amount={'Rp ' + new Intl.NumberFormat('id-ID').format(element.amount)} + /> + ))} + <HistorySingle status="Berhasil" title="Transfer ke"