Skip to content

Commit

Permalink
refactor: role enum on user schema
Browse files Browse the repository at this point in the history
  • Loading branch information
mrevanzak committed May 22, 2024
1 parent 4f0ef04 commit 54d8dd0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions apps/web/src/app/(app)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default async function AuthLayout(props: {
admin: React.ReactNode;
}) {
const session = await auth();
const isAdmin = session?.user.role === "ADMIN";
const isAdmin = session?.user.role === "admin";

const isMaintenance = await get("maintenance");

Expand All @@ -20,7 +20,7 @@ export default async function AuthLayout(props: {

return (
<div className="flex flex-row">
{session?.user.role === "ADMIN" && <SidebarWrapper />}
{session?.user.role === "admin" && <SidebarWrapper />}
<div className="flex-1">
<Navbar />
<main className="container flex min-h-[calc(100vh-8rem)]">
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function Footer() {
const { resolvedTheme } = useTheme();
const { collapsed } = useSidebarContext();
const { data: session } = useSession();
const isAdmin = session?.user.role === "ADMIN";
const isAdmin = session?.user.role === "admin";

return (
<footer
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { UserButton } from "./user";

export async function Navbar() {
const session = await auth();
const isAdmin = session?.user.role === "ADMIN";
const isAdmin = session?.user.role === "admin";

return (
<header className="sticky top-0 z-10 bg-content1 px-4 sm:px-8">
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/sidebar/sidebar-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const SidebarButton = () => {
const { data: session } = useSession();

return (
session?.user.role === "ADMIN" && (
session?.user.role === "admin" && (
<Button
isIconOnly
variant="light"
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/server/db/schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { pgEnum, pgTable, text, timestamp } from "drizzle-orm/pg-core";

const roleEnum = pgEnum("role", ["USER", "ADMIN"]);
const roleEnum = pgEnum("role", ["user", "admin"]);
export const users = pgTable("user", {
id: text("id")
.primaryKey()
Expand All @@ -9,5 +9,5 @@ export const users = pgTable("user", {
email: text("email").notNull(),
emailVerified: timestamp("emailVerified", { mode: "date" }),
password: text("password").notNull(),
role: roleEnum("role").notNull().default("USER"),
role: roleEnum("role").notNull().default("user"),
});

0 comments on commit 54d8dd0

Please sign in to comment.