feat: separate pazuz and lamassu routing tree
fix: routes.js routing tree getter
This commit is contained in:
parent
2a2880a7da
commit
cf3defbc93
4 changed files with 540 additions and 311 deletions
|
|
@ -21,8 +21,6 @@ import styles from './Header.styles'
|
||||||
|
|
||||||
const useStyles = makeStyles(styles)
|
const useStyles = makeStyles(styles)
|
||||||
|
|
||||||
const buildTarget = process.env.REACT_APP_BUILD_TARGET
|
|
||||||
|
|
||||||
const HAS_UNREAD = gql`
|
const HAS_UNREAD = gql`
|
||||||
query getUnread {
|
query getUnread {
|
||||||
hasUnreadNotifications
|
hasUnreadNotifications
|
||||||
|
|
@ -39,7 +37,6 @@ const Subheader = ({ item, classes, user }) => {
|
||||||
<ul className={classes.subheaderUl}>
|
<ul className={classes.subheaderUl}>
|
||||||
{item.children.map((it, idx) => {
|
{item.children.map((it, idx) => {
|
||||||
if (!R.includes(user.role, it.allowedRoles)) return <></>
|
if (!R.includes(user.role, it.allowedRoles)) return <></>
|
||||||
if (!R.includes(buildTarget, it.targets)) return <></>
|
|
||||||
return (
|
return (
|
||||||
<li key={idx} className={classes.subheaderLi}>
|
<li key={idx} className={classes.subheaderLi}>
|
||||||
<NavLink
|
<NavLink
|
||||||
|
|
@ -132,7 +129,6 @@ const Header = memo(({ tree, user }) => {
|
||||||
<ul className={classes.ul}>
|
<ul className={classes.ul}>
|
||||||
{tree.map((it, idx) => {
|
{tree.map((it, idx) => {
|
||||||
if (!R.includes(user.role, it.allowedRoles)) return <></>
|
if (!R.includes(user.role, it.allowedRoles)) return <></>
|
||||||
if (!R.includes(buildTarget, it.targets)) return <></>
|
|
||||||
return (
|
return (
|
||||||
<NavLink
|
<NavLink
|
||||||
key={idx}
|
key={idx}
|
||||||
|
|
|
||||||
256
new-lamassu-admin/src/routing/lamassu.routes.js
Normal file
256
new-lamassu-admin/src/routing/lamassu.routes.js
Normal file
|
|
@ -0,0 +1,256 @@
|
||||||
|
import React from 'react'
|
||||||
|
import { Redirect } from 'react-router-dom'
|
||||||
|
|
||||||
|
import Blacklist from 'src/pages/Blacklist'
|
||||||
|
import Cashout from 'src/pages/Cashout'
|
||||||
|
import Commissions from 'src/pages/Commissions'
|
||||||
|
import { Customers, CustomerProfile } from 'src/pages/Customers'
|
||||||
|
import Funding from 'src/pages/Funding'
|
||||||
|
import Locales from 'src/pages/Locales'
|
||||||
|
import PromoCodes from 'src/pages/LoyaltyPanel/PromoCodes'
|
||||||
|
import MachineLogs from 'src/pages/MachineLogs'
|
||||||
|
import CashCassettes from 'src/pages/Maintenance/CashCassettes'
|
||||||
|
import MachineStatus from 'src/pages/Maintenance/MachineStatus'
|
||||||
|
import Notifications from 'src/pages/Notifications/Notifications'
|
||||||
|
import CoinAtmRadar from 'src/pages/OperatorInfo/CoinATMRadar'
|
||||||
|
import ContactInfo from 'src/pages/OperatorInfo/ContactInfo'
|
||||||
|
import ReceiptPrinting from 'src/pages/OperatorInfo/ReceiptPrinting'
|
||||||
|
import TermsConditions from 'src/pages/OperatorInfo/TermsConditions'
|
||||||
|
import ServerLogs from 'src/pages/ServerLogs'
|
||||||
|
import Services from 'src/pages/Services/Services'
|
||||||
|
import SessionManagement from 'src/pages/SessionManagement/SessionManagement'
|
||||||
|
import Transactions from 'src/pages/Transactions/Transactions'
|
||||||
|
import Triggers from 'src/pages/Triggers'
|
||||||
|
import UserManagement from 'src/pages/UserManagement/UserManagement'
|
||||||
|
import WalletSettings from 'src/pages/Wallet/Wallet'
|
||||||
|
import { namespaces } from 'src/utils/config'
|
||||||
|
|
||||||
|
import { ROLES } from './utils'
|
||||||
|
|
||||||
|
const getLamassuRoutes = () => [
|
||||||
|
{
|
||||||
|
key: 'transactions',
|
||||||
|
label: 'Transactions',
|
||||||
|
route: '/transactions',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Transactions
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'maintenance',
|
||||||
|
label: 'Maintenance',
|
||||||
|
route: '/maintenance',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
get component() {
|
||||||
|
return () => <Redirect to={this.children[0].route} />
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: 'cash_cassettes',
|
||||||
|
label: 'Cash Cassettes',
|
||||||
|
route: '/maintenance/cash-cassettes',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: CashCassettes
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'funding',
|
||||||
|
label: 'Funding',
|
||||||
|
route: '/maintenance/funding',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Funding
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'logs',
|
||||||
|
label: 'Machine Logs',
|
||||||
|
route: '/maintenance/logs',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: MachineLogs
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'machine-status',
|
||||||
|
label: 'Machine Status',
|
||||||
|
route: '/maintenance/machine-status',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: MachineStatus
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'server-logs',
|
||||||
|
label: 'Server',
|
||||||
|
route: '/maintenance/server-logs',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: ServerLogs
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'settings',
|
||||||
|
label: 'Settings',
|
||||||
|
route: '/settings',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
get component() {
|
||||||
|
return () => <Redirect to={this.children[0].route} />
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: namespaces.COMMISSIONS,
|
||||||
|
label: 'Commissions',
|
||||||
|
route: '/settings/commissions',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Commissions
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: namespaces.LOCALE,
|
||||||
|
label: 'Locales',
|
||||||
|
route: '/settings/locale',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Locales
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: namespaces.CASH_OUT,
|
||||||
|
label: 'Cash-out',
|
||||||
|
route: '/settings/cash-out',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Cashout
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: namespaces.NOTIFICATIONS,
|
||||||
|
label: 'Notifications',
|
||||||
|
route: '/settings/notifications',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Notifications
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'services',
|
||||||
|
label: '3rd party services',
|
||||||
|
route: '/settings/3rd-party-services',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Services
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: namespaces.WALLETS,
|
||||||
|
label: 'Wallet',
|
||||||
|
route: '/settings/wallet-settings',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: WalletSettings
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: namespaces.OPERATOR_INFO,
|
||||||
|
label: 'Operator Info',
|
||||||
|
route: '/settings/operator-info',
|
||||||
|
title: 'Operator Information',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
get component() {
|
||||||
|
return () => (
|
||||||
|
<Redirect
|
||||||
|
to={{
|
||||||
|
pathname: this.children[0].route,
|
||||||
|
state: { prev: this.state?.prev }
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: 'contact-info',
|
||||||
|
label: 'Contact information',
|
||||||
|
route: '/settings/operator-info/contact-info',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: ContactInfo
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'receipt-printing',
|
||||||
|
label: 'Receipt',
|
||||||
|
route: '/settings/operator-info/receipt-printing',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: ReceiptPrinting
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'coin-atm-radar',
|
||||||
|
label: 'Coin ATM Radar',
|
||||||
|
route: '/settings/operator-info/coin-atm-radar',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: CoinAtmRadar
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'terms-conditions',
|
||||||
|
label: 'Terms & Conditions',
|
||||||
|
route: '/settings/operator-info/terms-conditions',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: TermsConditions
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'compliance',
|
||||||
|
label: 'Compliance',
|
||||||
|
route: '/compliance',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
get component() {
|
||||||
|
return () => <Redirect to={this.children[0].route} />
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: 'triggers',
|
||||||
|
label: 'Triggers',
|
||||||
|
route: '/compliance/triggers',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Triggers
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'customers',
|
||||||
|
label: 'Customers',
|
||||||
|
route: '/compliance/customers',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Customers
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'blacklist',
|
||||||
|
label: 'Blacklist',
|
||||||
|
route: '/compliance/blacklist',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Blacklist
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'promo-codes',
|
||||||
|
label: 'Promo Codes',
|
||||||
|
route: '/compliance/loyalty/codes',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: PromoCodes
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'customer',
|
||||||
|
route: '/compliance/customer/:id',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: CustomerProfile
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'system',
|
||||||
|
label: 'System',
|
||||||
|
route: '/system',
|
||||||
|
allowedRoles: [ROLES.SUPERUSER],
|
||||||
|
get component() {
|
||||||
|
return () => <Redirect to={this.children[0].route} />
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: 'user-management',
|
||||||
|
label: 'User Management',
|
||||||
|
route: '/system/user-management',
|
||||||
|
allowedRoles: [ROLES.SUPERUSER],
|
||||||
|
component: UserManagement
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'session-management',
|
||||||
|
label: 'Session Management',
|
||||||
|
route: '/system/session-management',
|
||||||
|
allowedRoles: [ROLES.SUPERUSER],
|
||||||
|
component: SessionManagement
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
export default getLamassuRoutes
|
||||||
267
new-lamassu-admin/src/routing/pazuz.routes.js
Normal file
267
new-lamassu-admin/src/routing/pazuz.routes.js
Normal file
|
|
@ -0,0 +1,267 @@
|
||||||
|
import React from 'react'
|
||||||
|
import { Redirect } from 'react-router-dom'
|
||||||
|
|
||||||
|
import ATMWallet from 'src/pages/ATMWallet/ATMWallet'
|
||||||
|
import Blacklist from 'src/pages/Blacklist'
|
||||||
|
import Cashout from 'src/pages/Cashout'
|
||||||
|
import Commissions from 'src/pages/Commissions'
|
||||||
|
import { Customers, CustomerProfile } from 'src/pages/Customers'
|
||||||
|
import Funding from 'src/pages/Funding'
|
||||||
|
import Locales from 'src/pages/Locales'
|
||||||
|
import PromoCodes from 'src/pages/LoyaltyPanel/PromoCodes'
|
||||||
|
import MachineLogs from 'src/pages/MachineLogs'
|
||||||
|
import CashCassettes from 'src/pages/Maintenance/CashCassettes'
|
||||||
|
import MachineStatus from 'src/pages/Maintenance/MachineStatus'
|
||||||
|
import Notifications from 'src/pages/Notifications/Notifications'
|
||||||
|
import CoinAtmRadar from 'src/pages/OperatorInfo/CoinATMRadar'
|
||||||
|
import ContactInfo from 'src/pages/OperatorInfo/ContactInfo'
|
||||||
|
import ReceiptPrinting from 'src/pages/OperatorInfo/ReceiptPrinting'
|
||||||
|
import TermsConditions from 'src/pages/OperatorInfo/TermsConditions'
|
||||||
|
import ServerLogs from 'src/pages/ServerLogs'
|
||||||
|
import Services from 'src/pages/Services/Services'
|
||||||
|
import SessionManagement from 'src/pages/SessionManagement/SessionManagement'
|
||||||
|
import Transactions from 'src/pages/Transactions/Transactions'
|
||||||
|
import Triggers from 'src/pages/Triggers'
|
||||||
|
import UserManagement from 'src/pages/UserManagement/UserManagement'
|
||||||
|
import { namespaces } from 'src/utils/config'
|
||||||
|
|
||||||
|
import { ROLES } from './utils'
|
||||||
|
|
||||||
|
const getPazuzRoutes = () => [
|
||||||
|
{
|
||||||
|
key: 'transactions',
|
||||||
|
label: 'Transactions',
|
||||||
|
route: '/transactions',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Transactions
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'maintenance',
|
||||||
|
label: 'Maintenance',
|
||||||
|
route: '/maintenance',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
get component() {
|
||||||
|
return () => <Redirect to={this.children[0].route} />
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: 'cash_cassettes',
|
||||||
|
label: 'Cash Cassettes',
|
||||||
|
route: '/maintenance/cash-cassettes',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: CashCassettes
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'funding',
|
||||||
|
label: 'Funding',
|
||||||
|
route: '/maintenance/funding',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Funding
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'logs',
|
||||||
|
label: 'Machine Logs',
|
||||||
|
route: '/maintenance/logs',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: MachineLogs
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'machine-status',
|
||||||
|
label: 'Machine Status',
|
||||||
|
route: '/maintenance/machine-status',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: MachineStatus
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'server-logs',
|
||||||
|
label: 'Server',
|
||||||
|
route: '/maintenance/server-logs',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: ServerLogs
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'settings',
|
||||||
|
label: 'Settings',
|
||||||
|
route: '/settings',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
get component() {
|
||||||
|
return () => <Redirect to={this.children[0].route} />
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: namespaces.COMMISSIONS,
|
||||||
|
label: 'Commissions',
|
||||||
|
route: '/settings/commissions',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Commissions
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: namespaces.LOCALE,
|
||||||
|
label: 'Locales',
|
||||||
|
route: '/settings/locale',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Locales
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: namespaces.CASH_OUT,
|
||||||
|
label: 'Cash-out',
|
||||||
|
route: '/settings/cash-out',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Cashout
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: namespaces.NOTIFICATIONS,
|
||||||
|
label: 'Notifications',
|
||||||
|
route: '/settings/notifications',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Notifications
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'services',
|
||||||
|
label: '3rd party services',
|
||||||
|
route: '/settings/3rd-party-services',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Services
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: namespaces.OPERATOR_INFO,
|
||||||
|
label: 'Operator Info',
|
||||||
|
route: '/settings/operator-info',
|
||||||
|
title: 'Operator Information',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
get component() {
|
||||||
|
return () => (
|
||||||
|
<Redirect
|
||||||
|
to={{
|
||||||
|
pathname: this.children[0].route,
|
||||||
|
state: { prev: this.state?.prev }
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: 'contact-info',
|
||||||
|
label: 'Contact information',
|
||||||
|
route: '/settings/operator-info/contact-info',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: ContactInfo
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'receipt-printing',
|
||||||
|
label: 'Receipt',
|
||||||
|
route: '/settings/operator-info/receipt-printing',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: ReceiptPrinting
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'coin-atm-radar',
|
||||||
|
label: 'Coin ATM Radar',
|
||||||
|
route: '/settings/operator-info/coin-atm-radar',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: CoinAtmRadar
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'terms-conditions',
|
||||||
|
label: 'Terms & Conditions',
|
||||||
|
route: '/settings/operator-info/terms-conditions',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: TermsConditions
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'compliance',
|
||||||
|
label: 'Compliance',
|
||||||
|
route: '/compliance',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
get component() {
|
||||||
|
return () => <Redirect to={this.children[0].route} />
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: 'triggers',
|
||||||
|
label: 'Triggers',
|
||||||
|
route: '/compliance/triggers',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Triggers
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'customers',
|
||||||
|
label: 'Customers',
|
||||||
|
route: '/compliance/customers',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Customers
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'blacklist',
|
||||||
|
label: 'Blacklist',
|
||||||
|
route: '/compliance/blacklist',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: Blacklist
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'promo-codes',
|
||||||
|
label: 'Promo Codes',
|
||||||
|
route: '/compliance/loyalty/codes',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: PromoCodes
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'customer',
|
||||||
|
route: '/compliance/customer/:id',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: CustomerProfile
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'accounting',
|
||||||
|
label: 'Accounting',
|
||||||
|
route: '/accounting',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
get component() {
|
||||||
|
return () => <Redirect to={this.children[0].route} />
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: 'atmwallets',
|
||||||
|
label: 'ATM Wallets',
|
||||||
|
route: '/accounting/wallets',
|
||||||
|
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
||||||
|
component: ATMWallet
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'system',
|
||||||
|
label: 'System',
|
||||||
|
route: '/system',
|
||||||
|
allowedRoles: [ROLES.SUPERUSER],
|
||||||
|
get component() {
|
||||||
|
return () => <Redirect to={this.children[0].route} />
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: 'user-management',
|
||||||
|
label: 'User Management',
|
||||||
|
route: '/system/user-management',
|
||||||
|
allowedRoles: [ROLES.SUPERUSER],
|
||||||
|
component: UserManagement
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'session-management',
|
||||||
|
label: 'Session Management',
|
||||||
|
route: '/system/session-management',
|
||||||
|
allowedRoles: [ROLES.SUPERUSER],
|
||||||
|
component: SessionManagement
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
export default getPazuzRoutes
|
||||||
|
|
@ -12,42 +12,19 @@ import {
|
||||||
} from 'react-router-dom'
|
} from 'react-router-dom'
|
||||||
|
|
||||||
import AppContext from 'src/AppContext'
|
import AppContext from 'src/AppContext'
|
||||||
import ATMWallet from 'src/pages/ATMWallet/ATMWallet'
|
|
||||||
import Login from 'src/pages/Authentication/Login'
|
import Login from 'src/pages/Authentication/Login'
|
||||||
import Register from 'src/pages/Authentication/Register'
|
import Register from 'src/pages/Authentication/Register'
|
||||||
import Reset2FA from 'src/pages/Authentication/Reset2FA'
|
import Reset2FA from 'src/pages/Authentication/Reset2FA'
|
||||||
import ResetPassword from 'src/pages/Authentication/ResetPassword'
|
import ResetPassword from 'src/pages/Authentication/ResetPassword'
|
||||||
import Blacklist from 'src/pages/Blacklist'
|
|
||||||
import Cashout from 'src/pages/Cashout'
|
|
||||||
import Commissions from 'src/pages/Commissions'
|
|
||||||
// import ConfigMigration from 'src/pages/ConfigMigration'
|
// import ConfigMigration from 'src/pages/ConfigMigration'
|
||||||
import { Customers, CustomerProfile } from 'src/pages/Customers'
|
|
||||||
import Dashboard from 'src/pages/Dashboard'
|
import Dashboard from 'src/pages/Dashboard'
|
||||||
import Funding from 'src/pages/Funding'
|
|
||||||
import Locales from 'src/pages/Locales'
|
|
||||||
import PromoCodes from 'src/pages/LoyaltyPanel/PromoCodes'
|
|
||||||
import MachineLogs from 'src/pages/MachineLogs'
|
|
||||||
import Machines from 'src/pages/Machines'
|
import Machines from 'src/pages/Machines'
|
||||||
import CashCassettes from 'src/pages/Maintenance/CashCassettes'
|
|
||||||
import MachineStatus from 'src/pages/Maintenance/MachineStatus'
|
|
||||||
import Notifications from 'src/pages/Notifications/Notifications'
|
|
||||||
import CoinAtmRadar from 'src/pages/OperatorInfo/CoinATMRadar'
|
|
||||||
import ContactInfo from 'src/pages/OperatorInfo/ContactInfo'
|
|
||||||
import ReceiptPrinting from 'src/pages/OperatorInfo/ReceiptPrinting'
|
|
||||||
import TermsConditions from 'src/pages/OperatorInfo/TermsConditions'
|
|
||||||
import ServerLogs from 'src/pages/ServerLogs'
|
|
||||||
import Services from 'src/pages/Services/Services'
|
|
||||||
import SessionManagement from 'src/pages/SessionManagement/SessionManagement'
|
|
||||||
import Transactions from 'src/pages/Transactions/Transactions'
|
|
||||||
import Triggers from 'src/pages/Triggers'
|
|
||||||
import UserManagement from 'src/pages/UserManagement/UserManagement'
|
|
||||||
import WalletSettings from 'src/pages/Wallet/Wallet'
|
|
||||||
import Wizard from 'src/pages/Wizard'
|
import Wizard from 'src/pages/Wizard'
|
||||||
import { namespaces } from 'src/utils/config'
|
|
||||||
|
|
||||||
import PrivateRoute from './PrivateRoute'
|
import PrivateRoute from './PrivateRoute'
|
||||||
import PublicRoute from './PublicRoute'
|
import PublicRoute from './PublicRoute'
|
||||||
import { BUILD_TARGETS, ROLES } from './utils'
|
import getLamassuRoutes from './lamassu.routes'
|
||||||
|
import getPazuzRoutes from './pazuz.routes'
|
||||||
|
|
||||||
const useStyles = makeStyles({
|
const useStyles = makeStyles({
|
||||||
wrapper: {
|
wrapper: {
|
||||||
|
|
@ -58,279 +35,21 @@ const useStyles = makeStyles({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const tree = [
|
const getTree = () => {
|
||||||
{
|
const buildTarget = process.env.REACT_APP_BUILD_TARGET
|
||||||
key: 'transactions',
|
|
||||||
label: 'Transactions',
|
if (buildTarget === 'LAMASSU') {
|
||||||
route: '/transactions',
|
return getLamassuRoutes()
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: Transactions
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'maintenance',
|
|
||||||
label: 'Maintenance',
|
|
||||||
route: '/maintenance',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
get component() {
|
|
||||||
return () => <Redirect to={this.children[0].route} />
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
key: 'cash_cassettes',
|
|
||||||
label: 'Cash Cassettes',
|
|
||||||
route: '/maintenance/cash-cassettes',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: CashCassettes
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'funding',
|
|
||||||
label: 'Funding',
|
|
||||||
route: '/maintenance/funding',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: Funding
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'logs',
|
|
||||||
label: 'Machine Logs',
|
|
||||||
route: '/maintenance/logs',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: MachineLogs
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'machine-status',
|
|
||||||
label: 'Machine Status',
|
|
||||||
route: '/maintenance/machine-status',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: MachineStatus
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'server-logs',
|
|
||||||
label: 'Server',
|
|
||||||
route: '/maintenance/server-logs',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: ServerLogs
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'settings',
|
|
||||||
label: 'Settings',
|
|
||||||
route: '/settings',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
get component() {
|
|
||||||
return () => <Redirect to={this.children[0].route} />
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
key: namespaces.COMMISSIONS,
|
|
||||||
label: 'Commissions',
|
|
||||||
route: '/settings/commissions',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: Commissions
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: namespaces.LOCALE,
|
|
||||||
label: 'Locales',
|
|
||||||
route: '/settings/locale',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: Locales
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: namespaces.CASH_OUT,
|
|
||||||
label: 'Cash-out',
|
|
||||||
route: '/settings/cash-out',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: Cashout
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: namespaces.NOTIFICATIONS,
|
|
||||||
label: 'Notifications',
|
|
||||||
route: '/settings/notifications',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: Notifications
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'services',
|
|
||||||
label: '3rd party services',
|
|
||||||
route: '/settings/3rd-party-services',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: Services
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: namespaces.WALLETS,
|
|
||||||
label: 'Wallet',
|
|
||||||
route: '/settings/wallet-settings',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU],
|
|
||||||
component: WalletSettings
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: namespaces.OPERATOR_INFO,
|
|
||||||
label: 'Operator Info',
|
|
||||||
route: '/settings/operator-info',
|
|
||||||
title: 'Operator Information',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
get component() {
|
|
||||||
return () => (
|
|
||||||
<Redirect
|
|
||||||
to={{
|
|
||||||
pathname: this.children[0].route,
|
|
||||||
state: { prev: this.state?.prev }
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
key: 'contact-info',
|
|
||||||
label: 'Contact information',
|
|
||||||
route: '/settings/operator-info/contact-info',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: ContactInfo
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'receipt-printing',
|
|
||||||
label: 'Receipt',
|
|
||||||
route: '/settings/operator-info/receipt-printing',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: ReceiptPrinting
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'coin-atm-radar',
|
|
||||||
label: 'Coin ATM Radar',
|
|
||||||
route: '/settings/operator-info/coin-atm-radar',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: CoinAtmRadar
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'terms-conditions',
|
|
||||||
label: 'Terms & Conditions',
|
|
||||||
route: '/settings/operator-info/terms-conditions',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: TermsConditions
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'compliance',
|
|
||||||
label: 'Compliance',
|
|
||||||
route: '/compliance',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
get component() {
|
|
||||||
return () => <Redirect to={this.children[0].route} />
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
key: 'triggers',
|
|
||||||
label: 'Triggers',
|
|
||||||
route: '/compliance/triggers',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: Triggers
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'customers',
|
|
||||||
label: 'Customers',
|
|
||||||
route: '/compliance/customers',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: Customers
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'blacklist',
|
|
||||||
label: 'Blacklist',
|
|
||||||
route: '/compliance/blacklist',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: Blacklist
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'promo-codes',
|
|
||||||
label: 'Promo Codes',
|
|
||||||
route: '/compliance/loyalty/codes',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: PromoCodes
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'customer',
|
|
||||||
route: '/compliance/customer/:id',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: CustomerProfile
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'accounting',
|
|
||||||
label: 'Accounting',
|
|
||||||
route: '/accounting',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.PAZUZ],
|
|
||||||
get component() {
|
|
||||||
return () => <Redirect to={this.children[0].route} />
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
key: 'atmwallets',
|
|
||||||
label: 'ATM Wallets',
|
|
||||||
route: '/accounting/wallets',
|
|
||||||
allowedRoles: [ROLES.USER, ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.PAZUZ],
|
|
||||||
component: ATMWallet
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'system',
|
|
||||||
label: 'System',
|
|
||||||
route: '/system',
|
|
||||||
allowedRoles: [ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
get component() {
|
|
||||||
return () => <Redirect to={this.children[0].route} />
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
key: 'user-management',
|
|
||||||
label: 'User Management',
|
|
||||||
route: '/system/user-management',
|
|
||||||
allowedRoles: [ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: UserManagement
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'session-management',
|
|
||||||
label: 'Session Management',
|
|
||||||
route: '/system/session-management',
|
|
||||||
allowedRoles: [ROLES.SUPERUSER],
|
|
||||||
targets: [BUILD_TARGETS.LAMASSU, BUILD_TARGETS.PAZUZ],
|
|
||||||
component: SessionManagement
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
|
||||||
|
if (buildTarget === 'PAZUZ') {
|
||||||
|
return getPazuzRoutes()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const tree = getTree()
|
||||||
|
|
||||||
|
console.log('tree', tree)
|
||||||
|
|
||||||
const map = R.map(R.when(R.has('children'), R.prop('children')))
|
const map = R.map(R.when(R.has('children'), R.prop('children')))
|
||||||
const mappedRoutes = R.compose(R.flatten, map)(tree)
|
const mappedRoutes = R.compose(R.flatten, map)(tree)
|
||||||
|
|
@ -386,19 +105,10 @@ const Routes = () => {
|
||||||
const getFilteredRoutes = () => {
|
const getFilteredRoutes = () => {
|
||||||
if (!userData) return []
|
if (!userData) return []
|
||||||
|
|
||||||
const currentBuildTarget = process.env.REACT_APP_BUILD_TARGET
|
return flattened.filter(value => {
|
||||||
|
|
||||||
const roleFilter = flattened.filter(value => {
|
|
||||||
const keys = value.allowedRoles
|
const keys = value.allowedRoles
|
||||||
return R.includes(userData.role, keys)
|
return R.includes(userData.role, keys)
|
||||||
})
|
})
|
||||||
|
|
||||||
const buildFilter = roleFilter.filter(value => {
|
|
||||||
const keys = value.targets
|
|
||||||
return R.includes(currentBuildTarget, keys)
|
|
||||||
})
|
|
||||||
|
|
||||||
return buildFilter
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Transition = location.state ? Slide : Fade
|
const Transition = location.state ? Slide : Fade
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue