Skip to content

Commit

Permalink
fix: allow removal of mailing address (#4130)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludtkemorgan committed Jun 12, 2024
1 parent 726e992 commit 871690b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
13 changes: 13 additions & 0 deletions api/src/services/listing.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,19 @@ export class ListingService implements OnModuleInit {
},
});
} else {
// in order to delete the old address we first need to disconnect it from the listing
await this.prisma.listings.update({
data: {
[field]: {
disconnect: {
id: existingListing[field].id,
},
},
},
where: {
id: existingListing.id,
},
});
await this.prisma.address.delete({
where: {
id: existingListing[field].id,
Expand Down
1 change: 1 addition & 0 deletions api/test/integration/listing.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ describe('Listing Controller Tests', () => {
});

const val = await constructFullListingData(listing.id, jurisdictionA.id);
val.listingsApplicationMailingAddress = undefined;

const res = await request(app.getHttpServer())
.put(`/listings/${listing.id}`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ const ApplicationAddress = ({ listing }: ApplicationAddressProps) => {
)
}
inputProps={{
onChange: () => clearErrors("applicationMailingAddress"),
onChange: () => clearErrors("listingsApplicationMailingAddress"),
}}
/>
</Grid.Cell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ export default class AdditionalMetadataFormatter extends Formatter {

cleanAddress("leasingAgentAddress")
cleanAddress("buildingAddress")
cleanAddress("applicationMailingAddress")
cleanAddress("applicationPickUpAddress")
cleanAddress("applicationDropOffAddress")
cleanAddress("listingsApplicationMailingAddress")
cleanAddress("listingsApplicationPickUpAddress")
cleanAddress("listingsApplicationDropOffAddress")

this.data.customMapPin = this.metadata.customMapPositionChosen
this.data.yearBuilt = this.data.yearBuilt ? Number(this.data.yearBuilt) : null
Expand Down
6 changes: 3 additions & 3 deletions sites/partners/src/lib/listings/BooleansFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ export default class BooleansFormatter extends Formatter {
addressTypes[this.data.whereApplicationsMailedIn] !== addressTypes.anotherAddress,
trueCase: () => addressTypes[this.data.whereApplicationsMailedIn],
})
this.processBoolean("applicationDropOffAddress", {
this.processBoolean("listingsApplicationDropOffAddress", {
when:
this.data.canApplicationsBeDroppedOff === YesNoEnum.yes &&
this.data.whereApplicationsDroppedOff === addressTypes.anotherAddress,
trueCase: () => this.data.listingsApplicationDropOffAddress,
})
this.processBoolean("applicationPickUpAddress", {
this.processBoolean("listingsApplicationPickUpAddress", {
when:
this.data.canPaperApplicationsBePickedUp === YesNoEnum.yes &&
this.data.whereApplicationsPickedUp === addressTypes.anotherAddress,
trueCase: () => this.data.listingsApplicationPickUpAddress,
})
this.processBoolean("applicationMailingAddress", {
this.processBoolean("listingsApplicationMailingAddress", {
when:
this.data.canApplicationsBeMailedIn === YesNoEnum.yes &&
this.data.whereApplicationsMailedIn === addressTypes.anotherAddress,
Expand Down

0 comments on commit 871690b

Please sign in to comment.