Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 22 additions & 27 deletions api/src/services/listing-csv-export.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import {
} from '../utilities/feature-flag-utilities';
import { UnitGroupSummary } from '../dtos/unit-groups/unit-group-summary.dto';
import { addUnitGroupsSummarized } from '../utilities/unit-groups-transformations';
import { ListingDocuments } from 'src/dtos/listings/listing-documents.dto';

includeViews.csv = {
listingMultiselectQuestions: {
Expand Down Expand Up @@ -429,6 +430,19 @@ export class ListingCsvExporterService implements CsvExporterServiceInterface {
return fieldValue;
};

buildSelectList(
val: ListingUtilities | ListingDocuments | ListingFeatures,
): string {
if (!val) return '';
const selectedValues = Object.entries(val).reduce((combined, entry) => {
if (entry[1] === true) {
combined.push(entry[0]);
}
return combined;
}, []);
return selectedValues.join(', ');
}

async getCsvHeaders(user: User): Promise<CsvHeader[]> {
const enableNonRegulatedListings = doAnyJurisdictionHaveFeatureFlagSet(
user.jurisdictions,
Expand Down Expand Up @@ -655,19 +669,7 @@ export class ListingCsvExporterService implements CsvExporterServiceInterface {
headers.push({
path: 'listingUtilities',
label: 'Utilities Included',
format: (val: ListingUtilities): string => {
if (!val) return '';
const selectedValues = Object.entries(val).reduce(
(combined, entry) => {
if (entry[1] === true) {
combined.push(entry[0]);
}
return combined;
},
[],
);
return selectedValues.join(', ');
},
format: this.buildSelectList,
});
}
if (
Expand All @@ -679,19 +681,7 @@ export class ListingCsvExporterService implements CsvExporterServiceInterface {
headers.push({
path: 'listingFeatures',
label: 'Property Amenities',
format: (val: ListingFeatures): string => {
if (!val) return '';
const selectedValues = Object.entries(val).reduce(
(combined, entry) => {
if (entry[1] === true) {
combined.push(entry[0]);
}
return combined;
},
[],
);
return selectedValues.join(', ');
},
format: this.buildSelectList,
});
}

Expand Down Expand Up @@ -989,9 +979,14 @@ export class ListingCsvExporterService implements CsvExporterServiceInterface {
path: 'programRules',
label: 'Important Program Rules',
},
{
path: 'requiredDocumentsList',
label: 'Required documents',
format: this.buildSelectList,
},
{
path: 'requiredDocuments',
label: 'Required Documents',
label: 'Required documents (Additional Info)',
},
{
path: 'specialNotes',
Expand Down
Loading
Loading