Skip to content

Commit

Permalink
fix table pop up after size change
Browse files Browse the repository at this point in the history
  • Loading branch information
0101oak committed Oct 23, 2024
1 parent 9de8273 commit c31723a
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const SizesAndMeasurements: FC<ProductSizesAndMeasurementsInterface> = ({
const { values, setFieldValue, errors, touched } = useFormikContext<common_ProductNew>();
const [lastSizeNonZero, setLastSizeNonZero] = useState(false);
const [hasChangedSize, setHasChangedSize] = useState<{ [key: number]: boolean }>({});
const [hasConfirmedSizeChange, setHasConfirmedSizeChange] = useState(false);
const sortedSizes = dictionary && dictionary.sizes ? sortItems(dictionary.sizes) : [];
const sortedMeasurements =
dictionary && dictionary.measurements ? sortItems(dictionary.measurements) : [];
Expand Down Expand Up @@ -82,12 +83,13 @@ export const SizesAndMeasurements: FC<ProductSizesAndMeasurementsInterface> = ({
) => {
const { value } = event.target;

if (isEditMode && sizeId && !hasChangedSize[sizeId]) {
if (isEditMode && sizeId && !hasChangedSize[sizeId] && !hasConfirmedSizeChange) {
const confirmed = window.confirm('Are you sure you want to change the size quantity?');
if (!confirmed) {
return;
}
setHasChangedSize((prev) => ({ ...prev, [sizeId]: true }));
setHasConfirmedSizeChange(true);
}

const sizeIndex = values.sizeMeasurements?.findIndex(
Expand Down

0 comments on commit c31723a

Please sign in to comment.