@bjsdistribution/dms-client-return 0.1.97-prod → 0.1.98-prod
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/icons/ChevronDownIcon.js +26 -0
- package/dist/assets/icons/ChevronDownIcon.js.map +1 -0
- package/dist/common/modals/order-action-modal/OrderActionModal.js.map +1 -1
- package/dist/common/modals/order-action-modal/footer/OrderActionFooter.js.map +1 -1
- package/dist/components/order-view/notes/order-dropdown/NewReturnDropdown.js +7 -7
- package/dist/components/order-view/notes/order-dropdown/NewReturnDropdown.js.map +1 -1
- package/dist/components/order-view/order-actions/actions/split-order/SplitOrderTable.js +222 -55
- package/dist/components/order-view/order-actions/actions/split-order/SplitOrderTable.js.map +1 -1
- package/dist/components/order-view/order-actions/actions/split-order/index.js +50 -37
- package/dist/components/order-view/order-actions/actions/split-order/index.js.map +1 -1
- package/dist/components/order-view/products-info/collapsed-content/index.js +1 -1
- package/dist/components/order-view/products-info/collapsed-content/index.js.map +1 -1
- package/dist/components/order-view/products-info/index.js +36 -36
- package/dist/components/order-view/products-info/index.js.map +1 -1
- package/dist/components/order-view/return-client-products/product-table/ReturnProductTable.js +333 -162
- package/dist/components/order-view/return-client-products/product-table/ReturnProductTable.js.map +1 -1
- package/dist/components/order-view/return-client-products/product-table/palletGrouping.js +47 -0
- package/dist/components/order-view/return-client-products/product-table/palletGrouping.js.map +1 -0
- package/dist/components/order-view/store.js +164 -159
- package/dist/components/order-view/store.js.map +1 -1
- package/dist/types/common/modals/order-action-modal/OrderActionModal.d.ts +2 -1
- package/dist/types/common/modals/order-action-modal/footer/OrderActionFooter.d.ts +1 -1
- package/dist/types/components/order-view/return-client-products/product-table/palletGrouping.d.ts +23 -0
- package/dist/types/components/order-view/store.d.ts +1 -0
- package/package.json +1 -1
package/dist/components/order-view/return-client-products/product-table/ReturnProductTable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReturnProductTable.js","sources":["../../../../../src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport {\n StyledTable,\n StyledTableWrapper,\n} from '../../../order-daily-overview/return-order-table/return-orders-filters/returnstyles';\nimport {\n CancelAndCompleteAction,\n CancelationModal,\n Checkbox,\n displayValueOrNA,\n useAxios,\n} from '@bjsdistribution/dms-component-library';\nimport ActionIcon from '../../../../assets/icons/ActionIcon';\nimport { useOrderId, useProductDetails } from '../../store';\nimport { ApiResponse } from '../../types';\nimport { Empty, notification, Skeleton, Spin } from 'antd';\nimport {\n useIsShowNorthSouth,\n useNewReturnOrderData,\n useSelectedProducts,\n useClientPortal,\n} from '../../../store';\nimport styled from 'styled-components';\nimport { NavLink } from 'react-router-dom';\nimport { EmptyDataContainer } from '../../order-actions/actions/charge-log';\nimport CustomInput from '../../northern-southern-info/CustomInput';\n\ninterface IPROS {\n callReturnProducts: any;\n loading: boolean;\n locationloading: boolean;\n}\n\nconst ReturnProductTable = (props: IPROS) => {\n const [selectedProducts, setSelectedProducts] = useSelectedProducts();\n const [selectAll, setSelectAll] = useState(false);\n const [productData, setProductData] = useProductDetails();\n const [selectedRowId, setSelectedRowId] = useState<number | null>(null);\n const [orderId] = useOrderId();\n const [returnOrderData] = useNewReturnOrderData();\n const [isNorthSouth] = useIsShowNorthSouth();\n const [isClientPortal] = useClientPortal();\n\n const [productToDelete, setProductToDelete] = useState<number | null>(null);\n const [isDeleteModalOpen, setIsDeleteModalOpen] = useState<boolean>(false);\n\n const { loading: deleteLoading, fetchData: callDeleteProduct } = useAxios<{\n data: ApiResponse[];\n }>({\n endpoint: `v1/return/product/remove/`,\n method: 'POST',\n });\n\n const handleOpenDeleteModal = (id: number) => {\n setProductToDelete(id);\n setIsDeleteModalOpen(true);\n };\n\n const handleConfirmDelete = async () => {\n if (productToDelete === null) return;\n const targetId = productToDelete;\n try {\n const response = (await callDeleteProduct({\n payload: {\n return_order_product_id: targetId,\n return_order_id: +orderId,\n },\n })) as {\n code: number | null;\n error?: string | null;\n data?: any[];\n message?: string;\n };\n\n if (response?.code === 200) {\n notification.success({\n message: 'Success',\n description: response?.message || 'Product deleted successfully.',\n });\n props?.callReturnProducts();\n } else {\n notification.error({\n message: 'Deletion Failed',\n description: response?.message || 'Could not delete the product.',\n });\n }\n } catch (error) {\n console.error('Error deleting product:', error);\n notification.error({\n message: 'Error',\n //@ts-ignore\n description: error?.message || 'An unexpected error occurred.',\n });\n } finally {\n setProductToDelete(null);\n setIsDeleteModalOpen(false);\n }\n };\n\n const handleCancelDelete = () => {\n if (deleteLoading) return;\n setProductToDelete(null);\n setIsDeleteModalOpen(false);\n };\n\n const handleSelectAll = () => {\n if (selectAll) {\n setSelectedProducts([]);\n } else {\n const allProductIds = productData?.map((product: any) => product.id);\n setSelectedProducts(allProductIds);\n }\n setSelectAll(!selectAll);\n };\n\n const handleSelectProduct = (id: number) => {\n setSelectedProducts((prevSelected: any) =>\n prevSelected.includes(id)\n ? prevSelected.filter((selectedId: any) => selectedId !== id)\n : [...prevSelected, id]\n );\n };\n\n const disableCheckbox =\n productData?.length == 0 || returnOrderData?.length == 0;\n return (\n <div>\n <StyledTableWrapper id=\"tableScrolling\" className=\"orderProductTable\">\n <StyledTable>\n <thead>\n <tr>\n <th className=\"emailproductsCheckbox\">\n <StyleCheckbox\n disabled={disableCheckbox}\n checked={selectAll}\n onChange={handleSelectAll}\n />\n </th>\n <th>Location</th>\n <th>Sender</th>\n <th>Code</th>\n <th>Description</th>\n <th>Return Reason</th>\n {!isClientPortal && <th>Additional Services</th>}\n <th>Part</th>\n <th>Action</th>\n </tr>\n </thead>\n <tbody>\n {props?.loading || props?.locationloading ? (\n <tr>\n <td colSpan={14}>\n <Skeleton active />\n </td>\n </tr>\n ) : productData?.length === 0 ? (\n <tr>\n <td colSpan={14}>\n <EmptyDataContainer>\n <Empty />\n </EmptyDataContainer>\n </td>\n </tr>\n ) : (\n productData?.map((product: any) => (\n <React.Fragment key={product.id}>\n {/* MAIN ROW */}\n <tr className=\"product-row\">\n <td>\n <StyleCheckbox\n checked={selectedProducts?.includes(product?.id)}\n onChange={() => handleSelectProduct(product?.id)}\n disabled={disableCheckbox}\n />\n </td>\n <td>{product?.location || 'N/A'}</td>\n <td>\n <ul style={{ listStyleType: 'none', padding: 0 }}>\n <li\n style={{\n color: '#0099ff',\n fontWeight: 600,\n }}\n >\n <NavLink to={`/orders/view/${product?.order_id}`}>\n {displayValueOrNA(product?.recipient_name)}\n </NavLink>\n </li>\n <li style={{ color: '#888075' }}>\n {displayValueOrNA(product?.postcode)}\n </li>\n </ul>\n </td>\n <td>{product?.code}</td>\n <td>{product?.description}</td>\n <td>{product?.return_reason}</td>\n {!isClientPortal && (\n <td>\n {Array.isArray(product?.product_addon_services) && product?.product_addon_services?.length > 0\n ? product.product_addon_services\n .map((service: any) => service?.service_code || service?.name || service)\n .filter(Boolean)\n .join(', ')\n : Array.isArray(product?.addon_services) && product?.addon_services?.length > 0\n ? product.addon_services\n .map((service: any) => service?.service_code || service?.name || service)\n .filter(Boolean)\n .join(', ')\n : Array.isArray(product?.addon_services_list) && product?.addon_services_list?.length > 0\n ? product.addon_services_list.join(', ')\n : typeof product?.addon_services === 'string' && product?.addon_services.trim() !== ''\n ? product.addon_services\n : 'NA'}\n </td>\n )}\n <td>{product?.part}</td>\n <td>\n <div\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n handleOpenDeleteModal(product?.id);\n }}\n style={{ cursor: 'pointer' }}\n >\n <ActionIcon />\n </div>\n </td>\n </tr>\n\n {/* EXPANDED ROW */}\n {isNorthSouth === true && (\n <td colSpan={isClientPortal ? 8 : 9}>\n <NSWrapper>\n <div className=\"left\">Northern/Southern Ireland</div>\n <div className=\"left-end\"></div>\n\n <div className=\"section\">\n <CustomInput\n label=\"Commodity Code\"\n type=\"text\"\n direction=\"row\"\n placeholder=\"Enter Commodity Code\"\n value={\n product?.product_customs_details\n ?.commodity_code || 'NA'\n }\n disabled\n />\n\n <CustomInput\n label=\"Country of Origin\"\n type=\"text\"\n direction=\"row\"\n placeholder=\"Enter Country of Origin\"\n value={\n product?.product_customs_details\n ?.country_of_origin || 'NA'\n }\n disabled\n />\n\n <CustomInput\n label=\"Item Invoice Amount\"\n type=\"number\"\n direction=\"row\"\n placeholder=\"Enter Item Invoice Amount\"\n value={\n product?.product_customs_details\n ?.item_invoice_amount || 0\n }\n disabled\n />\n\n <CustomInput\n label=\"NI Additional Info Codes\"\n type=\"text\"\n direction=\"row\"\n placeholder=\"Enter NI Add Info Codes\"\n value={\n product?.product_customs_details\n ?.ni_additional_information_codes || 'NA'\n }\n disabled\n />\n </div>\n </NSWrapper>\n </td>\n )}\n </React.Fragment>\n ))\n )}\n </tbody>\n </StyledTable>\n </StyledTableWrapper>\n\n {isDeleteModalOpen && (\n <Spin spinning={deleteLoading}>\n <StyledCancelationModal\n title=\"Remove Product\"\n description=\"Are you sure, you want to remove this order product for returns?\"\n actions={\n <CustomCancelAndCompleteAction\n cancelLabel=\"Cancel\"\n onCancel={handleCancelDelete}\n completeLabel={deleteLoading ? 'REMOVING...' : 'Confirm'}\n isDisabled={deleteLoading}\n onComplete={handleConfirmDelete}\n />\n }\n />\n </Spin>\n )}\n </div>\n );\n};\n\nexport const NSWrapper = styled.div`\n display: flex;\n width: 100%;\n padding: 5px 10px;\n align-items: center;\n gap: 10px;\n // position: absolute;\n // right: 84px;\n // top: 181px;\n border-radius: 6px;\n border: 1px solid rgb(237, 235, 232);\n background: rgb(248, 250, 252);\n margin-bottom: 14px;\n\n .left {\n display: flex;\n padding-right: 10px;\n align-items: center;\n gap: 5px;\n align-self: stretch;\n color: #3a3630;\n font-feature-settings: 'liga' off, 'clig' off;\n font-family: Roboto;\n font-size: 13px;\n font-style: normal;\n font-weight: 500;\n line-height: normal;\n text-transform: uppercase;\n }\n\n .left-end {\n display: flex;\n padding-right: 10px;\n align-items: center;\n gap: 5px;\n align-self: stretch;\n border-right: 1px solid #e2e0db;\n }\n\n .section {\n display: flex;\n align-items: center;\n gap: 30px;\n flex: 1 0 0;\n\n input {\n display: flex;\n height: 28px;\n padding: 3px 10px;\n align-items: center;\n gap: 8px;\n flex: 1 0 0;\n border-radius: 30px;\n border: 1px solid #ccc;\n background: #fff;\n }\n }\n`;\n\nconst StyleCheckbox = styled(Checkbox)`\n &:disabled {\n background-color: gray;\n cursor: not-allowed;\n opacity: -0.4;\n }\n`;\n\nconst StyledCancelationModal = styled(CancelationModal)`\n div {\n & > div > div:first-child {\n padding: 8px !important;\n }\n }\n svg {\n width: 28px !important;\n height: 28px !important;\n }\n`;\n\nconst CustomCancelAndCompleteAction = styled(CancelAndCompleteAction)`\n justify-content: center;\n`;\n\nexport default ReturnProductTable;\n"],"names":["ReturnProductTable","props","selectedProducts","setSelectedProducts","useSelectedProducts","selectAll","setSelectAll","useState","productData","setProductData","useProductDetails","selectedRowId","setSelectedRowId","orderId","useOrderId","returnOrderData","useNewReturnOrderData","isNorthSouth","useIsShowNorthSouth","isClientPortal","useClientPortal","productToDelete","setProductToDelete","isDeleteModalOpen","setIsDeleteModalOpen","deleteLoading","callDeleteProduct","useAxios","handleOpenDeleteModal","id","handleConfirmDelete","targetId","response","notification","error","handleCancelDelete","handleSelectAll","allProductIds","product","handleSelectProduct","prevSelected","selectedId","disableCheckbox","jsx","StyledTableWrapper","StyledTable","StyleCheckbox","Skeleton","EmptyDataContainer","Empty","jsxs","React","NavLink","displayValueOrNA","service","e","ActionIcon","NSWrapper","CustomInput","Spin","StyledCancelationModal","CustomCancelAndCompleteAction","styled","Checkbox","CancelationModal","CancelAndCompleteAction"],"mappings":";;;;;;;;;;;;AAiCA,MAAMA,KAAqB,CAACC,MAAiB;AAC3C,QAAM,CAACC,GAAkBC,CAAmB,IAAIC,EAAA,GAC1C,CAACC,GAAWC,CAAY,IAAIC,EAAS,EAAK,GAC1C,CAACC,GAAaC,EAAc,IAAIC,EAAA,GAChC,CAACC,IAAeC,EAAgB,IAAIL,EAAwB,IAAI,GACh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d,UAAA,gBAAAkB;AAAA,MAACiB;AAAA,MAAA;AAAA,QACC,OAAM;AAAA,QACN,aAAY;AAAA,QACZ,SACE,gBAAAjB;AAAA,UAACkB;AAAA,UAAA;AAAA,YACC,aAAY;AAAA,YACZ,UAAU1B;AAAA,YACV,eAAeV,IAAgB,gBAAgB;AAAA,YAC/C,YAAYA;AAAA,YACZ,YAAYK;AAAA,UAAA;AAAA,QAAA;AAAA,MACd;AAAA,IAAA,EAEJ,CACF;AAAA,EAAA,GAEJ;AAEJ,GAEa2B,IAAYK,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GA2D1BhB,IAAgBgB,EAAOC,CAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAQ/BH,IAAyBE,EAAOE,CAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAYhDH,KAAgCC,EAAOG,CAAuB;AAAA;AAAA;"}
|
|
1
|
+
{"version":3,"file":"ReturnProductTable.js","sources":["../../../../../src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport {\n StyledTable,\n StyledTableWrapper,\n} from '../../../order-daily-overview/return-order-table/return-orders-filters/returnstyles';\nimport {\n CancelAndCompleteAction,\n CancelationModal,\n Checkbox,\n displayValueOrNA,\n useAxios,\n} from '@bjsdistribution/dms-component-library';\nimport ActionIcon from '../../../../assets/icons/ActionIcon';\nimport { useOrderId, useReturnProductDetails } from '../../store';\nimport { ApiResponse } from '../../types';\nimport { Empty, notification, Skeleton, Spin } from 'antd';\nimport {\n useIsShowNorthSouth,\n useNewReturnOrderData,\n useSelectedProducts,\n useClientPortal,\n} from '../../../store';\nimport styled from 'styled-components';\nimport { NavLink } from 'react-router-dom';\nimport { EmptyDataContainer } from '../../order-actions/actions/charge-log';\nimport CustomInput from '../../northern-southern-info/CustomInput';\nimport ChevronDownIcon from '../../../../assets/icons/ChevronDownIcon';\nimport {\n groupProductsByPallet,\n hasAnyPallet,\n PalletGroup,\n toggleGroupSelectionIds,\n} from './palletGrouping';\n\ninterface IPROS {\n callReturnProducts: any;\n loading: boolean;\n locationloading: boolean;\n}\n\nconst ReturnProductTable = (props: IPROS) => {\n const [selectedProducts, setSelectedProducts] = useSelectedProducts();\n const [selectAll, setSelectAll] = useState(false);\n const [productData] = useReturnProductDetails();\n const [orderId] = useOrderId();\n const [returnOrderData] = useNewReturnOrderData();\n const [isNorthSouth] = useIsShowNorthSouth();\n const [isClientPortal] = useClientPortal();\n\n const [productToDelete, setProductToDelete] = useState<number | null>(null);\n const [isDeleteModalOpen, setIsDeleteModalOpen] = useState<boolean>(false);\n\n const { loading: deleteLoading, fetchData: callDeleteProduct } = useAxios<{\n data: ApiResponse[];\n }>({\n endpoint: `v1/return/product/remove/`,\n method: 'POST',\n });\n\n const handleOpenDeleteModal = (id: number) => {\n setProductToDelete(id);\n setIsDeleteModalOpen(true);\n };\n\n const handleConfirmDelete = async () => {\n if (productToDelete === null) return;\n const targetId = productToDelete;\n try {\n const response = (await callDeleteProduct({\n payload: {\n return_order_product_id: targetId,\n return_order_id: +orderId,\n },\n })) as {\n code: number | null;\n error?: string | null;\n data?: any[];\n message?: string;\n };\n\n if (response?.code === 200) {\n notification.success({\n message: 'Success',\n description: response?.message || 'Product deleted successfully.',\n });\n props?.callReturnProducts();\n } else {\n notification.error({\n message: 'Deletion Failed',\n description: response?.message || 'Could not delete the product.',\n });\n }\n } catch (error) {\n console.error('Error deleting product:', error);\n notification.error({\n message: 'Error',\n //@ts-ignore\n description: error?.message || 'An unexpected error occurred.',\n });\n } finally {\n setProductToDelete(null);\n setIsDeleteModalOpen(false);\n }\n };\n\n const handleCancelDelete = () => {\n if (deleteLoading) return;\n setProductToDelete(null);\n setIsDeleteModalOpen(false);\n };\n\n const handleSelectAll = () => {\n if (selectAll) {\n setSelectedProducts([]);\n } else {\n const allProductIds = productData?.map((product: any) => product.id);\n setSelectedProducts(allProductIds);\n }\n setSelectAll(!selectAll);\n };\n\n const handleSelectProduct = (id: number) => {\n setSelectedProducts((prevSelected: any) =>\n prevSelected.includes(id)\n ? prevSelected.filter((selectedId: any) => selectedId !== id)\n : [...prevSelected, id]\n );\n };\n\n const disableCheckbox =\n productData?.length == 0 || returnOrderData?.length == 0;\n\n const columnCount = isClientPortal ? 8 : 9;\n\n const palletGroups = useMemo(() => groupProductsByPallet(productData), [\n productData,\n ]);\n\n /**\n * Orders picked before pallet scanning existed have no pallet IDs at all. Grouping\n * those would render every item under \"re-scan required\", so they keep the flat\n * list — matching the spec's \"one group per distinct pallet ID scanned\".\n */\n const isGrouped = useMemo(() => hasAnyPallet(productData), [productData]);\n\n /** Pallet groups default to collapsed; the No Pallet ID group is always open. */\n const [expandedPallets, setExpandedPallets] = useState<\n Record<string, boolean>\n >({});\n\n /**\n * Moving between return orders re-uses this component (route `/:id`, so no\n * remount), and a pallet_id can legitimately appear on two orders — a whole-pallet\n * split carries it to the new B number. Without this reset, a pallet the user had\n * expanded on the previous order would open expanded on the next one, breaking\n * \"default state: all groups collapsed\".\n */\n useEffect(() => {\n setExpandedPallets({});\n }, [orderId]);\n\n const isGroupExpanded = (group: PalletGroup) =>\n group.isNoPallet || !!expandedPallets[group.key];\n\n const togglePallet = (key: string) =>\n setExpandedPallets(prev => ({ ...prev, [key]: !prev[key] }));\n\n const renderProductRow = (product: any) => (\n <React.Fragment key={product.id}>\n {/* MAIN ROW */}\n <tr className=\"product-row\">\n <td>\n <StyleCheckbox\n checked={selectedProducts?.includes(product?.id)}\n onChange={() => handleSelectProduct(product?.id)}\n disabled={disableCheckbox}\n />\n </td>\n <td>{product?.location || 'N/A'}</td>\n <td>\n <ul style={{ listStyleType: 'none', padding: 0 }}>\n <li\n style={{\n color: '#0099ff',\n fontWeight: 600,\n }}\n >\n <NavLink to={`/orders/view/${product?.order_id}`}>\n {displayValueOrNA(product?.recipient_name)}\n </NavLink>\n </li>\n <li style={{ color: '#888075' }}>\n {displayValueOrNA(product?.postcode)}\n </li>\n </ul>\n </td>\n <td>{product?.code}</td>\n <td>{product?.description}</td>\n <td>{product?.return_reason}</td>\n {!isClientPortal && (\n <td>\n {Array.isArray(product?.product_addon_services) && product?.product_addon_services?.length > 0\n ? product.product_addon_services\n .map((service: any) => service?.service_code || service?.name || service)\n .filter(Boolean)\n .join(', ')\n : Array.isArray(product?.addon_services) && product?.addon_services?.length > 0\n ? product.addon_services\n .map((service: any) => service?.service_code || service?.name || service)\n .filter(Boolean)\n .join(', ')\n : Array.isArray(product?.addon_services_list) && product?.addon_services_list?.length > 0\n ? product.addon_services_list.join(', ')\n : typeof product?.addon_services === 'string' && product?.addon_services.trim() !== ''\n ? product.addon_services\n : 'NA'}\n </td>\n )}\n <td>{product?.part}</td>\n <td>\n <div\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n handleOpenDeleteModal(product?.id);\n }}\n style={{ cursor: 'pointer' }}\n >\n <ActionIcon />\n </div>\n </td>\n </tr>\n\n {/* EXPANDED ROW */}\n {/*\n NOTE: this <td> is not wrapped in a <tr>, which is invalid DOM nesting and\n logs a React validateDOMNesting warning. Left exactly as it was — it only\n affects Northern/Southern Ireland orders and is unrelated to pallet\n grouping, so it belongs in its own ticket rather than this change.\n */}\n {isNorthSouth === true && (\n <td colSpan={columnCount}>\n <NSWrapper>\n <div className=\"left\">Northern/Southern Ireland</div>\n <div className=\"left-end\"></div>\n\n <div className=\"section\">\n <CustomInput\n label=\"Commodity Code\"\n type=\"text\"\n direction=\"row\"\n placeholder=\"Enter Commodity Code\"\n value={\n product?.product_customs_details?.commodity_code || 'NA'\n }\n disabled\n />\n\n <CustomInput\n label=\"Country of Origin\"\n type=\"text\"\n direction=\"row\"\n placeholder=\"Enter Country of Origin\"\n value={\n product?.product_customs_details?.country_of_origin || 'NA'\n }\n disabled\n />\n\n <CustomInput\n label=\"Item Invoice Amount\"\n type=\"number\"\n direction=\"row\"\n placeholder=\"Enter Item Invoice Amount\"\n value={\n product?.product_customs_details?.item_invoice_amount || 0\n }\n disabled\n />\n\n <CustomInput\n label=\"NI Additional Info Codes\"\n type=\"text\"\n direction=\"row\"\n placeholder=\"Enter NI Add Info Codes\"\n value={\n product?.product_customs_details\n ?.ni_additional_information_codes || 'NA'\n }\n disabled\n />\n </div>\n </NSWrapper>\n </td>\n )}\n </React.Fragment>\n );\n\n /**\n * Group-level selection is purely a shortcut for ticking each row in the group —\n * it writes the same `selectedProducts` state and adds no whole-pallet semantics.\n * The pallet_id rules for whole vs partial moves land with Part 2.\n */\n const toggleGroupSelection = (group: PalletGroup, allSelected: boolean) => {\n const groupIds = group.items.map((item: any) => item?.id);\n const nextSelection = toggleGroupSelectionIds(\n selectedProducts,\n groupIds,\n allSelected\n );\n\n setSelectedProducts(nextSelection);\n // Keep the header select-all in step, or ticking every group leaves it unchecked.\n setSelectAll(nextSelection.length === productData?.length);\n };\n\n const renderPalletGroup = (group: PalletGroup) => {\n const expanded = isGroupExpanded(group);\n const selectedInGroup = group.items.filter((item: any) =>\n selectedProducts?.includes(item?.id)\n ).length;\n const allSelectedInGroup =\n group.items.length > 0 && selectedInGroup === group.items.length;\n const itemLabel = `${group.items.length} ${\n group.items.length === 1 ? 'item' : 'items'\n }`;\n\n return (\n <React.Fragment key={group.key}>\n <PalletHeaderRow className={group.isNoPallet ? 'no-pallet' : undefined}>\n <td colSpan={columnCount}>\n <PalletHeaderBar>\n {/*\n Sibling of the toggle, not a child of it — a checkbox nested inside\n a <button> is invalid HTML and swallows the click.\n */}\n <StyleCheckbox\n checked={allSelectedInGroup}\n onChange={() => toggleGroupSelection(group, allSelectedInGroup)}\n disabled={disableCheckbox}\n aria-label={\n group.isNoPallet\n ? 'Select all items with no pallet ID'\n : `Select all items on pallet ${group.label}`\n }\n />\n\n <PalletHeaderToggle\n type=\"button\"\n /* The No Pallet ID group is always open, so its toggle is inert. */\n disabled={group.isNoPallet}\n onClick={\n group.isNoPallet ? undefined : () => togglePallet(group.key)\n }\n aria-expanded={group.isNoPallet ? undefined : expanded}\n >\n {!group.isNoPallet && (\n <Chevron $isExpanded={expanded}>\n <ChevronDownIcon />\n </Chevron>\n )}\n\n <span className=\"title\">\n {group.isNoPallet ? (\n <span>No Pallet ID</span>\n ) : (\n <>\n <span>Pallet ID:</span>\n <strong>{group.label}</strong>\n </>\n )}\n </span>\n\n <span className=\"count\">({itemLabel})</span>\n\n {group.depotLocation && (\n <span className=\"depot\">{group.depotLocation}</span>\n )}\n\n {selectedInGroup > 0 && (\n <span className=\"selected\">{selectedInGroup} selected</span>\n )}\n\n {!group.isNoPallet && (\n <ToggleGlyph aria-hidden=\"true\">\n {expanded ? '−' : '+'}\n </ToggleGlyph>\n )}\n </PalletHeaderToggle>\n </PalletHeaderBar>\n </td>\n </PalletHeaderRow>\n\n {expanded && group.items.map((item: any) => renderProductRow(item))}\n </React.Fragment>\n );\n };\n\n return (\n <div>\n <StyledTableWrapper id=\"tableScrolling\" className=\"orderProductTable\">\n <StyledTable>\n <thead>\n <tr>\n <th className=\"emailproductsCheckbox\">\n <StyleCheckbox\n disabled={disableCheckbox}\n checked={selectAll}\n onChange={handleSelectAll}\n />\n </th>\n <th>Location</th>\n <th>Sender</th>\n <th>Code</th>\n <th>Description</th>\n <th>Return Reason</th>\n {!isClientPortal && <th>Additional Services</th>}\n <th>Part</th>\n <th>Action</th>\n </tr>\n </thead>\n <tbody>\n {props?.loading || props?.locationloading ? (\n <tr>\n <td colSpan={columnCount}>\n <Skeleton active />\n </td>\n </tr>\n ) : productData?.length === 0 ? (\n <tr>\n <td colSpan={columnCount}>\n <EmptyDataContainer>\n <Empty />\n </EmptyDataContainer>\n </td>\n </tr>\n ) : isGrouped ? (\n palletGroups.map(renderPalletGroup)\n ) : (\n /* Called explicitly so `map`'s index is not passed as `isNoPallet`. */\n productData?.map((product: any) => renderProductRow(product))\n )}\n </tbody>\n </StyledTable>\n </StyledTableWrapper>\n\n {isDeleteModalOpen && (\n <Spin spinning={deleteLoading}>\n <StyledCancelationModal\n title=\"Remove Product\"\n description=\"Are you sure, you want to remove this order product for returns?\"\n actions={\n <CustomCancelAndCompleteAction\n cancelLabel=\"Cancel\"\n onCancel={handleCancelDelete}\n completeLabel={deleteLoading ? 'REMOVING...' : 'Confirm'}\n isDisabled={deleteLoading}\n onComplete={handleConfirmDelete}\n />\n }\n />\n </Spin>\n )}\n </div>\n );\n};\n\nexport const NSWrapper = styled.div`\n display: flex;\n width: 100%;\n padding: 5px 10px;\n align-items: center;\n gap: 10px;\n // position: absolute;\n // right: 84px;\n // top: 181px;\n border-radius: 6px;\n border: 1px solid rgb(237, 235, 232);\n background: rgb(248, 250, 252);\n margin-bottom: 14px;\n\n .left {\n display: flex;\n padding-right: 10px;\n align-items: center;\n gap: 5px;\n align-self: stretch;\n color: #3a3630;\n font-feature-settings: 'liga' off, 'clig' off;\n font-family: Roboto;\n font-size: 13px;\n font-style: normal;\n font-weight: 500;\n line-height: normal;\n text-transform: uppercase;\n }\n\n .left-end {\n display: flex;\n padding-right: 10px;\n align-items: center;\n gap: 5px;\n align-self: stretch;\n border-right: 1px solid #e2e0db;\n }\n\n .section {\n display: flex;\n align-items: center;\n gap: 30px;\n flex: 1 0 0;\n\n input {\n display: flex;\n height: 28px;\n padding: 3px 10px;\n align-items: center;\n gap: 8px;\n flex: 1 0 0;\n border-radius: 30px;\n border: 1px solid #ccc;\n background: #fff;\n }\n }\n`;\n\nconst PalletHeaderRow = styled.tr`\n > td {\n padding: 0;\n border: none;\n }\n\n /*\n Spec: the No Pallet ID group must be separated from the palletised groups by\n a divider line. Neutral rule only — the rows themselves keep their normal\n background, and the header keeps the same design as the pallet headers.\n */\n &.no-pallet > td {\n border-top: 1px solid #c9c6c1;\n padding-top: 10px;\n }\n`;\n\n/** Carries the header's frame so the checkbox can sit outside the toggle button. */\nconst PalletHeaderBar = styled.div`\n /*\n The library Checkbox renders its real <input> as position:absolute with no\n offsets, so it needs a positioned ancestor or the click target drifts away\n from the visible box as the table scrolls. The shared table CSS happens to\n position td already; pinning it here too so this does not depend on that.\n */\n position: relative;\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n padding: 8px 12px;\n border: 1px solid #e2e0db;\n border-radius: 6px;\n background: #f1f5f9;\n font-family: 'Roboto', sans-serif;\n font-size: 13px;\n font-weight: 500;\n color: #3a3630;\n\n &:hover {\n background: #e7edf4;\n }\n\n`;\n\nconst PalletHeaderToggle = styled.button`\n display: flex;\n align-items: center;\n gap: 8px;\n flex: 1;\n padding: 0;\n border: none;\n background: transparent;\n cursor: pointer;\n text-align: left;\n font: inherit;\n color: inherit;\n\n &:disabled {\n cursor: default;\n /* Inert, but must not read as a greyed-out disabled control. */\n opacity: 1;\n }\n\n .title {\n display: flex;\n align-items: center;\n gap: 6px;\n text-transform: uppercase;\n letter-spacing: 0.3px;\n\n strong {\n font-weight: 700;\n text-transform: none;\n letter-spacing: 0;\n }\n }\n\n .count {\n color: #6a7378;\n font-weight: 400;\n }\n\n .depot {\n color: #888075;\n font-weight: 400;\n font-size: 12px;\n }\n\n .selected {\n color: #0099ff;\n font-weight: 600;\n font-size: 12px;\n }\n\n`;\n\nconst Chevron = styled.span<{ $isExpanded: boolean }>`\n display: inline-flex;\n align-items: center;\n transition: transform 0.15s ease-in-out;\n transform: rotate(${props => (props.$isExpanded ? '0deg' : '-90deg')});\n`;\n\nconst ToggleGlyph = styled.span`\n margin-left: auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n border: 1px solid #cbd5e1;\n border-radius: 4px;\n background: #fff;\n font-size: 14px;\n line-height: 1;\n color: #475569;\n`;\n\nconst StyleCheckbox = styled(Checkbox)`\n &:disabled {\n background-color: gray;\n cursor: not-allowed;\n opacity: -0.4;\n }\n`;\n\nconst StyledCancelationModal = styled(CancelationModal)`\n div {\n & > div > div:first-child {\n padding: 8px !important;\n }\n }\n svg {\n width: 28px !important;\n height: 28px !important;\n }\n`;\n\nconst CustomCancelAndCompleteAction = styled(CancelAndCompleteAction)`\n justify-content: center;\n`;\n\nexport default ReturnProductTable;\n"],"names":["ReturnProductTable","props","selectedProducts","setSelectedProducts","useSelectedProducts","selectAll","setSelectAll","useState","productData","useReturnProductDetails","orderId","useOrderId","returnOrderData","useNewReturnOrderData","isNorthSouth","useIsShowNorthSouth","isClientPortal","useClientPortal","productToDelete","setProductToDelete","isDeleteModalOpen","setIsDeleteModalOpen","deleteLoading","callDeleteProduct","useAxios","handleOpenDeleteModal","id","handleConfirmDelete","targetId","response","notification","error","handleCancelDelete","handleSelectAll","allProductIds","product","handleSelectProduct","prevSelected","selectedId","disableCheckbox","columnCount","palletGroups","useMemo","groupProductsByPallet","isGrouped","hasAnyPallet","expandedPallets","setExpandedPallets","useEffect","isGroupExpanded","group","togglePallet","key","prev","renderProductRow","jsxs","React","jsx","StyleCheckbox","NavLink","displayValueOrNA","service","e","ActionIcon","NSWrapper","CustomInput","toggleGroupSelection","allSelected","groupIds","item","nextSelection","toggleGroupSelectionIds","renderPalletGroup","expanded","selectedInGroup","allSelectedInGroup","itemLabel","PalletHeaderRow","PalletHeaderBar","PalletHeaderToggle","Chevron","ChevronDownIcon","Fragment","ToggleGlyph","StyledTableWrapper","StyledTable","Skeleton","EmptyDataContainer","Empty","Spin","StyledCancelationModal","CustomCancelAndCompleteAction","styled","Checkbox","CancelationModal","CancelAndCompleteAction"],"mappings":";;;;;;;;;;;;;;AAwCA,MAAMA,KAAqB,CAACC,MAAiB;AAC3C,QAAM,CAACC,GAAkBC,CAAmB,IAAIC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kBe,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAkBzBd,KAAkBc,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GA2BzBb,KAAqBa,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAoD5BZ,KAAUY,EAAO;AAAA;AAAA;AAAA;AAAA,sBAID,CAAA3F,MAAUA,EAAM,cAAc,SAAS,QAAS;AAAA,GAGhEkF,KAAcS,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAerBlC,IAAgBkC,EAAOC,CAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAQ/BH,KAAyBE,EAAOE,CAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAYhDH,KAAgCC,EAAOG,EAAuB;AAAA;AAAA;"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const i = "__no_pallet__", r = (t) => t?.pallet_info?.alias || t?.pallet_id, c = (t, a) => {
|
|
2
|
+
const o = t.createdAt ? new Date(t.createdAt).getTime() : NaN, n = a.createdAt ? new Date(a.createdAt).getTime() : NaN, e = !Number.isNaN(o), l = !Number.isNaN(n);
|
|
3
|
+
return e && l && o !== n ? o - n : e !== l ? e ? -1 : 1 : t.label.localeCompare(a.label, void 0, { numeric: !0 });
|
|
4
|
+
}, u = (t) => (t ?? []).some((a) => !!a?.pallet_id), d = (t, a, o) => {
|
|
5
|
+
const n = t ?? [], e = a ?? [];
|
|
6
|
+
return o ? n.filter((l) => !e.includes(l)) : [...n, ...e.filter((l) => !n.includes(l))];
|
|
7
|
+
}, p = (t) => {
|
|
8
|
+
const a = /* @__PURE__ */ new Map(), o = [];
|
|
9
|
+
(t ?? []).forEach((e) => {
|
|
10
|
+
const l = e?.pallet_id;
|
|
11
|
+
if (!l) {
|
|
12
|
+
o.push(e);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const s = a.get(l);
|
|
16
|
+
if (s) {
|
|
17
|
+
s.items.push(e);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
a.set(l, {
|
|
21
|
+
key: l,
|
|
22
|
+
palletId: l,
|
|
23
|
+
label: r(e),
|
|
24
|
+
depotLocation: e?.pallet_info?.depot_location ?? null,
|
|
25
|
+
createdAt: e?.pallet_info?.created_at ?? null,
|
|
26
|
+
items: [e],
|
|
27
|
+
isNoPallet: !1
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
const n = Array.from(a.values()).sort(c);
|
|
31
|
+
return o.length > 0 && n.push({
|
|
32
|
+
key: i,
|
|
33
|
+
palletId: null,
|
|
34
|
+
label: "No Pallet ID",
|
|
35
|
+
depotLocation: null,
|
|
36
|
+
createdAt: null,
|
|
37
|
+
items: o,
|
|
38
|
+
isNoPallet: !0
|
|
39
|
+
}), n;
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
i as NO_PALLET_KEY,
|
|
43
|
+
p as groupProductsByPallet,
|
|
44
|
+
u as hasAnyPallet,
|
|
45
|
+
d as toggleGroupSelectionIds
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=palletGrouping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"palletGrouping.js","sources":["../../../../../src/components/order-view/return-client-products/product-table/palletGrouping.ts"],"sourcesContent":["export const NO_PALLET_KEY = '__no_pallet__';\n\nexport interface PalletGroup {\n /** Grouping key — the raw `pallet_id`, or NO_PALLET_KEY for unpalletised items. */\n key: string;\n palletId: string | null;\n /** Warehouse-facing pallet ID (`pallet_info.alias`), falling back to the raw id. */\n label: string;\n depotLocation: string | null;\n createdAt: string | null;\n items: any[];\n isNoPallet: boolean;\n}\n\n/**\n * Items are grouped by `pallet_id` (a UUID) but labelled with `pallet_info.alias`,\n * which is the short ID the warehouse prints from Toolbox and scans against.\n */\nconst palletLabel = (product: any) =>\n product?.pallet_info?.alias || product?.pallet_id;\n\n/** Scan order (`pallet_info.created_at`) reads most naturally for the warehouse. */\nconst comparePalletGroups = (a: PalletGroup, b: PalletGroup) => {\n const aTime = a.createdAt ? new Date(a.createdAt).getTime() : NaN;\n const bTime = b.createdAt ? new Date(b.createdAt).getTime() : NaN;\n const aValid = !Number.isNaN(aTime);\n const bValid = !Number.isNaN(bTime);\n\n if (aValid && bValid && aTime !== bTime) return aTime - bTime;\n // Pallets with no scan timestamp sort after those that have one.\n if (aValid !== bValid) return aValid ? -1 : 1;\n\n // `numeric` keeps numeric aliases in human order (1234 before 1235, 2 before 10).\n return a.label.localeCompare(b.label, undefined, { numeric: true });\n};\n\nexport const hasAnyPallet = (products: any[]) =>\n (products ?? []).some((product: any) => !!product?.pallet_id);\n\n/**\n * Adds or removes a whole group's item ids from the current selection. Purely a\n * shortcut for ticking each row — it carries no whole-pallet split semantics.\n */\nexport const toggleGroupSelectionIds = (\n currentSelection: any[],\n groupIds: any[],\n allSelected: boolean\n): any[] => {\n const current = currentSelection ?? [];\n const ids = groupIds ?? [];\n\n if (allSelected) {\n return current.filter((id: any) => !ids.includes(id));\n }\n\n // Union, so an already-selected item is never duplicated in the move payload.\n return [...current, ...ids.filter((id: any) => !current.includes(id))];\n};\n\n/**\n * Groups return-order products into one group per distinct pallet ID, ordered by\n * scan time, with any unpalletised items collected into a trailing group.\n */\nexport const groupProductsByPallet = (products: any[]): PalletGroup[] => {\n const groups = new Map<string, PalletGroup>();\n const unpalletised: any[] = [];\n\n (products ?? []).forEach((product: any) => {\n const palletId = product?.pallet_id;\n\n if (!palletId) {\n unpalletised.push(product);\n return;\n }\n\n const existing = groups.get(palletId);\n if (existing) {\n existing.items.push(product);\n return;\n }\n\n groups.set(palletId, {\n key: palletId,\n palletId,\n label: palletLabel(product),\n depotLocation: product?.pallet_info?.depot_location ?? null,\n createdAt: product?.pallet_info?.created_at ?? null,\n items: [product],\n isNoPallet: false,\n });\n });\n\n const ordered = Array.from(groups.values()).sort(comparePalletGroups);\n\n if (unpalletised.length > 0) {\n ordered.push({\n key: NO_PALLET_KEY,\n palletId: null,\n label: 'No Pallet ID',\n depotLocation: null,\n createdAt: null,\n items: unpalletised,\n isNoPallet: true,\n });\n }\n\n return ordered;\n};\n"],"names":["NO_PALLET_KEY","palletLabel","product","comparePalletGroups","a","b","aTime","bTime","aValid","bValid","hasAnyPallet","products","toggleGroupSelectionIds","currentSelection","groupIds","allSelected","current","ids","id","groupProductsByPallet","groups","unpalletised","palletId","existing","ordered"],"mappings":"AAAO,MAAMA,IAAgB,iBAkBvBC,IAAc,CAACC,MACnBA,GAAS,aAAa,SAASA,GAAS,WAGpCC,IAAsB,CAACC,GAAgBC,MAAmB;AAC9D,QAAMC,IAAQF,EAAE,YAAY,IAAI,KAAKA,EAAE,SAAS,EAAE,QAAA,IAAY,KACxDG,IAAQF,EAAE,YAAY,IAAI,KAAKA,EAAE,SAAS,EAAE,QAAA,IAAY,KACxDG,IAAS,CAAC,OAAO,MAAMF,CAAK,GAC5BG,IAAS,CAAC,OAAO,MAAMF,CAAK;AAElC,SAAIC,KAAUC,KAAUH,MAAUC,IAAcD,IAAQC,IAEpDC,MAAWC,IAAeD,IAAS,KAAK,IAGrCJ,EAAE,MAAM,cAAcC,EAAE,OAAO,QAAW,EAAE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