Skip to content

Commit

Permalink
My Applications loading state
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyjablonski committed Apr 12, 2021
1 parent 35eb0d8 commit acb4640
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions sites/public/pages/account/applications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
RequireLogin,
t,
UserContext,
LoadingOverlay,
} from "@bloom-housing/ui-components"
import Layout from "../../layouts/application"
import { PaginatedApplication } from "@bloom-housing/backend-core/types"
Expand All @@ -20,17 +21,20 @@ export default () => {
const { profile } = useContext(UserContext)
const [applications, setApplications] = useState<PaginatedApplication>()
const [error, setError] = useState(null)
const [loading, setLoading] = useState(true)

useEffect(() => {
if (profile) {
applicationsService
.list({ userId: profile.id })
.then((apps) => {
setApplications(apps)
setLoading(false)
})
.catch((err) => {
console.error(`Error fetching applications: ${err}`)
setError(`${err}`)
setLoading(false)
})
}
}, [profile, applicationsService])
Expand All @@ -49,14 +53,14 @@ export default () => {
}

return (
<>
<RequireLogin signInPath="/sign-in" signInMessage={t("t.loginIsRequired")}>
<Layout>
<Head>
<title>{t("nav.myApplications")}</title>
</Head>
<MetaTags title={t("nav.myApplications")} description="" />
<section className="bg-gray-300">
<RequireLogin signInPath="/sign-in" signInMessage={t("t.loginIsRequired")}>
<Layout>
<Head>
<title>{t("nav.myApplications")}</title>
</Head>
<MetaTags title={t("nav.myApplications")} description="" />
<section className="bg-gray-300">
<LoadingOverlay isLoading={loading}>
<div className="flex flex-wrap relative max-w-3xl mx-auto md:py-8">
<DashBlocks>
<DashBlock title={t("account.myApplications")} icon={<HeaderBadge />}>
Expand All @@ -67,13 +71,13 @@ export default () => {
<AppStatusItemWrapper key={index} application={application} />
))}
</Fragment>
{!applications && noApplicationsSection()}
{!applications && !loading && noApplicationsSection()}
</DashBlock>
</DashBlocks>
</div>
</section>
</Layout>
</RequireLogin>
</>
</LoadingOverlay>
</section>
</Layout>
</RequireLogin>
)
}

0 comments on commit acb4640

Please sign in to comment.