Skip to content

Commit

Permalink
hooks for the edit and delete components
Browse files Browse the repository at this point in the history
  • Loading branch information
vantage-ola committed Nov 4, 2024
1 parent 1b792a1 commit 69c4a73
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions tracknow/web/src/hooks/useLaptimes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ export const useLaptimes = () => {
mySetPage((prevPage) => prevPage + 1);
}
};

// add laptimes
const addLaptime = async (newLaptime: Laptime,) => {
const addLaptime = async (newLaptime: Laptime) => {

try {

Expand All @@ -109,10 +110,39 @@ export const useLaptimes = () => {
}
};

// edit user laptime
const editLaptime = async (id: number, editLaptime: Laptime) => {

try {

const response = await API.editUserLaptime(id, editLaptime);
return response;

} catch (error) {

throw new Error("Laptime cannot be edited!")
}

};

// delete user laptime
const deleteLaptime = async (id: number) => {

try {

const response = await API.deleteUserLaptime(id);
return response;

} catch (error) {

throw new Error("Laptime cannot be deleted.")
}
};

return {
laptime, addLaptime, mylaptime, fetchMoreData,
hasMore, fetchMoreData2, hasMore2, laptime_loading,
fetchUsersLaptimes, fetchAUserLaptime
fetchUsersLaptimes, fetchAUserLaptime, editLaptime, deleteLaptime

};

Expand Down

0 comments on commit 69c4a73

Please sign in to comment.