bigcommerce / b2b-buyer-portal

B2B Buyer Portal - BigCommerce B2B Edition
MIT License
25 stars 19 forks source link

Navigation Menu showing disabled features #61

Closed SE-Graham closed 1 month ago

SE-Graham commented 2 months ago

Type: (Select one)

Summary:

The navigation menu is showing features that have been disabled e.g you turn invoices off in the b2b app in BC.

The issue seems to have been caused by changes made in bdcda35c2b21d4191fde5eb951fd8f35b9be97f1

The following was added to the routes - getAllowedRoutes this seems to skip checking if features are enabled and only check permissions

    // b2b user
     if (isB2BUser && permissionCodes && permissionCodes.length > 0) {
       const permissionsInfo: {
         code: string;
         permissionLevel?: number | string;
       } = {
         code: permissionCodes.join(','),
       };
       const isHasPermission = checkEveryPermissionsCode(permissionsInfo);

       if (path === '/company-orders' && isHasPermission) {
         let companyOrdersPermissions: boolean = isHasPermission;

         const myOrdersLevel = 1;
         permissionsInfo.permissionLevel = myOrdersLevel;

         companyOrdersPermissions = !checkEveryPermissionsCode(permissionsInfo);

         return companyOrdersPermissions;
       }

       return isHasPermission;
     }

Expected Behavior:

Actual Behavior:

Steps to Reproduce (Bug Reports Only):

  1. Disable Invoices
  2. Load Buyer Portal, Invoices are still on the navigation menu
SE-Graham commented 2 months ago

Does PR https://github.com/bigcommerce/b2b-buyer-portal/pull/67 resolve this issue?

deov31 commented 2 months ago

@SE-Graham yes, that one is related to this issue

SE-Graham commented 1 month ago

Closing as this was resolved with PR https://github.com/bigcommerce/b2b-buyer-portal/pull/67