Skip to content

Commit

Permalink
refactor: toast
Browse files Browse the repository at this point in the history
  • Loading branch information
AlirezaYousefpourM committed Nov 24, 2023
1 parent 4814f27 commit 71269a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 0 additions & 1 deletion frontend/src/pages/presenters/usePresentersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export default function usePresenterPage() {
useEffect(() => {
if (teachersData == null) return;
setTeachers(teachersData);
console.log(teachersData);
}, [teachersData]);

return {
Expand Down
12 changes: 9 additions & 3 deletions frontend/src/pages/workshops/useWorkshopsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default function useWorkshopsPage() {
presentationsData,
addToCartResponse,
addItemToCart,
setAddToCartResponse,
} = useAPI()

const [parsedItemsList, setParsedItemsList] = useState()
Expand All @@ -28,17 +29,22 @@ export default function useWorkshopsPage() {
if (addToCartResponse == null) return

const toastDataTemp = {}
switch (addToCartResponse.response.status) {
switch (addToCartResponse.status) {
case 200:
toastDataTemp.type = "success"
toastDataTemp.message = "Item Successfully Added to Cart!"
break;
default:
case 400:
toastDataTemp.type = "error"
toastDataTemp.message = "Failed to Add Item to Cart!"
toastDataTemp.message = "Failed to Add Item to Cart: Item Is Already In Your Cart!"
break;
case 401:
toastDataTemp.type = "error"
toastDataTemp.message = "Failed to Add Item to Cart: You Should Login First!"
}
setToastData(toastDataTemp)
setOpenToast(true)
setAddToCartResponse(null)
}, [addToCartResponse])

useEffect(() => {
Expand Down

0 comments on commit 71269a8

Please sign in to comment.