Skip to content

Commit

Permalink
#93 frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
fdhhhdjd committed Nov 4, 2022
1 parent 339dcfb commit c83792a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion frontend/src/v1/redux/payment_slice/payment_slice.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Payments = createSlice({
},
[Check_Stock_Product_Initial.rejected]: (state, action) => {
state.loading = false;
state.error = action.payload;
state.error = action.payload.element;
},
//* Payment Check Total
[Check_Total_Cart_Initial.pending]: (state, action) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import React, { useEffect } from 'react'
import { useDispatch, useSelector } from "react-redux"
import { Check_Stock_Product_Initial, Check_Total_Cart_Initial } from '../../../../../redux/payment_slice/Api_Redux_Thunk_Payment';
import { reset_stock_transaction } from '../../../../../redux/payment_slice/payment_slice';
import STORAGES from '../../../../../utils/storage';
import SwaleMessage from '../../../SwaleMessage/SwaleMessage';
const Check_Stock = () => {
const { total_user, stock_transaction } = useSelector((state) => ({ ...state.payment_user }));
const { error } = useSelector((state) => ({ ...state.payment_user }));

const dispatch = useDispatch();
const accessToken = STORAGES.getLocalStorage("accessToken");

const checkCountInStock = async () => {
dispatch(Check_Stock_Product_Initial(accessToken))
};
useEffect(() => {
if (error) {
SwaleMessage("Out Of Stock", 'warning')
}
dispatch(reset_stock_transaction())
}, [error])
return (
<React.Fragment>
<button className="paypal" onClick={checkCountInStock}>
Expand Down

0 comments on commit c83792a

Please sign in to comment.