Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug/my applications loading state #1121

Merged
merged 1 commit into from
Apr 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
)
}