Skip to content

Commit

Permalink
feat(BUN-2085): utils directory eslint cleanup (#952)
Browse files Browse the repository at this point in the history
* feat(BUN-2085): utils directory eslint cleanup

* fix(BUN-2085): addressed

* fix(BUN-2085): commented code removal
  • Loading branch information
bc-victor authored Mar 6, 2024
1 parent 5cad08e commit 7d39a2b
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 49 deletions.
8 changes: 1 addition & 7 deletions apps/storefront/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
{
"files": [
"src/pages/**/*.{ts,tsx}",
"src/utils/**/*.{ts,tsx}",
"src/components/**/*.{ts,tsx}"
],
"rules": {
Expand Down Expand Up @@ -149,12 +148,7 @@
"rules": { "react/jsx-wrap-multilines": 0 }
},
{
"files": [
"src/components/**/*.tsx",
"src/pages/**/*.{ts,tsx}",
"src/hooks/**/*.ts",
"src/hooks/*.ts"
],
"files": ["src/**/*.{ts,tsx}"],
"rules": { "import/extensions": 0 }
},
{
Expand Down
6 changes: 4 additions & 2 deletions apps/storefront/src/utils/b3HideRegister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ const handleHideRegisterPage = (registerEnabled: boolean) => {

if (registerPageAll.length > 0) {
registerPageAll.forEach((page: CustomFieldItems) => {
page.style.display = registerEnabled ? 'inline-block' : 'none'
const node = page
node.style.display = registerEnabled ? 'inline-block' : 'none'
})
}

if (navUserOrText.length > 0) {
navUserOrText.forEach((text: CustomFieldItems) => {
text.style.display = registerEnabled ? 'inline-block' : 'none'
const node = text
node.style.display = registerEnabled ? 'inline-block' : 'none'
})
}
}
Expand Down
5 changes: 3 additions & 2 deletions apps/storefront/src/utils/b3ManipulateString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ const manipulateString = (input: string): string => {

const convertLabel = (infos: RegisterFields[]) =>
infos.map((info: RegisterFields) => {
const { label } = info
const node = info
const { label } = node
if (label) {
info.label = manipulateString(label)
node.label = manipulateString(label)
}

return info
Expand Down
22 changes: 12 additions & 10 deletions apps/storefront/src/utils/b3Product/b3Product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,9 @@ const setItemProductPrice = (newListProducts: ListItemProps[]) => {
singleCurrentPrice * ((100 + rate) / 100) + singleextraProductPrice
const productTax = singleCurrentPrice * (rate / 100) + singleAllTax

item.node.baseAllPrice = productPrice.toFixed(decimalPlaces)
item.node.baseAllPricetax = productTax.toFixed(decimalPlaces)
const { node } = item ?? { node: {} }
node.baseAllPrice = productPrice.toFixed(decimalPlaces)
node.baseAllPricetax = productTax.toFixed(decimalPlaces)
})
}

Expand Down Expand Up @@ -960,6 +961,7 @@ const calculateProductListPrice = async (
const { data: calculatedData } = res

products.forEach((product: Partial<Product>, index: number) => {
const productNode = product
let qty = 0

if (type === '1') {
Expand All @@ -971,15 +973,15 @@ const calculateProductListPrice = async (
const { taxPrice, itemPrice } = getBulkPrice(calculatedData[index], qty)

if (type === '1') {
product.basePrice = itemPrice.toFixed(decimalPlaces)
product.taxPrice = taxPrice.toFixed(decimalPlaces)
product.tax = taxPrice.toFixed(decimalPlaces)
product.calculatedValue = calculatedData[index]
productNode.basePrice = itemPrice.toFixed(decimalPlaces)
productNode.taxPrice = taxPrice.toFixed(decimalPlaces)
productNode.tax = taxPrice.toFixed(decimalPlaces)
productNode.calculatedValue = calculatedData[index]
} else if (type === '2') {
product.node.basePrice = itemPrice.toFixed(decimalPlaces)
product.node.taxPrice = taxPrice.toFixed(decimalPlaces)
product.node.tax = taxPrice.toFixed(decimalPlaces)
product.node.calculatedValue = calculatedData[index]
productNode.node.basePrice = itemPrice.toFixed(decimalPlaces)
productNode.node.taxPrice = taxPrice.toFixed(decimalPlaces)
productNode.node.tax = taxPrice.toFixed(decimalPlaces)
productNode.node.calculatedValue = calculatedData[index]
}
})
return products
Expand Down
3 changes: 2 additions & 1 deletion apps/storefront/src/utils/b3Product/shared/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,10 @@ export const conversionProductsList = (

export const getOptionRequestData = (
formFields: CustomFieldItems[],
requestData: CustomFieldItems,
data: CustomFieldItems,
value: CustomFieldItems
) => {
const requestData = data
formFields.forEach((item: CustomFieldItems) => {
const { fieldType, name } = item

Expand Down
4 changes: 2 additions & 2 deletions apps/storefront/src/utils/cryptoJs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const encryptedStr = 'B3Info'

export const cipherText = (text: any) => {
if (!text) return ''
text =
const stringifiedText =
typeof text === 'boolean' || typeof text === 'number'
? text.toString()
: text
return tripledes.encrypt(text, encryptedStr).toString()
return tripledes.encrypt(stringifiedText, encryptedStr).toString()
}

export const plainText = (text: any) => {
Expand Down
9 changes: 5 additions & 4 deletions apps/storefront/src/utils/setTranslation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ export const setGlobalTranslation = async ({

export const setTranslation = async ({
channelId,
page,
page: pageKey,
}: SetTranslationParams) => {
const page =
pageKey in REPEATED_PAGES
? REPEATED_PAGES[pageKey as keyof typeof REPEATED_PAGES]
: pageKey
const translationVersion = B3LStorage.get('translationVersion')
const fetchedPages = B3LStorage.get('fetchedPages')
if (page in REPEATED_PAGES) {
page = REPEATED_PAGES[page as keyof typeof REPEATED_PAGES]
}

if (fetchedPages?.includes(page) || !(translationVersion > 0)) return

Expand Down
23 changes: 2 additions & 21 deletions apps/storefront/src/utils/storefrontConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,6 @@ import {
} from '@/store'
import { B3SStorage } from '@/utils'

// import {
// storeHash,
// } from '@/utils'

// interface Rates {
// enabled: boolean,
// id: number,
// name: string,
// priority: number,
// classRates: TaxZoneRates[],
// }

// interface TaxZoneRatesProps {
// enabled: boolean,
// id: number,
// name: string,
// rates: Rates[]
// }

interface StoreforntKeysProps {
key: string
name: string
Expand Down Expand Up @@ -179,7 +160,8 @@ const getTemPlateConfig = async (
const obj: Partial<CustomStyleButtonState> | {} = {}
let blockPendingAccountOrderCreation = true
let blockPendingAccountViewPrice = true
storefrontConfigs.forEach((item: any) => {
storefrontConfigs.forEach((currentItem: CustomFieldItems) => {
const item = currentItem
const storeforntKey: StoreforntKeysProps | undefined = storeforntKeys.find(
(option) => option.key === item.key
)
Expand Down Expand Up @@ -258,7 +240,6 @@ const getTemPlateConfig = async (
store.dispatch(
setBlockPendingQuoteNonPurchasableOOS({
isEnableProduct: item.value === '1',
// isEnableRequest: false
})
)
}
Expand Down

0 comments on commit 7d39a2b

Please sign in to comment.