From 905d8e2935b452da20480057d460dde6dcbbae66 Mon Sep 17 00:00:00 2001 From: Estefania Ocampo Date: Tue, 23 Apr 2024 16:26:10 -0700 Subject: [PATCH] fix: changing imports to avoid cycle dependencies (#1024) * fix: changing imports to avoid cycle dependencies * fix: reset before assing new values on quoteinfo slice Co-authored-by: Marco Loyo --- apps/storefront/.eslintrc.json | 1 - apps/storefront/src/App.tsx | 22 ++++++---- apps/storefront/src/buyerPortal.ts | 2 +- .../src/components/HeadlessController.tsx | 11 ++--- .../src/components/layout/B3Mainheader.tsx | 2 +- .../src/components/upload/B3Upload.tsx | 2 +- apps/storefront/src/hooks/dom/useMyQuote.ts | 5 ++- apps/storefront/src/hooks/dom/utils.ts | 19 ++++---- .../src/pages/accountSetting/utils.ts | 3 +- apps/storefront/src/pages/address/Address.tsx | 3 +- .../pages/address/shared/getAddressFields.ts | 2 +- .../src/pages/dashboard/Dashboard.tsx | 2 +- apps/storefront/src/pages/invoice/Invoice.tsx | 2 +- .../src/pages/invoice/utils/payment.ts | 2 +- .../src/pages/login/ForgotPassword.tsx | 2 +- apps/storefront/src/pages/login/Login.tsx | 13 ++---- apps/storefront/src/pages/login/config.ts | 3 +- .../src/pages/orderDetail/OrderDetail.tsx | 2 +- .../orderDetail/components/OrderDialog.tsx | 4 +- apps/storefront/src/pages/pdp/PDP.tsx | 11 ++--- .../components/QuickOrderFooter.tsx | 10 ++--- .../quickorder/components/QuickOrderPad.tsx | 4 +- .../src/pages/quote/QuoteDetail.tsx | 4 +- .../storefront/src/pages/quote/QuoteDraft.tsx | 8 +--- .../src/pages/quote/components/AddToQuote.tsx | 6 +-- .../quote/components/QuoteDetailFooter.tsx | 3 +- .../src/pages/quote/components/QuoteTable.tsx | 8 ++-- .../src/pages/registered/RegisterComplete.tsx | 3 +- .../src/pages/registered/Registered.tsx | 9 ++-- .../pages/registered/RegisteredBCToB2B.tsx | 9 ++-- .../ShoppingListDetails.tsx | 7 ++- .../components/AddToShoppingList.tsx | 3 +- .../components/ChooseOptionsDialog.tsx | 7 +-- .../components/QuickAdd.tsx | 3 +- .../components/ReAddToCart.tsx | 10 ++--- .../components/SearchProduct.tsx | 3 +- .../components/ShoppingDetailFooter.tsx | 10 ++--- .../components/ShoppingDetailTable.tsx | 8 +++- apps/storefront/src/shared/routes/routes.ts | 3 +- apps/storefront/src/utils/b3Callbacks.ts | 2 +- apps/storefront/src/utils/b3ClearCart.tsx | 2 +- apps/storefront/src/utils/b3CurrencyFormat.ts | 2 +- apps/storefront/src/utils/b3Logger.ts | 2 +- apps/storefront/src/utils/b3PrintInvoice.tsx | 2 +- .../src/utils/b3Product/b3Product.ts | 3 +- .../src/utils/b3Product/shared/config.ts | 2 +- apps/storefront/src/utils/b3Proxy.ts | 4 +- .../src/utils/b3TriggerCartNumber.ts | 2 +- apps/storefront/src/utils/b3logout.ts | 2 +- apps/storefront/src/utils/index.ts | 44 ------------------- apps/storefront/src/utils/loginInfo.ts | 9 ++-- 51 files changed, 129 insertions(+), 178 deletions(-) diff --git a/apps/storefront/.eslintrc.json b/apps/storefront/.eslintrc.json index 013d941c..c3deee6d 100644 --- a/apps/storefront/.eslintrc.json +++ b/apps/storefront/.eslintrc.json @@ -10,7 +10,6 @@ { "files": [ "src/pages/**/*.{ts,tsx}", - "src/utils/**/*.{ts,tsx}", "src/components/**/*.{ts,tsx}", "src/hooks/dom/*.ts", "src/hooks/*.ts", diff --git a/apps/storefront/src/App.tsx b/apps/storefront/src/App.tsx index 9c7f4330..0616a921 100644 --- a/apps/storefront/src/App.tsx +++ b/apps/storefront/src/App.tsx @@ -11,21 +11,25 @@ import { GlobaledContext } from '@/shared/global' import { gotoAllowedAppPage } from '@/shared/routes' import { setChannelStoreType } from '@/shared/service/b2b' import { - clearInvoiceCart, - getCompanyUserInfo, - getCurrentCustomerInfo, getQuoteEnabled, - getStoreTaxZoneRates, - getTemPlateConfig, handleHideRegisterPage, - isUserGotoLogin, - loginInfo, openPageByClick, removeBCMenus, - setStorefrontConfig, } from '@/utils' -import { getCompanyInfo } from './utils/loginInfo' +import clearInvoiceCart from './utils/b3ClearCart' +import { isUserGotoLogin } from './utils/b3logout' +import { + getCompanyInfo, + getCompanyUserInfo, + getCurrentCustomerInfo, + loginInfo, +} from './utils/loginInfo' +import { + getStoreTaxZoneRates, + getTemPlateConfig, + setStorefrontConfig, +} from './utils/storefrontConfig' import { isB2BUserSelector, setGlabolCommonState, diff --git a/apps/storefront/src/buyerPortal.ts b/apps/storefront/src/buyerPortal.ts index 387edd6c..76123186 100644 --- a/apps/storefront/src/buyerPortal.ts +++ b/apps/storefront/src/buyerPortal.ts @@ -1,4 +1,4 @@ -import { b2bLogger } from '@/utils' +import b2bLogger from './utils/b3Logger' const { MODE: mode, VITE_LOCAL_GRAPHQL_ORIGIN } = import.meta.env diff --git a/apps/storefront/src/components/HeadlessController.tsx b/apps/storefront/src/components/HeadlessController.tsx index cabefdc5..38219126 100644 --- a/apps/storefront/src/components/HeadlessController.tsx +++ b/apps/storefront/src/components/HeadlessController.tsx @@ -21,14 +21,11 @@ import { import { setB2BToken } from '@/store/slices/company' import { OpenPageState } from '@/types/hooks' import { QuoteItem } from '@/types/quotes' -import { - endMasquerade, - getCurrentCustomerInfo, - LineItems, - startMasquerade, -} from '@/utils' import CallbackManager from '@/utils/b3Callbacks' +import { LineItems } from '@/utils/b3Product/b3Product' import createShoppingList from '@/utils/b3ShoppingList/b3ShoppingList' +import { getCurrentCustomerInfo } from '@/utils/loginInfo' +import { endMasquerade, startMasquerade } from '@/utils/masquerade' export interface FormatedQuoteItem extends Omit< @@ -91,7 +88,7 @@ export default function HeadlessController({ const role = useAppSelector(({ company }) => company.customer.role) const platform = useAppSelector(({ global }) => global.storeInfo.platform) const productList = useAppSelector(formatedQuoteDraftListSelector) - const B2BToken = useAppSelector(({company}) => company.tokens.B2BToken); + const B2BToken = useAppSelector(({ company }) => company.tokens.B2BToken) const { state: { addQuoteBtn, shoppingListBtn, addToAllQuoteBtn }, diff --git a/apps/storefront/src/components/layout/B3Mainheader.tsx b/apps/storefront/src/components/layout/B3Mainheader.tsx index 281025a2..83972137 100644 --- a/apps/storefront/src/components/layout/B3Mainheader.tsx +++ b/apps/storefront/src/components/layout/B3Mainheader.tsx @@ -8,7 +8,7 @@ import useMobile from '@/hooks/useMobile' import { CustomStyleContext } from '@/shared/customStyleButtton' import { GlobaledContext } from '@/shared/global' import { useAppSelector } from '@/store' -import { b3TriggerCartNumber } from '@/utils' +import b3TriggerCartNumber from '@/utils/b3TriggerCartNumber' import { getContrastColor } from '../outSideComponents/utils/b3CustomStyles' diff --git a/apps/storefront/src/components/upload/B3Upload.tsx b/apps/storefront/src/components/upload/B3Upload.tsx index bb94a684..044c729c 100644 --- a/apps/storefront/src/components/upload/B3Upload.tsx +++ b/apps/storefront/src/components/upload/B3Upload.tsx @@ -27,7 +27,7 @@ import { useAppSelector, } from '@/store' import { Currency } from '@/types' -import { b2bLogger } from '@/utils' +import b2bLogger from '@/utils/b3Logger' import B3Dialog from '../B3Dialog' diff --git a/apps/storefront/src/hooks/dom/useMyQuote.ts b/apps/storefront/src/hooks/dom/useMyQuote.ts index 8bcc7733..b60b04f2 100644 --- a/apps/storefront/src/hooks/dom/useMyQuote.ts +++ b/apps/storefront/src/hooks/dom/useMyQuote.ts @@ -57,11 +57,12 @@ const useMyQuote = ({ ) const b2bId = useAppSelector(({ company }) => company.customer.b2bId) useEffect(() => { - const isLogin = role !== CustomerRole.GUEST + const isLoginAndNotB2CAccount = + role !== CustomerRole.GUEST && role !== CustomerRole.B2C if ( quoteDraftUserId && - isLogin && + isLoginAndNotB2CAccount && +quoteDraftUserId !== 0 && +quoteDraftUserId !== b2bId ) { diff --git a/apps/storefront/src/hooks/dom/utils.ts b/apps/storefront/src/hooks/dom/utils.ts index 19d70bea..ea6955f5 100644 --- a/apps/storefront/src/hooks/dom/utils.ts +++ b/apps/storefront/src/hooks/dom/utils.ts @@ -7,21 +7,22 @@ import { getCart } from '@/shared/service/bc/graphql/cart' import { store } from '@/store' import { OpenPageState } from '@/types/hooks' import { - addQuoteDraftProduce, - addQuoteDraftProducts, - b2bLogger, B3LStorage, B3SStorage, - calculateProductsPrice, - getCalculatedProductPrice, getCookie, - getProductOptionList, globalSnackbar, - isAllRequiredOptionFilled, - LineItems, serialize, - validProductQty, } from '@/utils' +import { getProductOptionList, isAllRequiredOptionFilled } from '@/utils/b3AddToShoppingList' +import b2bLogger from '@/utils/b3Logger' +import { + addQuoteDraftProduce, + addQuoteDraftProducts, + calculateProductsPrice, + getCalculatedProductPrice, + LineItems, + validProductQty, +} from '@/utils/b3Product/b3Product' import { conversionProductsList } from '../../utils/b3Product/shared/config' diff --git a/apps/storefront/src/pages/accountSetting/utils.ts b/apps/storefront/src/pages/accountSetting/utils.ts index 0a4bebe3..6ae8d845 100644 --- a/apps/storefront/src/pages/accountSetting/utils.ts +++ b/apps/storefront/src/pages/accountSetting/utils.ts @@ -1,6 +1,7 @@ import { store } from '@/store/reducer' import { Fields, ParamProps } from '@/types/accountSetting' -import { b2bLogger, validatorRules } from '@/utils' +import { validatorRules } from '@/utils' +import b2bLogger from '@/utils/b3Logger' import { deCodeField } from '../registered/config' diff --git a/apps/storefront/src/pages/address/Address.tsx b/apps/storefront/src/pages/address/Address.tsx index 2f94e820..24013f23 100644 --- a/apps/storefront/src/pages/address/Address.tsx +++ b/apps/storefront/src/pages/address/Address.tsx @@ -14,7 +14,8 @@ import { } from '@/shared/service/b2b' import { isB2BUserSelector, useAppSelector } from '@/store' import { CustomerRole } from '@/types' -import { b2bLogger, snackbar } from '@/utils' +import { snackbar } from '@/utils' +import b2bLogger from '@/utils/b3Logger' import B3Filter from '../../components/filter/B3Filter' import { diff --git a/apps/storefront/src/pages/address/shared/getAddressFields.ts b/apps/storefront/src/pages/address/shared/getAddressFields.ts index 809d7dfa..aa97c591 100644 --- a/apps/storefront/src/pages/address/shared/getAddressFields.ts +++ b/apps/storefront/src/pages/address/shared/getAddressFields.ts @@ -2,7 +2,7 @@ import { getB2BAccountFormFields, getB2BAddressExtraFields, } from '@/shared/service/b2b' -import { b2bLogger } from '@/utils' +import b2bLogger from '@/utils/b3Logger' import { AccountFormFieldsItems, diff --git a/apps/storefront/src/pages/dashboard/Dashboard.tsx b/apps/storefront/src/pages/dashboard/Dashboard.tsx index d616fe79..6d588223 100644 --- a/apps/storefront/src/pages/dashboard/Dashboard.tsx +++ b/apps/storefront/src/pages/dashboard/Dashboard.tsx @@ -20,7 +20,7 @@ import { GlobaledContext } from '@/shared/global' import { superAdminCompanies } from '@/shared/service/b2b' import { useAppSelector } from '@/store' import { OpenPageState } from '@/types/hooks' -import { endMasquerade, startMasquerade } from '@/utils' +import { endMasquerade, startMasquerade } from '@/utils/masquerade' import B3FilterSearch from '../../components/filter/B3FilterSearch' diff --git a/apps/storefront/src/pages/invoice/Invoice.tsx b/apps/storefront/src/pages/invoice/Invoice.tsx index 118e9c3f..1fc9f721 100644 --- a/apps/storefront/src/pages/invoice/Invoice.tsx +++ b/apps/storefront/src/pages/invoice/Invoice.tsx @@ -22,7 +22,6 @@ import { import { useAppSelector } from '@/store' import { InvoiceList, InvoiceListNode } from '@/types/invoice' import { - b2bLogger, currencyFormat, currencyFormatInfo, displayFormat, @@ -30,6 +29,7 @@ import { handleGetCorrespondingCurrencyToken, snackbar, } from '@/utils' +import b2bLogger from '@/utils/b3Logger' import B3Filter from '../../components/filter/B3Filter' diff --git a/apps/storefront/src/pages/invoice/utils/payment.ts b/apps/storefront/src/pages/invoice/utils/payment.ts index 1bba33f0..179687a9 100644 --- a/apps/storefront/src/pages/invoice/utils/payment.ts +++ b/apps/storefront/src/pages/invoice/utils/payment.ts @@ -1,7 +1,7 @@ import { getInvoiceCheckoutUrl } from '@/shared/service/b2b' import { BcCartData } from '@/types/invoice' -import { b2bLogger } from '@/utils' import { attemptCheckoutLoginAndRedirect } from '@/utils/b3checkout' +import b2bLogger from '@/utils/b3Logger' export const getCheckouUrlAndCart = async (params: BcCartData) => { const { diff --git a/apps/storefront/src/pages/login/ForgotPassword.tsx b/apps/storefront/src/pages/login/ForgotPassword.tsx index 99061e57..250a290c 100644 --- a/apps/storefront/src/pages/login/ForgotPassword.tsx +++ b/apps/storefront/src/pages/login/ForgotPassword.tsx @@ -9,7 +9,7 @@ import { useMobile } from '@/hooks' import { CustomStyleContext } from '@/shared/customStyleButtton' import { GlobaledContext } from '@/shared/global' import { OpenPageState } from '@/types/hooks' -import { b2bLogger } from '@/utils' +import b2bLogger from '@/utils/b3Logger' import { getForgotPasswordFields, LoginConfig, sendEmail } from './config' import { B3ResetPassWordButton, LoginImage } from './styled' diff --git a/apps/storefront/src/pages/login/Login.tsx b/apps/storefront/src/pages/login/Login.tsx index 1dd47814..315966bf 100644 --- a/apps/storefront/src/pages/login/Login.tsx +++ b/apps/storefront/src/pages/login/Login.tsx @@ -23,15 +23,10 @@ import { isLoggedInSelector, useAppDispatch, useAppSelector } from '@/store' import { setB2BToken } from '@/store/slices/company' import { CustomerRole, UserTypes } from '@/types' import { OpenPageState } from '@/types/hooks' -import { - b2bLogger, - B3SStorage, - getCurrentCustomerInfo, - loginjump, - logoutSession, - snackbar, - storeHash, -} from '@/utils' +import { B3SStorage, loginjump, snackbar, storeHash } from '@/utils' +import b2bLogger from '@/utils/b3Logger' +import { logoutSession } from '@/utils/b3logout' +import { getCurrentCustomerInfo } from '@/utils/loginInfo' import LoginWidget from './component/LoginWidget' import { loginCheckout, LoginConfig, LoginInfoInit } from './config' diff --git a/apps/storefront/src/pages/login/config.ts b/apps/storefront/src/pages/login/config.ts index be99ae85..3076adfa 100644 --- a/apps/storefront/src/pages/login/config.ts +++ b/apps/storefront/src/pages/login/config.ts @@ -1,7 +1,8 @@ import { LangFormatFunction } from '@b3/lang' import { store } from '@/store/reducer' -import { b2bLogger, storeHash, validatorRules } from '@/utils' +import { storeHash, validatorRules } from '@/utils' +import b2bLogger from '@/utils/b3Logger' export interface QuoteConfig { [key: string]: string diff --git a/apps/storefront/src/pages/orderDetail/OrderDetail.tsx b/apps/storefront/src/pages/orderDetail/OrderDetail.tsx index 92b31f42..b142a2fa 100644 --- a/apps/storefront/src/pages/orderDetail/OrderDetail.tsx +++ b/apps/storefront/src/pages/orderDetail/OrderDetail.tsx @@ -20,7 +20,7 @@ import { getOrderStatusType, } from '@/shared/service/b2b' import { isB2BUserSelector, useAppSelector } from '@/store' -import { b2bLogger } from '@/utils' +import b2bLogger from '@/utils/b3Logger' import { AddressConfigItem, diff --git a/apps/storefront/src/pages/orderDetail/components/OrderDialog.tsx b/apps/storefront/src/pages/orderDetail/components/OrderDialog.tsx index ff3ce0e5..73628907 100644 --- a/apps/storefront/src/pages/orderDetail/components/OrderDialog.tsx +++ b/apps/storefront/src/pages/orderDetail/components/OrderDialog.tsx @@ -12,7 +12,9 @@ import { getBcVariantInfoBySkus, } from '@/shared/service/b2b' import { isB2BUserSelector, store, useAppSelector } from '@/store' -import { b2bLogger, b3TriggerCartNumber, snackbar } from '@/utils' +import { snackbar } from '@/utils' +import b2bLogger from '@/utils/b3Logger' +import b3TriggerCartNumber from '@/utils/b3TriggerCartNumber' import { callCart } from '@/utils/cartUtils' import { EditableProductItem, OrderProductItem } from '../../../types' diff --git a/apps/storefront/src/pages/pdp/PDP.tsx b/apps/storefront/src/pages/pdp/PDP.tsx index 7feb57c3..0c112087 100644 --- a/apps/storefront/src/pages/pdp/PDP.tsx +++ b/apps/storefront/src/pages/pdp/PDP.tsx @@ -20,14 +20,9 @@ import { } from '@/shared/service/b2b' import { isB2BUserSelector, store, useAppSelector } from '@/store' import { OpenPageState } from '@/types/hooks' -import { - getDefaultCurrencyInfo, - getProductOptionList, - getValidOptionsList, - globalSnackbar, - isAllRequiredOptionFilled, - serialize, -} from '@/utils' +import { getDefaultCurrencyInfo, globalSnackbar, serialize } from '@/utils' +import { getProductOptionList, isAllRequiredOptionFilled } from '@/utils/b3AddToShoppingList' +import { getValidOptionsList } from '@/utils/b3Product/b3Product' import { conversionProductsList } from '../../utils/b3Product/shared/config' diff --git a/apps/storefront/src/pages/quickorder/components/QuickOrderFooter.tsx b/apps/storefront/src/pages/quickorder/components/QuickOrderFooter.tsx index 6f2bcc79..d67ba82c 100644 --- a/apps/storefront/src/pages/quickorder/components/QuickOrderFooter.tsx +++ b/apps/storefront/src/pages/quickorder/components/QuickOrderFooter.tsx @@ -32,18 +32,16 @@ import { searchBcProducts, } from '@/shared/service/b2b' import { useAppSelector } from '@/store' +import { currencyFormat, getProductPriceIncTax, snackbar } from '@/utils' +import b2bLogger from '@/utils/b3Logger' import { addQuoteDraftProducts, - b2bLogger, - b3TriggerCartNumber, calculateProductListPrice, - currencyFormat, - getProductPriceIncTax, getValidOptionsList, - snackbar, validProductQty, -} from '@/utils' +} from '@/utils/b3Product/b3Product' import { conversionProductsList } from '@/utils/b3Product/shared/config' +import b3TriggerCartNumber from '@/utils/b3TriggerCartNumber' import { callCart } from '@/utils/cartUtils' import CreateShoppingList from '../../orderDetail/components/CreateShoppingList' diff --git a/apps/storefront/src/pages/quickorder/components/QuickOrderPad.tsx b/apps/storefront/src/pages/quickorder/components/QuickOrderPad.tsx index e3abd17c..77728f37 100644 --- a/apps/storefront/src/pages/quickorder/components/QuickOrderPad.tsx +++ b/apps/storefront/src/pages/quickorder/components/QuickOrderPad.tsx @@ -13,7 +13,9 @@ import { import { B3Upload, CustomButton, successTip } from '@/components' import { useBlockPendingAccountViewPrice, useMobile } from '@/hooks' import { useAppSelector } from '@/store' -import { b2bLogger, b3TriggerCartNumber, snackbar } from '@/utils' +import { snackbar } from '@/utils' +import b2bLogger from '@/utils/b3Logger' +import b3TriggerCartNumber from '@/utils/b3TriggerCartNumber' import { callCart } from '@/utils/cartUtils' import SearchProduct from '../../shoppingListDetails/components/SearchProduct' diff --git a/apps/storefront/src/pages/quote/QuoteDetail.tsx b/apps/storefront/src/pages/quote/QuoteDetail.tsx index 40fc09ae..a87d6d61 100644 --- a/apps/storefront/src/pages/quote/QuoteDetail.tsx +++ b/apps/storefront/src/pages/quote/QuoteDetail.tsx @@ -22,8 +22,10 @@ import { useAppSelector, } from '@/store' import { Currency } from '@/types' -import { getSearchVal, getVariantInfoOOSAndPurchase, snackbar } from '@/utils' +import { snackbar } from '@/utils' +import { getVariantInfoOOSAndPurchase } from '@/utils/b3Product/b3Product' import { conversionProductsList } from '@/utils/b3Product/shared/config' +import { getSearchVal } from '@/utils/loginInfo' import Message from './components/Message' import QuoteAttachment from './components/QuoteAttachment' diff --git a/apps/storefront/src/pages/quote/QuoteDraft.tsx b/apps/storefront/src/pages/quote/QuoteDraft.tsx index fad95c81..e14e56f5 100644 --- a/apps/storefront/src/pages/quote/QuoteDraft.tsx +++ b/apps/storefront/src/pages/quote/QuoteDraft.tsx @@ -47,13 +47,13 @@ import { ShippingAddress, } from '@/types/quotes' import { - addQuoteDraftProducts, B3LStorage, getActiveCurrencyInfo, getDefaultCurrencyInfo, snackbar, storeHash, } from '@/utils' +import { addQuoteDraftProducts } from '@/utils/b3Product/b3Product' import { deleteCartData } from '@/utils/cartUtils' import validateObject from '@/utils/quoteUtils' @@ -136,11 +136,7 @@ const billingAddress = { function QuoteDraft({ setOpenPage }: QuoteDraftProps) { const { - state: { - countriesList, - currentChannelId: channelId, - openAPPParams, - }, + state: { countriesList, currentChannelId: channelId, openAPPParams }, } = useContext(GlobaledContext) const isB2BUser = useAppSelector(isB2BUserSelector) const companyB2BId = useAppSelector(({ company }) => company.companyInfo.id) diff --git a/apps/storefront/src/pages/quote/components/AddToQuote.tsx b/apps/storefront/src/pages/quote/components/AddToQuote.tsx index 250cc5ea..38a11c26 100644 --- a/apps/storefront/src/pages/quote/components/AddToQuote.tsx +++ b/apps/storefront/src/pages/quote/components/AddToQuote.tsx @@ -9,13 +9,13 @@ import { PRODUCT_DEFAULT_IMAGE } from '@/constants' import { useBlockPendingAccountViewPrice } from '@/hooks' import { searchB2BProducts, searchBcProducts } from '@/shared/service/b2b' import { useAppSelector } from '@/store' +import { snackbar } from '@/utils' +import b2bLogger from '@/utils/b3Logger' import { addQuoteDraftProducts, - b2bLogger, calculateProductListPrice, - snackbar, validProductQty, -} from '@/utils' +} from '@/utils/b3Product/b3Product' import { conversionProductsList } from '@/utils/b3Product/shared/config' import QuickAdd from '../../shoppingListDetails/components/QuickAdd' diff --git a/apps/storefront/src/pages/quote/components/QuoteDetailFooter.tsx b/apps/storefront/src/pages/quote/components/QuoteDetailFooter.tsx index 83bda4e7..3d013673 100644 --- a/apps/storefront/src/pages/quote/components/QuoteDetailFooter.tsx +++ b/apps/storefront/src/pages/quote/components/QuoteDetailFooter.tsx @@ -6,11 +6,12 @@ import { CustomButton } from '@/components' import { useMobile } from '@/hooks' import { b2bQuoteCheckout, bcQuoteCheckout } from '@/shared/service/b2b' import { useAppSelector } from '@/store' -import { b2bLogger, getSearchVal } from '@/utils' import { attemptCheckoutLoginAndRedirect, setQuoteToStorage, } from '@/utils/b3checkout' +import b2bLogger from '@/utils/b3Logger' +import { getSearchVal } from '@/utils/loginInfo' interface QuoteDetailFooterProps { quoteId: string diff --git a/apps/storefront/src/pages/quote/components/QuoteTable.tsx b/apps/storefront/src/pages/quote/components/QuoteTable.tsx index 07d8e630..3010a6f8 100644 --- a/apps/storefront/src/pages/quote/components/QuoteTable.tsx +++ b/apps/storefront/src/pages/quote/components/QuoteTable.tsx @@ -15,13 +15,13 @@ import { } from '@/store' import { Product } from '@/types' import { QuoteItem } from '@/types/quotes' +import { currencyFormat, snackbar } from '@/utils' import { calculateProductListPrice, - currencyFormat, + getBCPrice, + getDisplayPrice, setModifierQtyPrice, - snackbar, -} from '@/utils' -import { getBCPrice, getDisplayPrice } from '@/utils/b3Product/b3Product' +} from '@/utils/b3Product/b3Product' import { getProductOptionsFields } from '@/utils/b3Product/shared/config' import ChooseOptionsDialog from '../../shoppingListDetails/components/ChooseOptionsDialog' diff --git a/apps/storefront/src/pages/registered/RegisterComplete.tsx b/apps/storefront/src/pages/registered/RegisterComplete.tsx index 1cda0639..2795a7a5 100644 --- a/apps/storefront/src/pages/registered/RegisterComplete.tsx +++ b/apps/storefront/src/pages/registered/RegisterComplete.tsx @@ -13,7 +13,8 @@ import { sendSubscribersState, uploadB2BFile, } from '@/shared/service/b2b' -import { b2bLogger, storeHash } from '@/utils' +import { storeHash } from '@/utils' +import b2bLogger from '@/utils/b3Logger' import RegisteredStepButton from './component/RegisteredStepButton' import { RegisteredContext } from './context/RegisteredContext' diff --git a/apps/storefront/src/pages/registered/Registered.tsx b/apps/storefront/src/pages/registered/Registered.tsx index 784ac0cb..dbe94da4 100644 --- a/apps/storefront/src/pages/registered/Registered.tsx +++ b/apps/storefront/src/pages/registered/Registered.tsx @@ -17,12 +17,9 @@ import { getB2BAccountFormFields, getB2BCountries } from '@/shared/service/b2b' import { bcLogin } from '@/shared/service/bc' import { themeFrameSelector, useAppSelector } from '@/store' import { OpenPageState } from '@/types/hooks' -import { - b2bLogger, - B3SStorage, - getCurrentCustomerInfo, - loginjump, -} from '@/utils' +import { B3SStorage, loginjump } from '@/utils' +import b2bLogger from '@/utils/b3Logger' +import { getCurrentCustomerInfo } from '@/utils/loginInfo' import { loginCheckout, LoginConfig } from '../login/config' diff --git a/apps/storefront/src/pages/registered/RegisteredBCToB2B.tsx b/apps/storefront/src/pages/registered/RegisteredBCToB2B.tsx index 65a33845..9dd8971c 100644 --- a/apps/storefront/src/pages/registered/RegisteredBCToB2B.tsx +++ b/apps/storefront/src/pages/registered/RegisteredBCToB2B.tsx @@ -20,12 +20,9 @@ import { CustomStyleContext } from '@/shared/customStyleButtton' import { GlobaledContext } from '@/shared/global' import { useAppSelector } from '@/store' import { OpenPageState } from '@/types/hooks' -import { - b2bLogger, - getCurrentCustomerInfo, - loginjump, - storeHash, -} from '@/utils' +import { loginjump, storeHash } from '@/utils' +import b2bLogger from '@/utils/b3Logger' +import { getCurrentCustomerInfo } from '@/utils/loginInfo' import { createB2BCompanyUser, diff --git a/apps/storefront/src/pages/shoppingListDetails/ShoppingListDetails.tsx b/apps/storefront/src/pages/shoppingListDetails/ShoppingListDetails.tsx index 4f121c3a..66487bb6 100644 --- a/apps/storefront/src/pages/shoppingListDetails/ShoppingListDetails.tsx +++ b/apps/storefront/src/pages/shoppingListDetails/ShoppingListDetails.tsx @@ -25,12 +25,11 @@ import { updateBcShoppingList, } from '@/shared/service/b2b' import { isB2BUserSelector, useAppSelector } from '@/store' +import { getDefaultCurrencyInfo, snackbar } from '@/utils' import { calculateProductListPrice, - getDefaultCurrencyInfo, - snackbar, -} from '@/utils' -import { getBCPrice } from '@/utils/b3Product/b3Product' + getBCPrice, +} from '@/utils/b3Product/b3Product' import { conversionProductsList, CustomerInfoProps, diff --git a/apps/storefront/src/pages/shoppingListDetails/components/AddToShoppingList.tsx b/apps/storefront/src/pages/shoppingListDetails/components/AddToShoppingList.tsx index 0c1adb67..862dc504 100644 --- a/apps/storefront/src/pages/shoppingListDetails/components/AddToShoppingList.tsx +++ b/apps/storefront/src/pages/shoppingListDetails/components/AddToShoppingList.tsx @@ -11,7 +11,8 @@ import { addProductToShoppingList, } from '@/shared/service/b2b' import { useAppSelector } from '@/store' -import { getValidOptionsList, snackbar } from '@/utils' +import { snackbar } from '@/utils' +import { getValidOptionsList } from '@/utils/b3Product/b3Product' import { getAllModifierDefaultValue } from '../../../utils/b3Product/shared/config' import { ShoppingListDetailsContext } from '../context/ShoppingListDetailsContext' diff --git a/apps/storefront/src/pages/shoppingListDetails/components/ChooseOptionsDialog.tsx b/apps/storefront/src/pages/shoppingListDetails/components/ChooseOptionsDialog.tsx index 91daf064..37384da8 100644 --- a/apps/storefront/src/pages/shoppingListDetails/components/ChooseOptionsDialog.tsx +++ b/apps/storefront/src/pages/shoppingListDetails/components/ChooseOptionsDialog.tsx @@ -18,13 +18,10 @@ import { B3CustomForm, B3Dialog, B3Sping } from '@/components' import { PRODUCT_DEFAULT_IMAGE } from '@/constants' import { searchB2BProducts, searchBcProducts } from '@/shared/service/b2b' import { useAppSelector } from '@/store' +import { currencyFormat, snackbar } from '@/utils' +import b2bLogger from '@/utils/b3Logger' import { - b2bLogger, calculateProductListPrice, - currencyFormat, - snackbar, -} from '@/utils' -import { getBCPrice, getProductInfoDisplayPrice, getVariantInfoDisplayPrice, diff --git a/apps/storefront/src/pages/shoppingListDetails/components/QuickAdd.tsx b/apps/storefront/src/pages/shoppingListDetails/components/QuickAdd.tsx index 36de9439..71ed8dd4 100644 --- a/apps/storefront/src/pages/shoppingListDetails/components/QuickAdd.tsx +++ b/apps/storefront/src/pages/shoppingListDetails/components/QuickAdd.tsx @@ -6,7 +6,8 @@ import { Box, Grid, Typography } from '@mui/material' import { B3CustomForm, B3Sping, CustomButton } from '@/components' import { useBlockPendingAccountViewPrice } from '@/hooks' import { isB2BUserSelector, useAppSelector } from '@/store' -import { compareOption, snackbar } from '@/utils' +import { snackbar } from '@/utils' +import { compareOption } from '@/utils/b3Product/b3Product' import { getAllModifierDefaultValue, getQuickAddRowFields, diff --git a/apps/storefront/src/pages/shoppingListDetails/components/ReAddToCart.tsx b/apps/storefront/src/pages/shoppingListDetails/components/ReAddToCart.tsx index 33e51529..157cf2ca 100644 --- a/apps/storefront/src/pages/shoppingListDetails/components/ReAddToCart.tsx +++ b/apps/storefront/src/pages/shoppingListDetails/components/ReAddToCart.tsx @@ -14,18 +14,14 @@ import { import { PRODUCT_DEFAULT_IMAGE } from '@/constants' import { useMobile } from '@/hooks' import { useAppSelector } from '@/store' -import { - b3TriggerCartNumber, - currencyFormat, - getActiveCurrencyInfo, - setModifierQtyPrice, - snackbar, -} from '@/utils' +import { currencyFormat, getActiveCurrencyInfo, snackbar } from '@/utils' +import { setModifierQtyPrice } from '@/utils/b3Product/b3Product' import { addlineItems, getProductOptionsFields, ProductsProps, } from '@/utils/b3Product/shared/config' +import b3TriggerCartNumber from '@/utils/b3TriggerCartNumber' import { callCart } from '@/utils/cartUtils' interface ShoppingProductsProps { diff --git a/apps/storefront/src/pages/shoppingListDetails/components/SearchProduct.tsx b/apps/storefront/src/pages/shoppingListDetails/components/SearchProduct.tsx index fa18df4a..0b64176a 100644 --- a/apps/storefront/src/pages/shoppingListDetails/components/SearchProduct.tsx +++ b/apps/storefront/src/pages/shoppingListDetails/components/SearchProduct.tsx @@ -7,7 +7,8 @@ import { B3Sping, CustomButton } from '@/components' import { useBlockPendingAccountViewPrice } from '@/hooks' import { searchB2BProducts, searchBcProducts } from '@/shared/service/b2b' import { store, useAppSelector } from '@/store' -import { calculateProductListPrice, snackbar } from '@/utils' +import { snackbar } from '@/utils' +import { calculateProductListPrice } from '@/utils/b3Product/b3Product' import { conversionProductsList } from '@/utils/b3Product/shared/config' import { ShoppingListProductItem } from '../../../types' diff --git a/apps/storefront/src/pages/shoppingListDetails/components/ShoppingDetailFooter.tsx b/apps/storefront/src/pages/shoppingListDetails/components/ShoppingDetailFooter.tsx index eac5637e..0e26ed21 100644 --- a/apps/storefront/src/pages/shoppingListDetails/components/ShoppingDetailFooter.tsx +++ b/apps/storefront/src/pages/shoppingListDetails/components/ShoppingDetailFooter.tsx @@ -16,21 +16,19 @@ import { } from '@/shared/service/b2b/graphql/product' import { deleteCart, getCart } from '@/shared/service/bc/graphql/cart' import { useAppSelector } from '@/store' +import { currencyFormat, getCookie, snackbar } from '@/utils' +import b2bLogger from '@/utils/b3Logger' import { addQuoteDraftProducts, - b2bLogger, - b3TriggerCartNumber, calculateProductListPrice, - currencyFormat, - getCookie, - snackbar, validProductQty, -} from '@/utils' +} from '@/utils/b3Product/b3Product' import { addlineItems, conversionProductsList, ProductsProps, } from '@/utils/b3Product/shared/config' +import b3TriggerCartNumber from '@/utils/b3TriggerCartNumber' import { callCart, deleteCartData, updateCart } from '@/utils/cartUtils' interface ShoppingDetailFooterProps { diff --git a/apps/storefront/src/pages/shoppingListDetails/components/ShoppingDetailTable.tsx b/apps/storefront/src/pages/shoppingListDetails/components/ShoppingDetailTable.tsx index 84de4156..fbe6a64a 100644 --- a/apps/storefront/src/pages/shoppingListDetails/components/ShoppingDetailTable.tsx +++ b/apps/storefront/src/pages/shoppingListDetails/components/ShoppingDetailTable.tsx @@ -23,8 +23,12 @@ import { updateBcShoppingListsItem, } from '@/shared/service/b2b' import { useAppSelector } from '@/store' -import { currencyFormat, getValidOptionsList, snackbar } from '@/utils' -import { getBCPrice, getDisplayPrice } from '@/utils/b3Product/b3Product' +import { currencyFormat, snackbar } from '@/utils' +import { + getBCPrice, + getDisplayPrice, + getValidOptionsList, +} from '@/utils/b3Product/b3Product' import { getProductOptionsFields } from '@/utils/b3Product/shared/config' import B3FilterSearch from '../../../components/filter/B3FilterSearch' diff --git a/apps/storefront/src/shared/routes/routes.ts b/apps/storefront/src/shared/routes/routes.ts index 1cf57fe1..63d98c6b 100644 --- a/apps/storefront/src/shared/routes/routes.ts +++ b/apps/storefront/src/shared/routes/routes.ts @@ -5,7 +5,8 @@ import { GlobalState, QuoteConfigProps } from '@/shared/global/context/config' import { getCustomerInfo } from '@/shared/service/bc' import { store, useAppSelector } from '@/store' import { CompanyStatus, CustomerRole, UserTypes } from '@/types' -import { b2bLogger, isB2bTokenPage, logoutSession } from '@/utils' +import b2bLogger from '@/utils/b3Logger' +import { isB2bTokenPage, logoutSession } from '@/utils/b3logout' const OrderList = lazy(() => import('../../pages/order/MyOrder')) diff --git a/apps/storefront/src/utils/b3Callbacks.ts b/apps/storefront/src/utils/b3Callbacks.ts index ed067b41..3eb71a7b 100644 --- a/apps/storefront/src/utils/b3Callbacks.ts +++ b/apps/storefront/src/utils/b3Callbacks.ts @@ -1,6 +1,6 @@ import { CallbackKey } from '@b3/hooks' -import { b2bLogger } from '@/utils' +import b2bLogger from './b3Logger' type CallbackEvent = { data: CustomFieldItems diff --git a/apps/storefront/src/utils/b3ClearCart.tsx b/apps/storefront/src/utils/b3ClearCart.tsx index 41088f4f..87260a10 100644 --- a/apps/storefront/src/utils/b3ClearCart.tsx +++ b/apps/storefront/src/utils/b3ClearCart.tsx @@ -1,8 +1,8 @@ import { deleteCart, getCart } from '@/shared/service/bc/graphql/cart' import { store } from '@/store/reducer' import { setCartNumber } from '@/store/slices/global' -import { b2bLogger } from '@/utils' +import b2bLogger from './b3Logger' import getCookie from './b3utils' import { deleteCartData } from './cartUtils' diff --git a/apps/storefront/src/utils/b3CurrencyFormat.ts b/apps/storefront/src/utils/b3CurrencyFormat.ts index ffa03413..9583e487 100644 --- a/apps/storefront/src/utils/b3CurrencyFormat.ts +++ b/apps/storefront/src/utils/b3CurrencyFormat.ts @@ -1,8 +1,8 @@ import globalB3 from '@b3/global-b3' import { store } from '@/store' -import { b2bLogger } from '@/utils' +import b2bLogger from './b3Logger' import { getActiveCurrencyInfo, getDefaultCurrencyInfo } from './currencyUtils' interface MoneyFormat { diff --git a/apps/storefront/src/utils/b3Logger.ts b/apps/storefront/src/utils/b3Logger.ts index 746f9e05..a7505a3e 100644 --- a/apps/storefront/src/utils/b3Logger.ts +++ b/apps/storefront/src/utils/b3Logger.ts @@ -1,6 +1,6 @@ type B2BLoggerType = Pick -export const b2bLogger: B2BLoggerType = { +const b2bLogger: B2BLoggerType = { error: console.error, } diff --git a/apps/storefront/src/utils/b3PrintInvoice.tsx b/apps/storefront/src/utils/b3PrintInvoice.tsx index 78339ef7..c9ca1220 100644 --- a/apps/storefront/src/utils/b3PrintInvoice.tsx +++ b/apps/storefront/src/utils/b3PrintInvoice.tsx @@ -1,4 +1,4 @@ -import { b2bLogger } from '@/utils' +import b2bLogger from './b3Logger' const bindDom = (html: string, domId: string) => { let iframeDom = document.getElementById(domId) as HTMLIFrameElement | null diff --git a/apps/storefront/src/utils/b3Product/b3Product.ts b/apps/storefront/src/utils/b3Product/b3Product.ts index 136e5471..49a87695 100644 --- a/apps/storefront/src/utils/b3Product/b3Product.ts +++ b/apps/storefront/src/utils/b3Product/b3Product.ts @@ -23,13 +23,14 @@ import { } from '@/types/products' import { QuoteItem } from '@/types/quotes' import { - b2bLogger, B3SStorage, getActiveCurrencyInfo, getDefaultCurrencyInfo, storeHash, } from '@/utils' +import b2bLogger from '../b3Logger' + import { conversionProductsList, ListItemProps, diff --git a/apps/storefront/src/utils/b3Product/shared/config.ts b/apps/storefront/src/utils/b3Product/shared/config.ts index ed91e0d1..4bb14198 100644 --- a/apps/storefront/src/utils/b3Product/shared/config.ts +++ b/apps/storefront/src/utils/b3Product/shared/config.ts @@ -3,7 +3,7 @@ import format from 'date-fns/format' import isEmpty from 'lodash-es/isEmpty' import { AllOptionProps, ALlOptionValue, Product } from '@/types/products' -import { b2bLogger } from '@/utils' +import b2bLogger from '@/utils/b3Logger' import { BcCalculatedPrice, diff --git a/apps/storefront/src/utils/b3Proxy.ts b/apps/storefront/src/utils/b3Proxy.ts index 08a70e8b..9726b3d3 100644 --- a/apps/storefront/src/utils/b3Proxy.ts +++ b/apps/storefront/src/utils/b3Proxy.ts @@ -1,4 +1,6 @@ -import { B3SStorage, storeHash } from '@/utils' +import { storeHash } from '@/utils' + +import { B3SStorage } from './b3Storage' const getProxyInfo = (url: string, data = {}) => { const params = { diff --git a/apps/storefront/src/utils/b3TriggerCartNumber.ts b/apps/storefront/src/utils/b3TriggerCartNumber.ts index bedb8a17..8d38deac 100644 --- a/apps/storefront/src/utils/b3TriggerCartNumber.ts +++ b/apps/storefront/src/utils/b3TriggerCartNumber.ts @@ -3,8 +3,8 @@ import Cookies from 'js-cookie' import { getCart } from '@/shared/service/bc/graphql/cart' import { store } from '@/store/reducer' import { setCartNumber } from '@/store/slices/global' -import { b2bLogger } from '@/utils' +import b2bLogger from './b3Logger' import getCookie from './b3utils' const productTypeKey = [ diff --git a/apps/storefront/src/utils/b3logout.ts b/apps/storefront/src/utils/b3logout.ts index 1f77da6d..7e7c9e68 100644 --- a/apps/storefront/src/utils/b3logout.ts +++ b/apps/storefront/src/utils/b3logout.ts @@ -1,8 +1,8 @@ import { customerExists } from '@/shared/service/bc' import { store } from '@/store' import { clearCompanySlice } from '@/store/slices/company' -import { b2bLogger } from '@/utils' +import b2bLogger from './b3Logger' import { B3SStorage } from './b3Storage' export const logoutSession = () => { diff --git a/apps/storefront/src/utils/index.ts b/apps/storefront/src/utils/index.ts index 7c1d978d..d450e329 100644 --- a/apps/storefront/src/utils/index.ts +++ b/apps/storefront/src/utils/index.ts @@ -3,14 +3,6 @@ import { redirectBcMenus, removeBCMenus, } from './b3AccountItem' -import { - getProductOptionList, - handleGetCurrentProductInfo, - isAllRequiredOptionFilled, - isModifierNumberTextValid, - isModifierTextValid, -} from './b3AddToShoppingList' -import clearInvoiceCart from './b3ClearCart' import currencyFormat, { currencyFormatConvert, currencyFormatInfo, @@ -25,17 +17,14 @@ import { import { getLineNumber, getTextLenPX } from './b3GetTextLenPX' import handleHideRegisterPage from './b3HideRegister' import { getLogo, getQuoteEnabled } from './b3Init' -import { convertLabel, manipulateString } from './b3ManipulateString' import { showPageMask } from './b3PageMask' import distanceDay from './b3Picker' import getProductPriceIncTax from './b3Price' import b2bPrintInvoice from './b3PrintInvoice' -import getProxyInfo from './b3Proxy' import { setCartPermissions } from './b3RolePermissions' import { serialize } from './b3Serialize' import { B3LStorage, B3SStorage } from './b3Storage' import { globalSnackbar, snackbar } from './b3Tip' -import b3TriggerCartNumber from './b3TriggerCartNumber' import getCookie from './b3utils' import { getActiveCurrencyInfo, @@ -46,27 +35,9 @@ import { convertArrayToGraphql, convertObjectToGraphql, } from './graphqlDataConvert' -import { - clearCurrentCustomerInfo, - getCompanyUserInfo, - getCurrentCustomerInfo, - getSearchVal, - loginInfo, -} from './loginInfo' import { validatorRules } from './validatorRules' -export { isB2bTokenPage, isUserGotoLogin, logoutSession } from './b3logout' -export * from './b3Product/b3Product' export * from './basicConfig' -export * from './masquerade' -export { b2bLogger } from './b3Logger' -export { - getQuoteConfig, - getStoreInfo, - getStoreTaxZoneRates, - getTemPlateConfig, - setStorefrontConfig, -} from './storefrontConfig' export { loginjump } from './b3Login' @@ -75,11 +46,7 @@ export { b2bPrintInvoice, B3LStorage, B3SStorage, - b3TriggerCartNumber, - clearCurrentCustomerInfo, - clearInvoiceCart, convertArrayToGraphql, - convertLabel, convertObjectToGraphql, currencyFormat, currencyFormatConvert, @@ -88,28 +55,17 @@ export { displayFormat, distanceDay, getActiveCurrencyInfo, - getCompanyUserInfo, getCookie, - getCurrentCustomerInfo, getDefaultCurrencyInfo, getLineNumber, getLogo, - getProductOptionList, getProductPriceIncTax, - getProxyInfo, getQuoteEnabled, - getSearchVal, getTextLenPX, getUTCTimestamp, globalSnackbar, handleGetCorrespondingCurrency, - handleGetCurrentProductInfo, handleHideRegisterPage, - isAllRequiredOptionFilled, - isModifierNumberTextValid, - isModifierTextValid, - loginInfo, - manipulateString, openPageByClick, ordersCurrencyFormat, redirectBcMenus, diff --git a/apps/storefront/src/utils/loginInfo.ts b/apps/storefront/src/utils/loginInfo.ts index f6bc48ea..e93544f3 100644 --- a/apps/storefront/src/utils/loginInfo.ts +++ b/apps/storefront/src/utils/loginInfo.ts @@ -28,7 +28,10 @@ import { resetDraftQuoteList, } from '@/store/slices/quoteInfo' import { CompanyStatus, CustomerRole, UserTypes } from '@/types' -import { b2bLogger, B3LStorage, B3SStorage, storeHash } from '@/utils' + +import b2bLogger from './b3Logger' +import { B3LStorage, B3SStorage } from './b3Storage' +import { storeHash } from './basicConfig' const { VITE_B2B_CLIENT_ID, VITE_LOCAL_DEBUG } = import.meta.env @@ -345,12 +348,12 @@ export const getCurrentCustomerInfo = async ( companyName: companyInfo.companyName, } + store.dispatch(resetDraftQuoteList()) + store.dispatch(resetDraftQuoteInfo()) store.dispatch(setCompanyInfo(companyPayload)) store.dispatch(setCustomerInfo(customerInfo)) - store.dispatch(resetDraftQuoteList()) store.dispatch(setQuoteUserId(quoteUserId)) B3SStorage.set('isB2BUser', isB2BUser) - store.dispatch(resetDraftQuoteInfo()) B3LStorage.set('cartToQuoteId', '') return {