Skip to content

Commit

Permalink
feat(BUN-2245): types directory import no-cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 authored and libruce committed Apr 16, 2024
1 parent 63d01b2 commit 77d7ce5
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 81 deletions.
4 changes: 2 additions & 2 deletions apps/storefront/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"src/components/**/*.{ts,tsx}",
"src/hooks/dom/*.ts",
"src/hooks/*.ts",
"src/shared/**/**/**/*.ts",
"src/types/*.ts"
"src/shared/**/**/**/*.ts"
// "src/types/*.ts"
],
"rules": {
"import/no-cycle": 0
Expand Down
2 changes: 1 addition & 1 deletion apps/storefront/src/types/cart.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OptionValueProps } from '@/utils/b3Product/shared/config'
import { OptionValueProps } from './products'

export interface LineItems {
quantity: number
Expand Down
49 changes: 49 additions & 0 deletions apps/storefront/src/types/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
export interface Modifiers {
config?: {
default_value?: string
text_characters_limited?: boolean
text_max_length?: number
text_min_length?: number
text_lines_limited?: boolean
text_max_lines?: number
date_earliest_value?: string
date_latest_value?: string
date_limit_mode?: string
date_limited?: boolean
number_highest_value?: number
number_integers_only?: boolean
number_limit_mode?: string
number_limited?: boolean
number_lowest_value?: number
checkbox_label?: string
checked_by_default?: boolean
file_max_size?: number
file_types_mode?: string
file_types_other?: string[]
file_types_supported?: string[]
}
display_name: string
id?: number | string
option_values: ModifiersOption[]
required: boolean
type: string
isVariantOption?: boolean
}

export interface ModifiersOption {
id: number
is_default: boolean
label: string
option_id: number
value_data?: {
colors?: string[]
product_id?: number
}
}

export interface ProductItemOption {
display_name: string
is_required: boolean
option_id: number
sort_order: number
}
1 change: 1 addition & 0 deletions apps/storefront/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './order'
export * from './orderDetail'
export * from './products'
export * from './shoppingList'
export * from './common'
22 changes: 15 additions & 7 deletions apps/storefront/src/types/products.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import {
ShoppingListProductItemModifiers,
ShoppingListProductItemOption,
} from '@/types/shoppingList'
import { Modifiers, ProductItemOption } from './common'

interface DateProps {
day: string
month: string
year: string
}

export interface OptionValueProps {
optionId: string | number
optionValue: string | DateProps
}

export interface ProductOptionsItem {
option_id: number
Expand Down Expand Up @@ -166,9 +174,9 @@ export interface Product {
variants?: Partial<Variant>[]
currencyCode: string
imageUrl: string
modifiers: ShoppingListProductItemModifiers[]
options?: ShoppingListProductItemOption[]
optionsV3?: ShoppingListProductItemModifiers[]
modifiers: Modifiers[]
options?: ProductItemOption[]
optionsV3?: Modifiers[]
allOptions?: Partial<AllOptionProps>[]
productUrl: string
quantity: number | string
Expand Down
57 changes: 4 additions & 53 deletions apps/storefront/src/types/shoppingList.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Modifiers, ProductItemOption } from './common'
import { AllOptionProps, ProductItem, Variant } from './products'

export interface ShoppingListItem {
Expand All @@ -18,56 +19,6 @@ export interface ShoppingListItem {
totalTax: string
}

export interface ShoppingListProductItemOption {
display_name: string
is_required: boolean
option_id: number
sort_order: number
}

export interface ShoppingListProductItemModifiersOption {
id: number
is_default: boolean
label: string
option_id: number
value_data?: {
colors?: string[]
product_id?: number
}
}

export interface ShoppingListProductItemModifiers {
config?: {
default_value?: string
text_characters_limited?: boolean
text_max_length?: number
text_min_length?: number
text_lines_limited?: boolean
text_max_lines?: number
date_earliest_value?: string
date_latest_value?: string
date_limit_mode?: string
date_limited?: boolean
number_highest_value?: number
number_integers_only?: boolean
number_limit_mode?: string
number_limited?: boolean
number_lowest_value?: number
checkbox_label?: string
checked_by_default?: boolean
file_max_size?: number
file_types_mode?: string
file_types_other?: string[]
file_types_supported?: string[]
}
display_name: string
id?: number | string
option_values: ShoppingListProductItemModifiersOption[]
required: boolean
type: string
isVariantOption?: boolean
}

export interface ShoppingListProductItemVariantsOption {
id?: number
label: string
Expand All @@ -76,9 +27,9 @@ export interface ShoppingListProductItemVariantsOption {
}

export interface ShoppingListProductItem extends ProductItem {
options?: ShoppingListProductItemOption[]
optionsV3?: ShoppingListProductItemModifiers[]
modifiers?: ShoppingListProductItemModifiers[]
options?: ProductItemOption[]
optionsV3?: Modifiers[]
modifiers?: Modifiers[]
costPrice?: string
variants?: Variant[]
allOptions?: Partial<AllOptionProps>[]
Expand Down
12 changes: 5 additions & 7 deletions apps/storefront/src/utils/b3Product/b3Product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ import {
BcCalculatedPrice,
Calculateditems,
CalculatedOptions,
Modifiers,
OptionValue,
Product,
Variant,
} from '@/types/products'
import {
ShoppingListProductItem,
ShoppingListProductItemModifiers,
} from '@/types/shoppingList'
Variant,
} from '@/types'
import {
B3LStorage,
B3SStorage,
Expand Down Expand Up @@ -892,8 +890,8 @@ const calculateProductListPrice = async (
let allOptions: Partial<AllOptionProps>[] = []
let variants: Partial<Variant>[] = []
let variantId = 0
let modifiers: Partial<ShoppingListProductItemModifiers>[] = []
let optionsV3: Partial<ShoppingListProductItemModifiers>[] = []
let modifiers: Partial<Modifiers>[] = []
let optionsV3: Partial<Modifiers>[] = []

if (type === '1') {
newSelectOptionList = products[i].newSelectOptionList
Expand Down
12 changes: 1 addition & 11 deletions apps/storefront/src/utils/b3Product/shared/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { AllOptionProps, ALlOptionValue, Product } from '@/types/products'

import {
BcCalculatedPrice,
OptionValueProps,
ShoppingListProductItem,
ShoppingListSelectProductOption,
SimpleObject,
Expand Down Expand Up @@ -606,17 +607,6 @@ interface OptionListProps {
option_value: string
}

interface DateProps {
day: string
month: string
year: string
}

export interface OptionValueProps {
optionId: string | number
optionValue: string | DateProps
}

interface AllOptionsProps {
id: string | number
type: string
Expand Down

0 comments on commit 77d7ce5

Please sign in to comment.