import { LuAirplay, LuAward, LuChartNoAxesCombined, LuBookOpen, LuBriefcase, LuFileText, LuTruck, LuUsers, } from 'react-icons/lu'; const hasAny = (permissions, keys) => keys.some((key) => permissions.includes(key)); const child = (key, label, url, permission, extra = {}) => ({ key, label, url, permission, ...extra, }); export function getMenuItems({ permissions = [], roles = [], domain = '', email = '' } = {}) { const items = [ { key: 'domain-title', label: `Domain: ${domain || '-'}`, isTitle: true, }, { key: 'dashboard', label: 'Dashboard', icon: LuAirplay, url: '/', }, { key: 'quick-actions', label: 'Quick Actions', icon: LuFileText, url: '/formaction/consolelist', }, ]; if ( hasAny(permissions, [ 'users_get_all', 'userattribute_get_all', 'roles_get_all', 'hierarchy_get_all', 'team_get_all', 'group_get_all', 'channel_get_all', 'domain_get_one', ]) ) { items.push({ key: 'organisation', label: 'Organisation', icon: LuBriefcase, children: [ child('users', 'Users', '/users', 'users_get_all'), child('userattributes', 'User Attributes', '/userattributes', 'userattribute_get_all'), child('roles', 'Roles', '/roles', 'roles_get_all'), child('hierarchys', 'Hierarchy', '/hierarchys', 'hierarchy_get_all'), child('positions', 'Positions', '/positions', 'all_data_access'), child('teams', 'Teams', '/teams', 'team_get_all'), child('groups', 'Groups', '/groups', 'group_get_all'), child('channels', 'Channels', '/channels', 'channel_get_all'), child('domain', 'Domain', '/domain/edit', 'domain_get_one'), child('apps', 'Apps', '/apps', 'app_get_all'), ].filter((item) => !item.permission || permissions.includes(item.permission)), }); } if (permissions.includes('maxterneo_ho')) { items.push({ key: 'special-price', label: 'Special Price Request Approvals', url: '/form/allsubmissions?partition=rapport-maxterneo&form_id=1745393615-b4248b7a-b416-42ce-bf7a-9e76fae07cad', }); } if (hasAny(permissions, ['contact_get_all', 'contactattribute_get_all'])) { items.push({ key: 'contacts', label: 'Contact Management', icon: LuUsers, children: [ child('contact-list', 'Contacts', '/contacts', 'contact_get_all'), child('contact-export', 'Contact Export', '/contactexports', 'contact_get_all'), child('contact-attrs', 'Attributes', '/contactattributes', 'contactattribute_get_all'), ].filter((item) => !item.permission || permissions.includes(item.permission)), }); } if (domain === 'team2') { items.push({ key: 'chemist', label: 'Chemist Availability', icon: LuFileText, url: '/foracortchemistavailabilitys', }); } if (domain === 'gennovadc') { items.push({ key: 'mydtx', label: 'MYDTx Dashboard', icon: LuFileText, url: '/gennovadcreport/dashboard', }); } if (domain === 'pulmocare' && roles.includes('1650360330-5bf35594-674a-4f31-HO_Audit-47738d2151ab')) { items.push({ key: 'healthy-lung', label: 'Healthy Lung Educator Daily reporting (Camp/ Clinic)', icon: LuFileText, url: '/form/allsubmissions?partition=rapport-pulmocare&form_id=1713351143-9afc68f4-653f-491a-9e0e-a27d61ed1e07', }); } if (permissions.includes('team3_nebmitra_ho')) { items.push({ key: 'neb-mitra', label: 'Neb Mitra Verification', icon: LuFileText, url: '/form/nebmitraverification', }); } if (domain === 'pulmocare') { items.push({ key: 'coaching', label: 'Coaching Tool Reports', icon: LuBookOpen, children: [ child('sbm-me-action', 'SBM/ME Action Plan Timeline', '/coachingtooldashboard/sbmandmeactionplanreport'), child('rm-action', 'RM Action Plan Timeline', '/coachingtooldashboard/rmactionplanreport'), child('sbm-goal', 'SBM/ME Goal & Proficiency Tracking', '/coachingtooldashboard/sbmandmegoalandproficiencytrackingreport'), child('rm-goal', 'RM Goal & Proficiency Tracking', '/coachingtooldashboard/rmgoalandproficiencytracking'), child('sbm-coachee', 'SBM/ME Coachee Report', '/coachingtooldashboard/sbmcoacheereport'), child('rm-coachee', 'RM Coachee Report', '/coachingtooldashboard/rmcoacheereport'), ], }); } if (hasAny(permissions, ['magazine_get_all', 'wallmessage_get_all', 'wallbanner_get_all', 'widgets_get_all'])) { items.push({ key: 'content', label: 'Content', icon: LuBookOpen, children: [ child('magazines', 'Magazine', '/magazines', 'magazine_get_all'), child('walls', 'Wall', '/walls', 'wallmessage_get_all'), child('banners', 'Banner', '/banners', 'wallbanner_get_all'), child('widgets', 'Widgets', '/widgets', 'widgets_get_all'), child('forums', 'Forums', '/forums', 'forum_get_all'), ].filter((item) => !item.permission || permissions.includes(item.permission)), }); } const nebRoles = [ '1733912682-7c353bf8-c309-49b3-93e7-superdepotmanager', '1733912682-7c353bf8-c309-49b3-93e7-depotmanager', '1733912682-7c353bf8-c309-49b3-93e7-0ee3024c01fe', '1655447696-148e5dc2-3983-4ec6-9ea3-a52c494a9209', ]; if (domain === 'team3' && roles.some((role) => nebRoles.includes(role))) { const nebChildren = [child('neb-report', 'Report', '/neblogisticreports')]; if (!roles.includes('1733912682-7c353bf8-c309-49b3-93e7-depotmanager')) { nebChildren.push( child('neb-depot', 'Add Depot', '/neblogisticreport/depot'), child('neb-mapping', 'Depot & TM Mapping', '/depotwithtmmappings'), ); } items.push({ key: 'neb-logistics', label: 'Neb Logistics', icon: LuTruck, children: nebChildren, }); } if (hasAny(permissions, ['rcpa_product_get_all', 'rcpa_reports'])) { items.push({ key: 'rcpa', label: 'RCPA', icon: LuUsers, children: [ child('rcpa-products', 'Products', '/rcpaproducts', 'rcpa_product_get_all'), child('rcpa-tm', 'TM Wise Report', '/rcpareport/tmwise', 'rcpa_reports'), child('rcpa-month', 'Month Wise Report', '/rcpareport/monthwise', 'rcpa_reports'), child('rcpa-form', 'Form Wise Report', '/rcpareport/formwise', 'rcpa_reports'), child('rcpa-forms', 'Forms', '/rcpaforms', 'rcpa_form_get_all'), ].filter((item) => !item.permission || permissions.includes(item.permission)), }); } if (hasAny(permissions, ['metric_get_all', 'injestion_mapping_get_all', 'metric_view_get_all'])) { items.push({ key: 'metric', label: 'Metric', icon: LuChartNoAxesCombined, children: [ child('metrics', 'Metric', '/metrics', 'metric_get_all'), child('metricmappings', 'Injestion Mapping', '/metricmappings', 'injestion_mapping_get_all'), child('metricviews', 'Metric Views', '/metricviews', 'metric_view_get_all'), child('metricreports', 'Metric Reports', '/metricreports', 'metric_view_get_all'), child('metricdataimports', 'Metric Data Import', '/metricdataimports', 'metric_view_get_all'), child('metriccampaigns', 'Metric Campaigns', '/metriccampaigns', 'campaign_view_get_all'), ].filter((item) => !item.permission || permissions.includes(item.permission)), }); } if ( hasAny(permissions, [ 'appreciation_category_get_all', 'appreciation_image_get_all', 'badge_list_get_all', 'reward_category_get_all', 'reward_get_all', ]) ) { items.push({ key: 'recognition', label: 'Recognition', icon: LuAward, children: [ child('appcats', 'Appreciation Category', '/appcategorys', 'appreciation_category_get_all'), child('appimages', 'Appreciation Images', '/appimages', 'appreciation_image_get_all'), child('badges', 'Badge List', '/badgelists', 'badge_list_get_all'), child('rewardcats', 'Reward Category', '/rewardcategorys', 'reward_category_get_all'), child('rewards', 'Rewards', '/rewards', 'reward_get_all'), child('milestones', 'Milestones', '/milestones', 'milestones_get_all'), ].filter((item) => !item.permission || permissions.includes(item.permission)), }); } if ( hasAny(permissions, [ 'formentity_get_all', 'formaction_get_all', 'all_data_access', 'formexports_get_all', 'quiz_get_all', 'roles_leaderboard_get_all', 'workflow_definition_get_all', 'workflow_instance_get_all', ]) ) { const formChildren = [ child('forms', 'Forms', '/formentitys', 'formentity_get_all'), child('formhooks', 'Form Hook', '/formhooks', 'form_hooks_get_all'), child('surveys', 'Survey', '/surveys', 'survey_get_all'), child('quizs', 'Quiz', '/quizs', 'quiz_get_all'), child('formactions', 'Quick Action', '/formactions', 'formaction_get_all'), child('formexports', 'Form Data Export', '/formexports', 'formexports_get_all'), child('reminders', 'Reminders', '/reminders', 'reminder_get_all'), child('leaderboards', 'Leaderboard', '/leaderboards', 'roles_leaderboard_get_all'), ].filter((item) => !item.permission || permissions.includes(item.permission)); if (hasAny(permissions, ['workflow_definition_get_all', 'workflow_instance_get_all'])) { formChildren.push( ...[ child('workflows', 'Workflows', '/workflows', 'workflow_definition_get_all'), child('workflow-monitor', 'Workflow monitor', '/workflow/monitor', 'workflow_instance_get_all'), ].filter((item) => !item.permission || permissions.includes(item.permission)) ); } if (domain === 'titans' && permissions.includes('all_data_access')) { formChildren.push(child('titans-hcp', 'Titans HCP Data Upload', '/titanshcpgatheringreports')); } if ( ['titans', 'team2'].includes(domain) && (permissions.includes('all_data_access') || permissions.includes('formexports_get_all')) ) { formChildren.push(child('monsoon', 'Monsoon Yatra Activity List', '/monsoonyatraactivitylist/import')); } items.push({ key: 'data-gathering', label: 'Data Gathering', icon: LuFileText, children: formChildren, }); } if (permissions.includes('injestion_mapping_get_all') && ['pulmocare', 'breathefree'].includes(domain)) { items.push({ key: 'aibot', label: 'AI Bot', icon: LuFileText, children: [ child('metricdetails', 'Metric Detail', '/metricdetails'), child('definations', 'Defination', '/definations'), ], }); } return items.filter((item) => !item.children || item.children.length > 0); }