Skip to content

Commit

Permalink
CNFT2-2271 Appearing in table (#1267)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlee-enquizit authored Apr 1, 2024
1 parent 1d22f39 commit bb0f7e0
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export const RepeatingBlock = ({ questions, valid, setValid }: Props) => {

const batches = useWatch({ control: control, name: 'batches' });
const calcTotal = (batches: Batch[]): number => {
return batches.reduce((n, { width }) => n + parseInt(String(width ?? 0)), 0);
return batches
.filter((batch) => batch.appearsInTable)
.reduce((n, { width }) => n + parseInt(String(width ?? 0)), 0);
};

useEffect(() => {
Expand All @@ -38,7 +40,7 @@ export const RepeatingBlock = ({ questions, valid, setValid }: Props) => {
const validateWidths = () => {
const calculated = calcTotal(batches);
setTotal(isNaN(calculated) ? undefined : calculated);
setValid(calcTotal(batches) === 100);
setValid(calculated === 100);
};

return (
Expand Down

0 comments on commit bb0f7e0

Please sign in to comment.