diff --git a/apps/storefront/src/components/layout/B3StatusNotification.tsx b/apps/storefront/src/components/layout/B3StatusNotification.tsx index 343ea976..429f9ac8 100644 --- a/apps/storefront/src/components/layout/B3StatusNotification.tsx +++ b/apps/storefront/src/components/layout/B3StatusNotification.tsx @@ -30,6 +30,9 @@ export default function B3StatusNotification(props: B3StatusNotificationProps) { const blockPendingAccountOrderCreation = B3SStorage.get( 'blockPendingAccountOrderCreation' ) + const blockPendingAccountViewPrice = B3SStorage.get( + 'blockPendingAccountViewPrice' + ) const loginType = JSON.parse(sessionStorage.getItem('loginType') || 'false') const [tip, setTip] = useState('') @@ -54,11 +57,24 @@ export default function B3StatusNotification(props: B3StatusNotificationProps) { setIsShow(showTip) if (showTip) { if (+companyStatus === 0) { - setTip( - blockPendingAccountOrderCreation - ? StatusNotifications.pendingOrderingBlocked - : StatusNotifications.pendingOrderingNotBlocked - ) + if (blockPendingAccountOrderCreation && blockPendingAccountViewPrice) { + setTip(StatusNotifications.pendingOrderingAndViewPriceBlocked) + } + + if (blockPendingAccountOrderCreation && !blockPendingAccountViewPrice) { + setTip(StatusNotifications.pendingOrderingBlocked) + } + + if (!blockPendingAccountOrderCreation && blockPendingAccountViewPrice) { + setTip(StatusNotifications.pendingViewPriceBlocked) + } + + if ( + !blockPendingAccountOrderCreation && + !blockPendingAccountViewPrice + ) { + setTip(StatusNotifications.pendingOrderingNotBlocked) + } setType('info') setBcColor('#0288D1') } diff --git a/apps/storefront/src/constants/index.ts b/apps/storefront/src/constants/index.ts index 5934cf94..b08fa2e8 100644 --- a/apps/storefront/src/constants/index.ts +++ b/apps/storefront/src/constants/index.ts @@ -49,6 +49,10 @@ export const StatusNotifications = { 'Your business account is pending approval. Ordering will be enabled after account approval.', pendingOrderingNotBlocked: 'Your business account is pending approval. You will gain access to business account features after account approval.', + pendingViewPriceBlocked: + 'Your business account is pending approval. You will gain access to business account features, products, and pricing after account approval.', + pendingOrderingAndViewPriceBlocked: + 'Your business account is pending approval. Products, pricing, and ordering will be enabled after account approval', approvedTip: 'Your business account has been approved. Check your email inbox, we sent you a letter with all details.', rejectedTip: diff --git a/apps/storefront/src/pages/quickorder/components/QuickAdd.tsx b/apps/storefront/src/pages/quickorder/components/QuickAdd.tsx index 93d4dc1e..665ce5bc 100644 --- a/apps/storefront/src/pages/quickorder/components/QuickAdd.tsx +++ b/apps/storefront/src/pages/quickorder/components/QuickAdd.tsx @@ -5,7 +5,7 @@ import { Box, Grid, Typography } from '@mui/material' import { B3CustomForm, B3Sping, CustomButton } from '@/components' import { GlobaledContext } from '@/shared/global' -import { snackbar } from '@/utils' +import { B3SStorage, snackbar } from '@/utils' import { getQuickAddRowFields } from '@/utils/b3Product/shared/config' import { @@ -288,6 +288,16 @@ export default function QuickAdd(props: AddToListContentProps) { } const handleAddToList = () => { + const blockPendingAccountViewPrice = B3SStorage.get( + 'blockPendingAccountViewPrice' + ) + if (blockPendingAccountViewPrice) { + snackbar.info( + 'Your business account is pending approval. This feature is currently disabled.' + ) + return + } + handleSubmit(async (value) => { try { setIsLoading(true) diff --git a/apps/storefront/src/pages/quickorder/components/QuickOrderPad.tsx b/apps/storefront/src/pages/quickorder/components/QuickOrderPad.tsx index 834592e0..dd425c4f 100644 --- a/apps/storefront/src/pages/quickorder/components/QuickOrderPad.tsx +++ b/apps/storefront/src/pages/quickorder/components/QuickOrderPad.tsx @@ -12,7 +12,7 @@ import { import { B3Upload, CustomButton, successTip } from '@/components' import { useMobile } from '@/hooks' import { addProductToCart, createCart, getCartInfo } from '@/shared/service/bc' -import { snackbar } from '@/utils' +import { B3SStorage, snackbar } from '@/utils' import SearchProduct from '../../shoppingListDetails/components/SearchProduct' @@ -401,6 +401,19 @@ export default function QuickOrderPad(props: QuickOrderPadProps) { return productData } + const handleOpenUploadDiag = () => { + const blockPendingAccountViewPrice = B3SStorage.get( + 'blockPendingAccountViewPrice' + ) + if (blockPendingAccountViewPrice) { + snackbar.info( + 'Your business account is pending approval. This feature is currently disabled.' + ) + } else { + setIsOpenBulkLoadCSV(true) + } + } + useEffect(() => { if (productData?.length > 0) { setAddBtnText(`Add ${productData.length} products to cart`) @@ -445,12 +458,7 @@ export default function QuickOrderPad(props: QuickOrderPadProps) { margin: '20px 0 0', }} > - { - setIsOpenBulkLoadCSV(true) - }} - > + handleOpenUploadDiag()}> { + const blockPendingAccountViewPrice = B3SStorage.get( + 'blockPendingAccountViewPrice' + ) + if (blockPendingAccountViewPrice) { + snackbar.info( + 'Your business account is pending approval. This feature is currently disabled.' + ) + } else { + setIsOpenBulkLoadCSV(true) + } + } + return ( @@ -287,12 +301,7 @@ export default function AddToQuote(props: AddToListProps) { margin: '20px 0 0', }} > - { - setIsOpenBulkLoadCSV(true) - }} - > + handleOpenUploadDiag()}> { + const blockPendingAccountViewPrice = B3SStorage.get( + 'blockPendingAccountViewPrice' + ) + if (blockPendingAccountViewPrice) { + snackbar.info( + 'Your business account is pending approval. This feature is currently disabled.' + ) + } else { + setIsOpenBulkLoadCSV(true) + } + } + return ( - { - setIsOpenBulkLoadCSV(true) - }} - > + handleOpenUploadDiag()}> { + const blockPendingAccountViewPrice = B3SStorage.get( + 'blockPendingAccountViewPrice' + ) + if (blockPendingAccountViewPrice) { + snackbar.info( + 'Your business account is pending approval. This feature is currently disabled.' + ) + return + } + handleSubmit(async (value) => { try { setIsLoading(true) diff --git a/apps/storefront/src/pages/shoppingListDetails/components/SearchProduct.tsx b/apps/storefront/src/pages/shoppingListDetails/components/SearchProduct.tsx index f0a9866d..36e293fd 100644 --- a/apps/storefront/src/pages/shoppingListDetails/components/SearchProduct.tsx +++ b/apps/storefront/src/pages/shoppingListDetails/components/SearchProduct.tsx @@ -4,7 +4,7 @@ import { Box, InputAdornment, TextField, Typography } from '@mui/material' import { B3Sping, CustomButton } from '@/components' import { searchB2BProducts, searchBcProducts } from '@/shared/service/b2b' -import { B3SStorage, calculateProductListPrice } from '@/utils' +import { B3SStorage, calculateProductListPrice, snackbar } from '@/utils' import { conversionProductsList } from '@/utils/b3Product/shared/config' import { ShoppingListProductItem } from '../../../types' @@ -45,6 +45,17 @@ export default function SearchProduct({ if (!searchText || isLoading) { return } + + const blockPendingAccountViewPrice = B3SStorage.get( + 'blockPendingAccountViewPrice' + ) + if (blockPendingAccountViewPrice) { + snackbar.info( + 'Your business account is pending approval. This feature is currently disabled.' + ) + return + } + const companyId = B3SStorage.get('B3CompanyInfo')?.id || B3SStorage.get('salesRepCompanyId') const customerGroupId = B3SStorage.get('B3CustomerInfo')?.customerGroupId diff --git a/apps/storefront/src/utils/storefrontConfig.ts b/apps/storefront/src/utils/storefrontConfig.ts index 43597449..847f45fd 100644 --- a/apps/storefront/src/utils/storefrontConfig.ts +++ b/apps/storefront/src/utils/storefrontConfig.ts @@ -139,6 +139,10 @@ const storeforntKeys: StoreforntKeysProps[] = [ key: 'block_pending_account_order_creation', name: 'blockPendingAccountOrderCreation', }, + { + key: 'block_pending_account_seeing_products_pricing', + name: 'blockPendingAccountViewPrice', + }, ] const getTemPlateConfig = async ( @@ -153,6 +157,7 @@ const getTemPlateConfig = async ( const obj: Partial | {} = {} let blockPendingAccountOrderCreation = true + let blockPendingAccountViewPrice = true storefrontConfigs.forEach((item: any) => { const storeforntKey: StoreforntKeysProps | undefined = storeforntKeys.find( (option) => option.key === item.key @@ -215,6 +220,16 @@ const getTemPlateConfig = async ( ) } + if ( + storeforntKey.key === 'block_pending_account_seeing_products_pricing' + ) { + blockPendingAccountViewPrice = item.value === '1' + B3SStorage.set( + 'blockPendingAccountViewPrice', + blockPendingAccountViewPrice + ) + } + ;(obj as CustomFieldItems)[(storeforntKey as StoreforntKeysProps).name] = { ...item.extraFields,