-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix/columns-sorting
- Loading branch information
Showing
28 changed files
with
265 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Injectable } from "@nestjs/common" | ||
import { CsvBuilder } from "./csv-builder.service" | ||
import { Application } from "../applications/entities/application.entity" | ||
import { | ||
applicationFormattingMetadataAggregateFactory, | ||
CSVFormattingType, | ||
} from "./formatting/application-formatting-metadata-factory" | ||
import { | ||
formatDemographicsEthnicity, | ||
formatDemographicsGender, | ||
formatDemographicsHowDidYouHear, | ||
formatDemographicsRace, | ||
formatDemographicsSexualOrientation, | ||
} from "./formatting/format-blocks" | ||
|
||
@Injectable() | ||
export class ApplicationCsvExporter { | ||
constructor(private readonly csvBuilder: CsvBuilder) {} | ||
export( | ||
applications: Application[], | ||
includeHeaders?: boolean, | ||
includeDemographics?: boolean | ||
): string { | ||
return this.csvBuilder.build( | ||
applications, | ||
applicationFormattingMetadataAggregateFactory, | ||
// Every application points to the same listing | ||
applications.length ? applications[0].listing.CSVFormattingType : CSVFormattingType.basic, | ||
includeHeaders, | ||
includeDemographics | ||
? [ | ||
formatDemographicsEthnicity, | ||
formatDemographicsRace, | ||
formatDemographicsGender, | ||
formatDemographicsSexualOrientation, | ||
formatDemographicsHowDidYouHear, | ||
] | ||
: [] | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,68 @@ | ||
import { t } from "@bloom-housing/ui-components" | ||
import moment from "moment" | ||
import { ApplicationSubmissionType } from "@bloom-housing/backend-core/types" | ||
|
||
type DateTimePST = { | ||
hour: string | ||
minute: string | ||
second: string | ||
dayPeriod: string | ||
year: string | ||
day: string | ||
month: string | ||
} | ||
|
||
export const emailRegex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ | ||
|
||
export const convertDataToPst = (dateObj: Date, type: ApplicationSubmissionType) => { | ||
if (!dateObj) { | ||
return { | ||
date: t("t.n/a"), | ||
time: t("t.n/a"), | ||
} | ||
} | ||
|
||
if (type === ApplicationSubmissionType.electronical) { | ||
// convert date and time to PST (electronical applications) | ||
const ptFormat = new Intl.DateTimeFormat("en-US", { | ||
timeZone: "America/Los_Angeles", | ||
hour: "numeric", | ||
minute: "numeric", | ||
second: "numeric", | ||
year: "numeric", | ||
day: "numeric", | ||
month: "numeric", | ||
}) | ||
|
||
const originalDate = new Date(dateObj) | ||
const ptDateParts = ptFormat.formatToParts(originalDate) | ||
const timeValues = ptDateParts.reduce((acc, curr) => { | ||
Object.assign(acc, { | ||
[curr.type]: curr.value, | ||
}) | ||
return acc | ||
}, {} as DateTimePST) | ||
|
||
const { month, day, year, hour, minute, second, dayPeriod } = timeValues | ||
|
||
const date = `${month}/${day}/${year}` | ||
const time = `${hour}:${minute}:${second} ${dayPeriod} PT` | ||
|
||
return { | ||
date, | ||
time, | ||
} | ||
} | ||
|
||
if (type === ApplicationSubmissionType.paper) { | ||
const momentDate = moment(dateObj) | ||
|
||
const date = momentDate.utc().format("MM/DD/YYYY") | ||
const time = momentDate.utc().format("hh:mm:ss A") | ||
|
||
return { | ||
date, | ||
time, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 6 additions & 17 deletions
23
sites/partners/src/applications/PaperApplicationDetails/sections/DetailsApplicationData.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.