@@ -57,13 +57,16 @@ export const ConsignmentWeightTableForm = ({ catches, transportType }: Consignme
5757 if ( isArrival ) {
5858 weight = catchItem ?. netWeightProductArrival ;
5959 } else if (
60- ! catchItem ?. netWeightProductDeparture &&
61- ! catchItem ?. netWeightFisheryProductDeparture &&
60+ // Only fall back to arrival weight when departure was NEVER submitted
61+ // (undefined). A null value means the user explicitly cleared the field;
62+ // in that case show nothing rather than re-showing the arrival weight.
63+ catchItem ?. netWeightProductDeparture === undefined &&
64+ catchItem ?. netWeightFisheryProductDeparture === undefined &&
6265 catchItem ?. netWeightProductArrival
6366 ) {
6467 weight = catchItem . netWeightProductArrival ;
6568 } else {
66- weight = catchItem ?. netWeightProductDeparture ;
69+ weight = catchItem ?. netWeightProductDeparture ?? undefined ;
6770 }
6871 return weight === undefined ? undefined : Number ( weight ) . toFixed ( 2 ) ;
6972 } ;
@@ -72,13 +75,13 @@ export const ConsignmentWeightTableForm = ({ catches, transportType }: Consignme
7275 if ( isArrival ) {
7376 weight = catchItem ?. netWeightFisheryProductArrival ;
7477 } else if (
75- ! catchItem ?. netWeightProductDeparture &&
76- ! catchItem ?. netWeightFisheryProductDeparture &&
78+ catchItem ?. netWeightProductDeparture === undefined &&
79+ catchItem ?. netWeightFisheryProductDeparture === undefined &&
7780 catchItem ?. netWeightFisheryProductArrival
7881 ) {
7982 weight = catchItem . netWeightFisheryProductArrival ;
8083 } else {
81- weight = catchItem ?. netWeightFisheryProductDeparture ;
84+ weight = catchItem ?. netWeightFisheryProductDeparture ?? undefined ;
8285 }
8386 return weight === undefined ? undefined : Number ( weight ) . toFixed ( 2 ) ;
8487 } ;
@@ -277,7 +280,11 @@ export const action: ActionFunction = async ({ request, params }): Promise<Respo
277280 const isNonJs = form . get ( "isNonJs" ) === "true" ;
278281 const { _action, ...values } = Object . fromEntries ( form ) ;
279282 const isDraft = form . get ( "_action" ) === "saveAsDraft" ;
280- const saveToRedisIfErrors = isDraft ;
283+ // Always persist submitted weights (even when validation fails) so that the
284+ // progress page correctly reflects the current state. Without this, a failed
285+ // Confirm submission reverts to the previously-saved valid weights in the DB,
286+ // causing the section to appear Complete even after the user has cleared them.
287+ const saveToRedisIfErrors = true ;
281288
282289 const isEdit = ( _action as string ) ?. startsWith ( "edit-" ) ;
283290 const isRemove = ( _action as string ) ?. startsWith ( "remove-" ) ;
0 commit comments