@@ -13,6 +13,7 @@ import {
1313import SectionWithGrid from "../../../shared/SectionWithGrid"
1414import styles from "../ListingForm.module.scss"
1515import { GridRow } from "@bloom-housing/ui-seeds/src/layout/Grid"
16+ import { ListingContext } from "../../ListingContext"
1617
1718type AdditionalFeesProps = {
1819 existingUtilities : ListingUtilities
@@ -22,6 +23,7 @@ type AdditionalFeesProps = {
2223const AdditionalFees = ( props : AdditionalFeesProps ) => {
2324 const formMethods = useFormContext ( )
2425 const { doJurisdictionsHaveFeatureFlagOn } = useContext ( AuthContext )
26+ const listing = useContext ( ListingContext )
2527 // eslint-disable-next-line @typescript-eslint/unbound-method
2628 const { register, watch, errors, clearErrors, setValue } = formMethods
2729
@@ -57,6 +59,14 @@ const AdditionalFees = (props: AdditionalFeesProps) => {
5759 }
5860 } , [ enableUtilitiesIncluded , setValue ] )
5961
62+ // After submitting the deposit max, min, and value can be removed via AdditionalMetadataFormatter.
63+ // On a save and continue flow the values need to be updated in the form
64+ useEffect ( ( ) => {
65+ setValue ( "depositMax" , listing ?. depositMax )
66+ setValue ( "depositMin" , listing ?. depositMin )
67+ setValue ( "depositValue" , listing ?. depositValue )
68+ } , [ listing ?. depositMax , listing ?. depositMin , listing ?. depositValue , setValue ] )
69+
6070 const showAsNonRegulated =
6171 enableNonRegulatedListings && listingType === EnumListingListingType . nonRegulated
6272
0 commit comments