Skip to content

Commit

Permalink
fix: set dialogs maxWidth
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 committed Dec 27, 2022
1 parent da23f35 commit 32733e5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
4 changes: 4 additions & 0 deletions apps/storefront/src/components/B3Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ interface B3DialogProps<T> {
isShowBordered?: boolean
showRightBtn?: boolean
maxWidth?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | false
fullWidth?: boolean
}

export const B3Dialog:<T> ({
Expand All @@ -59,6 +60,7 @@ export const B3Dialog:<T> ({
isShowBordered,
showRightBtn,
maxWidth,
fullWidth,
}: B3DialogProps<T>) => ReactElement = ({
customActions,
isOpen,
Expand All @@ -75,6 +77,7 @@ export const B3Dialog:<T> ({
isShowBordered = false,
showRightBtn = true,
maxWidth = 'sm',
fullWidth = false,
}) => {
const container = useRef<HTMLInputElement | null>(null)

Expand Down Expand Up @@ -107,6 +110,7 @@ export const B3Dialog:<T> ({
/>

<Dialog
fullWidth={fullWidth}
open={isOpen}
container={container.current}
onClose={handleCloseClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import {
ShoppingListInfoProps,
CustomerInfoProps,
ListItemProps,
CurrencyProps,
SearchProps,
} from './shared/config'

import {
Expand All @@ -60,14 +62,12 @@ import ShoppingDetailFooter from './components/ShoppingDetailFooter'
import ShoppingDetailTable from './components/ShoppingDetailTable'
import ShoppingDetailDeleteItems from './components/ShoppingDetailDeleteItems'

interface TableRefProps extends HTMLInputElement {
initSearch: () => void,
}

// shoppingList status: 0 -- Approved; 20 -- Rejected; 30 -- Draft; 40 -- Ready for approval
// 0: Admin, 1: Senior buyer, 2: Junior buyer, 3: Super admin
// const shoppingListStatus = {
// 0: 'Approved',
// 20: 'Rejected',
// 30: 'Draft',
// 40: 'Ready for approval',
// }

const ShoppingListDetails = () => {
const {
Expand All @@ -87,9 +87,9 @@ const ShoppingListDetails = () => {
dispatch,
} = useContext(ShoppingListDetailsContext)

const tableRef = useRef<any>(null)
const tableRef = useRef<TableRefProps | null>(null)

const [checkedArr, setCheckedArr] = useState<any>([])
const [checkedArr, setCheckedArr] = useState<CustomFieldItems>([])
const [shoppingListInfo, setShoppingListInfo] = useState<null | ShoppingListInfoProps>(null)
const [customerInfo, setCustomerInfo] = useState<null | CustomerInfoProps>(null)
const [selectedSubTotal, setSelectedSubTotal] = useState<number>(0.00)
Expand All @@ -107,7 +107,7 @@ const ShoppingListDetails = () => {
currencies: currencyArr,
} = currencies

const defaultCurrency = currencyArr.find((currency: any) => currency.is_default)
const defaultCurrency = currencyArr.find((currency: CurrencyProps) => currency.is_default)

return defaultCurrency
}
Expand Down Expand Up @@ -177,7 +177,7 @@ const ShoppingListDetails = () => {
}
}

const getShoppingListDetails = async (params: any) => {
const getShoppingListDetails = async (params: SearchProps) => {
const {
shoppingList,
shoppingList: {
Expand Down Expand Up @@ -213,7 +213,7 @@ const ShoppingListDetails = () => {
})

snackbar.success('Shipping list status updated successfully')
tableRef.current.initSearch()
tableRef.current?.initSearch()
} finally {
setIsRequestLoading(false)
}
Expand Down Expand Up @@ -256,14 +256,14 @@ const ShoppingListDetails = () => {
}

snackbar.success('Product removed from your shopping list')
tableRef.current.initSearch()
tableRef.current?.initSearch()
} finally {
setIsRequestLoading(false)
}
}

const updateList = () => {
tableRef.current.initSearch()
tableRef.current?.initSearch()
}

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export const ProductListDialog = (props: ProductListDialogProps) => {

return (
<B3Dialog
fullWidth
isOpen={isOpen}
handleLeftClick={handleCancelClicked}
title="Add to list"
Expand Down
12 changes: 12 additions & 0 deletions apps/storefront/src/pages/shoppingListDetails/shared/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ export interface ListItemProps {
node: ProductInfoProps,
}

export interface CurrencyProps {
is_default: boolean,
currency_code: string,
token: string,
}

export interface SearchProps {
search: string,
first?: number,
offset?: number,
}

const fieldTypes: CustomFieldItems = {
text: 'text',
numbers_only_text: 'number',
Expand Down

0 comments on commit 32733e5

Please sign in to comment.