Skip to content

Commit

Permalink
Visually handle a loss of access
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyjablonski committed Apr 6, 2021
1 parent e5879e1 commit 70622a3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
31 changes: 28 additions & 3 deletions sites/public/pages/account/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export default () => {
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
Expand All @@ -41,19 +43,42 @@ export default () => {
.then((retrievedListing) => {
setListing(retrievedListing)
})
.catch((err) => console.error(`Error fetching listing: ${err}`))
.catch((err) => {
console.error(`Error fetching listing: ${err}`)
})
})
.catch((err) => {
console.error(`Error fetching application: ${err}`)
if (`${err}`.indexOf("404") >= 0) setNoApplication(true)
if (`${err}`.indexOf("403") >= 0) setUnauthorized(true)
console.log(err)
})
.catch((err) => console.error(`Error fetching application: ${err}`))
}
}, [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="Confirmation">
<FormCard header={t("account.application.confirmation")}>
<div className="py-2">
{listing && (
<Link
Expand Down
9 changes: 8 additions & 1 deletion ui-components/src/locales/general.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
"createAccount": "Create Account",
"haveAnAccount": "Already have an account?",
"myApplications": "My Applications",
"myApplicationsSubtitle": "See lottery dates and listings for properties for which you've applied"
"myApplicationsSubtitle": "See lottery dates and listings for properties for which you've applied",
"application": {
"confirmation": "Confirmation",
"error": "Error",
"noAccessError": "No application with that ID exists",
"noApplicationError": "No application with that ID exists",
"return": "Return to applications"
}
},
"applications": {
"begin": {
Expand Down

0 comments on commit 70622a3

Please sign in to comment.