feat: affiliate

This commit is contained in:
Nevo David 2024-12-05 21:23:33 +07:00
parent 65e3bf0852
commit f5a5170c7f
1 changed files with 30 additions and 22 deletions

View File

@ -8,16 +8,16 @@ import { useUser } from '@gitroom/frontend/components/layout/user.context';
import { useVariables } from '@gitroom/react/helpers/variable.context'; import { useVariables } from '@gitroom/react/helpers/variable.context';
export const useMenuItems = () => { export const useMenuItems = () => {
const {isGeneral} = useVariables(); const { isGeneral } = useVariables();
return [ return [
...(!isGeneral ...(!isGeneral
? [ ? [
{ {
name: 'Analytics', name: 'Analytics',
icon: 'analytics', icon: 'analytics',
path: '/analytics', path: '/analytics',
}, },
] ]
: []), : []),
{ {
name: isGeneral ? 'Calendar' : 'Launches', name: isGeneral ? 'Calendar' : 'Launches',
@ -26,22 +26,22 @@ export const useMenuItems = () => {
}, },
...(isGeneral ...(isGeneral
? [ ? [
{ {
name: 'Analytics', name: 'Analytics',
icon: 'analytics', icon: 'analytics',
path: '/analytics', path: '/analytics',
}, },
] ]
: []), : []),
...(!isGeneral ...(!isGeneral
? [ ? [
{ {
name: 'Settings', name: 'Settings',
icon: 'settings', icon: 'settings',
path: '/settings', path: '/settings',
role: ['ADMIN', 'SUPERADMIN'], role: ['ADMIN', 'SUPERADMIN'],
}, },
] ]
: []), : []),
{ {
name: 'Marketplace', name: 'Marketplace',
@ -60,13 +60,20 @@ export const useMenuItems = () => {
role: ['ADMIN', 'SUPERADMIN'], role: ['ADMIN', 'SUPERADMIN'],
requireBilling: true, requireBilling: true,
}, },
{
name: 'Affiliate',
icon: 'affiliate',
path: 'https://affiliate.postiz.com',
role: ['ADMIN', 'SUPERADMIN', 'USER'],
requireBilling: true,
},
]; ];
} };
export const TopMenu: FC = () => { export const TopMenu: FC = () => {
const path = usePathname(); const path = usePathname();
const user = useUser(); const user = useUser();
const {billingEnabled} = useVariables(); const { billingEnabled } = useVariables();
const menuItems = useMenuItems(); const menuItems = useMenuItems();
return ( return (
@ -86,6 +93,7 @@ export const TopMenu: FC = () => {
<li key={item.name}> <li key={item.name}>
<Link <Link
prefetch={true} prefetch={true}
target={item.path.indexOf('http') > -1 ? '_blank' : '_self'}
href={item.path} href={item.path}
className={clsx( className={clsx(
'flex gap-2 items-center box px-[6px] md:px-[24px] py-[8px]', 'flex gap-2 items-center box px-[6px] md:px-[24px] py-[8px]',