22 lines
559 B
JavaScript
22 lines
559 B
JavaScript
|
|
import { useSelector, useDispatch } from "react-redux";
|
||
|
|
import {
|
||
|
|
ChangeTotalAmount,
|
||
|
|
globalExtraTotalAmount,
|
||
|
|
} from "../Features/ExteraCharges/ExtraCharges";
|
||
|
|
|
||
|
|
export const useUtilsComponent = () => {
|
||
|
|
const dispatch = useDispatch();
|
||
|
|
const extraCharges = useSelector(globalExtraTotalAmount);
|
||
|
|
|
||
|
|
const removeExtraCharge = (item) => {
|
||
|
|
const filtered = extraCharges?.filter(
|
||
|
|
(e) => e?.localId !== item?.localId
|
||
|
|
);
|
||
|
|
dispatch(ChangeTotalAmount(filtered));
|
||
|
|
};
|
||
|
|
|
||
|
|
return {
|
||
|
|
removeExtraCharge,
|
||
|
|
};
|
||
|
|
};
|