-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialized sidebar and menu-option, update user org layout
- Loading branch information
1 parent
c9e3ffe
commit 505bb7d
Showing
3 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react' | ||
|
||
type Props = { | ||
children: React.ReactNode | ||
params: { agencyId: string } | ||
} | ||
|
||
const layout = ({ children, params }: Props) => { | ||
return ( | ||
<div>layout</div> | ||
) | ||
} | ||
|
||
export default layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { getAuthUserDetails } from '@/lib/queries' | ||
import { off } from 'process' | ||
import React from 'react' | ||
import MenuOptions from './menu-options' | ||
|
||
type Props = { | ||
id: string | ||
type: 'agency' | 'subaccount' | ||
} | ||
|
||
const Sidebar = async ({ id, type }: Props) => { | ||
const user = await getAuthUserDetails() | ||
if (!user) return null | ||
|
||
if (!user.Agency) return | ||
|
||
const details = | ||
type === 'agency' | ||
? user?.Agency | ||
: user?.Agency.SubAccount.find((subaccount) => subaccount.id === id) | ||
|
||
const isWhiteLabeledAgency = user.Agency.whiteLabel | ||
if (!details) return | ||
|
||
let sideBarLogo = user.Agency.agencyLogo || '/assets/plura-logo.svg' | ||
|
||
if (!isWhiteLabeledAgency) { | ||
if (type === 'subaccount') { | ||
sideBarLogo = | ||
user?.Agency.SubAccount.find((subaccount) => subaccount.id === id) | ||
?.subAccountLogo || user.Agency.agencyLogo | ||
} | ||
} | ||
|
||
const sidebarOpt = | ||
type === 'agency' | ||
? user.Agency.SidebarOption || [] | ||
: user.Agency.SubAccount.find((subaccount) => subaccount.id === id) | ||
?.SidebarOption || [] | ||
|
||
const subaccounts = user.Agency.SubAccount.filter((subaccount) => | ||
user.Permissions.find( | ||
(permission) => | ||
permission.subAccountId === subaccount.id && permission.access | ||
) | ||
) | ||
|
||
return ( | ||
<> | ||
<MenuOptions | ||
defaultOpen={true} | ||
details={details} | ||
id={id} | ||
sidebarLogo={sideBarLogo} | ||
sidebarOpt={sidebarOpt} | ||
subAccounts={subaccounts} | ||
user={user} | ||
/> | ||
<MenuOptions | ||
details={details} | ||
id={id} | ||
sidebarLogo={sideBarLogo} | ||
sidebarOpt={sidebarOpt} | ||
subAccounts={subaccounts} | ||
user={user} | ||
/> | ||
</> | ||
) | ||
} | ||
|
||
export default Sidebar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react' | ||
import { | ||
Agency, | ||
AgencySidebarOption, | ||
SubAccount, | ||
SubAccountSidebarOption, | ||
} from '@prisma/client' | ||
import { useEffect, useMemo, useState } from 'react' | ||
|
||
type Props = { | ||
|
||
defaultOpen?: boolean | ||
subAccounts: SubAccount[] | ||
sidebarOpt: AgencySidebarOption[] | SubAccountSidebarOption[] | ||
sidebarLogo: string | ||
details: any | ||
user: any | ||
id: string | ||
} | ||
|
||
const MenuOptions = ({ | ||
details, | ||
id, | ||
sidebarLogo, | ||
sidebarOpt, | ||
subAccounts, | ||
user, | ||
defaultOpen, | ||
}: Props) => { | ||
// const { setOpen } = useModal() | ||
const [isMounted, setIsMounted] = useState(false) | ||
|
||
const openState = useMemo( | ||
() => (defaultOpen ? { open: true } : {}), | ||
[defaultOpen] | ||
) | ||
|
||
useEffect(() => { | ||
setIsMounted(true) | ||
}, []) | ||
|
||
return ( | ||
<div>MenuOptions</div> | ||
) | ||
} | ||
export default MenuOptions; |