-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e911ab
commit 2800ee3
Showing
13 changed files
with
273 additions
and
272 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
describe("My applications page", function () { | ||
it("renders the my applications page", function () { | ||
cy.visit("/account/applications") | ||
cy.getByID("email").type("admin@example.com") | ||
cy.getByID("password").type("abcdef") | ||
cy.get("button").contains("Sign In").click() | ||
cy.visit("/account/applications") | ||
cy.contains("My Applications") | ||
}) | ||
}) |
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 @@ | ||
import React, { useContext, useEffect, useState } from "react" | ||
import { Application, Listing } from "@bloom-housing/backend-core/types" | ||
import { AppStatusItem, ApiClientContext } from "@bloom-housing/ui-components" | ||
|
||
interface AppStatusItemWrapperProps { | ||
application: Application | ||
} | ||
|
||
const AppStatusItemWrapper = (props: AppStatusItemWrapperProps) => { | ||
const { listingsService } = useContext(ApiClientContext) | ||
const [listing, setListing] = useState<Listing>() | ||
|
||
useEffect(() => { | ||
listingsService | ||
?.retrieve({ listingId: props.application.listing.id }) | ||
.then((retrievedListing) => { | ||
setListing(retrievedListing) | ||
}) | ||
.catch((err) => console.error(`Error fetching listing: ${err}`)) | ||
}, [listingsService, props.application]) | ||
|
||
return listing ? ( | ||
<AppStatusItem application={props.application} listing={listing} key={props.application.id} /> | ||
) : ( | ||
// Potential for a loading state here | ||
<></> | ||
) | ||
} | ||
|
||
export { AppStatusItemWrapper as default, AppStatusItemWrapper } |
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,124 @@ | ||
import React, { useEffect, useState, useContext } from "react" | ||
import { | ||
ApiClientContext, | ||
RequireLogin, | ||
t, | ||
UserContext, | ||
FormCard, | ||
dateToString, | ||
} from "@bloom-housing/ui-components" | ||
import Link from "next/link" | ||
import FormSummaryDetails from "../../src/forms/applications/FormSummaryDetails" | ||
import FormsLayout from "../../layouts/forms" | ||
import { Application, Listing } from "@bloom-housing/backend-core/types" | ||
import { useRouter } from "next/router" | ||
|
||
export default () => { | ||
const router = useRouter() | ||
const applicationId = router.query.id as string | ||
const { applicationsService, listingsService } = useContext(ApiClientContext) | ||
const { profile } = useContext(UserContext) | ||
const [application, setApplication] = useState<Application>() | ||
const [listing, setListing] = useState<Listing>() | ||
const [unauthorized, setUnauthorized] = useState(false) | ||
const [noApplication, setNoApplication] = useState(false) | ||
useEffect(() => { | ||
if (profile) { | ||
applicationsService | ||
.retrieve({ applicationId }) | ||
.then((app) => { | ||
setApplication(app) | ||
listingsService | ||
?.retrieve({ listingId: app.listing.id }) | ||
.then((retrievedListing) => { | ||
setListing(retrievedListing) | ||
}) | ||
.catch((err) => { | ||
console.error(`Error fetching listing: ${err}`) | ||
}) | ||
}) | ||
.catch((err) => { | ||
console.error(`Error fetching application: ${err}`) | ||
const { status } = err.response || {} | ||
if (status === 404) { | ||
setNoApplication(true) | ||
} | ||
if (status === 403) { | ||
setUnauthorized(true) | ||
} | ||
}) | ||
} | ||
}, [profile, applicationId, applicationsService, listingsService]) | ||
|
||
return ( | ||
<> | ||
<RequireLogin signInPath="/sign-in" signInMessage={t("t.loginIsRequired")}> | ||
<FormsLayout> | ||
{noApplication && ( | ||
<FormCard header={t("account.application.error")}> | ||
<p className="field-note mb-5">{t("account.application.noApplicationError")}</p> | ||
<a href={`applications`} className="button is-small"> | ||
{t("account.application.return")} | ||
</a> | ||
</FormCard> | ||
)} | ||
{unauthorized && ( | ||
<FormCard header={t("account.application.error")}> | ||
<p className="field-note mb-5">{t("account.application.noAccessError")}</p> | ||
<a href={`applications`} className="button is-small"> | ||
{t("account.application.return")} | ||
</a> | ||
</FormCard> | ||
)} | ||
{application && ( | ||
<> | ||
<FormCard header={t("account.application.confirmation")}> | ||
<div className="py-2"> | ||
{listing && ( | ||
<Link | ||
href={`listing/id=${listing.id}`} | ||
as={`${origin}/listing/${listing.id}/${listing.urlSlug}`} | ||
> | ||
<a className="lined text-tiny"> | ||
{t("application.confirmation.viewOriginalListing")} | ||
</a> | ||
</Link> | ||
)} | ||
</div> | ||
</FormCard> | ||
|
||
<FormCard> | ||
<div className="form-card__lead border-b"> | ||
<h2 className="form-card__title is-borderless"> | ||
{t("application.confirmation.informationSubmittedTitle")} | ||
</h2> | ||
<p className="field-note mt-4 text-center"> | ||
{t("application.confirmation.submitted")} | ||
{dateToString(application.submissionDate)} | ||
</p> | ||
</div> | ||
<div className="form-card__group text-center"> | ||
<h3 className="form-card__paragraph-title"> | ||
{t("application.confirmation.lotteryNumber")} | ||
</h3> | ||
|
||
<p className="font-serif text-3xl my-0">{application.id}</p> | ||
</div> | ||
|
||
<FormSummaryDetails application={application} /> | ||
|
||
<div className="form-card__pager hide-for-print"> | ||
<div className="form-card__pager-row py-6"> | ||
<a href="#" className="lined text-tiny" onClick={() => window.print()}> | ||
{t("application.confirmation.printCopy")} | ||
</a> | ||
</div> | ||
</div> | ||
</FormCard> | ||
</> | ||
)} | ||
</FormsLayout> | ||
</RequireLogin> | ||
</> | ||
) | ||
} |
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.