permission in sidemenu base and permium
This commit is contained in:
@@ -44,6 +44,7 @@ export interface Restaurant {
|
||||
vat: number;
|
||||
domain: string;
|
||||
score: Score;
|
||||
plan: 'base' | 'premium';
|
||||
}
|
||||
|
||||
export interface ReviewFood {
|
||||
|
||||
@@ -25,15 +25,16 @@ type MenuItemType = {
|
||||
icon: Icon;
|
||||
auth?: boolean;
|
||||
guestOnly?: boolean;
|
||||
premiumOnly?: boolean;
|
||||
};
|
||||
|
||||
const menuItems: Array<Array<MenuItemType>> = [
|
||||
[
|
||||
{ href: 'notifications', title: 'Notifications', icon: Notification },
|
||||
{ href: 'transactions/discount/club', title: 'CustomerClub', icon: Cup },
|
||||
{ href: 'transactions/discount', title: 'Discounts', icon: TicketDiscount },
|
||||
{ href: 'order/history', title: 'Orders', icon: CalendarSearch },
|
||||
{ href: 'transactions', title: 'Transactions', icon: Receipt1 },
|
||||
{ href: 'transactions/discount/club', title: 'CustomerClub', icon: Cup, premiumOnly: true },
|
||||
{ href: 'transactions/discount', title: 'Discounts', icon: TicketDiscount, premiumOnly: true },
|
||||
{ href: 'order/history', title: 'Orders', icon: CalendarSearch, premiumOnly: true },
|
||||
{ href: 'transactions', title: 'Transactions', icon: Receipt1, premiumOnly: true },
|
||||
{ href: 'game', title: 'Games', icon: Game },
|
||||
{ href: '?share', title: 'ShareWithFriends', icon: Like1 },
|
||||
{ href: 'report', title: 'ReportProblem', icon: NoteBoardIcon },
|
||||
@@ -82,6 +83,8 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS
|
||||
const [isPWAInstalled, setIsPWAInstalled] = useState(false);
|
||||
const { data: aboutData } = useGetAbout();
|
||||
const { isSuccess } = useGetProfile();
|
||||
const isPremium = aboutData?.data?.plan === 'premium';
|
||||
|
||||
|
||||
const params = useParams();
|
||||
const { name } = params;
|
||||
@@ -163,6 +166,7 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS
|
||||
if (item.auth && !isSuccess) return false;
|
||||
if (item.guestOnly && isSuccess) return false;
|
||||
if (item.href === '?installpwa' && isPWAInstalled) return false;
|
||||
if (item.premiumOnly && !isPremium) return false;
|
||||
return true;
|
||||
})
|
||||
.map(({ icon: Icon, ...item }, index) => {
|
||||
|
||||
Reference in New Issue
Block a user