openinventory ofpd update viq admin
This commit is contained in:
parent
faeb4faa5b
commit
1ec4d8951f
@ -14,6 +14,7 @@ const DistributorOpeningInventory = () => {
|
||||
const { id, distributortype } = useParams();
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [success, setSuccess] = useState(false);
|
||||
const [productsData, setProductsData] = useState([]);
|
||||
const [allProductsData, setAllProductsData] = useState([]);
|
||||
const [categories, setCategories] = useState([]);
|
||||
@ -112,7 +113,7 @@ const DistributorOpeningInventory = () => {
|
||||
}, [getUserDetails]);
|
||||
useEffect(() => {
|
||||
getProductsData();
|
||||
}, [currentPage, itemPerPage]);
|
||||
}, [success, currentPage, itemPerPage]);
|
||||
const getCatagories = () => {
|
||||
axios
|
||||
.get(`/api/category/getCategories`, {
|
||||
@ -199,6 +200,8 @@ const DistributorOpeningInventory = () => {
|
||||
{ headers: { Authorization: `Bearer ${token}` } }
|
||||
);
|
||||
swal("Success", "Stocks updated successfully!", "success");
|
||||
setUpdatedStocks({});
|
||||
setSuccess((prev) => !prev);
|
||||
} catch (error) {
|
||||
swal("Error", "Failed to update stocks!", "error");
|
||||
}
|
||||
@ -359,7 +362,7 @@ const DistributorOpeningInventory = () => {
|
||||
className="mt-4"
|
||||
variant="contained"
|
||||
color="primary"
|
||||
// onClick={handleSubmitStocks}
|
||||
onClick={handleSubmitStocks}
|
||||
disabled={loading}
|
||||
>
|
||||
Save
|
||||
@ -435,18 +438,18 @@ const DistributorOpeningInventory = () => {
|
||||
<input
|
||||
type="text"
|
||||
value={
|
||||
updatedStocks[product.SKU] ||
|
||||
product.openingInventory
|
||||
updatedStocks[product.SKU] !== undefined
|
||||
? updatedStocks[product.SKU]
|
||||
: product.openingInventory
|
||||
}
|
||||
onChange={(e) => {
|
||||
// Check if the input is a valid number or empty
|
||||
const value = e.target.value;
|
||||
if (
|
||||
value === "" ||
|
||||
/^[0-9]*$/.test(value)
|
||||
) {
|
||||
// Allow only numbers or empty
|
||||
handleStockChange(product.SKU, value);
|
||||
if (/^[0-9]*$/.test(value)) {
|
||||
// Allow only numbers or empty input, but set 0 if input is empty
|
||||
handleStockChange(
|
||||
product.SKU,
|
||||
value === "" ? 0 : value
|
||||
);
|
||||
}
|
||||
}}
|
||||
className="form-control"
|
||||
|
Loading…
Reference in New Issue
Block a user