refactor code to improve readability and maintainability + redesigned announcement bar

This commit is contained in:
daniel31x13
2024-05-22 20:56:56 -04:00
parent 811628a952
commit a498f3a10d
22 changed files with 319 additions and 171 deletions
+3 -4
View File
@@ -9,7 +9,6 @@ interface Props {
children: ReactNode;
}
const emailEnabled = process.env.NEXT_PUBLIC_EMAIL_PROVIDER === "true";
const stripeEnabled = process.env.NEXT_PUBLIC_STRIPE === "true";
export default function AuthRedirect({ children }: Props) {
@@ -26,6 +25,8 @@ export default function AuthRedirect({ children }: Props) {
const isPublicPage = router.pathname.startsWith("/public");
const hasInactiveSubscription =
account.id && !account.subscription?.active && stripeEnabled;
// There are better ways of doing this... but this one works for now
const routes = [
{ path: "/login", isProtected: false },
{ path: "/register", isProtected: false },
@@ -53,9 +54,7 @@ export default function AuthRedirect({ children }: Props) {
redirectTo("/dashboard");
} else if (
isUnauthenticated &&
!routes.some(
(e) => router.pathname.startsWith(e.path) && !e.isProtected
)
routes.some((e) => router.pathname.startsWith(e.path) && e.isProtected)
) {
redirectTo("/login");
} else {