-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Render email to DHCR using React on server-side. (#1520)
This fixes #892 and tees us up for localizing the email content (#1508). It also refactors our CSS a bit by adding a new `.jf-email-subject` class that can be used to style the subject lines of our email previews in a DRY way.
- Loading branch information
Showing
24 changed files
with
271 additions
and
178 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,43 @@ | ||
import React from "react"; | ||
|
||
import { useContext } from "react"; | ||
import { AppContext } from "../app-context"; | ||
import { | ||
EmailSubject, | ||
asEmailStaticPage, | ||
} from "../static-page/email-static-page"; | ||
import { | ||
getBoroughChoiceLabels, | ||
BoroughChoice, | ||
} from "../../../common-data/borough-choices"; | ||
|
||
export const RhEmailToDhcr: React.FC<{}> = () => { | ||
const rh = useContext(AppContext).session.rentalHistoryInfo; | ||
|
||
if (!rh) { | ||
return <p>We do not have enough information to create an email to DHCR.</p>; | ||
} | ||
|
||
const fullName = `${rh.firstName} ${rh.lastName}`; | ||
const borough = getBoroughChoiceLabels()[rh.borough as BoroughChoice]; | ||
const fullAddress = `${rh.address}, ${borough} ${rh.zipcode}`.trim(); | ||
|
||
return ( | ||
<> | ||
<EmailSubject value="Request for Rent History" /> | ||
<p>DHCR administrator,</p> | ||
<p> | ||
I, {fullName}, am currently living at {fullAddress} in apartment{" "} | ||
{rh.apartmentNumber}, and would like to request the complete Rent | ||
History for this apartment back to the year 1984. | ||
</p> | ||
<p> | ||
Thank you, | ||
<br /> | ||
{fullName} | ||
</p> | ||
</> | ||
); | ||
}; | ||
|
||
export const RhEmailToDhcrStaticPage = asEmailStaticPage(RhEmailToDhcr); |
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
30 changes: 30 additions & 0 deletions
30
frontend/lib/rh/tests/__snapshots__/email-to-dhcr.test.tsx.snap
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,30 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`email to dhcr renders 1`] = ` | ||
<div> | ||
<p | ||
class="jf-email-subject" | ||
> | ||
Subject: | ||
Request for Rent History | ||
</p> | ||
<p> | ||
DHCR administrator, | ||
</p> | ||
<p> | ||
I, | ||
boop jones | ||
, am currently living at | ||
150 DOOMBRINGER STREET, Manhattan 10001 | ||
in apartment | ||
2 | ||
, and would like to request the complete Rent History for this apartment back to the year 1984. | ||
</p> | ||
<p> | ||
Thank you, | ||
<br /> | ||
boop jones | ||
</p> | ||
</div> | ||
`; |
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,14 @@ | ||
import React from "react"; | ||
import { AppTesterPal } from "../../tests/app-tester-pal"; | ||
import { RhEmailToDhcr } from "../email-to-dhcr"; | ||
import { exampleRentalHistoryInfo } from "./example-rh-info"; | ||
|
||
test("email to dhcr renders", () => { | ||
const pal = new AppTesterPal(<RhEmailToDhcr />, { | ||
session: { | ||
rentalHistoryInfo: exampleRentalHistoryInfo, | ||
}, | ||
}); | ||
|
||
expect(pal.rr.container).toMatchSnapshot(); | ||
}); |
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,12 @@ | ||
import { AllSessionInfo_rentalHistoryInfo } from "../../queries/AllSessionInfo"; | ||
|
||
export const exampleRentalHistoryInfo: AllSessionInfo_rentalHistoryInfo = { | ||
firstName: "boop", | ||
lastName: "jones", | ||
address: "150 DOOMBRINGER STREET", | ||
apartmentNumber: "2", | ||
phoneNumber: "2120000000", | ||
borough: "MANHATTAN", | ||
zipcode: "10001", | ||
addressVerified: true, | ||
}; |
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,6 @@ | ||
.jf-email-subject { | ||
font-size: 1rem; | ||
font-style: italic; | ||
border-bottom: 2px solid $grey-lighter; | ||
padding-bottom: 1rem; | ||
} |
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,3 @@ | ||
.jf-email-subject { | ||
border-bottom: 1px solid $light; | ||
} |
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
Oops, something went wrong.