Skip to content

Commit

Permalink
fix: org layout page
Browse files Browse the repository at this point in the history
  • Loading branch information
yashdev9274 committed May 10, 2024
1 parent 505bb7d commit aeb870e
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/app/(main)/agency/[agencyId]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
import { verifyAndAcceptInvitation } from '@/lib/queries'
import { currentUser } from '@clerk/nextjs'
import { redirect } from "next/navigation"
import React from 'react'

type Props = {
children: React.ReactNode
params: { agencyId: string }
}

const layout = ({ children, params }: Props) => {
return (
<div>layout</div>
const layout = async ({ children, params }: Props) => {

const agencyId = await verifyAndAcceptInvitation()
const user = await currentUser()

if (!user) {
return redirect("/")
}

if (!agencyId) {
return redirect('/agency')
}

if (
user.privateMetadata.role !== 'AGENCY_OWNER' &&
user.privateMetadata.role !== 'AGENCY_ADMIN'
)
// return <Unauthorized />

return (
<div>layout</div>
)
}

export default layout;

0 comments on commit aeb870e

Please sign in to comment.