From 666215ac40eb79580964a610b74b74ffe53f4888 Mon Sep 17 00:00:00 2001 From: SpYrO272 Date: Wed, 30 Oct 2024 12:07:04 +0530 Subject: [PATCH] updated --- src/pages/Watchhistory.jsx | 33 ++++++++++++++++++++++++++++----- src/services/allApi.js | 18 +++++++++++++++++- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/pages/Watchhistory.jsx b/src/pages/Watchhistory.jsx index 7a1fc33..8ad7449 100644 --- a/src/pages/Watchhistory.jsx +++ b/src/pages/Watchhistory.jsx @@ -1,9 +1,28 @@ import { faHouse, faTrash } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import React from 'react'; +import React, { useEffect } from 'react'; import { Link } from 'react-router-dom'; function Watchhistory() { + const [allHisPlaylist, setallHisPlaylist] = useState([]) + + const getAllHistory = async()=>{ + const result = await getAudiobookHistoryApi() + setallHisPlaylist(result.data); + + } + + console.log(allHisPlaylist); + + const handleDelete = async(id)=>{ + const result = await deleteHistoryAudiobookApi(id) + console.log(result); + + } + + useEffect(()=>{ + getAllHistory() + },[]) return (
@@ -18,7 +37,7 @@ function Watchhistory() {
- + {allHisPlaylist?.length>0?
@@ -29,20 +48,24 @@ function Watchhistory() { - + {allHisPlaylist?.map((item)=>( + + )) + }
SL.NO
1 dummy dummy dummy -
-

History Cleared

+ : +

History Cleared

}
diff --git a/src/services/allApi.js b/src/services/allApi.js index 13107ff..11d3371 100644 --- a/src/services/allApi.js +++ b/src/services/allApi.js @@ -4,4 +4,20 @@ import {serverurl} from "./serverurl" export const AddCategoryApi = async(reqbody)=>{ return await commonApi('POST',`${serverurl}/category`,reqbody) - } \ No newline at end of file + } + + //add audiobook history + + export const addAudiobookHistoryApi = async(reqBody)=>{ + return await commonApi('POST',`${serverurl}/history`,reqBody) +} + +// get audiobook from history +export const getAudiobookHistoryApi = async()=>{ + return await commonApi('GET',`${serverurl}/history`) +} + +//delete audiobook from history +export const deleteHistoryAudiobookApi = async(id)=>{ + return await commonApi('DELETE',`${serverurl}/history/${id}`) +} \ No newline at end of file