actual fix for the reseting of limit, need to reset modal internal state

This commit is contained in:
phyzical 2022-04-02 13:29:56 +08:00
parent 9e39ca32a5
commit 8d56c41dd6
2 changed files with 16 additions and 2 deletions

@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import { LimitMaterialProduction } from "../../Actions";
import { Modal } from "../../../ui/React/Modal";
import Typography from "@mui/material/Typography";
@ -17,6 +17,13 @@ interface IProps {
export function LimitMaterialProductionModal(props: IProps): React.ReactElement {
const [limit, setLimit] = useState<number | null>(null);
// reset modal internal state on modal close
useEffect(() => {
if (!props.open) {
setLimit(null);
}
}, [props.open]);
function limitMaterialProduction(): void {
let qty = limit;
if (qty === null) qty = -1;

@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import { Product } from "../../Product";
import { LimitProductProduction } from "../../Actions";
import { Modal } from "../../../ui/React/Modal";
@ -18,6 +18,13 @@ interface IProps {
export function LimitProductProductionModal(props: IProps): React.ReactElement {
const [limit, setLimit] = useState<number | null>(null);
// reset modal internal state on modal close
useEffect(() => {
if (!props.open) {
setLimit(null);
}
}, [props.open]);
function limitProductProduction(): void {
let qty = limit;
if (qty === null) qty = -1;