From e8ed8d174b4615a9dfb50f2ca509bbe53ce0da09 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 8 May 2026 09:12:53 +0000 Subject: [PATCH] 2 --- .../db/seeders/20200430130760-user-roles.js | 4567 +++++++++-------- backend/src/routes/buyer_portal.js | 59 +- backend/src/services/buyer_portal.js | 287 +- .../public/locales/en-GB/translation.json | 1 + .../public/locales/en-US/translation.json | 1 + frontend/public/locales/en/translation.json | 1 + frontend/src/._colors.ts | Bin 0 -> 163 bytes frontend/src/._menuAside.ts | Bin 0 -> 163 bytes frontend/src/._styles.ts | Bin 0 -> 163 bytes frontend/src/colors.ts | 67 +- frontend/src/components/._AsideMenu.tsx | Bin 0 -> 163 bytes frontend/src/components/._AsideMenuItem.tsx | Bin 0 -> 163 bytes frontend/src/components/._AsideMenuLayer.tsx | Bin 0 -> 163 bytes frontend/src/components/._AsideMenuList.tsx | Bin 0 -> 163 bytes frontend/src/components/._CardBox.tsx | Bin 0 -> 163 bytes frontend/src/components/._FooterBar.tsx | Bin 0 -> 163 bytes frontend/src/components/._NavBar.tsx | Bin 0 -> 163 bytes frontend/src/components/._NavBarItem.tsx | Bin 0 -> 163 bytes frontend/src/components/._NavBarItemPlain.tsx | Bin 0 -> 163 bytes frontend/src/components/._Search.tsx | Bin 0 -> 163 bytes frontend/src/components/._SectionMain.tsx | Bin 0 -> 163 bytes .../._SectionTitleLineWithButton.tsx | Bin 0 -> 163 bytes frontend/src/components/AsideMenu.tsx | 30 +- frontend/src/components/AsideMenuItem.tsx | 138 +- frontend/src/components/AsideMenuLayer.tsx | 96 +- frontend/src/components/AsideMenuList.tsx | 46 +- frontend/src/components/CardBox.tsx | 56 +- frontend/src/components/ErrorBoundary.tsx | 224 +- frontend/src/components/FooterBar.tsx | 44 +- frontend/src/components/NavBar.tsx | 53 +- frontend/src/components/NavBarItem.tsx | 107 +- frontend/src/components/NavBarItemPlain.tsx | 28 +- frontend/src/components/Search.tsx | 17 +- frontend/src/components/SectionMain.tsx | 14 +- .../components/SectionTitleLineWithButton.tsx | 60 +- frontend/src/css/.__table.css | Bin 0 -> 163 bytes frontend/src/css/_table.css | 48 +- frontend/src/layouts/._Authenticated.tsx | Bin 0 -> 163 bytes frontend/src/layouts/Authenticated.tsx | 140 +- frontend/src/layouts/BuyerPortal.tsx | 138 + frontend/src/menuAside.ts | 380 +- frontend/src/pages/._dashboard.tsx | Bin 0 -> 163 bytes frontend/src/pages/._profile.tsx | Bin 0 -> 163 bytes frontend/src/pages/buyer-login.tsx | 279 + frontend/src/pages/buyer-portal.tsx | 1829 +++++-- frontend/src/pages/dashboard.tsx | 1199 ++--- frontend/src/pages/index.tsx | 8 +- frontend/src/pages/login.tsx | 540 +- frontend/src/pages/profile.tsx | 577 ++- frontend/src/styles.ts | 115 +- 50 files changed, 6598 insertions(+), 4551 deletions(-) create mode 100644 frontend/public/locales/en-GB/translation.json create mode 100644 frontend/public/locales/en-US/translation.json create mode 100644 frontend/public/locales/en/translation.json create mode 100644 frontend/src/._colors.ts create mode 100644 frontend/src/._menuAside.ts create mode 100644 frontend/src/._styles.ts create mode 100644 frontend/src/components/._AsideMenu.tsx create mode 100644 frontend/src/components/._AsideMenuItem.tsx create mode 100644 frontend/src/components/._AsideMenuLayer.tsx create mode 100644 frontend/src/components/._AsideMenuList.tsx create mode 100644 frontend/src/components/._CardBox.tsx create mode 100644 frontend/src/components/._FooterBar.tsx create mode 100644 frontend/src/components/._NavBar.tsx create mode 100644 frontend/src/components/._NavBarItem.tsx create mode 100644 frontend/src/components/._NavBarItemPlain.tsx create mode 100644 frontend/src/components/._Search.tsx create mode 100644 frontend/src/components/._SectionMain.tsx create mode 100644 frontend/src/components/._SectionTitleLineWithButton.tsx create mode 100644 frontend/src/css/.__table.css create mode 100644 frontend/src/layouts/._Authenticated.tsx create mode 100644 frontend/src/layouts/BuyerPortal.tsx create mode 100644 frontend/src/pages/._dashboard.tsx create mode 100644 frontend/src/pages/._profile.tsx create mode 100644 frontend/src/pages/buyer-login.tsx diff --git a/backend/src/db/seeders/20200430130760-user-roles.js b/backend/src/db/seeders/20200430130760-user-roles.js index 596d62a..60ed72c 100644 --- a/backend/src/db/seeders/20200430130760-user-roles.js +++ b/backend/src/db/seeders/20200430130760-user-roles.js @@ -1,5 +1,4 @@ - -const { v4: uuid } = require("uuid"); +const { v4: uuid } = require('uuid'); module.exports = { /** @@ -26,26 +25,45 @@ module.exports = { return id; } - await queryInterface.bulkInsert("roles", [ - - - { id: getId("Administrator"), name: "Administrator", createdAt, updatedAt }, - - - - { id: getId("PortalOwner"), name: "Portal Owner", createdAt, updatedAt }, - - { id: getId("OperationsManager"), name: "Operations Manager", createdAt, updatedAt }, - - { id: getId("SalesRepresentative"), name: "Sales Representative", createdAt, updatedAt }, - - { id: getId("CustomerBuyerAdmin"), name: "Customer Buyer Admin", createdAt, updatedAt }, - - { id: getId("CustomerBuyer"), name: "Customer Buyer", createdAt, updatedAt }, - - - - { id: getId("Public"), name: "Public", createdAt, updatedAt }, + await queryInterface.bulkInsert('roles', [ + { + id: getId('Administrator'), + name: 'Administrator', + createdAt, + updatedAt, + }, + + { id: getId('PortalOwner'), name: 'Portal Owner', createdAt, updatedAt }, + + { + id: getId('OperationsManager'), + name: 'Operations Manager', + createdAt, + updatedAt, + }, + + { + id: getId('SalesRepresentative'), + name: 'Sales Representative', + createdAt, + updatedAt, + }, + + { + id: getId('CustomerBuyerAdmin'), + name: 'Customer Buyer Admin', + createdAt, + updatedAt, + }, + + { + id: getId('CustomerBuyer'), + name: 'Customer Buyer', + createdAt, + updatedAt, + }, + + { id: getId('Public'), name: 'Public', createdAt, updatedAt }, ]); /** @@ -53,22 +71,97 @@ module.exports = { */ function createPermissions(name) { return [ - { id: getId(`CREATE_${name.toUpperCase()}`), createdAt, updatedAt, name: `CREATE_${name.toUpperCase()}` }, - { id: getId(`READ_${name.toUpperCase()}`), createdAt, updatedAt, name: `READ_${name.toUpperCase()}` }, - { id: getId(`UPDATE_${name.toUpperCase()}`), createdAt, updatedAt, name: `UPDATE_${name.toUpperCase()}` }, - { id: getId(`DELETE_${name.toUpperCase()}`), createdAt, updatedAt, name: `DELETE_${name.toUpperCase()}` } + { + id: getId(`CREATE_${name.toUpperCase()}`), + createdAt, + updatedAt, + name: `CREATE_${name.toUpperCase()}`, + }, + { + id: getId(`READ_${name.toUpperCase()}`), + createdAt, + updatedAt, + name: `READ_${name.toUpperCase()}`, + }, + { + id: getId(`UPDATE_${name.toUpperCase()}`), + createdAt, + updatedAt, + name: `UPDATE_${name.toUpperCase()}`, + }, + { + id: getId(`DELETE_${name.toUpperCase()}`), + createdAt, + updatedAt, + name: `DELETE_${name.toUpperCase()}`, + }, ]; } const entities = [ - "users","roles","permissions","accounts","locations","contacts","product_categories","products","inventory_items","price_lists","price_list_items","account_price_lists","carts","cart_items","orders","order_items","shipments","quotes","quote_items","sample_requests","saved_lists","saved_list_items",, + 'users', + 'roles', + 'permissions', + 'accounts', + 'locations', + 'contacts', + 'product_categories', + 'products', + 'inventory_items', + 'price_lists', + 'price_list_items', + 'account_price_lists', + 'carts', + 'cart_items', + 'orders', + 'order_items', + 'shipments', + 'quotes', + 'quote_items', + 'sample_requests', + 'saved_lists', + 'saved_list_items', + , ]; -await queryInterface.bulkInsert("permissions", entities.flatMap(createPermissions)); -await queryInterface.bulkInsert("permissions", [{ id: getId(`READ_API_DOCS`), createdAt, updatedAt, name: `READ_API_DOCS` }]); -await queryInterface.bulkInsert("permissions", [{ id: getId(`CREATE_SEARCH`), createdAt, updatedAt, name: `CREATE_SEARCH`}]); + await queryInterface.bulkInsert( + 'permissions', + entities.flatMap(createPermissions), + ); + await queryInterface.bulkInsert('permissions', [ + { + id: getId(`READ_API_DOCS`), + createdAt, + updatedAt, + name: `READ_API_DOCS`, + }, + ]); + await queryInterface.bulkInsert('permissions', [ + { + id: getId(`READ_BUYER_PORTAL`), + createdAt, + updatedAt, + name: `READ_BUYER_PORTAL`, + }, + ]); + await queryInterface.bulkInsert('permissions', [ + { + id: getId(`READ_BUYER_TEAM_QUEUE`), + createdAt, + updatedAt, + name: `READ_BUYER_TEAM_QUEUE`, + }, + ]); + await queryInterface.bulkInsert('permissions', [ + { + id: getId(`CREATE_SEARCH`), + createdAt, + updatedAt, + name: `CREATE_SEARCH`, + }, + ]); - -await queryInterface.sequelize.query(`create table "rolesPermissionsPermissions" + await queryInterface.sequelize + .query(`create table "rolesPermissionsPermissions" ( "createdAt" timestamp with time zone not null, "updatedAt" timestamp with time zone not null, @@ -77,2118 +170,2310 @@ await queryInterface.sequelize.query(`create table "rolesPermissionsPermissions" primary key ("roles_permissionsId", "permissionId") );`); + await queryInterface.bulkInsert('rolesPermissionsPermissions', [ + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_USERS'), + }, -await queryInterface.bulkInsert("rolesPermissionsPermissions", [ - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_USERS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_USERS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_USERS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_USERS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_USERS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_USERS') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('UPDATE_USERS') }, - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_ACCOUNTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_ACCOUNTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_ACCOUNTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_ACCOUNTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_ACCOUNTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_ACCOUNTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('DELETE_ACCOUNTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_ACCOUNTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('UPDATE_ACCOUNTS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_ACCOUNTS') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_ACCOUNTS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_LOCATIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_LOCATIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_LOCATIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_LOCATIONS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_LOCATIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_LOCATIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('DELETE_LOCATIONS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_LOCATIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('UPDATE_LOCATIONS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_LOCATIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('UPDATE_LOCATIONS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_LOCATIONS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_CONTACTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_CONTACTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_CONTACTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_CONTACTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_CONTACTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_CONTACTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('DELETE_CONTACTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_CONTACTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('UPDATE_CONTACTS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_CONTACTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('UPDATE_CONTACTS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_CONTACTS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_PRODUCT_CATEGORIES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_PRODUCT_CATEGORIES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_PRODUCT_CATEGORIES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_PRODUCT_CATEGORIES') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_PRODUCT_CATEGORIES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_PRODUCT_CATEGORIES') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_PRODUCT_CATEGORIES') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_PRODUCT_CATEGORIES') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_PRODUCT_CATEGORIES') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_PRODUCTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_PRODUCTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_PRODUCTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_PRODUCTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_PRODUCTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_PRODUCTS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_PRODUCTS') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_PRODUCTS') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_PRODUCTS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_INVENTORY_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_INVENTORY_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_INVENTORY_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_INVENTORY_ITEMS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_INVENTORY_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_INVENTORY_ITEMS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_INVENTORY_ITEMS') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_INVENTORY_ITEMS') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_INVENTORY_ITEMS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_PRICE_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_PRICE_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_PRICE_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_PRICE_LISTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_PRICE_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_PRICE_LISTS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_PRICE_LISTS') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_PRICE_LISTS') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_PRICE_LISTS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_PRICE_LIST_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_PRICE_LIST_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_PRICE_LIST_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_PRICE_LIST_ITEMS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_PRICE_LIST_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_PRICE_LIST_ITEMS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_PRICE_LIST_ITEMS') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_PRICE_LIST_ITEMS') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_PRICE_LIST_ITEMS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_ACCOUNT_PRICE_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_ACCOUNT_PRICE_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_ACCOUNT_PRICE_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_ACCOUNT_PRICE_LISTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_ACCOUNT_PRICE_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_ACCOUNT_PRICE_LISTS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_ACCOUNT_PRICE_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('UPDATE_ACCOUNT_PRICE_LISTS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_ACCOUNT_PRICE_LISTS') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_ACCOUNT_PRICE_LISTS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_CARTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_CARTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_CARTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_CARTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_CARTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_CARTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('DELETE_CARTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_CARTS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('CREATE_CARTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_CARTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('UPDATE_CARTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('CREATE_CARTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_CARTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('UPDATE_CARTS') }, - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_CART_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_CART_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_CART_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_CART_ITEMS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_CART_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_CART_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('DELETE_CART_ITEMS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_CART_ITEMS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('CREATE_CART_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_CART_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('UPDATE_CART_ITEMS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('CREATE_CART_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_CART_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('UPDATE_CART_ITEMS') }, - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_ORDERS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_ORDERS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_ORDERS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_ORDERS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_ORDERS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_ORDERS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('DELETE_ORDERS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_ORDERS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('UPDATE_ORDERS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_ORDERS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('UPDATE_ORDERS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_ORDERS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('UPDATE_ORDERS') }, - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_ORDER_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_ORDER_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_ORDER_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_ORDER_ITEMS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_ORDER_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_ORDER_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('DELETE_ORDER_ITEMS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_ORDER_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('UPDATE_ORDER_ITEMS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_ORDER_ITEMS') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_ORDER_ITEMS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_SHIPMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_SHIPMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_SHIPMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_SHIPMENTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_SHIPMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_SHIPMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('DELETE_SHIPMENTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_SHIPMENTS') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_SHIPMENTS') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_SHIPMENTS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_QUOTES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_QUOTES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_QUOTES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_QUOTES') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_QUOTES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_QUOTES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('DELETE_QUOTES') }, - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('CREATE_QUOTES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_QUOTES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('UPDATE_QUOTES') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('CREATE_QUOTES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_QUOTES') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('CREATE_QUOTES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_QUOTES') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_QUOTE_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_QUOTE_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_QUOTE_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_QUOTE_ITEMS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_QUOTE_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_QUOTE_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('DELETE_QUOTE_ITEMS') }, - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('CREATE_QUOTE_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_QUOTE_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('UPDATE_QUOTE_ITEMS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('CREATE_QUOTE_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_QUOTE_ITEMS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('CREATE_QUOTE_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_QUOTE_ITEMS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_SAMPLE_REQUESTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_SAMPLE_REQUESTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_SAMPLE_REQUESTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_SAMPLE_REQUESTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_SAMPLE_REQUESTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_SAMPLE_REQUESTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('DELETE_SAMPLE_REQUESTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_SAMPLE_REQUESTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('UPDATE_SAMPLE_REQUESTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('CREATE_SAMPLE_REQUESTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_SAMPLE_REQUESTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('UPDATE_SAMPLE_REQUESTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('CREATE_SAMPLE_REQUESTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_SAMPLE_REQUESTS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_SAVED_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_SAVED_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_SAVED_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_SAVED_LISTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_SAVED_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_SAVED_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('DELETE_SAVED_LISTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_SAVED_LISTS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('CREATE_SAVED_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_SAVED_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('UPDATE_SAVED_LISTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('CREATE_SAVED_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_SAVED_LISTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('UPDATE_SAVED_LISTS') }, - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_SAVED_LIST_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('READ_SAVED_LIST_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('UPDATE_SAVED_LIST_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('DELETE_SAVED_LIST_ITEMS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('READ_SAVED_LIST_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('UPDATE_SAVED_LIST_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('DELETE_SAVED_LIST_ITEMS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('READ_SAVED_LIST_ITEMS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('CREATE_SAVED_LIST_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('READ_SAVED_LIST_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('UPDATE_SAVED_LIST_ITEMS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('CREATE_SAVED_LIST_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('READ_SAVED_LIST_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('UPDATE_SAVED_LIST_ITEMS') }, - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PortalOwner"), permissionId: getId('CREATE_SEARCH') }, - - { createdAt, updatedAt, roles_permissionsId: getId("OperationsManager"), permissionId: getId('CREATE_SEARCH') }, - - { createdAt, updatedAt, roles_permissionsId: getId("SalesRepresentative"), permissionId: getId('CREATE_SEARCH') }, - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyerAdmin"), permissionId: getId('CREATE_SEARCH') }, - - { createdAt, updatedAt, roles_permissionsId: getId("CustomerBuyer"), permissionId: getId('CREATE_SEARCH') }, - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_USERS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_USERS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_USERS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_USERS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_ROLES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_ROLES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_ROLES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_ROLES') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_PERMISSIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_PERMISSIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_PERMISSIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_PERMISSIONS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_ACCOUNTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_ACCOUNTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_ACCOUNTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_ACCOUNTS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_LOCATIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_LOCATIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_LOCATIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_LOCATIONS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_CONTACTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_CONTACTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_CONTACTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_CONTACTS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_PRODUCT_CATEGORIES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_PRODUCT_CATEGORIES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_PRODUCT_CATEGORIES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_PRODUCT_CATEGORIES') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_PRODUCTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_PRODUCTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_PRODUCTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_PRODUCTS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_INVENTORY_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_INVENTORY_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_INVENTORY_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_INVENTORY_ITEMS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_PRICE_LISTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_PRICE_LISTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_PRICE_LISTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_PRICE_LISTS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_PRICE_LIST_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_PRICE_LIST_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_PRICE_LIST_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_PRICE_LIST_ITEMS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_ACCOUNT_PRICE_LISTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_ACCOUNT_PRICE_LISTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_ACCOUNT_PRICE_LISTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_ACCOUNT_PRICE_LISTS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_CARTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_CARTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_CARTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_CARTS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_CART_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_CART_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_CART_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_CART_ITEMS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_ORDERS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_ORDERS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_ORDERS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_ORDERS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_ORDER_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_ORDER_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_ORDER_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_ORDER_ITEMS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_SHIPMENTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_SHIPMENTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_SHIPMENTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_SHIPMENTS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_QUOTES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_QUOTES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_QUOTES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_QUOTES') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_QUOTE_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_QUOTE_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_QUOTE_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_QUOTE_ITEMS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_SAMPLE_REQUESTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_SAMPLE_REQUESTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_SAMPLE_REQUESTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_SAMPLE_REQUESTS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_SAVED_LISTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_SAVED_LISTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_SAVED_LISTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_SAVED_LISTS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_SAVED_LIST_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_SAVED_LIST_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_SAVED_LIST_ITEMS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_SAVED_LIST_ITEMS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_API_DOCS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_SEARCH') }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_USERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_USERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_USERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_USERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_USERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('UPDATE_USERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_ACCOUNTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_ACCOUNTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_ACCOUNTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_ACCOUNTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_ACCOUNTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_ACCOUNTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('DELETE_ACCOUNTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_ACCOUNTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('UPDATE_ACCOUNTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_ACCOUNTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_ACCOUNTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_LOCATIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_LOCATIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_LOCATIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_LOCATIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_LOCATIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_LOCATIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('DELETE_LOCATIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_LOCATIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('UPDATE_LOCATIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_LOCATIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('UPDATE_LOCATIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_LOCATIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_CONTACTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_CONTACTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_CONTACTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_CONTACTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_CONTACTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_CONTACTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('DELETE_CONTACTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_CONTACTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('UPDATE_CONTACTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_CONTACTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('UPDATE_CONTACTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_CONTACTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_PRODUCT_CATEGORIES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_PRODUCT_CATEGORIES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_PRODUCT_CATEGORIES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_PRODUCT_CATEGORIES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_PRODUCT_CATEGORIES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_PRODUCT_CATEGORIES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_PRODUCT_CATEGORIES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_PRODUCT_CATEGORIES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_PRODUCT_CATEGORIES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_PRODUCTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_PRODUCTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_PRODUCTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_PRODUCTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_PRODUCTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_PRODUCTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_PRODUCTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_PRODUCTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_PRODUCTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_INVENTORY_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_INVENTORY_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_INVENTORY_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_INVENTORY_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_INVENTORY_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_INVENTORY_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_INVENTORY_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_INVENTORY_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_INVENTORY_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_PRICE_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_PRICE_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_PRICE_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_PRICE_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_PRICE_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_PRICE_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_PRICE_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_PRICE_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_PRICE_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_ACCOUNT_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_ACCOUNT_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_ACCOUNT_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_ACCOUNT_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_ACCOUNT_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_ACCOUNT_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_ACCOUNT_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('UPDATE_ACCOUNT_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_ACCOUNT_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_ACCOUNT_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_CARTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_CARTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_CARTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_CARTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_CARTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_CARTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('DELETE_CARTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_CARTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('CREATE_CARTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_CARTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('UPDATE_CARTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('CREATE_CARTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_CARTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('UPDATE_CARTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_CART_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_CART_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_CART_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_CART_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_CART_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_CART_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('DELETE_CART_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_CART_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('CREATE_CART_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_CART_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('UPDATE_CART_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('CREATE_CART_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_CART_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('UPDATE_CART_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_ORDERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_ORDERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_ORDERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_ORDERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_ORDERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_ORDERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('DELETE_ORDERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_ORDERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('UPDATE_ORDERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_ORDERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('UPDATE_ORDERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_ORDERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('UPDATE_ORDERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_ORDER_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_ORDER_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_ORDER_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_ORDER_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_ORDER_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_ORDER_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('DELETE_ORDER_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_ORDER_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('UPDATE_ORDER_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_ORDER_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_ORDER_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_SHIPMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_SHIPMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_SHIPMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_SHIPMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_SHIPMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_SHIPMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('DELETE_SHIPMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_SHIPMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_SHIPMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_SHIPMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_QUOTES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_QUOTES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_QUOTES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_QUOTES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_QUOTES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_QUOTES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('DELETE_QUOTES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('CREATE_QUOTES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_QUOTES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('UPDATE_QUOTES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('CREATE_QUOTES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_QUOTES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('CREATE_QUOTES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_QUOTES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_QUOTE_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_QUOTE_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_QUOTE_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_QUOTE_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_QUOTE_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_QUOTE_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('DELETE_QUOTE_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('CREATE_QUOTE_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_QUOTE_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('UPDATE_QUOTE_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('CREATE_QUOTE_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_QUOTE_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('CREATE_QUOTE_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_QUOTE_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_SAMPLE_REQUESTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_SAMPLE_REQUESTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_SAMPLE_REQUESTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_SAMPLE_REQUESTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_SAMPLE_REQUESTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_SAMPLE_REQUESTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('DELETE_SAMPLE_REQUESTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_SAMPLE_REQUESTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('UPDATE_SAMPLE_REQUESTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('CREATE_SAMPLE_REQUESTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_SAMPLE_REQUESTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('UPDATE_SAMPLE_REQUESTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('CREATE_SAMPLE_REQUESTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_SAMPLE_REQUESTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_SAVED_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_SAVED_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_SAVED_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_SAVED_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_SAVED_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_SAVED_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('DELETE_SAVED_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_SAVED_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('CREATE_SAVED_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_SAVED_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('UPDATE_SAVED_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('CREATE_SAVED_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_SAVED_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('UPDATE_SAVED_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_SAVED_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('READ_SAVED_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('UPDATE_SAVED_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('DELETE_SAVED_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('READ_SAVED_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('UPDATE_SAVED_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('DELETE_SAVED_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('READ_SAVED_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('CREATE_SAVED_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_SAVED_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('UPDATE_SAVED_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('CREATE_SAVED_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_SAVED_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('UPDATE_SAVED_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PortalOwner'), + permissionId: getId('CREATE_SEARCH'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OperationsManager'), + permissionId: getId('CREATE_SEARCH'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('SalesRepresentative'), + permissionId: getId('CREATE_SEARCH'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('CREATE_SEARCH'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('CREATE_SEARCH'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_USERS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_USERS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_USERS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_USERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_ROLES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_ROLES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_ROLES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_ROLES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_PERMISSIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_PERMISSIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_PERMISSIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_PERMISSIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_ACCOUNTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_ACCOUNTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_ACCOUNTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_ACCOUNTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_LOCATIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_LOCATIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_LOCATIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_LOCATIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_CONTACTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_CONTACTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_CONTACTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_CONTACTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_PRODUCT_CATEGORIES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_PRODUCT_CATEGORIES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_PRODUCT_CATEGORIES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_PRODUCT_CATEGORIES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_PRODUCTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_PRODUCTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_PRODUCTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_PRODUCTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_INVENTORY_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_INVENTORY_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_INVENTORY_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_INVENTORY_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_PRICE_LISTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_PRICE_LISTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_PRICE_LISTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_PRICE_LIST_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_PRICE_LIST_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_PRICE_LIST_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_PRICE_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_ACCOUNT_PRICE_LISTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_ACCOUNT_PRICE_LISTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_ACCOUNT_PRICE_LISTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_ACCOUNT_PRICE_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_CARTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_CARTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_CARTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_CARTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_CART_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_CART_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_CART_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_CART_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_ORDERS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_ORDERS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_ORDERS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_ORDERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_ORDER_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_ORDER_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_ORDER_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_ORDER_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_SHIPMENTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_SHIPMENTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_SHIPMENTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_SHIPMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_QUOTES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_QUOTES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_QUOTES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_QUOTES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_QUOTE_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_QUOTE_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_QUOTE_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_QUOTE_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_SAMPLE_REQUESTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_SAMPLE_REQUESTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_SAMPLE_REQUESTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_SAMPLE_REQUESTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_SAVED_LISTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_SAVED_LISTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_SAVED_LISTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_SAVED_LISTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_SAVED_LIST_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_SAVED_LIST_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_SAVED_LIST_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_SAVED_LIST_ITEMS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_API_DOCS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_BUYER_PORTAL'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_BUYER_TEAM_QUEUE'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_SEARCH'), + }, ]); + await queryInterface.sequelize.query(` + DELETE FROM "rolesPermissionsPermissions" + WHERE "roles_permissionsId" IN ( + '${getId('CustomerBuyerAdmin')}', + '${getId('CustomerBuyer')}' + ); + `); - await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("SuperAdmin")}' WHERE "email"='super_admin@flatlogic.com'`); - await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("Administrator")}' WHERE "email"='admin@flatlogic.com'`); - - - - - - - await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("PortalOwner")}' WHERE "email"='client@hello.com'`); - await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("OperationsManager")}' WHERE "email"='john@doe.com'`); - - - + await queryInterface.bulkInsert('rolesPermissionsPermissions', [ + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_BUYER_PORTAL'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('READ_BUYER_TEAM_QUEUE'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('CREATE_ORDERS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('CREATE_ORDER_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('CREATE_SAMPLE_REQUESTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('CREATE_SAVED_LISTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyerAdmin'), + permissionId: getId('CREATE_SAVED_LIST_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('READ_BUYER_PORTAL'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('CREATE_ORDERS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('CREATE_ORDER_ITEMS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('CustomerBuyer'), + permissionId: getId('CREATE_SAMPLE_REQUESTS'), + }, + ]); -} + await queryInterface.sequelize.query( + `UPDATE "users" SET "app_roleId"='${getId('SuperAdmin')}' WHERE "email"='super_admin@flatlogic.com'`, + ); + await queryInterface.sequelize.query( + `UPDATE "users" SET "app_roleId"='${getId('Administrator')}' WHERE "email"='admin@flatlogic.com'`, + ); + + await queryInterface.sequelize.query( + `UPDATE "users" SET "app_roleId"='${getId('PortalOwner')}' WHERE "email"='client@hello.com'`, + ); + await queryInterface.sequelize.query( + `UPDATE "users" SET "app_roleId"='${getId('OperationsManager')}' WHERE "email"='john@doe.com'`, + ); + }, }; - diff --git a/backend/src/routes/buyer_portal.js b/backend/src/routes/buyer_portal.js index a910f6b..30e2896 100644 --- a/backend/src/routes/buyer_portal.js +++ b/backend/src/routes/buyer_portal.js @@ -6,50 +6,36 @@ const { checkPermissions } = require('../middlewares/check-permissions'); const router = express.Router(); -const workspacePermissions = [ - 'READ_ACCOUNTS', - 'READ_LOCATIONS', - 'READ_CONTACTS', - 'READ_PRODUCTS', - 'READ_PRICE_LISTS', - 'READ_PRICE_LIST_ITEMS', - 'READ_ACCOUNT_PRICE_LISTS', - 'READ_ORDERS', - 'READ_ORDER_ITEMS', - 'READ_QUOTES', - 'READ_QUOTE_ITEMS', - 'READ_SAMPLE_REQUESTS', - 'READ_SAVED_LISTS', - 'READ_SAVED_LIST_ITEMS', -]; +const workspacePermissions = ['READ_BUYER_PORTAL']; const createSavedListPermissions = [ + 'READ_BUYER_PORTAL', 'CREATE_SAVED_LISTS', 'CREATE_SAVED_LIST_ITEMS', - 'READ_ACCOUNTS', - 'READ_PRODUCTS', - 'READ_PRICE_LIST_ITEMS', - 'READ_ACCOUNT_PRICE_LISTS', ]; const createOrderPermissions = [ + 'READ_BUYER_PORTAL', 'CREATE_ORDERS', 'CREATE_ORDER_ITEMS', - 'READ_ACCOUNTS', - 'READ_LOCATIONS', - 'READ_PRODUCTS', - 'READ_PRICE_LIST_ITEMS', - 'READ_ACCOUNT_PRICE_LISTS', +]; + +const createSampleRequestPermissions = [ + 'READ_BUYER_PORTAL', + 'CREATE_SAMPLE_REQUESTS', ]; router.get( '/workspace', ...workspacePermissions.map((permission) => checkPermissions(permission)), wrapAsync(async (req, res) => { - const workspace = await BuyerPortalService.workspace({ - accountId: req.query.accountId, - locationId: req.query.locationId, - }); + const workspace = await BuyerPortalService.workspace( + { + accountId: req.query.accountId, + locationId: req.query.locationId, + }, + req.currentUser, + ); res.status(200).send(workspace); }), @@ -83,4 +69,19 @@ router.post( }), ); +router.post( + '/sample-requests', + ...createSampleRequestPermissions.map((permission) => + checkPermissions(permission), + ), + wrapAsync(async (req, res) => { + const sampleRequest = await BuyerPortalService.createSampleRequest( + req.body, + req.currentUser, + ); + + res.status(200).send({ sampleRequest }); + }), +); + module.exports = router; diff --git a/backend/src/services/buyer_portal.js b/backend/src/services/buyer_portal.js index 7ab4dff..02fb8bf 100644 --- a/backend/src/services/buyer_portal.js +++ b/backend/src/services/buyer_portal.js @@ -19,9 +19,66 @@ function toNumber(value) { function makeError(message) { const error = new Error(message); error.code = 400; + error.status = 400; + error.statusCode = 400; return error; } +const BUYER_ROLE_NAMES = ['Customer Buyer Admin', 'Customer Buyer']; + +function isCustomerBuyer(currentUser) { + return currentUser?.app_role?.name === 'Customer Buyer'; +} + +function isCustomerBuyerAdmin(currentUser) { + return currentUser?.app_role?.name === 'Customer Buyer Admin'; +} + +function isBuyerRole(currentUser) { + return BUYER_ROLE_NAMES.includes(currentUser?.app_role?.name); +} + +async function getBuyerAccountIds(currentUser) { + if (!isBuyerRole(currentUser)) { + return null; + } + + if (!currentUser.email) { + return []; + } + + const contacts = await db.contacts.findAll({ + where: { + email: { + [Op.iLike]: currentUser.email, + }, + is_active: true, + }, + }); + + return Array.from( + new Set( + contacts + .map((contact) => contact.accountId) + .filter((accountId) => Boolean(accountId)), + ), + ); +} + +async function assertAccountAccess(accountId, currentUser) { + const buyerAccountIds = await getBuyerAccountIds(currentUser); + + if (buyerAccountIds === null) { + return; + } + + if (!buyerAccountIds.includes(accountId)) { + throw makeError( + 'Your buyer account is not allowed to access the selected customer account.', + ); + } +} + function isCurrent(start, end) { const now = new Date(); @@ -48,6 +105,18 @@ function buildOrderNumber() { return `ORD-${stamp}-${suffix}`; } +function buildSampleRequestNumber() { + const now = new Date(); + const stamp = [ + now.getUTCFullYear(), + String(now.getUTCMonth() + 1).padStart(2, '0'), + String(now.getUTCDate()).padStart(2, '0'), + ].join(''); + const suffix = String(Math.floor(1000 + Math.random() * 9000)); + + return `SR-${stamp}-${suffix}`; +} + function serializeUser(user) { if (!user) { return null; @@ -284,14 +353,23 @@ async function ensureBuyerPortalSeeded() { await buyerPortalSeedPromise; } -async function getAccounts() { - const accounts = await db.accounts.findAll({ - where: { - is_active: true, - default_price_listId: { - [Op.ne]: null, - }, +async function getAccounts(currentUser) { + const buyerAccountIds = await getBuyerAccountIds(currentUser); + const where = { + is_active: true, + default_price_listId: { + [Op.ne]: null, }, + }; + + if (buyerAccountIds !== null) { + where.id = { + [Op.in]: buyerAccountIds, + }; + } + + const accounts = await db.accounts.findAll({ + where, include: [ { model: db.price_lists, @@ -517,11 +595,17 @@ async function getCatalogForAccount(account) { ); } -async function getRecentOrders(accountId) { +async function getRecentOrders(accountId, currentUser) { + const where = { + accountId, + }; + + if (isCustomerBuyer(currentUser)) { + where.buyerId = currentUser.id; + } + const orders = await db.orders.findAll({ - where: { - accountId, - }, + where, include: [ { model: db.locations, @@ -563,11 +647,17 @@ async function getRecentOrders(accountId) { return orders.map((order) => serializeOrder(order.get({ plain: true }))); } -async function getRecentQuotes(accountId) { +async function getRecentQuotes(accountId, currentUser) { + const where = { + accountId, + }; + + if (isCustomerBuyer(currentUser)) { + where.requested_byId = currentUser.id; + } + const quotes = await db.quotes.findAll({ - where: { - accountId, - }, + where, include: [ { model: db.locations, @@ -614,11 +704,17 @@ async function getRecentQuotes(accountId) { return quotes.map((quote) => serializeQuote(quote.get({ plain: true }))); } -async function getRecentSamples(accountId) { +async function getRecentSamples(accountId, currentUser) { + const where = { + accountId, + }; + + if (isCustomerBuyer(currentUser)) { + where.requested_byId = currentUser.id; + } + const sampleRequests = await db.sample_requests.findAll({ - where: { - accountId, - }, + where, include: [ { model: db.products, @@ -655,11 +751,17 @@ async function getRecentSamples(accountId) { ); } -async function getSavedLists(accountId) { +async function getSavedLists(accountId, currentUser) { + const where = { + accountId, + }; + + if (isCustomerBuyer(currentUser)) { + where.ownerId = currentUser.id; + } + const savedLists = await db.saved_lists.findAll({ - where: { - accountId, - }, + where, include: [ { model: db.users, @@ -692,10 +794,10 @@ async function getSavedLists(accountId) { } module.exports = class BuyerPortalService { - static async workspace(filter = {}) { + static async workspace(filter = {}, currentUser) { await ensureBuyerPortalSeeded(); - const accounts = await getAccounts(); + const accounts = await getAccounts(currentUser); const accountIds = accounts.map((account) => account.id); const locations = await getLocations(accountIds); const contacts = await getContacts(accountIds); @@ -721,16 +823,16 @@ module.exports = class BuyerPortalService { const catalog = await getCatalogForAccount(selectedAccountWithPricing); const recentOrders = selectedAccount - ? await getRecentOrders(selectedAccount.id) + ? await getRecentOrders(selectedAccount.id, currentUser) : []; const recentQuotes = selectedAccount - ? await getRecentQuotes(selectedAccount.id) + ? await getRecentQuotes(selectedAccount.id, currentUser) : []; const recentSamples = selectedAccount - ? await getRecentSamples(selectedAccount.id) + ? await getRecentSamples(selectedAccount.id, currentUser) : []; const savedLists = selectedAccount - ? await getSavedLists(selectedAccount.id) + ? await getSavedLists(selectedAccount.id, currentUser) : []; return { @@ -742,6 +844,10 @@ module.exports = class BuyerPortalService { recentQuotes, recentSamples, savedLists, + roleContext: { + isBuyerAdmin: isCustomerBuyerAdmin(currentUser), + isBuyerUser: isCustomerBuyer(currentUser), + }, }; } @@ -756,6 +862,8 @@ module.exports = class BuyerPortalService { throw makeError('Choose an account before saving a reorder list.'); } + await assertAccountAccess(payload.accountId, currentUser); + if (!payload.listName || !String(payload.listName).trim()) { throw makeError('Give this reorder list a name.'); } @@ -893,6 +1001,8 @@ module.exports = class BuyerPortalService { throw makeError('Choose an account before placing an order.'); } + await assertAccountAccess(payload.accountId, currentUser); + if (!payload.locationId) { throw makeError('Choose a delivery location before placing an order.'); } @@ -1071,4 +1181,123 @@ module.exports = class BuyerPortalService { throw error; } } + + static async createSampleRequest(payload = {}, currentUser) { + await ensureBuyerPortalSeeded(); + + if (!currentUser?.id) { + throw makeError('You must be signed in to request a sample.'); + } + + if (!payload.accountId) { + throw makeError('Choose an account before requesting a sample.'); + } + + await assertAccountAccess(payload.accountId, currentUser); + + if (!payload.locationId) { + throw makeError('Choose a delivery location before requesting a sample.'); + } + + if (!payload.productId) { + throw makeError('Choose a sample-eligible product.'); + } + + const quantity = Number.parseInt(String(payload.sampleQuantity), 10); + if (!Number.isInteger(quantity) || quantity <= 0) { + throw makeError('Enter a valid sample quantity.'); + } + + const account = await db.accounts.findOne({ + where: { + id: payload.accountId, + is_active: true, + }, + include: [ + { + model: db.price_lists, + as: 'default_price_list', + required: false, + }, + ], + }); + + if (!account) { + throw makeError('The selected account could not be found.'); + } + + const location = await db.locations.findOne({ + where: { + id: payload.locationId, + accountId: payload.accountId, + is_active: true, + }, + }); + + if (!location) { + throw makeError( + 'The selected delivery location is invalid for this account.', + ); + } + + const catalog = await getCatalogForAccount(account.get({ plain: true })); + const product = catalog.find((item) => item.id === payload.productId); + + if (!product) { + throw makeError( + 'The selected product is no longer on the contract catalog.', + ); + } + + if (!product.is_sample_eligible) { + throw makeError(`${product.product_name} is not sample eligible.`); + } + + const sampleRequest = await db.sample_requests.create({ + sample_request_number: buildSampleRequestNumber(), + sample_quantity: quantity, + requested_at: new Date(), + needed_by: payload.neededBy || null, + sample_status: 'requested', + notes: payload.notes || null, + accountId: account.id, + locationId: location.id, + requested_byId: currentUser.id, + productId: product.id, + createdById: currentUser.id, + updatedById: currentUser.id, + }); + + const createdSampleRequest = await db.sample_requests.findByPk( + sampleRequest.id, + { + include: [ + { + model: db.products, + as: 'product', + required: false, + }, + { + model: db.locations, + as: 'location', + required: false, + include: [ + { + model: db.contacts, + as: 'default_contact', + required: false, + }, + ], + }, + { + model: db.users, + as: 'requested_by', + required: false, + }, + ], + }, + ); + + return serializeSampleRequest(createdSampleRequest.get({ plain: true })); + } }; diff --git a/frontend/public/locales/en-GB/translation.json b/frontend/public/locales/en-GB/translation.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/frontend/public/locales/en-GB/translation.json @@ -0,0 +1 @@ +{} diff --git a/frontend/public/locales/en-US/translation.json b/frontend/public/locales/en-US/translation.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/frontend/public/locales/en-US/translation.json @@ -0,0 +1 @@ +{} diff --git a/frontend/public/locales/en/translation.json b/frontend/public/locales/en/translation.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/frontend/public/locales/en/translation.json @@ -0,0 +1 @@ +{} diff --git a/frontend/src/._colors.ts b/frontend/src/._colors.ts new file mode 100644 index 0000000000000000000000000000000000000000..8bcc114c1ab59537a5552fec12c7153349af59ae GIT binary patch literal 163 zcmZQz6=P>$Vqox1Ojhs@R)|o50+1L3ClDI}aUl?c_=|y<2;dkJ5(HHS(lG;wxzV&S nBE&_L^K$Vqox1Ojhs@R)|o50+1L3ClDI}aUl?c_=|y<2;dkJ5(HHS(lG;wxzV&S nBE&_L^K$Vqox1Ojhs@R)|o50+1L3ClDI}aUl?c_=|y<2;dkJ5(HHS(lG;wxzV&S nBE&_L^K { if (color === 'void') { - return '' + return ''; } const colors = { @@ -56,7 +59,7 @@ export const getButtonColor = ( success: 'ring-emerald-300 dark:ring-pavitra-blue', danger: 'ring-red-300 dark:ring-red-700', warning: 'ring-yellow-300 dark:ring-yellow-700', - info: "ring-blue-300 dark:ring-pavitra-blue", + info: 'ring-slate-300 dark:ring-pavitra-blue', }, active: { white: 'bg-gray-100', @@ -66,7 +69,7 @@ export const getButtonColor = ( success: 'bg-emerald-700 dark:bg-pavitra-blue', danger: 'bg-red-700 dark:bg-red-600', warning: 'bg-yellow-700 dark:bg-yellow-600', - info: 'bg-blue-700 dark:bg-pavitra-blue', + info: 'bg-slate-800 dark:bg-pavitra-blue', }, bg: { white: 'bg-white text-black', @@ -76,7 +79,7 @@ export const getButtonColor = ( success: 'bg-emerald-600 dark:bg-pavitra-blue text-white', danger: 'bg-red-600 text-white dark:bg-red-500 ', warning: 'bg-yellow-600 dark:bg-yellow-500 text-white', - info: " bg-blue-600 dark:bg-pavitra-blue text-white ", + info: ' bg-slate-900 dark:bg-pavitra-blue text-white ', }, bgHover: { white: 'hover:bg-gray-100', @@ -84,12 +87,12 @@ export const getButtonColor = ( lightDark: 'hover:bg-gray-200 hover:dark:bg-slate-700', contrast: 'hover:bg-gray-700 hover:dark:bg-slate-100', success: - 'hover:bg-emerald-700 hover:border-emerald-700 hover:dark:bg-pavitra-blue hover:dark:border-pavitra-blue', + 'hover:bg-emerald-700 hover:border-emerald-700 hover:dark:bg-pavitra-blue hover:dark:border-pavitra-blue', danger: 'hover:bg-red-700 hover:border-red-700 hover:dark:bg-red-600 hover:dark:border-red-600', warning: 'hover:bg-yellow-700 hover:border-yellow-700 hover:dark:bg-yellow-600 hover:dark:border-yellow-600', - info: "hover:bg-blue-700 hover:border-blue-700 hover:dark:bg-pavitra-blue/80 hover:dark:border-pavitra-blue/80", + info: 'hover:bg-slate-800 hover:border-slate-800 hover:dark:bg-pavitra-blue/80 hover:dark:border-pavitra-blue/80', }, borders: { white: 'border-white', @@ -99,40 +102,44 @@ export const getButtonColor = ( success: 'border-emerald-600 dark:border-pavitra-blue', danger: 'border-red-600 dark:border-red-500', warning: 'border-yellow-600 dark:border-yellow-500', - info: "border-blue-600 border-blue-600 dark:border-pavitra-blue", + info: 'border-slate-900 dark:border-pavitra-blue', }, text: { contrast: 'dark:text-slate-100', success: 'text-emerald-600 dark:text-pavitra-blue', danger: 'text-red-600 dark:text-red-500', warning: 'text-yellow-600 dark:text-yellow-500', - info: 'text-blue-600 dark:text-pavitra-blue', + info: 'text-slate-900 dark:text-pavitra-blue', }, outlineHover: { contrast: 'hover:bg-gray-800 hover:text-gray-100 hover:dark:bg-slate-100 hover:dark:text-black', - success: 'hover:bg-emerald-600 hover:text-white hover:text-white hover:dark:text-white hover:dark:border-pavitra-blue', + success: + 'hover:bg-emerald-600 hover:text-white hover:text-white hover:dark:text-white hover:dark:border-pavitra-blue', danger: 'hover:bg-red-600 hover:text-white hover:text-white hover:dark:text-white hover:dark:border-red-600', warning: 'hover:bg-yellow-600 hover:text-white hover:text-white hover:dark:text-white hover:dark:border-yellow-600', - info: "hover:bg-blue-600 hover:bg-blue-600 hover:text-white hover:dark:text-white hover:dark:border-pavitra-blue", + info: 'hover:bg-slate-900 hover:text-white hover:dark:text-white hover:dark:border-pavitra-blue', }, - } + }; - const isOutlinedProcessed = isOutlined && ['white', 'whiteDark', 'lightDark'].indexOf(color) < 0 + const isOutlinedProcessed = + isOutlined && ['white', 'whiteDark', 'lightDark'].indexOf(color) < 0; - const base = [colors.borders[color], colors.ring[color]] + const base = [colors.borders[color], colors.ring[color]]; if (isActive) { - base.push(colors.active[color]) + base.push(colors.active[color]); } else { - base.push(isOutlinedProcessed ? colors.text[color] : colors.bg[color]) + base.push(isOutlinedProcessed ? colors.text[color] : colors.bg[color]); } if (hasHover) { - base.push(isOutlinedProcessed ? colors.outlineHover[color] : colors.bgHover[color]) + base.push( + isOutlinedProcessed ? colors.outlineHover[color] : colors.bgHover[color], + ); } - return base.join(' ') -} + return base.join(' '); +}; diff --git a/frontend/src/components/._AsideMenu.tsx b/frontend/src/components/._AsideMenu.tsx new file mode 100644 index 0000000000000000000000000000000000000000..8bcc114c1ab59537a5552fec12c7153349af59ae GIT binary patch literal 163 zcmZQz6=P>$Vqox1Ojhs@R)|o50+1L3ClDI}aUl?c_=|y<2;dkJ5(HHS(lG;wxzV&S nBE&_L^K$Vqox1Ojhs@R)|o50+1L3ClDI}aUl?c_=|y<2;dkJ5(HHS(lG;wxzV&S nBE&_L^K$Vqox1Ojhs@R)|o50+1L3ClDI}aUl?c_=|y<2;dkJ5(HHS(lG;wxzV&S nBE&_L^K$Vqox1Ojhs@R)|o50+1L3ClDI}aUl?c_=|y<2;dkJ5(HHS(lG;wxzV&S nBE&_L^K$Vqox1Ojhs@R)|o50+1L3ClDI}aUl?c_=|y<2;dkJ5(HHS(lG;wxzV&S nBE&_L^K$Vqox1Ojhs@R)|o50+1L3ClDI}aUl?c_=|y<2;dkJ5(HHS(lG;wxzV&S nBE&_L^K$Vqox1Ojhs@R)|o50+1L3ClDI}aUl?c_=|y<2;dkJ5(HHS(lG;wxzV&S nBE&_L^K$Vqox1Ojhs@R)|o50+1L3ClDI}aUl?c_=|y<2;dkJ5(HHS(lG;wxzV&S nBE&_L^K$Vqox1Ojhs@R)|o50+1L3ClDI}aUl?c_=|y<2;dkJ5(HHS(lG;wxzV&S nBE&_L^K$Vqox1Ojhs@R)|o50+1L3ClDI}aUl?c_=|y<2;dkJ5(HHS(lG;wxzV&S nBE&_L^K$Vqox1Ojhs@R)|o50+1L3ClDI}aUl?c_=|y<2;dkJ5(HHS(lG;wxzV&S nBE&_L^K$Vqox1Ojhs@R)|o50+1L3ClDI}aUl?c_=|y<2;dkJ5(HHS(lG;wxzV&S nBE&_L^K void -} + menu: MenuAsideItem[]; + isAsideMobileExpanded: boolean; + isAsideLgActive: boolean; + onAsideLgClose: () => void; +}; export default function AsideMenu({ isAsideMobileExpanded = false, @@ -19,12 +19,14 @@ export default function AsideMenu({ <> - {isAsideLgActive && } + {isAsideLgActive && ( + + )} - ) + ); } diff --git a/frontend/src/components/AsideMenuItem.tsx b/frontend/src/components/AsideMenuItem.tsx index dbb09b2..583cb23 100644 --- a/frontend/src/components/AsideMenuItem.tsx +++ b/frontend/src/components/AsideMenuItem.tsx @@ -1,102 +1,108 @@ -import React, { useEffect, useState } from 'react' -import { mdiMinus, mdiPlus } from '@mdi/js' -import BaseIcon from './BaseIcon' -import Link from 'next/link' -import { getButtonColor } from '../colors' -import AsideMenuList from './AsideMenuList' -import { MenuAsideItem } from '../interfaces' -import { useAppSelector } from '../stores/hooks' -import { useRouter } from 'next/router' +import React, { useEffect, useState } from 'react'; +import { mdiChevronDown, mdiChevronRight } from '@mdi/js'; +import Link from 'next/link'; +import { useRouter } from 'next/router'; +import BaseIcon from './BaseIcon'; +import AsideMenuList from './AsideMenuList'; +import { MenuAsideItem } from '../interfaces'; type Props = { - item: MenuAsideItem - isDropdownList?: boolean -} + item: MenuAsideItem; + isDropdownList?: boolean; +}; + +const getViewName = (href: string) => { + return new URL(href, location.href).pathname.split('/')[1]; +}; const AsideMenuItem = ({ item, isDropdownList = false }: Props) => { - const [isLinkActive, setIsLinkActive] = useState(false) - const [isDropdownActive, setIsDropdownActive] = useState(false) - - const asideMenuItemStyle = useAppSelector((state) => state.style.asideMenuItemStyle) - const asideMenuDropdownStyle = useAppSelector((state) => state.style.asideMenuDropdownStyle) - const asideMenuItemActiveStyle = useAppSelector((state) => state.style.asideMenuItemActiveStyle) - const borders = useAppSelector((state) => state.style.borders); - const activeLinkColor = useAppSelector( - (state) => state.style.activeLinkColor, - ); - const activeClassAddon = !item.color && isLinkActive ? asideMenuItemActiveStyle : '' - - const { asPath, isReady } = useRouter() + const [isLinkActive, setIsLinkActive] = useState(false); + const [isDropdownActive, setIsDropdownActive] = useState(false); + const { asPath, isReady } = useRouter(); useEffect(() => { - if (item.href && isReady) { - const linkPathName = new URL(item.href, location.href).pathname + '/'; - const activePathname = new URL(asPath, location.href).pathname - - const activeView = activePathname.split('/')[1]; - const linkPathNameView = linkPathName.split('/')[1]; - - setIsLinkActive(linkPathNameView === activeView); + if (!isReady) { + return; } - }, [item.href, isReady, asPath]) + + const activeView = new URL(asPath, location.href).pathname.split('/')[1]; + const currentItemView = item.href ? getViewName(item.href) : ''; + const activeChild = (item.menu || []).some((child) => { + if (!child.href) { + return false; + } + + return getViewName(child.href) === activeView; + }); + + setIsLinkActive(currentItemView === activeView || activeChild); + + if (activeChild) { + setIsDropdownActive(true); + } + }, [item.href, item.menu, isReady, asPath]); + + const activeClass = isLinkActive + ? 'bg-emerald-50 text-slate-950 ring-1 ring-emerald-200' + : 'text-slate-600 hover:bg-slate-100 hover:text-slate-950 dark:text-slate-300 dark:hover:bg-dark-800 dark:hover:text-white'; + + const componentClass = [ + 'group flex min-h-10 cursor-pointer items-center rounded-xl px-3 py-2 text-sm font-semibold transition-colors', + isDropdownList ? 'ml-3 text-[13px]' : '', + item.color ? '' : activeClass, + ].join(' '); + + const iconClass = isLinkActive + ? 'text-emerald-700' + : 'text-slate-400 group-hover:text-slate-700'; const asideMenuItemInnerContents = ( <> {item.icon && ( - + )} - - {item.label} - + {item.label} {item.menu && ( )} - ) - - const componentClass = [ - 'flex cursor-pointer py-1.5 ', - isDropdownList ? 'px-6 text-sm' : '', - item.color - ? getButtonColor(item.color, false, true) - : `${asideMenuItemStyle}`, - isLinkActive - ? `text-black ${activeLinkColor} dark:text-white dark:bg-dark-800` - : '', - ].join(' '); + ); return ( -
  • - {item.withDevider &&
    } +
  • + {item.withDevider &&
    } {item.href && ( {asideMenuItemInnerContents} )} {!item.href && ( -
    setIsDropdownActive(!isDropdownActive)}> +
    setIsDropdownActive(!isDropdownActive)} + > {asideMenuItemInnerContents}
    )} {item.menu && ( )}
  • - ) -} + ); +}; -export default AsideMenuItem +export default AsideMenuItem; diff --git a/frontend/src/components/AsideMenuLayer.tsx b/frontend/src/components/AsideMenuLayer.tsx index 9f3a49a..65fa6b2 100644 --- a/frontend/src/components/AsideMenuLayer.tsx +++ b/frontend/src/components/AsideMenuLayer.tsx @@ -1,63 +1,79 @@ -import React from 'react' -import { mdiLogout, mdiClose } from '@mdi/js' -import BaseIcon from './BaseIcon' -import AsideMenuList from './AsideMenuList' -import { MenuAsideItem } from '../interfaces' -import { useAppSelector } from '../stores/hooks' -import Link from 'next/link'; - +import React from 'react'; +import { mdiClose } from '@mdi/js'; +import BaseIcon from './BaseIcon'; +import AsideMenuList from './AsideMenuList'; +import { MenuAsideItem } from '../interfaces'; +import { useAppSelector } from '../stores/hooks'; type Props = { - menu: MenuAsideItem[] - className?: string - onAsideLgCloseClick: () => void -} + menu: MenuAsideItem[]; + className?: string; + onAsideLgCloseClick: () => void; +}; -export default function AsideMenuLayer({ menu, className = '', ...props }: Props) { - const corners = useAppSelector((state) => state.style.corners); - const asideStyle = useAppSelector((state) => state.style.asideStyle) - const asideBrandStyle = useAppSelector((state) => state.style.asideBrandStyle) - const asideScrollbarsStyle = useAppSelector((state) => state.style.asideScrollbarsStyle) - const darkMode = useAppSelector((state) => state.style.darkMode) +export default function AsideMenuLayer({ + menu, + className = '', + ...props +}: Props) { + const asideStyle = useAppSelector((state) => state.style.asideStyle); + const asideScrollbarsStyle = useAppSelector( + (state) => state.style.asideScrollbarsStyle, + ); + const darkMode = useAppSelector((state) => state.style.darkMode); const handleAsideLgCloseClick = (e: React.MouseEvent) => { - e.preventDefault() - props.onAsideLgCloseClick() - } - + e.preventDefault(); + props.onAsideLgCloseClick(); + }; return ( - ) + ); } diff --git a/frontend/src/components/AsideMenuList.tsx b/frontend/src/components/AsideMenuList.tsx index 9e33ea1..3a66714 100644 --- a/frontend/src/components/AsideMenuList.tsx +++ b/frontend/src/components/AsideMenuList.tsx @@ -1,35 +1,37 @@ -import React from 'react' -import { MenuAsideItem } from '../interfaces' -import AsideMenuItem from './AsideMenuItem' -import {useAppSelector} from "../stores/hooks"; -import {hasPermission} from "../helpers/userPermissions"; +import React from 'react'; +import { MenuAsideItem } from '../interfaces'; +import AsideMenuItem from './AsideMenuItem'; +import { useAppSelector } from '../stores/hooks'; +import { hasPermission } from '../helpers/userPermissions'; type Props = { - menu: MenuAsideItem[] - isDropdownList?: boolean - className?: string -} + menu: MenuAsideItem[]; + isDropdownList?: boolean; + className?: string; +}; -export default function AsideMenuList({ menu, isDropdownList = false, className = '' }: Props) { +export default function AsideMenuList({ + menu, + isDropdownList = false, + className = '', +}: Props) { const { currentUser } = useAppSelector((state) => state.auth); if (!currentUser) return null; return ( -
      +
        {menu.map((item, index) => { - - if (!hasPermission(currentUser, item.permissions)) return null; - + if (!hasPermission(currentUser, item.permissions)) return null; + return ( -
        - -
        - ) + + ); })}
      - ) + ); } diff --git a/frontend/src/components/CardBox.tsx b/frontend/src/components/CardBox.tsx index 988f162..0ff2435 100644 --- a/frontend/src/components/CardBox.tsx +++ b/frontend/src/components/CardBox.tsx @@ -1,23 +1,23 @@ -import React, { ReactNode } from 'react' -import CardBoxComponentBody from './CardBoxComponentBody' -import CardBoxComponentFooter from './CardBoxComponentFooter' +import React, { ReactNode } from 'react'; +import CardBoxComponentBody from './CardBoxComponentBody'; +import CardBoxComponentFooter from './CardBoxComponentFooter'; import { useAppSelector } from '../stores/hooks'; type Props = { - rounded?: string - flex?: string - className?: string - hasComponentLayout?: boolean - cardBoxClassName?: string - hasTable?: boolean - isHoverable?: boolean - isModal?: boolean - children?: ReactNode - footer?: ReactNode - isList?:boolean + rounded?: string; + flex?: string; + className?: string; + hasComponentLayout?: boolean; + cardBoxClassName?: string; + hasTable?: boolean; + isHoverable?: boolean; + isModal?: boolean; + children?: ReactNode; + footer?: ReactNode; + isList?: boolean; id?: string; - onClick?: (e: React.MouseEvent) => void -} + onClick?: (e: React.MouseEvent) => void; +}; export default function CardBox({ rounded = 'rounded', @@ -31,22 +31,22 @@ export default function CardBox({ isModal = false, children, footer, - id ='', + id = '', onClick, }: Props) { const corners = useAppSelector((state) => state.style.corners); const cardsStyle = useAppSelector((state) => state.style.cardsStyle); const componentClass = [ - `flex dark:border-dark-700 dark:bg-dark-900`, + `flex dark:border-dark-700 dark:bg-dark-900`, className, - corners !== 'rounded-full'? corners : 'rounded-3xl', + corners !== 'rounded-full' ? corners : 'rounded-3xl', flex, isList ? '' : `${cardsStyle}`, - hasTable ? '' : `border-dark-700 dark:border-dark-700`, - ] + hasTable ? '' : `dark:border-dark-700`, + ]; if (isHoverable) { - componentClass.push('hover:shadow-lg transition-shadow duration-500') + componentClass.push('transition-shadow duration-200 hover:shadow-md'); } return React.createElement( @@ -56,9 +56,15 @@ export default function CardBox({ children ) : ( <> - {children} + + {children} + {footer && {footer}} - ) - ) + ), + ); } diff --git a/frontend/src/components/ErrorBoundary.tsx b/frontend/src/components/ErrorBoundary.tsx index 93b2833..eec2f43 100644 --- a/frontend/src/components/ErrorBoundary.tsx +++ b/frontend/src/components/ErrorBoundary.tsx @@ -1,25 +1,23 @@ -import React, { Component, ErrorInfo, ReactNode } from 'react'; -import { mdiAlertCircle } from '@mdi/js'; -import BaseIcon from './BaseIcon'; +import React, { Component, ErrorInfo, ReactNode } from "react"; +import { mdiAlertCircle } from "@mdi/js"; -// Define the props and state interfaces -interface ErrorBoundaryProps { +import BaseIcon from "./BaseIcon"; + +type ErrorBoundaryProps = { children: ReactNode; -} +}; -interface ErrorBoundaryState { +type ErrorBoundaryState = { hasError: boolean; error: Error | null; errorInfo: ErrorInfo | null; showStack: boolean; -} +}; -// Class-based ErrorBoundary Component class ErrorBoundary extends Component { constructor(props: ErrorBoundaryProps) { super(props); - // Define state variables this.state = { hasError: false, error: null, @@ -29,80 +27,18 @@ class ErrorBoundary extends Component { } static getDerivedStateFromError(error: Error): Partial { - // Update state so the next render will show the fallback UI return { hasError: true, - error: error, + error, }; } - componentDidUpdate( - prevProps: Readonly, - prevState: Readonly, - snapshot?: any, - ) { - if (process.env.NODE_ENV !== 'production') { - console.log('componentDidUpdate'); - } - } + componentDidCatch(error: Error, errorInfo: ErrorInfo) { + console.error("Error caught in boundary:", error, errorInfo); - async componentWillUnmount() { - if (process.env.NODE_ENV !== 'production') { - console.log('componentWillUnmount'); - const response = await fetch('/api/logError', { - method: 'DELETE', - }); - - const data = await response.json(); - console.log('Error logs cleared:', data); - } - } - - async componentDidCatch(error: Error, errorInfo: ErrorInfo) { - // Update state with error details (always needed for UI) this.setState({ - errorInfo: errorInfo, + errorInfo, }); - - // Only perform logging in non-production environments - if (process.env.NODE_ENV !== 'production') { - console.log('Error caught in boundary:', error, errorInfo); - - // Function to log errors to the server - const logErrorToServer = async () => { - try { - const response = await fetch('/api/logError', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - message: error.message, - stack: errorInfo.componentStack, - }), - }); - - const data = await response.json(); - console.log('Error logged:', data); - } catch (err) { - console.error('Failed to log error:', err); - } - }; - - // Function to fetch logged errors (optional) - const fetchLoggedErrors = async () => { - try { - const response = await fetch('/api/logError'); - const data = await response.json(); - console.log('Fetched logs:', data); - } catch (err) { - console.error('Failed to fetch logs:', err); - } - }; - - await logErrorToServer(); - await fetchLoggedErrors(); - } } toggleStack = () => { @@ -120,98 +56,62 @@ class ErrorBoundary extends Component { }); }; - tryAgain = async () => { - // Only clear error logs in non-production environments - if (process.env.NODE_ENV !== 'production') { - try { - const response = await fetch('/api/logError', { - method: 'DELETE', - }); - - const data = await response.json(); - console.log('Error logs cleared:', data); - } catch (e) { - console.error('Failed to clear error logs:', e); - } + render() { + if (!this.state.hasError) { + return this.props.children; } - // Always reset the error state (needed for UI recovery) - this.setState({ hasError: false }); - }; + const { error, errorInfo, showStack } = this.state; + const errorMessage = error?.message || "An unexpected error occurred"; + const stackTrace = + errorInfo?.componentStack || error?.stack || "No stack trace available"; - render() { - if (this.state.hasError) { - // Extract error details - const { error, errorInfo, showStack } = this.state; - const errorMessage = error?.message || 'An unexpected error occurred'; - const stackTrace = - errorInfo?.componentStack || error?.stack || 'No stack trace available'; - - return ( -
      -
      -
      -
      - -
      - -
      -

      - Something went wrong -

      -

      - We're sorry, but we encountered an unexpected error. -

      -
      - -
      -

      - {errorMessage} -

      - -
      - - - {showStack && ( -
      -                      {stackTrace}
      -                    
      - )} -
      -
      - -
      - - - -
      -
      + return ( +
      +
      +
      +
      + +
      +
      +

      + Something went wrong +

      +

      + The app stopped on a visible frontend error. +

      - ); - } - return this.props.children; +
      + {errorMessage} +
      + + {showStack && ( +
      +              {stackTrace}
      +            
      + )} + +
      + + +
      +
      +
      + ); } } diff --git a/frontend/src/components/FooterBar.tsx b/frontend/src/components/FooterBar.tsx index 0acc9c5..d33128e 100644 --- a/frontend/src/components/FooterBar.tsx +++ b/frontend/src/components/FooterBar.tsx @@ -1,35 +1,31 @@ -import React, { ReactNode } from 'react' -import { containerMaxW } from '../config' -import Logo from './Logo' +import React, { ReactNode } from 'react'; +import { containerMaxW } from '../config'; type Props = { - children?: ReactNode -} + children?: ReactNode; +}; export default function FooterBar({ children }: Props) { - const year = new Date().getFullYear() + const year = new Date().getFullYear(); return ( -