Skip to content

Commit

Permalink
refactor(FooterWithAuth.tsx): remove unnecessary isLoading variable a…
Browse files Browse the repository at this point in the history
…nd match statement

The isLoading variable and the match statement are no longer needed as the useAuthorization hook now directly returns the isAuthorized value. This simplifies the code and improves readability.
  • Loading branch information
ktun95 committed Feb 16, 2024
1 parent 1c63ad2 commit b059139
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions apps/dicty-frontpage/src/app/layout/FooterWithAuth.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
import { Footer } from "@dictybase/footer"
import { match } from "ts-pattern"
import { displayOnAuthorized, useAuthorization, authFooterData } from "auth"
import { Loader } from "../../common/components/Loader"

const authorizedRoles = ["content-admin"]

const FooterWithAuth = () => {
const { isAuthorized, isLoading } = useAuthorization({
const { isAuthorized } = useAuthorization({
entries: authorizedRoles,
})
return match(isLoading)
.with(true, () => <Loader />)
.with(false, () =>
displayOnAuthorized({
isAuthorized,
authorized: <Footer data={authFooterData} />,
unauthorized: <Footer />,
}),
)
.exhaustive()
return displayOnAuthorized({
isAuthorized,
authorized: <Footer data={authFooterData} />,
unauthorized: <Footer />,
})
}

export { FooterWithAuth }

0 comments on commit b059139

Please sign in to comment.