132 lines
3.4 KiB
TypeScript
Raw Normal View History

2024-02-18 01:44:48 -05:00
// ** Icon imports
import Login from 'mdi-material-ui/Login'
import Table from 'mdi-material-ui/Table'
import CubeOutline from 'mdi-material-ui/CubeOutline'
import HomeOutline from 'mdi-material-ui/HomeOutline'
2024-02-18 06:59:55 -05:00
import SettingsApplicationsIcon from '@mui/icons-material/SettingsApplications';
import ListIcon from '@mui/icons-material/List';
2024-02-18 01:44:48 -05:00
// ** Type import
import { VerticalNavItemsType } from '../../core/layouts/types'
2024-02-27 21:37:43 -05:00
import { BankTransfer, Cart, Clipboard, PageFirst, StarOutline } from 'mdi-material-ui'
2024-03-03 16:03:22 -05:00
import { DocumentScanner, FileOpen, LockPerson, OpenInBrowser, People, PeopleOutline, Settings, WebAsset } from '@mui/icons-material'
2024-02-18 01:44:48 -05:00
import { useState, useEffect } from 'react'
const navigation = (): VerticalNavItemsType => {
const [isStripeOnboarded, setIsStripeOnboarded] = useState(false);
const [profileData, setProfileData] = useState(null);
const [userData, setUserData] = useState(null);
const [isAdmin, setIsAdmin] = useState(false);
2024-02-18 01:44:48 -05:00
const getData = async () => {
const adminCheck = await fetch('/api/admin/check', { method: "GET" });
if (adminCheck.status === 200) {
setIsAdmin(true);
}
2024-02-18 01:44:48 -05:00
const onboardCheckRequest = await fetch('/api/artist/onboarded', { method: "GET" });
const onboardCheckResponse = await onboardCheckRequest.json();
setIsStripeOnboarded(onboardCheckResponse["onboarded"]);
const artistProfileRequest = await fetch('/api/artist/profile', { method: "GET" });
const artistProfileResponse = await artistProfileRequest.json();
setProfileData(artistProfileResponse);
const userRequest = await fetch('/api/me', { method: "GET" });
const userResponse = await userRequest.json();
setUserData(userResponse);
////console.log(roleResponse)
2024-02-18 01:44:48 -05:00
}
2024-02-18 01:44:48 -05:00
useEffect(() => {
getData();
}, []);
var result = [
{
title: 'Dashboard',
icon: HomeOutline,
path: '/dashboard'
},
{
sectionTitle: 'General'
},
{
title: 'Account Settings',
icon: Settings,
path: '/dashboard/settings'
},
{
title: 'Your Requests',
icon: ListIcon,
path: '/dashboard/requests'
}
];
if (isAdmin) {
result.push(
{
sectionTitle: 'Admin'
},
{
title: 'Manage Artist Access',
icon: LockPerson,
path: '/dashboard/admin/requests'
},
{
title: 'Manage Users',
icon: People,
path: '/dashboard/admin/users'
},
{
title: 'Manage Artists',
icon: PeopleOutline,
path: '/dashboard/admin/artists'
},
);
}
if (isStripeOnboarded) {
result.push(
2024-02-18 01:44:48 -05:00
{
sectionTitle: 'Artist'
2024-02-18 01:44:48 -05:00
},
2024-02-27 21:37:43 -05:00
{
title: 'Request Reviews',
icon: StarOutline,
path: '/dashboard/artist/reviews'
},
2024-02-18 01:44:48 -05:00
{
title: 'Incoming Requests',
icon: ListIcon,
path: '/dashboard/artist/requests'
2024-02-18 01:44:48 -05:00
},
{
title: 'Payments/Payouts',
icon: BankTransfer,
2024-02-27 21:37:43 -05:00
path: '/dashboard/artist/payout'
2024-02-18 01:44:48 -05:00
},
2024-02-18 06:59:55 -05:00
{
2024-02-27 21:37:43 -05:00
title: 'Artist Settings',
icon: Settings,
2024-02-18 06:59:55 -05:00
path: '/dashboard/artist/artistsettings'
},
2024-02-18 01:44:48 -05:00
{
title: 'Page Settings',
2024-02-27 21:37:43 -05:00
icon: WebAsset,
2024-02-18 01:44:48 -05:00
path: '/dashboard/artist/pagesettings'
},
{
title: 'Your Page',
2024-02-27 21:37:43 -05:00
icon: OpenInBrowser,
path: '/box/' + (userData ? userData["displayName"] : "")
2024-02-18 01:44:48 -05:00
}
);
2024-02-18 01:44:48 -05:00
}
return result;
2024-02-18 01:44:48 -05:00
}
export default navigation;