\r\n \r\n {!isAddNewAddress ? (\r\n \r\n \r\n \r\n {showIossNumber && (\r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n {formikValues.applyIossNumber === 'true' && showIossNumber ? (\r\n \r\n \r\n \r\n ) : null}\r\n \r\n ) : null}\r\n \r\n \r\n );\r\n};\r\n\r\nAddDetailsForCustomDeclaration.propTypes = {\r\n formField: PropTypes.object,\r\n};\r\n\r\nconst applyIOSSOption = [\r\n {\r\n value: 'true',\r\n label: 'Yes',\r\n },\r\n {\r\n value: 'false',\r\n label: 'No',\r\n },\r\n];\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n fromPreviewSummary: state.loadedFrom.loadedFrom,\r\n iossProduct: state.addShipmentData.iossValueLimits,\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, null)(AddDetailsForCustomDeclaration);\r\n","import React, { useEffect } from 'react';\r\nimport { Grid } from '@material-ui/core';\r\nimport FormRenderer from '../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport PropTypes from 'prop-types';\r\nimport { setDropdownValues } from '../../../../utils/helperFunctions';\r\nimport { connect } from 'react-redux';\r\n\r\nconst BasicDeclaration = (props) => {\r\n const {\r\n formField: { descriptionOfGoods, customDeclarationCurrency, customDeclarationValue },\r\n setFieldValue,\r\n currencies,\r\n fromPreviewSummary,\r\n } = props;\r\n\r\n const setDefaultValues = (key, value) => {\r\n setFieldValue(key, value);\r\n };\r\n\r\n useEffect(() => {\r\n const dropDownValue = setDropdownValues(currencies, 'code', 'GBP');\r\n setDefaultValues('customDeclarationCurrency', dropDownValue ? dropDownValue : '');\r\n if ((fromPreviewSummary || {}).loadedFrom === 'fromPreviewSummary') {\r\n setFieldValue(\r\n 'customDeclarationCurrency',\r\n setDropdownValues(\r\n currencies,\r\n 'code',\r\n ((fromPreviewSummary.loadedResponse || {}).customDeclarationCurrency || {}).code,\r\n ),\r\n );\r\n }\r\n }, [currencies, fromPreviewSummary]);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nBasicDeclaration.propTypes = {\r\n setFieldValue: PropTypes.func,\r\n currencies: PropTypes.array,\r\n};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n fromPreviewSummary: state.loadedFrom.loadedFrom,\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, null)(BasicDeclaration);\r\n","import React, { useEffect, useState } from 'react';\r\nimport { connect, useSelector } from 'react-redux';\r\nimport { Grid } from '@material-ui/core';\r\nimport FormRenderer from '../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport PropTypes from 'prop-types';\r\nimport { setDropdownValues } from '../../../../utils/helperFunctions';\r\n\r\nconst ShippingDetails = (props) => {\r\n const {\r\n formField: {\r\n customDeclarationShippingCharges,\r\n customDeclarationCurrency,\r\n customDeclarationShippersEoriNo,\r\n customDeclarationReceiversEoriNo,\r\n reasonForExport,\r\n fdaRegistrationNumber,\r\n },\r\n setFieldValue,\r\n currencies,\r\n fromPreviewSummary,\r\n formikValues,\r\n isAddNewAddress,\r\n reasonsForExport,\r\n } = props;\r\n\r\n const [shippingChargesProps, setShippingChargesProps] = useState(customDeclarationShippingCharges.props);\r\n const [_customDeclarationCurrency, setcustomDeclarationCurrency] = useState(currencies);\r\n\r\n useEffect(() => {\r\n // if (formikValues.customDeclarationShippersEoriNo ) {\r\n // setFieldValue('customDeclarationShippersEoriNo', formikValues.customDeclarationShippersEoriNo);\r\n // } else {\r\n setFieldValue(\r\n // 'customDeclarationShippersEoriNo',\r\n // formikValues.accountNumber?.customsRegistration?.eoriNumber || '',\r\n 'customDeclarationShippersEoriNo', (fromPreviewSummary || {}).loadedFrom === 'fromPreviewSummary' ?fromPreviewSummary.loadedResponse?.customDeclarationShippersEoriNo : formikValues.accountNumber?.customsRegistration?.eoriNumber || ''\r\n );\r\n // }\r\n }, [formikValues.accountNumber, setFieldValue]);\r\n\r\n useEffect(() => {\r\n if (props.formikValues.destinationCountry.iossApplies) {\r\n let _filterCurrency = currencies.filter((obj) => obj.code == 'GBP' || obj.code == 'EUR');\r\n setcustomDeclarationCurrency(_filterCurrency);\r\n } else {\r\n setcustomDeclarationCurrency(currencies);\r\n }\r\n const dropDownValue = setDropdownValues(currencies, 'code', 'GBP');\r\n setFieldValue('customDeclarationCurrency', dropDownValue ? dropDownValue : '');\r\n }, [props.formikValues.destinationCountry, currencies]);\r\n\r\n useEffect(() => {\r\n if (fromPreviewSummary && (fromPreviewSummary || {}).loadedFrom === 'fromPreviewSummary') {\r\n setFieldValue(\r\n 'customDeclarationCurrency',\r\n setDropdownValues(\r\n _customDeclarationCurrency,\r\n 'code',\r\n fromPreviewSummary.loadedResponse?.customDeclarationCurrency?.code,\r\n ),\r\n );\r\n } else if (fromPreviewSummary && (fromPreviewSummary || {}).loadedFrom === 'dropdownResponse') {\r\n setFieldValue(\r\n 'customDeclarationCurrency',\r\n setDropdownValues(\r\n _customDeclarationCurrency,\r\n 'code',\r\n fromPreviewSummary.loadedResponse?.shipments?.[0]?.shipmentDetails?.currency\r\n ? fromPreviewSummary.loadedResponse?.shipments?.[0]?.shipmentDetails?.currency\r\n : 'GBP',\r\n ),\r\n );\r\n }\r\n }, [currencies, fromPreviewSummary, _customDeclarationCurrency]);\r\n\r\n useEffect(() => {\r\n const shippingChargesLabel = `${shippingChargesProps.label.split('(')[0]}(${\r\n props.formikValues.customDeclarationCurrency?.code || ''\r\n })`;\r\n setShippingChargesProps({ ...shippingChargesProps, label: shippingChargesLabel });\r\n }, [props.formikValues.customDeclarationCurrency]);\r\n\r\n useEffect(() => {\r\n if (formikValues.accountNumber) {\r\n const accountFdaNumber =\r\n formikValues.accountNumber?.customsRegistration?.fdaNumber === null ||\r\n formikValues.accountNumber?.customsRegistration?.fdaNumber === undefined\r\n ? ''\r\n : formikValues.accountNumber?.customsRegistration?.fdaNumber;\r\n setFieldValue('FDARegistrationNumber', accountFdaNumber);\r\n }\r\n }, [formikValues.accountNumber, setFieldValue]);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n {\r\n if (/^\\d+(\\.\\d{0,2})?$/.test(value)) {\r\n setFieldValue('customDeclarationShippingCharges', value);\r\n } else if (value === '') {\r\n setFieldValue('customDeclarationShippingCharges', '');\r\n }\r\n }}\r\n fullWidth\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {!isAddNewAddress ? (\r\n \r\n ) : null}\r\n \r\n {!isAddNewAddress ? (\r\n \r\n \r\n \r\n ) : null}\r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nShippingDetails.propTypes = {\r\n setFieldValue: PropTypes.func,\r\n currencies: PropTypes.array,\r\n};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n fromPreviewSummary: state.loadedFrom.loadedFrom,\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, null)(ShippingDetails);\r\n","import React, { useEffect, useRef, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, IconButton, SvgIcon, Tooltip } from '@material-ui/core';\r\nimport { Form, Formik } from 'formik';\r\nimport { getYupSchemaFromMetaData } from '../../../../../utils/yupSchema/yupSchemaGenerator';\r\nimport FormRenderer from '../../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport './addCommodityDetails.scss';\r\nimport InputButton from '../../../../../framework/Inputs/inputButton/inputButton';\r\nimport { GET } from '../../../../../api/axios';\r\nimport { ReactComponent as InfoIcon } from '../../../../../assets/images/InfoIcon.svg';\r\nimport { dynamicSort } from '../../../../../utils/helperFunctions';\r\nimport { ServiceEndPoints } from '../../../../../utils/constants/ApiConstant';\r\n\r\nconst AddCommodityDetails = (props) => {\r\n const {\r\n addNewCommodityDetails,\r\n updateCommodityDetails,\r\n marketPlacesList,\r\n isMarketplacesCommodity,\r\n data: { operationType, rowDetails, index, totalWeight },\r\n } = props;\r\n\r\n const countryDetails = { ...(rowDetails || {}).countryOfOrigin };\r\n const formField = getFormField(totalWeight);\r\n\r\n const validationSchema = getYupSchemaFromMetaData(formField, [], [], [['quantity', 'weight']]);\r\n const emptyValues = {\r\n commodityCode: '',\r\n fullDescriptionOfGoods: '',\r\n weight: '',\r\n quantity: '',\r\n unitValue: '',\r\n countryOfOrigin: '',\r\n skuNumber: '',\r\n marketplaceChannel: '',\r\n };\r\n\r\n const [countries, setCountries] = useState([]);\r\n const [disblebtn, setdisblebtn] = useState(false);\r\n const [initialValues, setInitialValues] = useState(\r\n operationType === 'updateCommodityDetails' ? rowDetails : emptyValues,\r\n );\r\n\r\n const formikRef = useRef(null);\r\n\r\n // const debounced = useDebouncedCallback((value) => {\r\n // fetchCommodityDetails(value);\r\n // }, 500);\r\n const isFormValid = (errors) => {\r\n // const {...restControls } = errors;\r\n if(!isMarketplacesCommodity)\r\n {\r\n delete errors.skuNumber;\r\n delete errors.marketplaceChannel;\r\n }\r\n return Object.keys(errors).length === 0;\r\n };\r\n const handleSubmit = async (values, actions) => {\r\n if (operationType === 'updateCommodityDetails') {\r\n updateCommodityDetails(index, values);\r\n } else {\r\n addNewCommodityDetails(values);\r\n }\r\n };\r\n\r\n const getCountry = (countryCode) => {\r\n return countries.find((country) => country.code === countryCode);\r\n };\r\n\r\n useEffect(() => {\r\n if (operationType === 'updateCommodityDetails') {\r\n let existingValues = { ...rowDetails };\r\n existingValues['countryOfOrigin'] = getCountry((countryDetails || {}).code);\r\n setInitialValues(existingValues);\r\n } else {\r\n emptyValues['countryOfOrigin'] = getCountry('GBR');\r\n setInitialValues(emptyValues);\r\n }\r\n }, [countries, operationType, rowDetails]);\r\n\r\n useEffect(() => {\r\n // eslint-disable-next-line new-cap\r\n GET(ServiceEndPoints.getCountries)\r\n .then((res) => {\r\n setCountries(res.data.countries.sort(dynamicSort('name')));\r\n })\r\n .catch((err) => {\r\n setCountries([]);\r\n });\r\n }, []);\r\n\r\n // const fetchCommodityDetails = (commodityCode) => {\r\n // GET(`${ServiceEndPoints.commodityCode}?code=${commodityCode}`).catch((err) => {\r\n // formikRef.current.setFieldError('commodityCode', 'Commodity code is invalid');\r\n // });\r\n // };\r\n\r\n const resetbtnForm = async (values,errors) => {\r\n if(isFormValid(errors)){\r\n await setdisblebtn(true);\r\n handleSubmit(values);\r\n }else{\r\n \r\n }\r\n }\r\n const resetCommodityForm = (resetForm, setFieldValue) => {\r\n resetForm();\r\n setFieldValue('countryOfOrigin', getCountry('GBR'));\r\n };\r\n\r\n return (\r\n \r\n \r\n \r\n {({ values, setFieldValue, errors, resetForm, dirty }) => (\r\n \r\n )}\r\n \r\n \r\n
\r\n );\r\n};\r\n\r\nAddCommodityDetails.propTypes = {};\r\n\r\nexport default AddCommodityDetails;\r\n\r\nconst getFormField = (totalWeight) => {\r\n return {\r\n commodityCode: {\r\n props: {\r\n name: 'commodityCode',\r\n label: 'Commodity code',\r\n type: 'text',\r\n class_Name: 'commodity_Code',\r\n inputProps: {\r\n maxLength: 8,\r\n },\r\n isRequired: true,\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Commodity code is required'],\r\n },\r\n {\r\n type: 'matches',\r\n params: [/^[0-9]{8}$/, 'Commodity code should be a 8 digit number'],\r\n },\r\n {\r\n type: 'max',\r\n params: [8, 'Commodity code should be a 8 digit number'],\r\n },\r\n {\r\n type: 'min',\r\n params: [8, 'Commodity code should be a 8 digit number'],\r\n },\r\n {\r\n type: 'test',\r\n params: [\r\n 'isCommodityCodeValid',\r\n 'Commodity code is invalid',\r\n (value) => {\r\n if (value?.length === 8) {\r\n return new Promise((resolve, reject) => {\r\n GET(`${ServiceEndPoints.commodityCode}?code=${value}`)\r\n .then((res) => {\r\n resolve(true);\r\n })\r\n .catch((err) => {\r\n resolve(false);\r\n });\r\n });\r\n }\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n fullDescriptionOfGoods: {\r\n props: {\r\n name: 'fullDescriptionOfGoods',\r\n label: 'Description of goods',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 50,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [50, 'Maximum of 50 characters are allowed'],\r\n },\r\n {\r\n type: 'required',\r\n params: ['Description of goods is required'],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Minimum 1 character is required'],\r\n },\r\n {\r\n type: 'matches',\r\n params: [/(.*[a-zA-Z0-9$&+,:;=?@#|'<>.^*()%!-]){3}/i, 'Description must be at least 3 non blank characters'],\r\n },\r\n ],\r\n },\r\n },\r\n weight: {\r\n props: {\r\n name: 'weight',\r\n label: 'Net weight (kg)',\r\n type: 'number',\r\n isRequired: true,\r\n inputProps: {\r\n min: 0,\r\n max: 999,\r\n step: 'any',\r\n },\r\n },\r\n validation: {\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Weight is required'],\r\n },\r\n {\r\n type: 'min',\r\n params: [0.01, 'Weight must be greater than 0'],\r\n },\r\n {\r\n type: 'max',\r\n params: [999, 'Weight must be 999 or less'],\r\n },\r\n ],\r\n },\r\n },\r\n quantity: {\r\n props: {\r\n name: 'quantity',\r\n label: 'Quantity',\r\n type: 'number',\r\n isRequired: true,\r\n inputProps: {\r\n max: 999,\r\n min: 1,\r\n },\r\n },\r\n validation: {\r\n validationType: 'number',\r\n name: 'quantity',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Quantity is required'],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Quantity must be greater than or equals to 1'],\r\n },\r\n {\r\n type: 'max',\r\n params: [999, 'Quantity must be 999 or less'],\r\n },\r\n {\r\n type: 'integer',\r\n params: ['Quantity should be a whole number'],\r\n },\r\n ],\r\n },\r\n },\r\n unitValue: {\r\n props: {\r\n name: 'unitValue',\r\n label: 'Unit value',\r\n type: 'number',\r\n isRequired: true,\r\n inputProps: {\r\n min: 0,\r\n max: 1000000,\r\n step: 'any',\r\n },\r\n },\r\n validation: {\r\n validationType: 'number',\r\n name: 'unitValue',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Unit value is required'],\r\n },\r\n {\r\n type: 'max',\r\n params: [10000, 'Unit value must be 10000 or less'],\r\n },\r\n {\r\n type: 'min',\r\n params: [0.01, 'Unit value must be greater than 0'],\r\n },\r\n // {\r\n // type: 'integer',\r\n // params: ['Unit Value should be a whole number'],\r\n // },\r\n ],\r\n },\r\n },\r\n countryOfOrigin: {\r\n props: {\r\n name: 'countryOfOrigin',\r\n label: 'Country of origin',\r\n type: 'select',\r\n displayField: 'name',\r\n isRequired: true,\r\n },\r\n validation: {\r\n validationType: 'object',\r\n name: 'countryOfOrigin',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Country of origin is required'],\r\n },\r\n\r\n {\r\n type: 'max',\r\n params: [2, 'Maximum of 2 characters allowed'],\r\n },\r\n {\r\n type: 'min',\r\n params: [2, 'Minimum of 2 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n\r\n skuNumber: {\r\n props: {\r\n name: 'skuNumber',\r\n label: 'SKU number',\r\n type: 'text',\r\n isRequired: true,\r\n hasDefaultValue: false,\r\n },\r\n validation: {\r\n validationType: 'string',\r\n name: 'skuNumber',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['SKU number is required'],\r\n },\r\n ]\r\n }\r\n },\r\n marketplaceChannel:{\r\n props: {\r\n name: 'marketplaceChannel',\r\n label: 'Marketplace channel',\r\n type: 'select',\r\n displayField: 'marketplaceName',\r\n isRequired: true,\r\n hasDefaultValue: true,\r\n },\r\n validation: {\r\n validationType: 'object',\r\n name: 'marketplaceChannel',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Marketplace channel is required'],\r\n },\r\n ]\r\n }\r\n }\r\n };\r\n};\r\n","import React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { FieldArray } from 'formik';\r\nimport {\r\n Grid,\r\n TableContainer,\r\n Paper,\r\n Table,\r\n TableHead,\r\n TableRow,\r\n TableCell,\r\n TableBody,\r\n TableFooter,\r\n IconButton,\r\n SvgIcon,\r\n} from '@material-ui/core';\r\n\r\nimport { ReactComponent as DeleteIcon } from '../../../../../assets/images/DeleteIcon.svg';\r\nimport { ReactComponent as EditIcon } from '../../../../../assets/images/EditIcon.svg';\r\nimport { ReactComponent as AddIcon } from '../../../../../assets/images/AddIcon.svg';\r\nimport CustomDialog from './../../../../../framework/dialog/customDialog';\r\nimport AddCommodityDetails from '../addCommodityDetails/addCommodityDetails';\r\nimport './commodityDetails.scss';\r\n\r\nconst CommodityDetails = (props) => {\r\n const {\r\n formField: { commodityDetails },\r\n formikValues,\r\n errors,\r\n setFieldValue,\r\n isAddNewAddress,\r\n isOrderDefaults\r\n } = props;\r\n\r\n const [open, setOpen] = React.useState(false);\r\n const [modalData, setModalData] = React.useState({});\r\n const [footerValues, setFooterValues] = React.useState({\r\n subTotal: 0,\r\n totalValue: 0,\r\n });\r\n const [spanIsActive, setspanIsActive] = React.useState(false);\r\n const [commodityWeight, setcommodityWeight] = React.useState(0);\r\n var commodityDetails_weight = 0;\r\n const openAddCommodityDetails = () => {\r\n setModalData({\r\n operationType: 'addCommodityDetails',\r\n totalWeight: formikValues.weight,\r\n });\r\n setOpen(true);\r\n };\r\n\r\n const handleClose = () => {\r\n setOpen(false);\r\n };\r\n\r\n const addNewCommodityDetails = (arrayHelpers, values) => {\r\n arrayHelpers.push(values);\r\n setOpen(false);\r\n };\r\n\r\n const updateCommodityDetails = (arrayHelpers, index, values) => {\r\n arrayHelpers.replace(index, values);\r\n setOpen(false);\r\n };\r\n\r\n const openUpdateCommodityDetails = (index, rowDetails) => {\r\n setModalData({\r\n index,\r\n rowDetails,\r\n operationType: 'updateCommodityDetails',\r\n totalWeight: formikValues.weight,\r\n });\r\n setOpen(true);\r\n };\r\n\r\n const truncateToTwoDecimal=(num)=> Math.floor(num * 100)/100; \r\n\r\n React.useEffect(() => {\r\n let product = 0;\r\n formikValues.commodityDetails.forEach((commodity) => {\r\n product = commodity.quantity * commodity.unitValue + product;\r\n });\r\n const shippingCharges =\r\n isNaN(parseFloat(formikValues.customDeclarationShippingCharges)) ||\r\n parseFloat(formikValues.customDeclarationShippingCharges) < 0\r\n ? 0\r\n : parseFloat(formikValues.customDeclarationShippingCharges);\r\n const totalValue = parseFloat(product + shippingCharges).toFixed(2); //+ parseFloat(shippingCharges).toFixed(2);\r\n setFooterValues({ subTotal: parseFloat(product).toFixed(2), totalValue: parseFloat(totalValue).toFixed(2) });\r\n setFieldValue('subTotal', parseFloat(product).toFixed(2));\r\n setFieldValue('totalValue', parseFloat(totalValue).toFixed(2));\r\n\r\n formikValues.commodityDetails.forEach((commodity) => {\r\n commodityDetails_weight += commodity.quantity * commodity.weight;\r\n commodityDetails_weight = parseFloat(commodityDetails_weight).toFixed(2);\r\n });\r\n setcommodityWeight(commodityDetails_weight);\r\n \r\n if (Number(parseFloat(commodityDetails_weight).toFixed(2)) > Number(parseFloat(formikValues.weight || 0).toFixed(2)) && !isOrderDefaults) {\r\n \r\n setspanIsActive(true);\r\n }\r\n else if(isOrderDefaults && parseFloat(commodityDetails_weight) > (parseFloat(formikValues.weight || 0)*(formikValues.noOfItems || 1))){\r\n setspanIsActive(true);\r\n } else {\r\n setspanIsActive(false);\r\n }\r\n let totalPiecesWeight = 0;\r\n formikValues?.intlParcelDetails?.map((piece)=>{\r\n totalPiecesWeight += parseFloat(piece.weight);\r\n })\r\n if(commodityDetails_weight > (formikValues.weight || 0) && !isOrderDefaults){\r\n setFieldValue(\"totalWeightExceed\",commodityDetails_weight);\r\n }\r\n else if(isOrderDefaults && (commodityDetails_weight > ((formikValues.weight || 0)*formikValues.noOfItems))){\r\n setFieldValue(\"totalWeightExceed\",commodityDetails_weight);\r\n }\r\n else if(totalPiecesWeight > formikValues.weight){\r\n setFieldValue(\"totalWeightExceed\",totalPiecesWeight);\r\n }else{\r\n setFieldValue(\"totalWeightExceed\",formikValues.weight || 0);\r\n }\r\n if(formikValues.reasonForExport?.type === 'documents' && formikValues?.subTotal > 5 ) \r\n {\r\n setspanIsActive(true);\r\n setFieldValue(\"totalWeightExceed\",formikValues.weight+1);\r\n }\r\n }, [formikValues.commodityDetails, formikValues.customDeclarationShippingCharges, formikValues.weight ,formikValues.noOfItems, formikValues.intlParcelDetails, formikValues.reasonForExport, formikValues?.subTotal]);\r\n return (\r\n \r\n
{\r\n const commodityItems = formikValues.commodityDetails;\r\n return (\r\n \r\n \r\n \r\n Item details \r\n \r\n \r\n \r\n 19} onClick={openAddCommodityDetails}>\r\n \r\n \r\n Add new\r\n \r\n \r\n {\r\n addNewCommodityDetails(arrayHelpers, values);\r\n }}\r\n updateCommodityDetails={(index, values) => updateCommodityDetails(arrayHelpers, index, values)}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Commodity code \r\n \r\n \r\n Full description of goods \r\n \r\n \r\n Weight \r\n \r\n \r\n Quantity \r\n \r\n \r\n Unit value \r\n \r\n \r\n Country of origin \r\n \r\n \r\n \r\n \r\n \r\n \r\n {commodityItems.map((row, index) => (\r\n \r\n \r\n {row.commodityCode}\r\n \r\n {row.fullDescriptionOfGoods} \r\n {truncateToTwoDecimal(row.weight)} kg \r\n {row.quantity} \r\n {row.unitValue} \r\n {row.countryOfOrigin?.name} \r\n \r\n openUpdateCommodityDetails(index, row)}>\r\n \r\n \r\n \r\n \r\n arrayHelpers.remove(index)}>\r\n \r\n \r\n \r\n \r\n ))}\r\n \r\n \r\n {!isAddNewAddress ? ( // for add new address screen only one footer value required\r\n <>\r\n {' '}\r\n \r\n Sub total \r\n \r\n \r\n \r\n \r\n \r\n \r\n {footerValues.subTotal} \r\n \r\n \r\n Shipping cost \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {isNaN(formikValues.customDeclarationShippingCharges) ||\r\n parseInt(formikValues.customDeclarationShippingCharges) < 0\r\n ? 0\r\n : formikValues.customDeclarationShippingCharges}\r\n \r\n \r\n >\r\n ) : null}\r\n \r\n \r\n Total value \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {footerValues.totalValue} \r\n \r\n \r\n \r\n
\r\n \r\n { formikValues.reasonForExport?.type === 'documents' && formikValues?.subTotal > 5 ?\r\n \r\n Max sub total allowed for this reason for export is 5.\r\n \r\n : \r\n Total weight: {parseFloat(commodityWeight).toFixed(2)} can not be greater than the declared\r\n weight {!isOrderDefaults ? parseFloat(formikValues.weight || 0).toFixed(2) : (parseFloat(formikValues.weight || 0)*(formikValues.noOfItems || 1)).toFixed(2) } \r\n \r\n }\r\n {errors?.commodityDetails ? {errors.commodityDetails} : null}\r\n \r\n );\r\n }}\r\n />\r\n \r\n );\r\n};\r\n\r\nCommodityDetails.propTypes = {\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n errors: PropTypes.object,\r\n};\r\n\r\nexport default CommodityDetails;\r\n","import React, { useEffect, useState } from 'react';\r\nimport { Grid } from '@material-ui/core';\r\nimport InvoiceTypeDeclaration from '../customsDeclaration/InvoiceTypeDeclaration/InvoiceTypeDeclaration';\r\nimport AddDetailsForCustomDeclaration from '../customsDeclaration/addDetailsForCustomDeclaration/addDetailsForCustomDeclaration';\r\nimport PropTypes from 'prop-types';\r\nimport BasicDeclaration from './basicDeclaration';\r\nimport ShippingDetails from './shippingDetails';\r\nimport './customsDeclaration.scss';\r\nimport CommodityDetails from './commodityDetails/commodityDetails';\r\n\r\nconst CustomsDeclaration = (props) => {\r\n const { isAddNewAddress, setFieldValue, formikValues, internationalProductList, setInternationalProductList, reasonsForExport} = props;\r\n\r\n const [customLevel, setCustomLevel] = useState(false);\r\n\r\n useEffect(() => {\r\n const accountFdaNumber =\r\n (formikValues.accountNumber?.customsRegistration?.fdaNumber === null || formikValues.accountNumber?.customsRegistration?.fdaNumber === undefined)\r\n ? ''\r\n : formikValues.accountNumber?.customsRegistration?.fdaNumber;\r\n setFieldValue('FDARegistrationNumber', accountFdaNumber);\r\n }, [formikValues.accountNumber, setFieldValue]);\r\n\r\n useEffect(() => {\r\n if (formikValues?.destinationCountry?.name === 'Select') {\r\n setCustomLevel(true);\r\n } else {\r\n formikValues.isFullCustomDetails ? setCustomLevel(true) : setCustomLevel(false);\r\n }\r\n }, [formikValues.isFullCustomDetails]);\r\n\r\n return (\r\n \r\n {customLevel ? (\r\n <>\r\n {!isAddNewAddress ? (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n ) : null}\r\n\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n >\r\n ) : (\r\n \r\n )}\r\n \r\n );\r\n};\r\n\r\nCustomsDeclaration.propTypes = {\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n currencies: PropTypes.array,\r\n};\r\n\r\nexport default CustomsDeclaration;\r\n","import React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\nimport Button from '@material-ui/core/Button';\r\nimport Avatar from '@material-ui/core/Avatar';\r\nimport List from '@material-ui/core/List';\r\nimport ListItem from '@material-ui/core/ListItem';\r\nimport ListItemAvatar from '@material-ui/core/ListItemAvatar';\r\nimport ListItemText from '@material-ui/core/ListItemText';\r\nimport DialogTitle from '@material-ui/core/DialogTitle';\r\nimport Dialog from '@material-ui/core/Dialog';\r\nimport PersonIcon from '@material-ui/icons/Person';\r\nimport AddIcon from '@material-ui/icons/Add';\r\nimport Typography from '@material-ui/core/Typography';\r\nimport { blue } from '@material-ui/core/colors';\r\nimport FormRenderer from '../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { SearchIcon } from '@material-ui/data-grid';\r\nimport ClearIcon from '@material-ui/icons/Clear';\r\nimport { Grid, Menu, MenuItem, IconButton, Box, Divider, SvgIcon } from '@material-ui/core';\r\nimport { Children } from 'react';\r\nimport { useSelector } from 'react-redux';\r\n\r\nimport './dialogForTemplate.scss';\r\nconst emails = ['username@gmail.com', 'user02@gmail.com'];\r\nconst useStyles = makeStyles({\r\n root: {\r\n height: '380px',\r\n width: '400px',\r\n marginLeft: '780px',\r\n marginTop: '100px',\r\n },\r\n});\r\n\r\n// function SimpleDialog(props) {\r\n// const classes = useStyles();\r\n// const { onClose, selectedValue, open } = props;\r\n\r\n// const handleClose = () => {\r\n// onClose(selectedValue);\r\n// };\r\n\r\n// const handleListItemClick = (value) => {\r\n// onClose(value);\r\n// };\r\n\r\n// return (\r\n// \r\n// Set backup account \r\n// \r\n// {emails.map((email) => (\r\n// handleListItemClick(email)} key={email}>\r\n// \r\n// \r\n// \r\n// \r\n// \r\n// \r\n// \r\n// ))}\r\n\r\n// handleListItemClick('addAccount')}>\r\n// \r\n// \r\n// \r\n// \r\n// \r\n// \r\n// \r\n//
\r\n// \r\n// );\r\n// }\r\n\r\n// SimpleDialog.propTypes = {\r\n// onClose: PropTypes.func.isRequired,\r\n// open: PropTypes.bool.isRequired,\r\n// selectedValue: PropTypes.string.isRequired,\r\n// };\r\n\r\nexport default function SimpleDialogDemo(props) {\r\n const classes = useStyles();\r\n let alertInfo = useSelector((state) => state.alertInfo.showAlert);\r\n // const { onClose, selectedValue, open, data ,\r\n // formField: { templateSearch },isClearBtn,onClickClear,onClickSearch} = props;\r\n const {\r\n // formField: { templateSearch },\r\n setFieldValue,\r\n setValues,\r\n templateData,\r\n formikValues,\r\n errors,\r\n resetForm,\r\n isDomestic,\r\n backUpResponse,\r\n currencies,\r\n countries,\r\n onClose,\r\n selectedValue,\r\n open,\r\n data,\r\n isClearBtn,\r\n onClickClear,\r\n onClickSearch,\r\n } = props;\r\n\r\n const handleListItemClick = (value) => {\r\n onClose(value);\r\n };\r\n return (\r\n \r\n \r\n {props.children}\r\n \r\n \r\n );\r\n}\r\n","/* eslint-disable multiline-ternary */\r\nimport React, { useEffect, useState } from 'react';\r\nimport { Grid, IconButton } from '@material-ui/core';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport PropTypes from 'prop-types';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { Divider } from '@material-ui/core';\r\nimport { SearchIcon } from '@material-ui/data-grid';\r\nimport List from '@material-ui/core/List';\r\nimport ListItem from '@material-ui/core/ListItem';\r\nimport './addShipment.scss';\r\nimport { KeyboardArrowDown, StarBorderOutlined } from '@material-ui/icons';\r\nimport { useDispatch, useSelector } from 'react-redux';\r\nimport ClearIcon from '@material-ui/icons/Clear';\r\nimport DialogBox from '../../../components/addShipment/templates/dialogForTemplate/dialogForTemplate';\r\nimport { useDebouncedCallback } from 'use-debounce';\r\nimport './favourite.scss';\r\n\r\nimport {\r\n setValuesToDeliveryAddress,\r\n setValuesToForm,\r\n sortBasedOnNestedOrNot\r\n} from '../../../utils/helperFunctions';\r\nimport { UserRoles } from '../../../utils/constants/constants';\r\n\r\nconst Favourite = (props) => {\r\n const {\r\n formField: { favouriteSearchBy },\r\n setFieldValue,\r\n setValues,\r\n favouriteValues,\r\n formikValues,\r\n countries,\r\n // errors,\r\n setCustomerNumber,\r\n currencies,\r\n getFavCustomerList,\r\n favouriteLimit,\r\n setAddressSearchObj,\r\n isAmendShipment,\r\n setIsServicePointAddress,\r\n searchedAddressBookData\r\n } = props;\r\n\r\n // const [anchorEl, setAnchorEl] = React.useState(null);\r\n const [filteredFavourites, setFilteredFavourites] = React.useState([]);\r\n const userDetails = useSelector(state => state.auth.userDetails)\r\n let [isClearBtn, setIsClearBtn] = useState(false);\r\n const [open, setOpen] = React.useState(false);\r\n const dispatch = useDispatch();\r\n const backUpResponse = useSelector((state) => state.backUpResponse);\r\n\r\n const debounced = useDebouncedCallback((value) => {\r\n getFavCustomerList(value);\r\n }, 500);\r\n\r\n const handleClick = () => {\r\n setOpen(true);\r\n };\r\n\r\n const handleClose = () => {\r\n setOpen(false);\r\n setFieldValue('favouriteSearchBy', '');\r\n };\r\n\r\n const handleMenuClick = (favoriteCustomerDetails, setValues) => {\r\n dispatch(actions.setLoaderLayOver(true));\r\n if (\r\n // backUpResponse?.loadedFrom?.loadedFrom === 'template' &&\r\n // backUpResponse?.loadedFrom?.loadedResponse &&\r\n formikValues?.selectedTemplate &&\r\n (favoriteCustomerDetails?.destinationCountry === 'GBR' || favoriteCustomerDetails?.destinationCountry === 'GB')\r\n ) {\r\n setValues({\r\n ...formikValues,\r\n ...setValuesToDeliveryAddress(favoriteCustomerDetails),\r\n });\r\n // setTimeout(() => {\r\n dispatch(\r\n actions.setLoadedFrom({\r\n loadedFrom: 'dropdownResponse',\r\n loadedResponse: { ...backUpResponse.loadedFrom.loadedResponse },\r\n }),\r\n );\r\n setFieldValue('weight', backUpResponse?.loadedFrom?.loadedResponse?.parcelDetails?.weight ?? '');\r\n // }, 0);\r\n } else {\r\n if(formikValues?.handOverMethod === 'servicePoint'){\r\n setIsServicePointAddress(true);\r\n }\r\n setValues(setValuesToForm(favoriteCustomerDetails, formikValues, countries, currencies));\r\n // setTimeout(() => {\r\n dispatch(\r\n actions.setLoadedFrom({ loadedFrom: 'dropdownResponse', loadedResponse: { ...favoriteCustomerDetails } }),\r\n );\r\n setFieldValue('weight', favoriteCustomerDetails?.parcelDetails?.weight ?? '');\r\n // }, 0);\r\n }\r\n dispatch(actions.setBackUpResponse({ loadedFrom: 'favourites', loadedResponse: { ...favoriteCustomerDetails } }));\r\n searchedAddressBookData(favoriteCustomerDetails);\r\n setTimeout(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n dispatch(actions.setLoadedFrom({ loadedFrom: '' }));\r\n }, 5000);\r\n setCustomerNumber(true);\r\n handleClose();\r\n setAddressSearchObj(favoriteCustomerDetails);\r\n };\r\n\r\n const getClear = (event = null, queryParams = '') => {\r\n if (event) {\r\n event.preventDefault();\r\n }\r\n setFieldValue('favouriteSearchBy', '');\r\n getFavCustomerList();\r\n setIsClearBtn(false);\r\n };\r\n\r\n const searchFavourities = (event = null) => {\r\n if (event) {\r\n event.preventDefault();\r\n }\r\n if (formikValues.favouriteSearchBy.trim() !== '') {\r\n setIsClearBtn(true);\r\n debounced(formikValues.favouriteSearchBy);\r\n } else {\r\n setIsClearBtn(false);\r\n debounced(formikValues.favouriteSearchBy);\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n sortBasedOnNestedOrNot(favouriteValues.addressBooks || [], 'deliveryAddress.customerNumber', true);\r\n setFilteredFavourites(favouriteValues.addressBooks || []);\r\n }, [favouriteValues.addressBooks]);\r\n\r\n useEffect(() => {\r\n return () => {\r\n dispatch(actions.setBackUpResponse({ loadedFrom: '', loadedResponse: {} }));\r\n };\r\n }, []);\r\n\r\n useEffect(() => {\r\n searchFavourities();\r\n }, [formikValues.favouriteSearchBy]);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n Favourites
\r\n \r\n \r\n \r\n getClear(event, 'clearField')}\r\n >\r\n \r\n getClear(event, '')}>\r\n \r\n \r\n ) : (\r\n searchFavourities(event)}>\r\n \r\n \r\n ),\r\n }}\r\n fullWidth\r\n />\r\n \r\n \r\n \r\n \r\n \r\n Customer no. \r\n \r\n \r\n Business/contact name \r\n \r\n\r\n {/* */}\r\n \r\n \r\n {filteredFavourites.length > 0 ? (\r\n (filteredFavourites || []).map((customerDetails) => (\r\n \r\n {\r\n handleMenuClick(customerDetails, setValues);\r\n }}\r\n >\r\n \r\n \r\n \r\n {((customerDetails || {}).deliveryAddress || {}).customerNumber}\r\n \r\n \r\n \r\n {((customerDetails || {}).deliveryAddress || {}).businessOrRecipientName}\r\n \r\n {/* */}\r\n \r\n \r\n \r\n \r\n ))\r\n ) : (\r\n \r\n \r\n No favourite found \r\n \r\n \r\n \r\n )}\r\n \r\n
\r\n \r\n \r\n \r\n );\r\n};\r\n\r\nFavourite.propTypes = {\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n setFieldValue: PropTypes.func,\r\n errors: PropTypes.object,\r\n favouriteValues: PropTypes.array,\r\n countries: PropTypes.array,\r\n getFavCustomerList: PropTypes.func,\r\n favouriteLimit: PropTypes.number,\r\n};\r\n\r\nexport default Favourite;\r\n","/* eslint-disable react-hooks/exhaustive-deps */\r\nimport React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, SvgIcon, makeStyles, Tooltip } from '@material-ui/core';\r\nimport FormRenderer from '../../framework/Inputs/formRenderer/formRenderer';\r\nimport { ReactComponent as InfoIcon } from '../../assets/images/InfoIcon.svg';\r\nimport { GET } from '../../api/axios';\r\nimport { useSelector } from 'react-redux';\r\nimport { ServiceEndPoints } from '../../utils/constants/ApiConstant';\r\nimport { getCustomerAccountID } from '../../utils/helperFunctions';\r\nimport { UserRoles } from '../../utils/constants/constants';\r\nconst useStyles = makeStyles((theme) => ({\r\n customTooltip: {\r\n backgroundColor: '#fff',\r\n color: '#000000E6',\r\n fontSize: '14px',\r\n boxShadow: '0px 3px 6px #00000029',\r\n padding: '8px 15px',\r\n borderRadius: '0',\r\n },\r\n customArrow: {\r\n color: '#fff',\r\n },\r\n}));\r\n\r\nconst AddToAddressAndFav = (props) => {\r\n const classes = useStyles();\r\n const {\r\n formikValues,\r\n formField,\r\n customerNumber,\r\n setFieldValue,\r\n addToAddressBookControl,\r\n addToFavControlName,\r\n updateAddressBookControl,\r\n customerNumberControl,\r\n addressSearchObj,\r\n shipmentDetails,\r\n isAmendShipment\r\n } = props;\r\n\r\n const [isInAddressbook, setIsInAddressbook] = useState(false);\r\n const [isInFavourites, setIsInFavourites] = useState(false);\r\n const [disabledFields, setDisabledFields] = useState({\r\n addToAddressBook: false,\r\n updateAddToAddressBook: false,\r\n addToFavCutomerList: false,\r\n });\r\n\r\n const userAccounts = useSelector((state) => state.auth.userDetails);\r\n const loadedFrom = useSelector((state) => state.loadedFrom.loadedFrom);\r\n const userDetails = useSelector(state => state.auth.userDetails);\r\n\r\n useEffect(() => {\r\n if (typeof customerNumber === 'string' && (customerNumber || '').trim().length < 1) {\r\n setFieldValue(addToAddressBookControl, false);\r\n setFieldValue(addToFavControlName, false);\r\n setFieldValue(updateAddressBookControl, false);\r\n setIsInAddressbook(false);\r\n setIsInFavourites(false);\r\n } else if (customerNumber === true) {\r\n setIsInAddressbook(true);\r\n setIsInFavourites(true);\r\n } else {\r\n checkCustomerIfAlreadyExists();\r\n }\r\n }, [customerNumber]);\r\n\r\n const checkCustomerIfAlreadyExists = () => {\r\n GET(\r\n `${ServiceEndPoints.getAddressBook\r\n }?organization=${getCustomerAccountID()}&offSet=0&limit=1&isExactMatch=true&customernumber=${formikValues[customerNumberControl]\r\n }`,\r\n )\r\n .then((res) => {\r\n if (res.data?.addressBooks?.length > 0) {\r\n setIsInAddressbook(true);\r\n addressSearchObj(res.data?.addressBooks[0]);\r\n const record = res.data.addressBooks[0];\r\n if (record?.favouriteUsers?.some((userId) => userId === userAccounts?.userId)) {\r\n setIsInFavourites(true);\r\n } else {\r\n setIsInFavourites(false);\r\n }\r\n } else {\r\n setIsInAddressbook(false);\r\n }\r\n })\r\n .catch((err) => {\r\n addressSearchObj({});\r\n console.log(err);\r\n setIsInAddressbook(false);\r\n setIsInFavourites(false);\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n if (isInAddressbook && !isInFavourites && loadedFrom !== 'fromPreviewSummary') {\r\n setDisabledFields({ ...disabledFields, updateAddToAddressBook: false, addToFavCutomerList: false });\r\n setFieldValue(updateAddressBookControl, false);\r\n setFieldValue(addToFavControlName, false);\r\n setFieldValue(addToAddressBookControl, false);\r\n } else if (isInAddressbook && isInFavourites && loadedFrom !== 'fromPreviewSummary') {\r\n setDisabledFields({ ...disabledFields, updateAddToAddressBook: false, addToFavCutomerList: true });\r\n setFieldValue(updateAddressBookControl, false);\r\n setFieldValue(addToFavControlName, true);\r\n setFieldValue(addToAddressBookControl, false);\r\n } else if (!isInAddressbook && !isInFavourites && loadedFrom !== 'fromPreviewSummary') {\r\n setDisabledFields({ ...disabledFields, addToAddressBook: false, addToFavCutomerList: false });\r\n setFieldValue(addToAddressBookControl, false);\r\n setFieldValue(addToFavControlName, false);\r\n setFieldValue(updateAddressBookControl, false);\r\n }\r\n }, [isInAddressbook, isInFavourites, setFieldValue]);\r\n\r\n useEffect(() => {\r\n if (formikValues[addToFavControlName] && !isInAddressbook) {\r\n setFieldValue(addToAddressBookControl, true);\r\n } else {\r\n setFieldValue(addToAddressBookControl, false);\r\n }\r\n }, [formikValues[addToFavControlName], isInAddressbook, setFieldValue]);\r\n\r\n useEffect(() => {\r\n if (\r\n shipmentDetails &&\r\n shipmentDetails.updateAddToAddressBook &&\r\n formikValues[addToFavControlName] &&\r\n isInAddressbook\r\n ) {\r\n setFieldValue(updateAddressBookControl, true);\r\n } else {\r\n setFieldValue(updateAddressBookControl, false);\r\n }\r\n }, [shipmentDetails, formikValues[addToFavControlName], isInAddressbook, setFieldValue]);\r\n\r\n return (\r\n \r\n {isInAddressbook ? (\r\n \r\n \r\n \r\n ) : (\r\n \r\n \r\n \r\n )}\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nAddToAddressAndFav.propTypes = {};\r\n\r\nexport default AddToAddressAndFav;\r\n","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from \"react\";\n\nvar _ref2 = /*#__PURE__*/React.createElement(\"path\", {\n id: \"Icon_metro-insert-template\",\n \"data-name\": \"Icon metro-insert-template\",\n d: \"M10.394,5.839H13v1.3H10.394Zm3.911,0h2.608v1.3H14.305Zm4.519,0v5.215H16.913v-1.3h.608V7.143h.7v-1.3ZM9.09,9.751H11.7v1.3H9.09Zm3.911,0h2.608v1.3H13ZM8.482,7.143V9.751h-.7v1.3H7.178V5.839H9.09v1.3Zm1.911,6.519H13v1.3H10.394Zm3.911,0h2.608v1.3H14.305Zm4.519,0v5.215H16.913v-1.3h.608V14.966h.7v-1.3ZM9.09,17.574H11.7v1.3H9.09Zm3.911,0h2.608v1.3H13ZM8.482,14.966v2.608h-.7v1.3H7.178V13.662H9.09v1.3ZM22.128,3.232H3.875V21.485H22.128V3.232Zm1.3-1.3V22.789H2.571V1.928H23.432Z\",\n transform: \"translate(-2.071 -1.428)\",\n stroke: \"#000\",\n strokeWidth: 1\n});\n\nfunction SvgTemplateIcon(_ref, svgRef) {\n var title = _ref.title,\n titleId = _ref.titleId,\n props = _objectWithoutProperties(_ref, [\"title\", \"titleId\"]);\n\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 21.861,\n height: 21.861,\n viewBox: \"0 0 21.861 21.861\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, _ref2);\n}\n\nvar ForwardRef = /*#__PURE__*/React.forwardRef(SvgTemplateIcon);\nexport default __webpack_public_path__ + \"static/media/TemplateIcon.fdf15fe7.svg\";\nexport { ForwardRef as ReactComponent };","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from \"react\";\n\nvar _ref2 = /*#__PURE__*/React.createElement(\"defs\", null, /*#__PURE__*/React.createElement(\"style\", null, \".cls-1{fill:#d40511;}\"));\n\nvar _ref3 = /*#__PURE__*/React.createElement(\"path\", {\n id: \"color\",\n className: \"cls-1\",\n d: \"M20,22.14l-9.77,9.77L8.05,29.74,17.83,20,8.05,10.19,10.23,8,20,17.8,29.77,8,32,10.19,22.17,20,32,29.74l-2.18,2.17Z\"\n});\n\nfunction SvgCloseIcon(_ref, svgRef) {\n var title = _ref.title,\n titleId = _ref.titleId,\n props = _objectWithoutProperties(_ref, [\"title\", \"titleId\"]);\n\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n id: \"Layer_1\",\n \"data-name\": \"Layer 1\",\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 40 39.94\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, _ref2, _ref3);\n}\n\nvar ForwardRef = /*#__PURE__*/React.forwardRef(SvgCloseIcon);\nexport default __webpack_public_path__ + \"static/media/closeIcon.fe5633cb.svg\";\nexport { ForwardRef as ReactComponent };","import * as JSPM_V3 from \"jsprintmanager\";\r\nimport * as JSPM_V4 from 'jsprintmanager-4';\r\nimport { GET } from '../api/axios';\r\nimport { ServiceEndPoints } from './constants/ApiConstant';\r\nimport { Base64 } from 'js-base64';\r\nimport { getCustomerAccountID } from './helperFunctions';\r\n\r\nlet JSPM, license_url;\r\n\r\nexport const updateJSPMReference = (jspmVersion) => {\r\n console.log(\"jspmVersion::: \", jspmVersion)\r\n if (jspmVersion === \"3\") {\r\n console.log(\"inside 3\")\r\n JSPM = JSPM_V3;\r\n license_url = ServiceEndPoints.getJSPMLicense_v3;\r\n } else {\r\n console.log(\"inside 4\")\r\n JSPM = JSPM_V4;\r\n license_url = ServiceEndPoints.getJSPMLicense_v4;\r\n }\r\n};\r\n\r\nexport const getJSPMStatus = (dispatch, actions) => {\r\n if (!JSPM) {\r\n JSPM = JSPM_V3;\r\n license_url = ServiceEndPoints.getJSPMLicense_v3;\r\n }\r\n console.log(\"JSPM\", JSPM)\r\n console.log(\"license_url\", license_url)\r\n JSPM.JSPrintManager.license_url = license_url;\r\n JSPM.JSPrintManager.auto_reconnect = true;\r\n JSPM.JSPrintManager.start();\r\n\r\n JSPM.JSPrintManager.WS.onStatusChanged = function () {\r\n const status = JSPM.JSPrintManager.WS.status === 0;\r\n dispatch(actions.setJSPMStatus(status));\r\n getAvaiablePrinters()\r\n .then((printerList) => {\r\n dispatch(actions.setAvailablePrinter(printerList));\r\n })\r\n .catch((err) => {\r\n dispatch(actions.setAvailablePrinter([]));\r\n });\r\n };\r\n\r\n JSPM.JSPrintManager.WS.onClose = function () {\r\n const status = JSPM.JSPrintManager.WS.status === 0;\r\n dispatch(actions.setJSPMStatus(status));\r\n };\r\n};\r\n\r\nexport const printZplLabels = (printData, selectedPrinter) => {\r\n var cpj = new JSPM.ClientPrintJob();\r\n cpj.clientPrinter = selectedPrinter ? new JSPM.InstalledPrinter(selectedPrinter) : 0;\r\n cpj.printerCommands = Base64.decode(printData);\r\n cpj.printerCommandsCodePage = -1;\r\n cpj.sendToClient();\r\n};\r\n\r\nexport const printPDF = (printData, selectedPrinter, type) => {\r\n let cpj = new JSPM.ClientPrintJob();\r\n cpj.clientPrinter = selectedPrinter ? new JSPM.InstalledPrinter(selectedPrinter) : 0;\r\n if (printData) {\r\n let myPdfFile;\r\n myPdfFile = new JSPM.PrintFilePDF(printData, JSPM.FileSourceType.Base64, `${type}.pdf`, 1);\r\n myPdfFile.pageSizing = JSPM.Sizing.None;\r\n myPdfFile.printRotation = JSPM.PrintRotation.Rot180\r\n cpj.files.push(myPdfFile);\r\n }\r\n cpj.sendToClient();\r\n};\r\n\r\nexport const downloadPDF = (base64, lableName, shipmentData, index) => {\r\n if (base64) {\r\n let shipmentid\r\n let blob = convertBase64toBlob(base64, 'application/pdf');\r\n const blobUrl = URL.createObjectURL(blob);\r\n const link = document.createElement(\"a\");\r\n if (shipmentData?.labelResponse && shipmentData?.labelResponse.length > 0) {\r\n if (index !== undefined) {\r\n shipmentid = shipmentData.labelResponse[index]?.shipmentId ?? index + 1;\r\n }\r\n else {\r\n shipmentData?.labelResponse.map((id) => {\r\n shipmentid = id.shipmentId\r\n })\r\n }\r\n }\r\n else if (shipmentData?.customsInvoiceResponse && shipmentData?.customsInvoiceResponse.length > 0) {\r\n if (index !== undefined) {\r\n shipmentid = shipmentData.customsInvoiceResponse[index]?.shipmentId ?? index + 1;\r\n }\r\n else {\r\n shipmentid = shipmentData?.customsInvoiceResponse[0]?.shipmentId\r\n }\r\n }\r\n else if (shipmentData.length > 0) {\r\n shipmentid = shipmentData[0]?.labelResponse[0]?.shipmentId ?? shipmentData[0]?.customsInvoiceResponse[0]?.shipmentId;\r\n }\r\n else if (shipmentData?.shipmentId) {\r\n shipmentid = shipmentData.shipmentId\r\n }\r\n else if (shipmentData?.shipments[0].shipmentId) {\r\n shipmentid = shipmentData?.shipments[0].shipmentId\r\n }\r\n else {\r\n shipmentid = \"\"\r\n }\r\n link.href = blobUrl;\r\n link.download = shipmentid + lableName;\r\n document.body.appendChild(link);\r\n link.dispatchEvent(\r\n new MouseEvent('click', {\r\n bubbles: false,\r\n cancelable: true,\r\n view: window\r\n })\r\n );\r\n }\r\n}\r\n\r\nconst convertBase64toBlob = (content, contentType) => {\r\n contentType = contentType || '';\r\n var sliceSize = 512;\r\n var byteCharacters = window.atob(content);\r\n var byteArrays = [\r\n ];\r\n for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {\r\n var slice = byteCharacters.slice(offset, offset + sliceSize);\r\n var byteNumbers = new Array(slice.length);\r\n for (var i = 0; i < slice.length; i++) {\r\n byteNumbers[i] = slice.charCodeAt(i);\r\n }\r\n var byteArray = new Uint8Array(byteNumbers);\r\n byteArrays.push(byteArray);\r\n }\r\n var blob = new Blob(byteArrays, {\r\n type: contentType\r\n });\r\n return blob;\r\n}\r\n\r\n\r\nexport const getAvaiablePrinters = () => {\r\n return JSPM?.JSPrintManager.getPrinters()\r\n // || new Promise((resolve,reject)=> {\r\n // reject([]);\r\n // });\r\n};\r\n\r\nexport const getPrintConfiguration = (dispacth, actions, userDetails) => {\r\n if (userDetails) {\r\n GET(`${ServiceEndPoints.printConfiguration}?userId=${userDetails.emailId}`)\r\n .then((response) => {\r\n dispacth(actions.setPrinterConfiguration(response.data));\r\n }).catch((err) => {\r\n dispacth(actions.setPrinterConfiguration({ userId: userDetails.emailId }));\r\n });\r\n GET(`${ServiceEndPoints.getOrderDefaults}?organization=${getCustomerAccountID()}`).then(res => {\r\n dispacth(actions.setPrinterConfiguration({\r\n \"printerQueueDefault\": res.data.printerQueueDefaults?.printerQueueDefault,\r\n \"printerQueue\": res.data.printerQueueDefaults?.printerQueue\r\n }))\r\n })\r\n }\r\n};\r\n","/* eslint-disable no-unused-vars */\r\nimport React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, Menu, MenuItem, IconButton, Box, Divider, SvgIcon } from '@material-ui/core';\r\nimport { KeyboardArrowDown } from '@material-ui/icons';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { SearchIcon } from '@material-ui/data-grid';\r\nimport ClearIcon from '@material-ui/icons/Clear';\r\nimport '../../../container/shipment/addShipment/addShipment.scss';\r\nimport { resetFormAndKeepInitialValues, setValuesToForm, sortBasedOnNestedOrNot } from '../../../utils/helperFunctions';\r\nimport { connect, useDispatch } from 'react-redux';\r\nimport TextField from '@material-ui/core/TextField';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\nimport List from '@material-ui/core/List';\r\nimport ListItem from '@material-ui/core/ListItem';\r\nimport ListItemAvatar from '@material-ui/core/ListItemAvatar';\r\nimport ListItemText from '@material-ui/core/ListItemText';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { ReactComponent as TemplateIcon } from '../../../assets/images/TemplateIcon.svg';\r\nimport { ReactComponent as CloseIcon } from '../../../assets/images/closeIcon.svg';\r\nimport DialogBox from './dialogForTemplate/dialogForTemplate';\r\nimport { useDebouncedCallback } from 'use-debounce';\r\nimport './templates.scss';\r\nimport { UserRoles } from '../../../utils/constants/constants';\r\n\r\nconst useStyles = makeStyles({\r\n underline: {\r\n '&&&:before': {\r\n borderBottom: 'none',\r\n },\r\n '&&:after': {\r\n borderBottom: 'none',\r\n },\r\n },\r\n});\r\nconst Templates = (props) => {\r\n const {\r\n formField: { templateSearch },\r\n setFieldValue,\r\n setValues,\r\n templateData,\r\n formikValues,\r\n errors,\r\n resetForm,\r\n isDomestic,\r\n backUpResponse,\r\n currencies,\r\n countries,\r\n getTemplates,\r\n templateLimit,\r\n isAmendShipment\r\n } = props;\r\n const classes = useStyles();\r\n const [filteredTemplates, setFilteredTemplates] = useState([]);\r\n let [isClearBtn, setIsClearBtn] = useState(false);\r\n const [open, setOpen] = React.useState(false);\r\n\r\n const debounced = useDebouncedCallback((value) => {\r\n getTemplates(value);\r\n }, 500);\r\n\r\n const handleClick = () => {\r\n setOpen(true);\r\n };\r\n\r\n const dispatch = useDispatch();\r\n\r\n const searchTemplate = (event = null) => {\r\n if (event) {\r\n event.preventDefault();\r\n }\r\n if (formikValues.templateSearch.trim() !== '') {\r\n setIsClearBtn(true);\r\n debounced(formikValues.templateSearch);\r\n } else {\r\n setIsClearBtn(false);\r\n debounced(formikValues.templateSearch);\r\n }\r\n };\r\n\r\n // const getClear = (event = null, from = '') => {\r\n // setIsClearBtn(false);\r\n // setFieldValue('templateSearch', '');\r\n // getTemplates();\r\n // if (from !== 'clearField') {\r\n // dispatch(actions.setBackUpResponse({ loadedFrom: '' }));\r\n // resetFormAndKeepInitialValues(\r\n // resetForm,\r\n // setFieldValue,\r\n // formikValues.accountNumber,\r\n // formikValues.destinationCountry,\r\n // );\r\n // setFieldValue('selectedTemplate', '');\r\n // handleClose();\r\n // }\r\n // if (event) {\r\n // event.stopPropagation();\r\n // }\r\n // };\r\n\r\n const getClear = (event = null, from = '') => {\r\n if (from !== 'clearField') {\r\n if ((backUpResponse || {}).loadedFrom === 'favourites' && (backUpResponse || {}).loadedResponse) {\r\n setValuesToFormAndDispatchAction((backUpResponse || {}).loadedResponse);\r\n } else {\r\n dispatch(actions.setBackUpResponse({ loadedFrom: '' }));\r\n resetFormAndKeepInitialValues(resetForm, setFieldValue, countries, formikValues.accountNumber);\r\n }\r\n setFieldValue('selectedTemplate', '');\r\n setFieldValue('templateSearch', '');\r\n }\r\n setFieldValue('templateSearch', '');\r\n setIsClearBtn(false);\r\n\r\n getTemplates();\r\n // handleClose();\r\n if (event) {\r\n event.stopPropagation();\r\n }\r\n };\r\n\r\n const handleMenuClick = (templateDetails) => {\r\n dispatch(actions.setLoaderLayOver(true));\r\n // dispatch(actions.setBackUpResponse({ loadedFrom: 'template', loadedResponse: { ...templateDetails } }));\r\n setValuesToFormAndDispatchAction(templateDetails);\r\n setFieldValue('selectedTemplate', templateDetails.templateName);\r\n setIsClearBtn(false);\r\n handleClose();\r\n };\r\n\r\n const setValuesToFormAndDispatchAction = (responseObj) => {\r\n responseObj['destinationCountry'] = 'GBR';\r\n setValues(setValuesToForm(responseObj, formikValues, countries, currencies));\r\n dispatch(actions.setLoadedFrom({ loadedFrom: 'dropdownResponse', loadedResponse: { ...responseObj } }));\r\n setTimeout(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n dispatch(actions.setLoadedFrom({ loadedFrom: '', loadedResponse: {} }));\r\n }, 5000);\r\n };\r\n\r\n useEffect(() => {\r\n sortBasedOnNestedOrNot(templateData.templates, 'templateName', false);\r\n setFilteredTemplates(templateData.templates);\r\n }, [templateData]);\r\n\r\n useEffect(() => {\r\n if (!isDomestic && formikValues.selectedTemplate) {\r\n setFieldValue(\"selectedTemplate\", \"\")\r\n }\r\n }, [formikValues.selectedTemplate, isDomestic]);\r\n\r\n useEffect(() => {\r\n searchTemplate();\r\n }, [formikValues.templateSearch]);\r\n\r\n const handleClose = (value) => {\r\n setOpen(false);\r\n // setFieldValue('selectedTemplate', '');\r\n setFieldValue('templateSearch', '');\r\n };\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n getClear(event, 'clearField')}\r\n >\r\n \r\n getClear(event, 'clearField')}>\r\n \r\n \r\n )\r\n : (\r\n searchTemplate(event)}>\r\n \r\n \r\n ),\r\n }}\r\n fullWidth\r\n />\r\n \r\n \r\n Templates \r\n \r\n {(filteredTemplates || []).length > 0\r\n ? (filteredTemplates || []).map((template) => (\r\n \r\n {\r\n handleMenuClick(template);\r\n }}\r\n style={{ pointer: 'cursor', paddingTop: '4px', paddingBottom: '4px' }}\r\n >\r\n \r\n \r\n \r\n \r\n \r\n {formikValues.selectedTemplate === template.templateName\r\n ? (\r\n getClear(event, 'menu')} style={{ height: '0px' }}>\r\n \r\n \r\n )\r\n : null}\r\n \r\n \r\n \r\n \r\n \r\n ))\r\n : \r\n \r\n \r\n No template found\r\n \r\n \r\n \r\n \r\n }\r\n
\r\n \r\n \r\n \r\n );\r\n};\r\n\r\nTemplates.propTypes = {\r\n formField: PropTypes.object,\r\n setFieldValue: PropTypes.func,\r\n formikValues: PropTypes.object,\r\n getTemplates: PropTypes.func,\r\n templateLimit: PropTypes.number,\r\n};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n backUpResponse: ((state || {}).backUpResponse || {}).loadedFrom,\r\n userDetails: state.auth.userDetails,\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, null)(Templates);\r\n","import React, { useEffect, useRef, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, IconButton, SvgIcon, Tooltip } from '@material-ui/core';\r\nimport { Form, Formik } from 'formik';\r\nimport { getYupSchemaFromMetaData } from '../../../../../utils/yupSchema/yupSchemaGenerator';\r\nimport FormRenderer from '../../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport './addCommodityDetails.scss';\r\nimport InputButton from '../../../../../framework/Inputs/inputButton/inputButton';\r\nimport { GET } from '../../../../../api/axios';\r\nimport { ReactComponent as InfoIcon } from '../../../../../assets/images/InfoIcon.svg';\r\nimport { dynamicSort } from '../../../../../utils/helperFunctions';\r\nimport { ServiceEndPoints } from '../../../../../utils/constants/ApiConstant';\r\n\r\nconst AddCommodityDetails = (props) => {\r\n const {\r\n addNewCommodityDetails,\r\n updateCommodityDetails,\r\n marketPlacesList,\r\n isMarketplacesCommodity,\r\n shipmentMovementType,\r\n data: { operationType, rowDetails, index, totalWeight },\r\n } = props;\r\n\r\n const countryDetails = { ...(rowDetails || {}).countryOfOrigin };\r\n const formField = getFormField(totalWeight);\r\n const formField2 = getFormField2();\r\n\r\n const validationSchema1 = getYupSchemaFromMetaData(formField, [], [], [['quantity', 'weight']]);\r\n const validationSchema2 = getYupSchemaFromMetaData(formField2, [], [], [['quantity', 'weight']]);\r\n const emptyValues = {\r\n commodityCode: '',\r\n fullDescriptionOfGoods: '',\r\n quantity: '',\r\n unitWeight: '',\r\n unitValue: '',\r\n countryOfOrigin: '',\r\n };\r\n\r\n const [countries, setCountries] = useState([]);\r\n const [disblebtn, setdisblebtn] = useState(false);\r\n const [initialValues, setInitialValues] = useState(\r\n operationType === 'updateCommodityDetails' ? rowDetails : emptyValues,\r\n );\r\n\r\n const formikRef = useRef(null);\r\n const isFormValid = (errors) => {\r\n return Object.keys(errors).length === 0;\r\n };\r\n const handleSubmit = async (values, actions) => {\r\n if (operationType === 'updateCommodityDetails') {\r\n updateCommodityDetails(index, values);\r\n } else {\r\n addNewCommodityDetails(values);\r\n }\r\n };\r\n\r\n const getCountry = (countryCode) => {\r\n return countries.find((country) => country.code === countryCode);\r\n };\r\n\r\n useEffect(() => {\r\n if (operationType === 'updateCommodityDetails') {\r\n let existingValues = { ...rowDetails };\r\n setInitialValues(existingValues);\r\n } else {\r\n setInitialValues(emptyValues);\r\n }\r\n }, [countries, operationType, rowDetails]);\r\n\r\n useEffect(() => {\r\n if (operationType === 'updateCommodityDetails') {\r\n let existingValues = { ...rowDetails };\r\n existingValues['countryOfOrigin'] = getCountry((countryDetails || {}).code);\r\n setInitialValues(existingValues);\r\n } else {\r\n emptyValues['countryOfOrigin'] = getCountry('GBR');\r\n setInitialValues(emptyValues);\r\n }\r\n }, [countries, operationType, rowDetails]);\r\n\r\n useEffect(() => {\r\n // eslint-disable-next-line new-cap\r\n GET(ServiceEndPoints.getCountries)\r\n .then((res) => {\r\n setCountries(res.data.countries.sort(dynamicSort('name')));\r\n })\r\n .catch((err) => {\r\n setCountries([]);\r\n });\r\n }, []);\r\n\r\n const resetbtnForm = async (values, errors, validateForm) => {\r\n\r\n // Trigger validation\r\n const validationErrors = await validateForm();\r\n if (isFormValid(validationErrors)) {\r\n await setdisblebtn(true);\r\n handleSubmit(values);\r\n } else {\r\n console.log('Form is not valid');\r\n }\r\n };\r\n const resetCommodityForm = (resetForm, setFieldValue) => {\r\n resetForm();\r\n setFieldValue('countryOfOrigin', getCountry('GBR'));\r\n };\r\n return (\r\n \r\n \r\n {shipmentMovementType == 'b2b' ? (\r\n \r\n {({ values, setFieldValue, errors, resetForm, dirty, validateForm }) => (\r\n \r\n )}\r\n \r\n ) : (\r\n \r\n {({ values, setFieldValue, errors, resetForm, dirty, validateForm }) => (\r\n \r\n )}\r\n \r\n )}\r\n \r\n
\r\n );\r\n};\r\n\r\nAddCommodityDetails.propTypes = {};\r\n\r\nexport default AddCommodityDetails;\r\n\r\nconst getFormField2 = () => {\r\n return {\r\n commodityCode: {\r\n props: {\r\n name: 'commodityCode',\r\n label: 'Commodity code',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 10,\r\n },\r\n isRequired: true,\r\n class_Name: 'commodity_Code',\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Commodity code is required'],\r\n },\r\n {\r\n type: 'matches',\r\n params: [/^[0-9]{10}$/, 'Commodity code should be a 10 digit number'],\r\n },\r\n {\r\n type: 'max',\r\n params: [10, 'Commodity code should be a 10 digit number'],\r\n },\r\n ],\r\n },\r\n },\r\n fullDescriptionOfGoods: {\r\n props: {\r\n name: 'fullDescriptionOfGoods',\r\n label: 'Description of goods',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 90,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [90, 'Maximum of 90 characters are allowed'],\r\n },\r\n {\r\n type: 'required',\r\n params: ['Description of goods is required'],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Minimum 1 character is required'],\r\n },\r\n {\r\n type: 'matches',\r\n params: [\r\n /(.*[a-zA-Z0-9$&+,:;=?@#|'<>.^*()%!-]){3}/i,\r\n 'Description must be at least 3 non blank characters',\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n quantity: {\r\n props: {\r\n name: 'quantity',\r\n label: 'Unit Quantity',\r\n type: 'number',\r\n isRequired: true,\r\n inputProps: {\r\n max: 999,\r\n min: 1,\r\n },\r\n },\r\n validation: {\r\n validationType: 'number',\r\n name: 'quantity',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Quantity is required'],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Unit Quantity must be greater than or equal to 1'],\r\n },\r\n {\r\n type: 'max',\r\n params: [999, 'Quantity must be 999 or less'],\r\n },\r\n {\r\n type: 'integer',\r\n params: ['Quantity should be a whole number'],\r\n },\r\n ],\r\n },\r\n },\r\n unitWeight: {\r\n props: {\r\n name: 'unitWeight',\r\n label: 'Unit Weight',\r\n type: 'number',\r\n isRequired: true,\r\n inputProps: {\r\n max: 999,\r\n min: 0,\r\n },\r\n },\r\n validation: {\r\n validationType: 'number',\r\n name: 'unitWeight',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Unit Weight is required'],\r\n },\r\n {\r\n type: 'min',\r\n params: [0.01, 'Unit Weight must be greater than 0'],\r\n },\r\n {\r\n type: 'max',\r\n params: [999, 'Unit Weight must be 999 or less'],\r\n },\r\n ],\r\n },\r\n },\r\n unitValue: {\r\n props: {\r\n name: 'unitValue',\r\n label: 'Unit Value',\r\n type: 'number',\r\n isRequired: true,\r\n inputProps: {\r\n max: 10000,\r\n min: 0,\r\n },\r\n },\r\n validation: {\r\n validationType: 'number',\r\n name: 'unitValue',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Unit Value is required'],\r\n },\r\n {\r\n type: 'min',\r\n params: [0.01, 'Unit Value must be greater than 0'],\r\n },\r\n {\r\n type: 'max',\r\n params: [10000, 'Unit Value must be 10000 or less'],\r\n },\r\n ],\r\n },\r\n },\r\n countryOfOrigin: {\r\n props: {\r\n name: 'countryOfOrigin',\r\n label: 'Country of Manufacture',\r\n type: 'select',\r\n displayField: 'name',\r\n isRequired: true,\r\n },\r\n validation: {\r\n validationType: 'object',\r\n name: 'countryOfOrigin',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Country of Manufacture is required'],\r\n },\r\n\r\n {\r\n type: 'max',\r\n params: [2, 'Maximum of 2 characters allowed'],\r\n },\r\n {\r\n type: 'min',\r\n params: [2, 'Minimum of 2 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n };\r\n};\r\n\r\nconst getFormField = (totalWeight) => {\r\n return {\r\n commodityCode: {\r\n props: {\r\n name: 'commodityCode',\r\n label: 'Commodity code',\r\n type: 'text',\r\n class_Name: 'commodity_Code',\r\n inputProps: {\r\n maxLength: 6,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'matches',\r\n params: [/^[0-9]{6}$/, 'Commodity code should be a 6 digit number'],\r\n },\r\n {\r\n type: 'max',\r\n params: [6, 'Commodity code should be a 6 digit number'],\r\n },\r\n ],\r\n },\r\n },\r\n fullDescriptionOfGoods: {\r\n props: {\r\n name: 'fullDescriptionOfGoods',\r\n label: 'Description of goods',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 90,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [90, 'Maximum of 90 characters are allowed'],\r\n },\r\n {\r\n type: 'required',\r\n params: ['Description of goods is required'],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Minimum 1 character is required'],\r\n },\r\n {\r\n type: 'matches',\r\n params: [\r\n /(.*[a-zA-Z0-9$&+,:;=?@#|'<>.^*()%!-]){3}/i,\r\n 'Description must be at least 3 non blank characters',\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n quantity: {\r\n props: {\r\n name: 'quantity',\r\n label: 'Unit Quantity',\r\n type: 'number',\r\n isRequired: true,\r\n inputProps: {\r\n max: 999,\r\n min: 1,\r\n },\r\n },\r\n validation: {\r\n validationType: 'number',\r\n name: 'quantity',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Quantity is required'],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Quantity must be greater than or equals to 1'],\r\n },\r\n {\r\n type: 'max',\r\n params: [999, 'Quantity must be 999 or less'],\r\n },\r\n {\r\n type: 'integer',\r\n params: ['Quantity should be a whole number'],\r\n },\r\n ],\r\n },\r\n },\r\n };\r\n};\r\n","import React, { useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { FieldArray } from 'formik';\r\nimport {\r\n Grid,\r\n TableContainer,\r\n Paper,\r\n Table,\r\n TableHead,\r\n TableRow,\r\n TableCell,\r\n TableBody,\r\n TableFooter,\r\n IconButton,\r\n SvgIcon,\r\n} from '@material-ui/core';\r\n\r\nimport { ReactComponent as DeleteIcon } from '../../../../../assets/images/DeleteIcon.svg';\r\nimport { ReactComponent as EditIcon } from '../../../../../assets/images/EditIcon.svg';\r\nimport { ReactComponent as AddIcon } from '../../../../../assets/images/AddIcon.svg';\r\nimport CustomDialog from './../../../../../framework/dialog/customDialog';\r\nimport AddCommodityDetails from '../addCommodityDetails/addCommodityDetails';\r\nimport './commodityDetails.scss';\r\nimport { CLERANCE_DECLARATION } from '../../../../../utils/constants/constants';\r\n\r\nconst CommodityDetails = (props) => {\r\n const {\r\n formField: { commodityDetails },\r\n formikValues,\r\n errors,\r\n setFieldValue,\r\n isAddNewAddress,\r\n isOrderDefaults,\r\n shipmentMovementType,\r\n isCollectionRequest\r\n } = props;\r\n\r\n const [open, setOpen] = React.useState(false);\r\n const [modalData, setModalData] = React.useState({});\r\n const [footerValues, setFooterValues] = React.useState({\r\n subTotal: 0,\r\n totalValue: 0,\r\n });\r\n const [spanIsActive, setspanIsActive] = React.useState(false);\r\n const [commodityWeight, setcommodityWeight] = React.useState(0);\r\n const [checkItemnumber, setItemNumber] = useState(true);\r\n const [messageIsActive, setmessageIsActive] = React.useState(false);\r\n const [commodityCollectiveWeight, setCommodityCollectiveWeight] = React.useState(0);\r\n\r\n var commodityDetails_weight = 0;\r\n var commodityTotalWeight = 0;\r\n\r\n const openAddCommodityDetails = () => {\r\n setModalData({\r\n operationType: 'addCommodityDetails',\r\n totalWeight: formikValues.weight,\r\n });\r\n setOpen(true);\r\n };\r\n const handleClose = () => {\r\n setOpen(false);\r\n };\r\n\r\n const addNewCommodityDetails = (arrayHelpers, values) => {\r\n arrayHelpers.push(values);\r\n setOpen(false);\r\n };\r\n\r\n const updateCommodityDetails = (arrayHelpers, index, values) => {\r\n arrayHelpers.replace(index, values);\r\n setOpen(false);\r\n };\r\n\r\n const openUpdateCommodityDetails = (index, rowDetails) => {\r\n setModalData({\r\n index,\r\n rowDetails,\r\n operationType: 'updateCommodityDetails',\r\n totalWeight: formikValues.weight,\r\n });\r\n setOpen(true);\r\n };\r\n React.useEffect(() => {\r\n let product = 0;\r\n formikValues.commodityDetails?.forEach((commodity) => {\r\n product = commodity.quantity * commodity.unitValue + product;\r\n });\r\n const shippingCharges =\r\n isNaN(parseFloat(formikValues.customDeclarationShippingCharges)) ||\r\n parseFloat(formikValues.customDeclarationShippingCharges) < 0\r\n ? 0\r\n : parseFloat(formikValues.customDeclarationShippingCharges);\r\n const totalValue = parseFloat(product + shippingCharges).toFixed(2); //+ parseFloat(shippingCharges).toFixed(2);\r\n setFooterValues({ subTotal: parseFloat(product).toFixed(2), totalValue: parseFloat(totalValue).toFixed(2) });\r\n setFieldValue('subTotal', parseFloat(product).toFixed(2));\r\n setFieldValue('totalValue', parseFloat(totalValue).toFixed(2));\r\n\r\n formikValues.commodityDetails?.forEach((commodity) => {\r\n commodityDetails_weight += commodity.quantity * commodity.weight;\r\n });\r\n setcommodityWeight(commodityDetails_weight);\r\n\r\n if (\r\n Number(parseFloat(commodityDetails_weight).toFixed(2)) >\r\n Number(parseFloat(formikValues.weight || 0).toFixed(2)) &&\r\n !isOrderDefaults\r\n ) {\r\n setspanIsActive(true);\r\n } else if (\r\n isOrderDefaults &&\r\n parseFloat(commodityDetails_weight) > parseFloat(formikValues.weight || 0) * (formikValues.noOfItems || 1)\r\n ) {\r\n setspanIsActive(true);\r\n } else {\r\n setspanIsActive(false);\r\n }\r\n let totalPiecesWeight = 0;\r\n formikValues?.intlParcelDetails?.map((piece) => {\r\n totalPiecesWeight += parseFloat(piece.weight);\r\n });\r\n if (commodityDetails_weight > (formikValues.weight || 0) && !isOrderDefaults) {\r\n setFieldValue('totalWeightExceed', commodityDetails_weight);\r\n } else if (isOrderDefaults && commodityDetails_weight > (formikValues.weight || 0) * formikValues.noOfItems) {\r\n setFieldValue('totalWeightExceed', commodityDetails_weight);\r\n } else if (totalPiecesWeight > formikValues.weight) {\r\n setFieldValue('totalWeightExceed', totalPiecesWeight);\r\n } else {\r\n setFieldValue('totalWeightExceed', formikValues.weight || 0);\r\n }\r\n if (formikValues.reasonForExport?.type === 'documents' && formikValues?.subTotal > 5) {\r\n setspanIsActive(true);\r\n setFieldValue('totalWeightExceed', formikValues.weight + 1);\r\n }\r\n if (formikValues?.commodityDetails?.length > 0) {\r\n setItemNumber(false);\r\n } else {\r\n setItemNumber(true);\r\n }\r\n }, [\r\n formikValues.commodityDetails,\r\n formikValues.customDeclarationShippingCharges,\r\n formikValues.weight,\r\n formikValues.noOfItems,\r\n formikValues.intlParcelDetails,\r\n formikValues.reasonForExport,\r\n formikValues?.subTotal,\r\n ]);\r\n\r\n React.useEffect(() => {\r\n formikValues?.commodityDetails?.forEach((commodity) => {\r\n commodityTotalWeight += commodity.quantity * commodity.unitWeight\r\n ;\r\n });\r\n const totalWeight = Number(parseFloat(commodityTotalWeight).toFixed(2));\r\n const declaredWeight = Number(parseFloat(isCollectionRequest ? formikValues.fromWeight : formikValues.weight || 0).toFixed(2));\r\n setTimeout(() => {\r\n setCommodityCollectiveWeight(\r\n <>\r\n Total weight: {totalWeight.toFixed(2)} cannot be greater than the declared weight{' '}\r\n {declaredWeight.toFixed(2)} \r\n >,\r\n );\r\n }, 0);\r\n if (totalWeight > declaredWeight) {\r\n setmessageIsActive(true);\r\n } else {\r\n setmessageIsActive(false);\r\n }\r\n }, [formikValues.commodityDetails, formikValues.weight, formikValues.fromWeight, isCollectionRequest]);\r\n\r\n return (\r\n \r\n
{\r\n const commodityItems = formikValues.commodityDetails;\r\n return (\r\n \r\n \r\n \r\n Item details \r\n \r\n \r\n \r\n 19} onClick={openAddCommodityDetails}>\r\n \r\n \r\n Add new\r\n \r\n \r\n {\r\n addNewCommodityDetails(arrayHelpers, values);\r\n }}\r\n updateCommodityDetails={(index, values) => updateCommodityDetails(arrayHelpers, index, values)}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Description of goods \r\n \r\n \r\n Commodity code \r\n \r\n \r\n Unit Quantity \r\n \r\n {shipmentMovementType == CLERANCE_DECLARATION.MOVEMENT_TYPE_B2B_VALUE && (\r\n <>\r\n \r\n Unit Weight \r\n \r\n \r\n Unit Value \r\n \r\n \r\n Country of Manufacture \r\n \r\n >\r\n )}\r\n \r\n \r\n \r\n \r\n \r\n {commodityItems?.map((row, index) => (\r\n \r\n {row?.fullDescriptionOfGoods} \r\n \r\n {row?.commodityCode}\r\n \r\n {row.quantity} \r\n {shipmentMovementType === CLERANCE_DECLARATION.MOVEMENT_TYPE_B2B_VALUE && (\r\n <>\r\n {row?.unitWeight} \r\n {row?.unitValue} \r\n {row?.countryOfOrigin?.name} \r\n >\r\n )}\r\n \r\n openUpdateCommodityDetails(index, row)}>\r\n \r\n \r\n \r\n \r\n arrayHelpers.remove(index)}>\r\n \r\n \r\n \r\n \r\n ))}\r\n \r\n
\r\n \r\n {checkItemnumber && Minimum of 1 item needs to be added }\r\n\r\n {shipmentMovementType === CLERANCE_DECLARATION.MOVEMENT_TYPE_B2B_VALUE && (\r\n <>\r\n \r\n {commodityCollectiveWeight}\r\n \r\n >\r\n )}\r\n \r\n );\r\n }}\r\n />\r\n \r\n );\r\n};\r\n\r\nCommodityDetails.propTypes = {\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n errors: PropTypes.object,\r\n};\r\n\r\nexport default CommodityDetails;","/* eslint-disable react-hooks/exhaustive-deps */\r\nimport React, { useEffect, useState } from 'react';\r\nimport { Grid, Tooltip } from '@material-ui/core';\r\nimport FormRenderer from '../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { connect } from 'react-redux';\r\nimport { shipmentMovementOptions, reasonOptions } from '../../../../utils/constants/constants';\r\nimport CommodityDetails from '../clearanceDeclaration/commodityDetails/commodityDetails';\r\nimport './clearanceDeclaration.scss';\r\nimport { CLERANCE_DECLARATION } from '../../../../utils/constants/constants';\r\n\r\nconst ClearanceDeclaration = (props) => {\r\n const {\r\n formField: {\r\n shipmentMovement,\r\n clearanceTotalValue,\r\n descriptionOfGoods,\r\n receipentUKIMS,\r\n receipentEORI,\r\n shipperUKIMS,\r\n shipperEORI,\r\n shippingCharges,\r\n reasonExport,\r\n shipperDeferment,\r\n clearanceDescriptionGoods,\r\n },\r\n formikValues,\r\n setFieldValue,\r\n isCarriageForward,\r\n clearanceDecleration,\r\n populateClearance,\r\n applyPadding,\r\n isCollectionRequest,\r\n isReturnToSender,\r\n shipmentDetails,\r\n selectedAccount\r\n } = props;\r\n\r\n useEffect(() => {\r\n if (populateClearance) {\r\n if(clearanceDecleration.accountNumber === selectedAccount?.accountId\r\n && !formikValues?.accountNumber?.customsRegistration?.hasOwnProperty('ukimsNumber')) {\r\n setFieldValue('shipperEORI', clearanceDecleration?.sendersEORINumber || '');\r\n setFieldValue('shipperDeferment', clearanceDecleration?.sendersDefermentAccount || '');\r\n setFieldValue('shipperUKIMS', clearanceDecleration?.sendersUKIMSNumber || '');\r\n } else if (shipmentDetails) {\r\n setFieldValue('shipperUKIMS', shipmentDetails?.shipperUKIMS || '');\r\n setFieldValue('shipperDeferment', shipmentDetails?.shipperDeferment || '');\r\n setFieldValue('shipperEORI', shipmentDetails?.shipperEORI || '');\r\n } else {\r\n setFieldValue('shipperUKIMS', formikValues?.accountNumber?.customsRegistration?.ukimsNumber || '');\r\n setFieldValue('shipperDeferment', formikValues?.accountNumber?.customsRegistration?.defermentAccountNumber || '');\r\n setFieldValue('shipperEORI', formikValues?.accountNumber?.customsRegistration?.eoriNumber || '');\r\n }\r\n } else {\r\n if (formikValues?.accountNumber?.accountId !== selectedAccount?.accountId) {\r\n setFieldValue('shipperUKIMS', formikValues?.accountNumber?.customsRegistration?.ukimsNumber || '');\r\n setFieldValue('shipperDeferment', formikValues?.accountNumber?.customsRegistration?.defermentAccountNumber || '');\r\n setFieldValue('shipperEORI', formikValues?.accountNumber?.customsRegistration?.eoriNumber || '');\r\n } else if (shipmentDetails) {\r\n setFieldValue('shipperUKIMS', shipmentDetails?.shipperUKIMS || '');\r\n setFieldValue('shipperDeferment', shipmentDetails?.shipperDeferment || '');\r\n setFieldValue('shipperEORI', shipmentDetails?.shipperEORI || '');\r\n } else {\r\n setFieldValue('shipperUKIMS', formikValues?.accountNumber?.customsRegistration?.ukimsNumber || '');\r\n setFieldValue('shipperDeferment', formikValues?.accountNumber?.customsRegistration?.defermentAccountNumber || '');\r\n setFieldValue('shipperEORI', formikValues?.accountNumber?.customsRegistration?.eoriNumber || '');\r\n }\r\n \r\n }\r\n }, [formikValues.shipmentMovement, formikValues.accountNumber]);\r\n useEffect(() => {\r\n if (populateClearance) {\r\n shipmentMovementOptions.map((shipmentMovementOption, index) => {\r\n if (clearanceDecleration?.shipmentMovementType == shipmentMovementOption.name) {\r\n setFieldValue('shipmentMovement', shipmentMovementOptions[index]);\r\n }\r\n });\r\n const itemData = clearanceDecleration?.items?.map((obj) => {\r\n const selectedCountry = clearanceDecleration?.itemCountry.filter((country) => {\r\n return obj?.countryOfManufacture == country?.code2Digit;\r\n });\r\n return {\r\n commodityCode: obj?.commodityCode || '',\r\n countryOfOrigin: selectedCountry[0],\r\n fullDescriptionOfGoods: obj?.descriptionOfGoods || '',\r\n quantity: obj?.unitQuantity || '',\r\n unitValue: obj?.unitValue || '',\r\n unitWeight: obj?.unitWeight || '',\r\n };\r\n });\r\n setFieldValue('descriptionOfGoods', clearanceDecleration?.descriptionOfGoodsShipment || '');\r\n setFieldValue('clearanceTotalValue', clearanceDecleration?.totalValue || '');\r\n setFieldValue('receipentUKIMS', clearanceDecleration?.recipientUKIMSNumber || '');\r\n setFieldValue('receipentEORI', clearanceDecleration?.recipientEORINumber || '');\r\n setFieldValue('shipperUKIMS', clearanceDecleration?.sendersUKIMSNumber || '');\r\n setFieldValue('shipperEORI', clearanceDecleration?.sendersEORINumber || '');\r\n setFieldValue('shippingCharges', clearanceDecleration?.shippingCharges ?? '');\r\n setFieldValue('shipperDeferment', clearanceDecleration?.sendersDefermentAccount || '');\r\n setFieldValue('clearanceDescriptionGoods', clearanceDecleration?.descriptionOfGoodsShipment || '');\r\n setFieldValue('commodityDetails', itemData);\r\n reasonOptions.map((reasonOption, index) => {\r\n if (clearanceDecleration?.reasonForExport == reasonOption.value) {\r\n setFieldValue('reasonExport', reasonOptions[index]);\r\n }\r\n });\r\n }\r\n }, [clearanceDecleration, populateClearance]);\r\n\r\n const style = applyPadding ? { paddingRight: '38px' } : {};\r\n const goodsDescription = isCollectionRequest ? clearanceDescriptionGoods : descriptionOfGoods;\r\n const {\r\n MOVEMENT_TYPE_B2B_VALUE,\r\n MOVEMENT_TYPE_C2C_VALUE,\r\n MOVEMENT_TYPE_C2B_VALUE,\r\n MOVEMENT_TYPE_B2C_VALUE,\r\n } = CLERANCE_DECLARATION;\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n {formikValues.shipmentMovement?.value && (\r\n <>\r\n \r\n {formikValues.shipmentMovement?.value === MOVEMENT_TYPE_C2C_VALUE && (\r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n \r\n\r\n {formikValues.shipmentMovement?.value === MOVEMENT_TYPE_C2B_VALUE && (\r\n \r\n \r\n {isReturnToSender ? (\r\n \r\n \r\n \r\n ) : (\r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n )}\r\n {formikValues.shipmentMovement?.value === MOVEMENT_TYPE_B2C_VALUE && (\r\n \r\n \r\n {isReturnToSender ? (\r\n \r\n \r\n \r\n ) : (\r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n )}\r\n\r\n {formikValues.shipmentMovement?.value === MOVEMENT_TYPE_B2B_VALUE && (\r\n \r\n \r\n {isReturnToSender ? (\r\n \r\n \r\n \r\n ) : (\r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n {isReturnToSender ? (\r\n \r\n \r\n \r\n ) : (\r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n )}\r\n {formikValues.shipmentMovement?.value !== MOVEMENT_TYPE_C2C_VALUE && (\r\n \r\n \r\n \r\n )}\r\n {!formikValues?.receipentUKIMS &&\r\n !formikValues?.shipperUKIMS &&\r\n formikValues.shipmentMovement?.value == MOVEMENT_TYPE_B2B_VALUE && (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n )}\r\n >\r\n )}\r\n
\r\n );\r\n};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n loadedFrom: state.loadedFrom.loadedFrom,\r\n shipmentDetails: state.addShipmentData.shipmentDetails,\r\n selectedAccount: state.accounts.selectedAccount,\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, null)(ClearanceDeclaration);\r\n","/* eslint-disable react-hooks/exhaustive-deps */\r\nimport React, { useEffect, useState } from 'react';\r\nimport { connect, useSelector } from 'react-redux';\r\nimport { NavLink, useParams } from 'react-router-dom';\r\nimport { getYupSchemaFromMetaData } from '../../../utils/yupSchema/yupSchemaGenerator';\r\nimport { Grid } from '@material-ui/core';\r\nimport { Form, Formik } from 'formik';\r\nimport Hotkeys from 'react-hot-keys';\r\nimport SetupDetails from './setupDetails/setupDetails';\r\nimport DeliveryAddress from './deliveryAddress/deliveryAddress';\r\nimport DeliveryOptions from './deliveryOptions/deliveryOptions';\r\nimport InternationalDeliveryOption from '../../../components/addShipment/DeliveryOptions/InternationalDeliveryOption';\r\nimport ProductAndServiceDetails from './productAndServiceDetails/productAndServiceDetails';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport newDomesticConsignmentForm from '../../../utils/formConfig/newDomesticConsignmentForm/newDomesticConsignmentForm';\r\nimport CustomAccordion from '../../../framework/accordion/customAccordion';\r\nimport ReturnOptions from './returnOptions/returnOptions';\r\nimport AdditionalInfo from './additionalInfo/additionalInfo';\r\nimport PromptJSPMClientInstallation from '../../../components/addShipment/Printing/PromptJSPMClientInstallation';\r\nimport CustomDialog from '../../../framework/dialog/customDialog';\r\nimport { abortOnGoingCallsFor, axiosConfig, GET, POST, PUT } from '../../../api/axios';\r\nimport { useHistory } from 'react-router';\r\nimport './addShipment.scss';\r\nimport { useDispatch } from 'react-redux';\r\nimport ParcelDetails from './parcelDetails/parcelDetails';\r\nimport CustomsDeclaration from './customsDeclaration/customsDeclaration';\r\nimport Favourite from './favourite';\r\nimport {\r\n formatAddToFavReqObj,\r\n formatCurrenciesToDisplay,\r\n createShipmentRequest,\r\n dynamicSort,\r\n setValuesToShipmentForm,\r\n resetFormAndKeepInitialValues,\r\n saveOrderReqObj,\r\n removeUndefinedProperties,\r\n getCustomerAccountID,\r\n createAmendRequest\r\n} from '../../../utils/helperFunctions';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport AddToAddressAndFav from '../../../components/helperComponents/addToAddressAndFav';\r\nimport Templates from '../../../components/addShipment/templates/templates';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { printZplLabels, printPDF, downloadPDF } from '../../../utils/PrintHelper';\r\nimport ConfirmationDialog from '../../../components/addressBook/confirmation/confirmation';\r\nimport CustomModal from '../../../framework/dialog/customDialog';\r\nimport ClearanceDeclaration from './clearanceDeclaration/clearanceDeclaration';\r\nimport { shipmentDetails } from '../../../utils/Models';\r\nimport { getCustomDeclaration, getCommodityTotalWeight } from '../../../../src/utils/utilsFunctions'\r\nimport { CLERANCE_DECLARATION, DELIVER_TYPE, DELIVERY_CHOICES, DELIVERY_OPTIONS, MISC_VALUES } from '../../../utils/constants/constants';\r\n\r\nconst { formId, formField } = newDomesticConsignmentForm;\r\nconst formikRef = React.createRef();\r\nlet reqFields = [\r\n 'postalCode',\r\n 'recipientName',\r\n 'businessName',\r\n 'addressLine1',\r\n 'town',\r\n 'emailAddress',\r\n 'customerNumber',\r\n 'weight',\r\n 'reasonForExport',\r\n 'commodityDetails',\r\n 'product',\r\n 'service',\r\n 'commodityDetails',\r\n 'extendedCoverDomestic',\r\n 'specialInstructions'\r\n];\r\n\r\nlet isPreview = false;\r\nlet isReviewOrder = false;\r\nlet orderSetupResponse = null;\r\n\r\nconst AddShipment = (props) => {\r\n const dispatch = useDispatch();\r\n const { id, isCollectionRequest, isvalid, shipmentId } = useParams();\r\n\r\n const { onLoad, onServicePoint } = props;\r\n const { genralConfiguration } = props;\r\n const [menuData, setMenuData] = React.useState({});\r\n const favouriteLimit = 100;\r\n const templateLimit = 100;\r\n const [countries, setCountries] = React.useState([]);\r\n const [customerNumber, setCustomerNumber] = React.useState('');\r\n const [currencies, setCurrencies] = React.useState([]);\r\n const [templateData, setTemplateData] = React.useState({});\r\n const [orderResponse, setOrderResponse] = React.useState({});\r\n const [shipmentResponse, setShipmentResponse] = React.useState();\r\n const [showDeliveryOptions, setShowDeliveryOptions] = React.useState(true);\r\n const [addressSearchObj, setAddressSearchObj] = React.useState({});\r\n const [isServicePointAddress, setIsServicePointAddress] = React.useState(false);\r\n\r\n const [openJSPMPrompt, setJSPMPrompt] = React.useState(false);\r\n const [showConfirmationDialog, setShowConfirmationDialog] = React.useState(false);\r\n const [newDomestiValidationSchema, setValidationSchema] = React.useState(getYupSchemaFromMetaData(formField, [], []));\r\n const [printerConfigurationMessage, setprinterConfigurationMessage] = React.useState(false);\r\n const [showAllAddressFields, setShowAllAddressFields] = React.useState(false);\r\n const [servicePointAddress, setServicePointAddress] = React.useState({});\r\n const [clearanceDecleration, setClearanceDecleration] = React.useState({});\r\n const [populateClearance,setPopulateClearance] = React.useState(false);\r\n const [internationalProductList, setInternationalProductList] = useState([]);\r\n const [reasonsForExport, setReasonsForExport] = useState([]);\r\n isPreview = false;\r\n const [flagForAfterSubmitCheck, setFlagForAfterSubmitCheck] = React.useState(false);\r\n const [afterSubmitFlag, setAfterSubmitFlag] = useState(false);\r\n const [searchedAddressData, setSearchedAddressData] = useState();\r\n const history = useHistory();\r\n const initialValues = {};\r\n const allProducts = useSelector((state) => state.common.allProducts);\r\n\r\n const handleSearchedAddressBookData = (childData)=>{setSearchedAddressData(childData)};\r\n \r\n for (let property in formField) {\r\n if (Object.prototype.hasOwnProperty.call(formField, property)) {\r\n const field = formField[property];\r\n if (field.props?.type === MISC_VALUES.CHECKBOX || field.props?.type === MISC_VALUES.RADIO) {\r\n initialValues[field.props.name] = field.value;\r\n } else if (field.props?.type === MISC_VALUES.ARRAY) {\r\n initialValues[field.props.name] = field.values;\r\n } else {\r\n initialValues[field.props.name] = field.value || '';\r\n }\r\n }\r\n }\r\n\r\n const isFormInValid = (errors, values) => {\r\n let clonedReqFields = [...reqFields];\r\n if (values?.destinationCountry?.postcodeOptional === true) {\r\n clonedReqFields.splice(0, 1);\r\n }\r\n if (values.isFullCustomDetails && values.destinationCountry.code !== MISC_VALUES.GBR) {\r\n clonedReqFields.push(\r\n 'customDeclarationReceiversEoriNo',\r\n 'customDeclarationShippersEoriNo',\r\n 'customDeclarationShippingCharges',\r\n 'customDeclarationCurrency',\r\n 'InvoiceNumber',\r\n 'InvoiceDate',\r\n 'telephone',\r\n );\r\n if (values.applyIossNumber === 'true' && values.iossType === MISC_VALUES.MARKETNO) {\r\n clonedReqFields.push('marketplaceIossNo');\r\n }\r\n } else if (!values.isFullCustomDetails && values.destinationCountry.code !== MISC_VALUES.GBR) {\r\n clonedReqFields.push('descriptionOfGoods', 'customDeclarationValue');\r\n }\r\n if (\r\n errors.addressLine1 !== undefined ||\r\n errors.addressLine2 !== undefined ||\r\n errors.addressLine3 !== undefined ||\r\n errors.postalCode !== undefined ||\r\n errors.town !== undefined ||\r\n errors.county !== undefined ||\r\n (values.destinationCountry.code === MISC_VALUES.USA && errors.county !== undefined)\r\n ) {\r\n setShowAllAddressFields(true);\r\n return true;\r\n } else {\r\n setShowAllAddressFields(false);\r\n }\r\n if (values.isFullCustomDetails && errors.totalWeightExceed !==undefined){\r\n return true;\r\n }\r\n if (values.destinationCountry.code === MISC_VALUES.USA) {\r\n clonedReqFields.push('county');\r\n }\r\n if (values.destinationCountry.code !== MISC_VALUES.GBR && values.intlParcelDetails.filter(x => x.isValid === false).length>0) {\r\n return true;\r\n }\r\n for (let err in errors) {\r\n if (clonedReqFields.some((fieldName) => fieldName === err)) {\r\n return true;\r\n }\r\n }\r\n if (values.destinationCountry.code === MISC_VALUES.GBR && values.createPalletShipment === MISC_VALUES.YES && errors.pallets) {\r\n return true;\r\n }\r\n if (errors.telephone !== undefined) {\r\n return true;\r\n }\r\n if (!values.product) {\r\n return true;\r\n }\r\n if (values.deliveryType === DELIVER_TYPE.DELIVER_SERVICE_POINT && !props.servicePointSelected?.servicePointID) {\r\n return true;\r\n }\r\n if (allProducts && getCustomDeclaration(allProducts)) {\r\n if (values.shipmentMovement == '') {\r\n return true;\r\n }\r\n\r\n if (values.shipmentMovement.value == CLERANCE_DECLARATION.MOVEMENT_TYPE_C2C_VALUE) {\r\n if (values.descriptionOfGoods == '') {\r\n return true;\r\n } else if (!values.clearanceTotalValue || values.clearanceTotalValue > 99999999.99) {\r\n return true;\r\n }\r\n } else if (values.shipmentMovement.value == CLERANCE_DECLARATION.MOVEMENT_TYPE_C2B_VALUE) {\r\n if (values.receipentUKIMS != '' && values.receipentEORI == '') {\r\n return true;\r\n } else if (!values.clearanceTotalValue || values.clearanceTotalValue > 99999999.99) {\r\n return true;\r\n } else if(values?.commodityDetails?.length<1)\r\n {\r\n return true;\r\n }\r\n\r\n } else if (values.shipmentMovement.value == CLERANCE_DECLARATION.MOVEMENT_TYPE_B2C_VALUE) {\r\n if (values.shipperUKIMS != '' && values.shipperEORI == '') {\r\n return true;\r\n } else if (!values.clearanceTotalValue || values.clearanceTotalValue > 99999999.99) {\r\n return true;\r\n }else if(values?.commodityDetails?.length<1)\r\n {\r\n return true;\r\n }\r\n\r\n }\r\n else if (values.shipmentMovement.value == CLERANCE_DECLARATION.MOVEMENT_TYPE_B2B_VALUE) {\r\n if (values.shipperUKIMS != '' && values.shipperEORI == '') {\r\n return true;\r\n } else if (values.receipentUKIMS !== '' && values.receipentEORI == '') {\r\n return true;\r\n } else if (!values.clearanceTotalValue || values.clearanceTotalValue > 99999999.99) {\r\n return true;\r\n } \r\n else if (values.receipentUKIMS == '' && values.shipperUKIMS == ''\r\n && (values.reasonExport === '' || values.shippingCharges === '')\r\n ) {\r\n if (values.reasonExport == '') {\r\n return true;\r\n } else if (!values.shippingCharges) {\r\n return true;\r\n }\r\n }else if(values?.commodityDetails?.length<1)\r\n {\r\n return true;\r\n }\r\n\r\n }\r\n\r\n if(values.weight > (values.noOfItems * props.maxWeightFullcustoms)){\r\n return true;\r\n }\r\n }\r\n\r\n // To display the form error if (unit quantity*unit weight) total is greater than total weight when shipment movement type\r\n const commodityTotalWeight = getCommodityTotalWeight(values);\r\n if(values.weight < commodityTotalWeight){\r\n return true;\r\n }\r\n\r\n console.log(values)\r\n return false;\r\n };\r\n\r\n const save_order = (values, errors) => {\r\n const payLoad = saveOrderReqObj(orderResponse, values, props.servicePointSelected);\r\n PUT(ServiceEndPoints.saveOrder, payLoad)\r\n .then((response) => {\r\n let isScanFlag = false;\r\n if (history.location && history.location.state !== undefined && history.location.state !== null) {\r\n isScanFlag = history.location.state.isScanFlag;\r\n }\r\n if (response.data.isValid === true) {\r\n history.push({\r\n pathname: '/shipment/processOrders',\r\n state: {\r\n isCollectionRequest: false,\r\n isProcessOrder: true,\r\n isScanFlag: isScanFlag,\r\n },\r\n });\r\n } else {\r\n history.push({\r\n pathname: '/shipment/processOrders',\r\n state: {\r\n isCollectionRequest: false,\r\n isProcessOrder: false,\r\n isScanFlag: isScanFlag,\r\n },\r\n });\r\n }\r\n dispatch(actions.setAppSnackBarData({ msg: `Order updated successfully.` }));\r\n })\r\n .catch((err) => {\r\n console.log(err.response);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: `Error in creating order : ${err?.response?.data?.title}`,\r\n },\r\n ],\r\n }),\r\n );\r\n });\r\n };\r\n\r\n const handleSubmit = (values, errors, inboxReturn) => {\r\n setAfterSubmitFlag(true);\r\n if (!isFormInValid(errors, values)) {\r\n const alertMsgs = [];\r\n dispatch(actions.setLoaderLayOver(true));\r\n let addressPromise = Promise.resolve();\r\n if (!shipmentId) {\r\n if (values.addToAddressBook || values.updateAddToAddressBook) {\r\n const reqObj = formatAddToFavReqObj(values, props.userDetails, addressSearchObj);\r\n addressPromise = axiosConfig\r\n .post(ServiceEndPoints.postAddressBook, reqObj)\r\n .then((res) => {\r\n getFavCustomerList();\r\n dispatch(actions.setAppSnackBarData({ msg: 'Customer details stored successfully' }));\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n alertMsgs.push({ type: 'error', msg: 'Could not add/update customer details to addressbook.' });\r\n });\r\n } else if (values.addToFavCutomerList) {\r\n const { userId } = props.userDetails;\r\n const payload = [addressSearchObj.id];\r\n addressPromise = axiosConfig\r\n .post(`${ServiceEndPoints.postAddressBook}/favourite?userid=${userId}`, payload)\r\n .then((response) => { })\r\n .catch((err) => {\r\n alertMsgs.push({ type: 'error', msg: 'Could not add items to favourites.' });\r\n });\r\n }\r\n }\r\n let orderId = '';\r\n let isOrderRequest = false;\r\n if (id) {\r\n orderId = id;\r\n isOrderRequest = true;\r\n }\r\n const payLoad = !shipmentId ? createShipmentRequest(values, props.servicePointSelected, inboxReturn, isOrderRequest) :\r\n createAmendRequest(values);\r\n removeUndefinedProperties(payLoad);\r\n let manualShipment = false;\r\n if (!shipmentId && !id && orderSetupResponse?.outputFileSetUp?.manualShipment) {\r\n manualShipment = true;\r\n }\r\n var printFormat;\r\n if (props.printerConfiguration?.labelType === 1 && props.printerConfiguration?.isDowloadLabelAsPDF === false) {\r\n printFormat = 'ZPL';\r\n } else if (props.printerConfiguration?.labelType === 2) {\r\n printFormat = 'PDF';\r\n } else if (props.printerConfiguration?.isDowloadLabelAsPDF === true) {\r\n printFormat = 'PDF';\r\n } else {\r\n printFormat = 'PDF';\r\n }\r\n\r\n let pageSize = props.printerConfiguration?.pageSize ? props.printerConfiguration?.pageSize : 0;\r\n const selctedPrinter = props.availablePrinter?.findIndex((x) => x === props.printerConfiguration?.labelPrinter);\r\n const invoiceReq =\r\n genralConfiguration?.printCustomInvoice && values.destinationCountry.code !== MISC_VALUES.GBR\r\n ? '&isCustomsInvoice=true'\r\n : '';\r\n const shipmentPromise = axiosConfig\r\n .post(\r\n `${shipmentId ? ServiceEndPoints.shipmentAmmendUrl : ServiceEndPoints.shipmentLabelUrl}?includeLabel=INCLUDE&format=${printFormat}&pageSize=${values.destinationCountry?.code !== MISC_VALUES.GBR ? 0 : pageSize\r\n }&orderId=${orderId}&isOrderRequest=${isOrderRequest}${invoiceReq}&shipmentId=${shipmentId ?? \"\"}&manualShipment=${manualShipment}`,\r\n payLoad,\r\n )\r\n .then((response) => {\r\n dispatch(actions.setServiceLocationDetails(null));\r\n isPreview = false;\r\n resetFormAndKeepInitialValues(\r\n formikRef.current.resetForm,\r\n formikRef.current.setFieldValue,\r\n countries,\r\n formikRef.current.values?.accountNumber,\r\n setFlagForAfterSubmitCheck,\r\n );\r\n formikRef.current.setFieldValue('DispatchDate', '');\r\n formikRef.current.setFieldValue('createPalletShipment', 'no');\r\n dispatch(actions.resetReturnReferenceParams());\r\n if (!props.printerConfiguration?.isDowloadLabelAsPDF && props.JSPMStatus !== null && !props.JSPMStatus) {\r\n setJSPMPrompt(true);\r\n } else {\r\n let shipment = response.data.shipments[0];\r\n (shipment?.labels ?? []).map((label, index) => {\r\n if (props.printerConfiguration?.isDowloadLabelAsPDF === true) {\r\n let lableName = '';\r\n if (index === 0) {\r\n lableName = '_Label.pdf';\r\n } else if (index === 1) {\r\n lableName = '_ReturnLabel.pdf';\r\n } else {\r\n lableName = '_ReturnInstructions.pdf';\r\n }\r\n downloadPDF(label, lableName, response.data);\r\n } else {\r\n if (props.printerConfiguration?.labelType == 1) {\r\n printZplLabels(label, props.printerConfiguration?.labelPrinter);\r\n } else {\r\n printPDF(label, props.printerConfiguration?.labelPrinter, 'Label');\r\n }\r\n }\r\n });\r\n if (values.destinationCountry.code !== MISC_VALUES.GBR && genralConfiguration?.printCustomInvoice) {\r\n response?.data?.shipments?.[0]?.invoices?.map((invoice, index) => {\r\n if (props.printerConfiguration?.isDowloadLabelAsPDF === true) {\r\n let lableName = '';\r\n if (index === 0) {\r\n lableName = '_CustomsInvoice.pdf';\r\n } else if (index === 1) {\r\n lableName = '_CustomsInvoice.pdf';\r\n } else {\r\n lableName = '_CustomsInvoice.pdf';\r\n }\r\n downloadPDF(invoice, lableName, response.data);\r\n } else {\r\n printPDF(invoice, props.printerConfiguration?.otherReportsPrinter, 'Invoice');\r\n }\r\n });\r\n }\r\n }\r\n shipmentId && dispatch(actions.setAppSnackBarData({ msg: `Shipment ${shipmentId} amended successfully` }));\r\n if (id) {\r\n let isScanFlag = false;\r\n if (history.location && history.location.state !== undefined && history.location.state !== null) {\r\n isScanFlag = history.location.state.isScanFlag;\r\n }\r\n history.push({\r\n pathname: '/shipment/processOrders',\r\n state: {\r\n isCollectionRequest: false,\r\n isProcessOrder: true,\r\n isScanFlag: isScanFlag,\r\n },\r\n });\r\n }\r\n else {\r\n history.push(\"/shipment/addShipment\");\r\n }\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n alertMsgs.push({\r\n type: 'error',\r\n msg: `Error in creating shipment : ${err.response?.data[0]?.detail ?? 'Error occurred while creating shipment, please try again'\r\n }`,\r\n });\r\n })\r\n .finally(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n });\r\n Promise.all([shipmentPromise, addressPromise]).then(() => {\r\n if (alertMsgs.length > 0) {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: alertMsgs,\r\n }),\r\n );\r\n }\r\n });\r\n } else {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [{ type: 'error', msg: 'The form has errors, please correct and try again' }],\r\n }),\r\n );\r\n }\r\n };\r\n\r\n const handlePreview = (values, errors) => {\r\n isPreview = true;\r\n dispatch(actions.setAddShipmentData(values));\r\n dispatch(actions.setOrderResponse(orderResponse));\r\n };\r\n\r\n useEffect(() => {\r\n if (id && Object.keys(orderResponse).length < 1 && Object.keys(props.orderResponse).length > 1) {\r\n setOrderResponse(props.orderResponse);\r\n }\r\n }, [id]);\r\n\r\n useEffect(() => {\r\n if (genralConfiguration && genralConfiguration.customerReferenceMandetory) {\r\n formField.customerReference.props.isRequired = true;\r\n formField.customerReference.validation.validations.push({\r\n type: 'required',\r\n params: ['Reference cannot be empty'],\r\n });\r\n reqFields.push(formField.customerReference.props.name);\r\n } else {\r\n formField.customerReference.validation.validations = formField.customerReference.validation.validations.filter(\r\n (x) => x.type !== MISC_VALUES.REQUIRED,\r\n );\r\n formField.customerReference.props.isRequired = false;\r\n }\r\n if (genralConfiguration && genralConfiguration.alternativeReferenceMandatory || (formikRef.current?.values.postalCode.substring(0,2).toUpperCase() === MISC_VALUES.GY || formikRef.current?.values.postalCode.substring(0,2).toUpperCase() === MISC_VALUES.JE)) {\r\n formField.alternateReference.props.isRequired = true;\r\n if(formikRef.current?.values.postalCode.substring(0,2).toUpperCase() === MISC_VALUES.GY || formikRef.current?.values.postalCode.substring(0,2).toUpperCase() === MISC_VALUES.JE)\r\n {\r\n formField.alternateReference.validation.validations.pop();\r\n formField.alternateReference.validation.validations.push({\r\n type: 'required',\r\n params: ['Description & value is required'],\r\n });\r\n }\r\n else{\r\n formField.alternateReference.validation.validations.push({\r\n type: 'required',\r\n params: ['Reference cannot be empty'],\r\n });\r\n }\r\n reqFields.push(formField.alternateReference.props.name);\r\n }\r\n else {\r\n formField.alternateReference.validation.validations = formField.alternateReference.validation.validations.filter(\r\n (x) => x.type !== MISC_VALUES.REQUIRED,\r\n );\r\n formField.alternateReference.props.isRequired = false;\r\n }\r\n if (genralConfiguration && genralConfiguration.reference1 && genralConfiguration.reference1 !== '') {\r\n formField.customerReference.props.label = genralConfiguration.reference1;\r\n }\r\n if(formikRef.current?.values.postalCode.substring(0,2).toUpperCase() === MISC_VALUES.GY || formikRef.current?.values.postalCode.substring(0,2).toUpperCase() === MISC_VALUES.JE)\r\n {\r\n formField.alternateReference.props.label = 'Description & value';\r\n }\r\n else if (genralConfiguration && genralConfiguration.reference2 ) {\r\n formField.alternateReference.props.label = genralConfiguration.reference2;\r\n }\r\n else{\r\n formField.alternateReference.props.label = 'Alternate reference';\r\n }\r\n updateValidationSchema();\r\n }, [genralConfiguration, formikRef.current?.values.postalCode]);\r\n\r\n const getFavCustomerList = (value = '') => {\r\n abortOnGoingCallsFor(ServiceEndPoints.getFavouritesForByText);\r\n axiosConfig\r\n .get(\r\n `${ServiceEndPoints.getFavouritesForByText\r\n }?organization=${getCustomerAccountID()}&offSet=0&limit=${favouriteLimit}&userid=${props.userDetails.userId\r\n }&text=${value}`,\r\n )\r\n .then((res) => {\r\n setMenuData(res.data);\r\n })\r\n .catch((err) => {\r\n setMenuData([]);\r\n console.log(err);\r\n });\r\n };\r\n\r\n const getTemplates = (value = '') => {\r\n abortOnGoingCallsFor(ServiceEndPoints.getTemplateBy);\r\n axiosConfig.get(\r\n `${ServiceEndPoints.getTemplateBy\r\n }?organization=${getCustomerAccountID()}&offSet=0&limit=${templateLimit}&templateName=${value}`,\r\n )\r\n .then((res) => {\r\n setTemplateData(res.data);\r\n })\r\n .catch((err) => {\r\n setTemplateData([]);\r\n console.log(err);\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n if (props?.userDetails?.userId) {\r\n GET(ServiceEndPoints.getCountries)\r\n .then((res) => {\r\n setCountries(res.data.countries.sort(dynamicSort('name')));\r\n })\r\n .catch((err) => {\r\n setCountries([]);\r\n });\r\n GET(ServiceEndPoints.getCurrencies)\r\n .then((res) => {\r\n setCurrencies(formatCurrenciesToDisplay(res.data.currencies));\r\n })\r\n .catch((err) => {\r\n setCurrencies([]);\r\n });\r\n getFavCustomerList();\r\n getTemplates();\r\n if (\r\n (history.location.state?.fromPreview !== true &&\r\n id !== undefined &&\r\n isCollectionRequest !== undefined &&\r\n isvalid !== undefined)\r\n ) {\r\n populateAddShipment();\r\n }\r\n else if (history.location.state?.fromPreview !== true && shipmentId) {\r\n populateAmmendShipment();\r\n }\r\n }\r\n }, [props.userDetails]);\r\n\r\nuseEffect(() => {\r\n\r\n if (\r\n (countries &&\r\n currencies &&\r\n countries.length > 0 &&\r\n currencies.length > 0 &&\r\n (Object.keys(orderResponse).length > 0 && props.loadedFromData?.loadedFrom !== MISC_VALUES.SUMMARY) &&\r\n id !== undefined &&\r\n isCollectionRequest !== undefined &&\r\n isvalid !== undefined) || shipmentResponse\r\n ) {\r\n\r\n if (shipmentResponse) { \r\n orderResponse.shipmentModel = shipmentResponse; \r\n }\r\n\r\n const formatedResponse = {\r\n ...orderResponse.shipmentModel,\r\n };\r\n\r\n if (orderResponse.shipmentModel.shipments[0].shipmentDetails.deliveryChoice === DELIVERY_CHOICES.DOORSTEP_AGE_VERIFICATION || orderResponse.shipmentModel.shipments[0].shipmentDetails.deliveryChoice ===DELIVERY_CHOICES.AGE) {\r\n orderResponse.shipmentModel.shipments[0].shipmentDetails.doorStepInstructions = DELIVERY_OPTIONS.DELIVERY_DOORSTEP_AGE_VERIFICATION;\r\n } else if (orderResponse.shipmentModel.shipments[0].shipmentDetails.deliveryChoice === DELIVERY_CHOICES.DOORSTEP_PIN || orderResponse.shipmentModel.shipments[0].shipmentDetails.deliveryChoice ===DELIVERY_CHOICES.PIN) {\r\n orderResponse.shipmentModel.shipments[0].shipmentDetails.doorStepInstructions = DELIVERY_OPTIONS.DELIVERY_DOORSTEP_PIN;\r\n } else {\r\n orderResponse.shipmentModel.shipments[0].shipmentDetails.doorStepInstructions = formatedResponse?.product\r\n ?.neighbourDelivery\r\n ? DELIVERY_OPTIONS.DELIVERY_LEAVE_NEIGHBOUR\r\n : formatedResponse?.product?.secureLocationDelivery\r\n ? DELIVERY_OPTIONS.DELIVERY_SAFE_LOCATION\r\n : DELIVERY_OPTIONS.DELIVERY_DOORSTEP_ONLY;\r\n }\r\n formikRef.current.setValues(\r\n setValuesToShipmentForm(\r\n orderResponse.shipmentModel,\r\n formikRef.current.values,\r\n countries,\r\n currencies,\r\n props.userDetails,\r\n ),\r\n );\r\n formatedResponse['deliveryOptions'] = {\r\n doorStepInstructions: orderResponse.shipmentModel.shipments[0].shipmentDetails.deliveryChoice === DELIVERY_CHOICES.DOORSTEP_AGE_VERIFICATION || orderResponse.shipmentModel.shipments[0].shipmentDetails.deliveryChoice === DELIVERY_CHOICES.AGE\r\n ? DELIVERY_OPTIONS.DELIVERY_DOORSTEP_AGE_VERIFICATION\r\n : orderResponse.shipmentModel.shipments[0].shipmentDetails.deliveryChoice === DELIVERY_CHOICES.DOORSTEP_PIN || orderResponse.shipmentModel.shipments[0].shipmentDetails.deliveryChoice === DELIVERY_CHOICES.PIN\r\n ? DELIVERY_OPTIONS.DELIVERY_DOORSTEP_PIN\r\n : formatedResponse?.product?.neighbourDelivery\r\n ? DELIVERY_OPTIONS.DELIVERY_LEAVE_NEIGHBOUR\r\n : formatedResponse?.product?.secureLocationDelivery\r\n ? DELIVERY_OPTIONS.DELIVERY_SAFE_LOCATION\r\n : DELIVERY_OPTIONS.DELIVERY_DOORSTEP_ONLY,\r\n };\r\n\r\n formatedResponse.product = orderResponse.shipmentModel.product?.productCode;\r\n formatedResponse.service = orderResponse.shipmentModel.service?.description;\r\n formatedResponse['accountNumber'] = { accountId: orderResponse?.shipmentModel.pickupAccount };\r\n formatedResponse.fromAddship = true;\r\n\r\n onLoad({\r\n loadedFrom: 'dropdownResponse',\r\n loadedResponse: { ...formatedResponse, ...orderResponse },\r\n });\r\n\r\n setTimeout(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n }, 2500);\r\n\r\n shipmentResponse && setTimeout(() => {\r\n if (props.loadedFromData?.loadedFrom !== MISC_VALUES.SUMMARY) {\r\n onLoad({ loadedFrom: '' });\r\n }\r\n \r\n }, 7000);\r\n\r\n setTimeout(() => {\r\n if (props.loadedFromData?.loadedFrom !== MISC_VALUES.SUMMARY) {\r\n onLoad({ loadedFrom: '' });\r\n }\r\n }, 12000);\r\n\r\n if (orderResponse.shipmentModel.shipments[0]?.consigneeAddress?.addressType?.toLowerCase() === MISC_VALUES.SERVICE_POINT_HANDOVER_METHOD) {\r\n let consigneeAddress = orderResponse.shipmentModel.shipments[0]?.consigneeAddress;\r\n let values = {\r\n servicePointID: consigneeAddress.locationId,\r\n address: {\r\n businessName: consigneeAddress.companyName,\r\n address1: consigneeAddress.address1,\r\n address2: consigneeAddress.address2,\r\n address3: consigneeAddress.address3,\r\n postalTown: consigneeAddress.city,\r\n zipcode: consigneeAddress.postalCode,\r\n },\r\n };\r\n setServicePointAddress(values);\r\n dispatch(actions.setServiceLocationDetails(values));\r\n }\r\n // changes to recall the postal code API while populating the postal code\r\n if(orderResponse.shipmentModel.shipments[0]?.consigneeAddress?.postalCode){\r\n let postalCode = orderResponse.shipmentModel.shipments[0]?.consigneeAddress?.postalCode;\r\n setTimeout(() => {\r\n abortOnGoingCallsFor(ServiceEndPoints.getPostcodeDistrict);\r\n axiosConfig\r\n .get(`${ServiceEndPoints.getPostcodeDistrict}?postcode=${postalCode}`)\r\n .then((res) => {\r\n dispatch(actions.setPostalCodeDistrict(res?.data));\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n return null;\r\n });\r\n }, 500);\r\n \r\n }\r\n \r\n if (orderResponse.shipmentModel.shipments[0]?.clearanceDeclaration) {\r\n let value = {\r\n descriptionOfGoodsShipment:orderResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.descriptionOfGoods,\r\n numberOfItems:orderResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.numberOfItems,\r\n reasonForExport:orderResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.reasonForExport,\r\n recipientEORINumber:orderResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.recipientEORINumber,\r\n recipientUKIMSNumber:orderResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.recipientUKIMSNumber,\r\n sendersDefermentAccount:orderResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.sendersDefermentAccount,\r\n sendersEORINumber:orderResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.sendersEORINumber,\r\n sendersUKIMSNumber:orderResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.sendersUKIMSNumber,\r\n shipmentMovementType:orderResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.shipmentMovementType,\r\n shippingCharges:orderResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.shippingCharges,\r\n totalValue:orderResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.totalValue,\r\n items:orderResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.items,\r\n itemCountry:countries,\r\n accountNumber: orderResponse.shipmentModel.pickupAccount\r\n }\r\n setPopulateClearance(true);\r\n setClearanceDecleration(value);\r\n }\r\n }\r\n}, [countries, currencies, orderResponse, shipmentResponse]);\r\n\r\n const populateAddShipment = () => {\r\n dispatch(actions.setLoaderLayOver(true));\r\n GET(\r\n `${ServiceEndPoints.getOrders\r\n }?organization=${getCustomerAccountID()}&id=${id}&isValid=${isvalid}&isCollectionRequest=${isCollectionRequest}`,\r\n )\r\n .then((res) => {\r\n setOrderResponse(res.data?.orders?.[0]);\r\n if (res.data?.orders?.[0]?.errors?.length > 0) {\r\n isReviewOrder = true;\r\n const errorMessages = res.data.orders[0].errors.map((val) => {\r\n return {\r\n type: 'error',\r\n msg: val,\r\n };\r\n });\r\n errorMessages.length > 0 && dispatch(actions.setLoaderLayOver(false));\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: errorMessages,\r\n }),\r\n );\r\n }\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n dispatch(actions.setLoaderLayOver(false));\r\n\r\n })\r\n };\r\n\r\n const populateAmmendShipment = () => {\r\n dispatch(actions.setLoaderLayOver(true));\r\n GET(\r\n `${ServiceEndPoints.shipmentLabelUrl}?shipmentId=${shipmentId}`,\r\n )\r\n .then((res) => {\r\n setShipmentResponse(res.data);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n dispatch(actions.setLoaderLayOver(false));\r\n\r\n })\r\n };\r\n\r\n const handleClose = () => {\r\n setJSPMPrompt(false);\r\n setprinterConfigurationMessage(false);\r\n };\r\n\r\n const handleCancel = (resetForm, setFieldValue, formikValues) => {\r\n if (id && isCollectionRequest && isvalid) {\r\n setShowConfirmationDialog(true);\r\n } else {\r\n resetFormAndKeepInitialValues(resetForm, setFieldValue, countries, formikValues.accountNumber);\r\n }\r\n dispatch(actions.resetReturnReferenceParams());\r\n };\r\n\r\n const handleDialogClose = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n\r\n const onDialogConfirm = () => {\r\n let isScanFlag = false;\r\n if (history.location && history.location.state !== undefined && history.location.state !== null) {\r\n isScanFlag = history.location.state.isScanFlag;\r\n }\r\n history.push({\r\n pathname: '/shipment/processOrders',\r\n state: {\r\n isCollectionRequest: false,\r\n isProcessOrder: !isReviewOrder,\r\n isScanFlag: isScanFlag,\r\n },\r\n });\r\n };\r\n\r\n const updateValidationSchema = () => {\r\n setValidationSchema(getYupSchemaFromMetaData(formField, [], []));\r\n };\r\n\r\n const getOrderSetupResponse = () => {\r\n GET(`${ServiceEndPoints.orderSetup}?organization=${getCustomerAccountID()}`)\r\n .then((res) => {\r\n orderSetupResponse = res.data\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n getOrderSetupResponse();\r\n if (\r\n props?.printerConfiguration &&\r\n !props.printerConfiguration?.isDowloadLabelAsPDF &&\r\n props.JSPMStatus !== null &&\r\n !props.JSPMStatus\r\n ) {\r\n setJSPMPrompt(true);\r\n }\r\n return () => {\r\n if (!isPreview) {\r\n dispatch(actions.setServiceLocationDetails(null));\r\n dispatch(actions.setAddShipmentData(null));\r\n dispatch(actions.setOrderResponse({}));\r\n dispatch(actions.setReturnReferenceCount(0));\r\n dispatch(actions.setIsReturnReferenceUpdated(false));\r\n }\r\n };\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (!shipmentId && !id) {\r\n resetFormAndKeepInitialValues(formikRef.current.resetForm, formikRef.current.setFieldValue, countries, formikRef.current.values?.accountNumber);\r\n dispatch(actions.resetReturnReferenceParams());\r\n }\r\n }, [shipmentId])\r\n\r\n const getCorrectData = () => {\r\n if (props.printerConfiguration === undefined) {\r\n setprinterConfigurationMessage(false);\r\n setJSPMPrompt(false);\r\n } else {\r\n if (props?.printerConfiguration?.isDowloadLabelAsPDF) {\r\n setprinterConfigurationMessage(false);\r\n setJSPMPrompt(false);\r\n } else {\r\n if (!props.JSPMStatus) {\r\n setJSPMPrompt(true);\r\n } else if (!props?.printerConfiguration?.labelPrinter?.trim()) {\r\n setprinterConfigurationMessage(true);\r\n } else {\r\n setprinterConfigurationMessage(false);\r\n setJSPMPrompt(false);\r\n }\r\n }\r\n }\r\n };\r\n useEffect(() => {\r\n getCorrectData();\r\n }, [\r\n props.printerConfiguration,\r\n props.printerConfiguration?.labelPrinter,\r\n props.printerConfiguration?.otherReportsPrinter,\r\n props.JSPMStatus,\r\n props?.printerConfiguration?.isDowloadLabelAsPDF,\r\n ]);\r\n\r\n const onKeyUp = (keyName, e, handle) => {\r\n if (keyName === MISC_VALUES.F2) {\r\n document.getElementById('downloadAsPDF').click();\r\n } else if (keyName === MISC_VALUES.ESC) {\r\n if (id) {\r\n document.getElementById('btnCancel').click();\r\n }\r\n }\r\n };\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n {({ values, setValues, setFieldValue, setFieldTouched, errors, setErrors, resetForm }) => {\r\n let showReturnLabel = values?.accountNumber?.returnConfiguration?.inboxReturnAllowed;\r\n const isDomestic = values?.destinationCountry?.code === MISC_VALUES.GBR;\r\n if ((values.noOfItems > 1 || values.weight > 20) && isDomestic) {\r\n showReturnLabel = false;\r\n }\r\n const inBoxReturnAvailable = values?.product?.deliveryCapabilities?.inBoxReturn ?? false;\r\n return (\r\n \r\n );\r\n }}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nAddShipment.propTypes = {};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n shipmentDetails: state.addShipmentData.shipmentDetails,\r\n orderResponse: state.addShipmentData.orderResponseData,\r\n userDetails: state.auth.userDetails,\r\n servicePointSelected: state.addShipmentData.servicePointDelivery,\r\n JSPMStatus: state.common.isJSPMInstalled,\r\n printerConfiguration: state.common.printerConfiguration,\r\n availablePrinter: state.common.availablePrinter,\r\n genralConfiguration: state.common.commonConfiguration,\r\n loadedFromData: state.loadedFrom.loadedFrom,\r\n maxWeightFullcustoms: state.common.maxWeightFullcustoms\r\n };\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n onLoad: (loadedFrom) => {\r\n dispatch(actions.setLoadedFrom(loadedFrom));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(AddShipment);\r\n","import { testFunctionForPostCodeRegex } from '../../helperFunctions';\r\nimport { CLERANCE_DECLARATION } from '../../constants/constants';\r\n\r\nconst carriageForwardForm = {\r\n formId: 'carriageForwardForm',\r\n formField: {\r\n accountNumber: {\r\n props: {\r\n name: 'accountNumber',\r\n label: 'Account number',\r\n type: 'radio',\r\n isRequired: true,\r\n },\r\n value: '',\r\n validation: {\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Account name is required'],\r\n },\r\n ],\r\n },\r\n },\r\n collectionDate: {\r\n props: {\r\n name: 'collectionDate',\r\n label: 'Collection date',\r\n type: 'date',\r\n isRequired: true,\r\n },\r\n value: '',\r\n },\r\n fromAddressType: {\r\n props: {\r\n name: 'fromAddressType',\r\n label: 'Address type:',\r\n type: 'radio',\r\n },\r\n value: 'residential',\r\n },\r\n fromWeight: {\r\n props: {\r\n name: 'fromWeight',\r\n label: 'Weight (Kg)',\r\n type: 'number',\r\n isRequired: true,\r\n placeholder: 'Select',\r\n inputProps: {\r\n min: 1,\r\n max: 999,\r\n },\r\n },\r\n validation: {\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Weight field is required'],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Weight is outside permitted range'],\r\n },\r\n {\r\n type: 'max',\r\n params: [999, 'Weight is outside permitted range'],\r\n },\r\n ],\r\n },\r\n value: 0,\r\n },\r\n\r\n fromParcel: {\r\n props: {\r\n name: 'fromParcel',\r\n label: 'No. of parcels',\r\n type: 'number',\r\n placeholder: 'Select',\r\n isRequired: true,\r\n inputProps: {\r\n min: 1,\r\n max: 20,\r\n },\r\n restrictDecimal: true\r\n },\r\n validation: {\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Number of Items is required.'],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Must be a value between 1 to 20'],\r\n },\r\n {\r\n type: 'max',\r\n params: [20, 'Must be a value between 1 to 20'],\r\n },\r\n ],\r\n },\r\n value: 1,\r\n },\r\n\r\n fromSearchFor: {\r\n props: {\r\n name: 'fromSearchFor',\r\n type: 'searchControl',\r\n },\r\n selectProps: {\r\n props: {\r\n name: 'fromSearchBy',\r\n label: 'Search by',\r\n },\r\n },\r\n textProps: {\r\n props: {\r\n name: 'fromSearchFor',\r\n label: 'Search For',\r\n },\r\n },\r\n },\r\n fromCustomerNo: {\r\n props: {\r\n name: 'fromCustomerNo',\r\n label: 'Customer no.',\r\n type: 'text',\r\n },\r\n },\r\n fromPostCode: {\r\n props: {\r\n name: 'fromPostCode',\r\n label: 'Postal code',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 15,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Postal code is required'],\r\n },\r\n {\r\n type: 'min',\r\n params: [3, 'Minimum of 3 characters are required'],\r\n },\r\n {\r\n type: 'max',\r\n params: [15, 'Maximum 15 characters are allowed'],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n 'deliveryType',\r\n (deliveryType, schema) => {\r\n return testFunctionForPostCodeRegex(schema, 'Invalid postal code', '', true);\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n fromContactName: {\r\n props: {\r\n name: 'fromContactName',\r\n label: 'Contact name',\r\n isRequired: true,\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Contact name is required'],\r\n },\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum of 35 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n fromBusinessName: {\r\n props: {\r\n name: 'fromBusinessName',\r\n label: 'Business name',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'fromAddressType',\r\n (fromAddressType, schema) => {\r\n return fromAddressType === 'business'\r\n ? schema.required('Business name is required')\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum 35 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n fromAddressLine1: {\r\n props: {\r\n name: 'fromAddressLine1',\r\n label: 'Address line 1',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Address is required'],\r\n },\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum 35 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n fromAddressLine2: {\r\n props: {\r\n name: 'fromAddressLine2',\r\n label: 'Address line 2',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum 35 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n fromAddressLine3: {\r\n props: {\r\n name: 'fromAddressLine3',\r\n label: 'Address line 3',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum 35 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n fromTown: {\r\n props: {\r\n name: 'fromTown',\r\n label: 'Town',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Town is required'],\r\n },\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum 35 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n fromCounty: {\r\n props: {\r\n name: 'fromCounty',\r\n label: 'County',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum 35 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n fromTelephoneNumber: {\r\n props: {\r\n name: 'fromTelephoneNumber',\r\n label: 'Telephone number',\r\n isRequired: true,\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Telephone number is required'],\r\n },\r\n {\r\n type: 'min',\r\n params: [10, 'Invalid Phone Number'],\r\n },\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum 35 characters are allowed'],\r\n },\r\n {\r\n type: 'matches',\r\n params: [/^[0-9,(,),+,\\-,.,[,\\] ]+$/, 'Invalid phone number'],\r\n },\r\n ],\r\n },\r\n },\r\n fromEmailAddress: {\r\n props: {\r\n name: 'fromEmailAddress',\r\n label: 'Email address',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 70,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Email address is required'],\r\n },\r\n {\r\n type: 'max',\r\n params: [70, 'Maximum 70 characters are allowed'],\r\n },\r\n {\r\n type: 'email',\r\n params: ['Invalid email address'],\r\n },\r\n ],\r\n },\r\n },\r\n fromCustomerReference: {\r\n props: {\r\n name: 'fromCustomerReference',\r\n label: 'Customer reference',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 20,\r\n },\r\n },\r\n validation: {\r\n name: 'fromCustomerReference',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [20, 'Maximum 20 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n collectionInstructions: {\r\n props: {\r\n name: 'collectionInstructions',\r\n label: 'Collection instructions',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 60,\r\n },\r\n },\r\n validation: {\r\n name: 'collectionInstructions',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [60, 'Maximum 60 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n descriptionOfGoods: {\r\n props: {\r\n name: 'descriptionOfGoods',\r\n label: 'Description of goods to be collected',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 50,\r\n },\r\n },\r\n },\r\n fromAddToaddressBook: {\r\n props: {\r\n name: 'fromAddToaddressBook',\r\n label: 'Add to address book',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n updateFromAddToaddressBook: {\r\n props: {\r\n name: 'updateFromAddToaddressBook',\r\n label: 'Update address in address book',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n fromAddToFavourites: {\r\n props: {\r\n name: 'fromAddToFavourites',\r\n label: 'Add to favourites',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n serviceRequired: {\r\n props: {\r\n name: 'serviceRequired',\r\n label: 'Service required',\r\n type: 'select',\r\n },\r\n },\r\n toAddressType: {\r\n props: {\r\n name: 'toAddressType',\r\n label: 'Address type:',\r\n type: 'radio',\r\n },\r\n value: 'residential',\r\n },\r\n toSearchFor: {\r\n props: {\r\n name: 'toSearchFor',\r\n type: 'searchControl',\r\n },\r\n selectProps: {\r\n props: {\r\n name: 'toSearchBy',\r\n label: 'Search by',\r\n },\r\n },\r\n textProps: {\r\n props: {\r\n name: 'toSearchFor',\r\n label: 'Search For',\r\n },\r\n },\r\n },\r\n toCustomerNo: {\r\n props: {\r\n name: 'toCustomerNo',\r\n label: 'Customer no.',\r\n type: 'text',\r\n },\r\n validation: {\r\n name: 'toCustomerNo',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n ['fromCustomerNo'],\r\n (fromCustomerNo, schema) => {\r\n if (fromCustomerNo) {\r\n return schema.test('', 'Customer no. can not be same', (value) => {\r\n return value?.trim() !== fromCustomerNo?.trim();\r\n });\r\n } else {\r\n return schema;\r\n }\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n toPostCode: {\r\n props: {\r\n name: 'toPostCode',\r\n label: 'Postal code',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 15,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n // {\r\n // type: 'matches',\r\n // params: [UK_POSTAL_CODE_REGEX, 'Invalid postal code'],\r\n // },\r\n {\r\n type: 'when',\r\n params: [\r\n 'returnType',\r\n (returnType, schema) => {\r\n return returnType === 'sendToThirdParty'\r\n ? schema.required('Postal code is required')\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n {\r\n type: 'min',\r\n params: [3, 'Minimum of 3 characters are required'],\r\n },\r\n {\r\n type: 'max',\r\n params: [15, 'Maximum 15 characters are allowed'],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n 'returnType',\r\n (returnType, schema) => {\r\n if (returnType === 'sendToThirdParty') {\r\n return testFunctionForPostCodeRegex(schema, 'Invalid postal code', '', true);\r\n }\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n toContactName: {\r\n props: {\r\n name: 'toContactName',\r\n label: 'Contact name',\r\n // placeholder: 'Contact 1',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n name: 'toContactName',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'returnType',\r\n (returnType, schema) => {\r\n return returnType === 'sendToThirdParty'\r\n ? schema.required('Contact name is required')\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum 35 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n toBusinessName: {\r\n props: {\r\n name: 'toBusinessName',\r\n label: 'Business name',\r\n // placeholder: 'Business 1',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n name: 'toBusinessName',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n ['toAddressType', 'returnType'],\r\n (toAddressType, returnType, schema) => {\r\n return toAddressType === 'business' && returnType === 'sendToThirdParty'\r\n ? schema.required('Business name is required').max(35, 'Maximum of 35 characters allowed')\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum 35 characters are allowed'],\r\n },\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum 35 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n toAddressLine1: {\r\n props: {\r\n name: 'toAddressLine1',\r\n label: 'Address line 1',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n name: 'toAddressLine1',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'returnType',\r\n (returnType, schema) => {\r\n return returnType === 'sendToThirdParty'\r\n ? schema.required('Address is required')\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum 35 characters are allowed'],\r\n },\r\n // {\r\n // type: 'max',\r\n // params: [100, 'Maximum of 100 characters allowed'],\r\n // },\r\n ],\r\n },\r\n },\r\n toAddressLine2: {\r\n props: {\r\n name: 'toAddressLine2',\r\n label: 'Address line 2',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n name: 'toAddressLine2',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum of 35 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n toAddressLine3: {\r\n props: {\r\n name: 'toAddressLine3',\r\n label: 'Address line 3',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n name: 'toAddressLine3',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum of 35 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n toTown: {\r\n props: {\r\n name: 'toTown',\r\n label: 'Town',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n name: 'toTown',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'returnType',\r\n (returnType, schema) => {\r\n return returnType === 'sendToThirdParty' ? schema.required('Town is required') : schema.notRequired();\r\n },\r\n ],\r\n },\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum of 35 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n toCounty: {\r\n props: {\r\n name: 'toCounty',\r\n label: 'County',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n name: 'toCounty',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum of 35 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n toTelephoneNumber: {\r\n props: {\r\n name: 'toTelephoneNumber',\r\n label: 'Telephone number',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n name: 'toTelephoneNumber',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'min',\r\n params: [10, 'Invalid phone number'],\r\n },\r\n {\r\n type: 'max',\r\n params: [35, 'Invalid phone number'],\r\n },\r\n {\r\n type: 'matches',\r\n params: [/^[0-9,(,),+,\\-,.,[,\\] ]+$/, 'Invalid phone number'],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n 'returnType',\r\n (returnType, schema) => {\r\n return returnType === 'sendToThirdParty'\r\n ? schema.required('Phone Number is required')\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n toEmailAddress: {\r\n props: {\r\n name: 'toEmailAddress',\r\n label: 'Email address',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 70,\r\n },\r\n },\r\n validation: {\r\n name: 'emailAddress',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [70, 'Maximum 70 characters are allowed'],\r\n },\r\n {\r\n type: 'email',\r\n params: ['Invalid email address'],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n 'returnType',\r\n (returnType, schema) => {\r\n return returnType === 'sendToThirdParty'\r\n ? schema\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n deliveryType: {\r\n props: {\r\n name: 'deliveryType',\r\n label: 'Delivery type:',\r\n type: 'radio',\r\n },\r\n value: 'deliverToDoorStep',\r\n validation: {\r\n name: 'deliveryType',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Delivery Type is required'],\r\n },\r\n ],\r\n },\r\n },\r\n doorStepInstructions: {\r\n props: {\r\n name: 'doorStepInstructions',\r\n label: 'Doorstep Instructions',\r\n type: 'select',\r\n displayField: 'name',\r\n hasDefaultValue: true,\r\n isRequired: true,\r\n },\r\n validation: {\r\n name: 'doorStepInstructions',\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'returnType',\r\n (returnType, schema) => {\r\n return returnType === 'sendToThirdParty'\r\n ? schema.required('Doorstep Instructions is required')\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n deliveryServicePoint: {\r\n props: {\r\n name: 'deliveryServicePoint',\r\n label: 'Find ServicePoint',\r\n type: 'text',\r\n placeholder: 'Search For ServicePoint',\r\n },\r\n validation: {\r\n name: 'postalCode',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'deliveryType',\r\n (deliveryType, schema) => {\r\n return deliveryType === 'deliverToServicePoint'\r\n ? schema.required('Postal code is required')\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n ['deliveryType', 'returnType'],\r\n (deliveryType, returnType, schema) => {\r\n if (deliveryType === 'deliverToServicePoint' && returnType === 'sendToThirdParty') {\r\n return testFunctionForPostCodeRegex(schema, 'Invalid postal code', '', true);\r\n }\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n specialInstructions: {\r\n props: {\r\n name: 'specialInstructions',\r\n label: 'Special instructions',\r\n type: 'text',\r\n },\r\n inputProps: {\r\n maxLength: 30,\r\n },\r\n validation: {\r\n name: 'specialInstructions',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [30, 'Maximum 30 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n additionalInstruction: {\r\n props: {\r\n name: 'additionalInstruction',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 30,\r\n },\r\n },\r\n validation: {\r\n name: 'additionalInstruction',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [30, 'Maximum 30 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n leaveSafeLocation: {\r\n props: {\r\n name: 'leaveSafeLocation',\r\n label: 'Leave Safe location',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 60,\r\n },\r\n },\r\n validation: {\r\n name: 'leaveSafeLocation',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [60, 'Maximum 60 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n toAddToaddressBook: {\r\n props: {\r\n name: 'toAddToaddressBook',\r\n label: 'Add to address book',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n updateToAddToaddressBook: {\r\n props: {\r\n name: 'updateToAddToaddressBook',\r\n label: 'Update address in address book',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n toAddToFavourites: {\r\n props: {\r\n name: 'toAddToFavourites',\r\n label: 'Add to my favourites',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n specialInstructions: {\r\n props: {\r\n name: 'specialInstructions',\r\n label: 'Special instructions',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 30,\r\n },\r\n },\r\n // value: 'ENTER',\r\n validation: {\r\n name: 'specialInstructions',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [30, 'Maximum of 30 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n toServiceRequired: {\r\n props: {\r\n name: 'toServiceRequired',\r\n label: 'Service',\r\n type: 'select',\r\n displayField: 'name',\r\n isRequired: true,\r\n hasDefaultValue: true,\r\n },\r\n value: 'nextday',\r\n validation: {\r\n name: 'toServiceRequired',\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Service is required'],\r\n },\r\n ],\r\n },\r\n },\r\n accounts: {\r\n props: {\r\n name: 'accountNumber',\r\n label: 'Account number',\r\n type: 'autoComplete',\r\n displayField: 'displayName',\r\n hasDefaultValue: true,\r\n },\r\n validation: {\r\n name: 'accountNumber',\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Account number is required'],\r\n },\r\n ],\r\n },\r\n },\r\n returnType: {\r\n props: {\r\n name: 'returnType',\r\n type: 'radio',\r\n },\r\n value: 'returnToSender',\r\n },\r\n sendLabelEmailAddress: {\r\n props: {\r\n name: 'sendLabelEmailAddress',\r\n label: 'Email address',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 70,\r\n },\r\n },\r\n validation: {\r\n name: 'sendLabelEmailAddress',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Email address is required'],\r\n },\r\n {\r\n type: 'max',\r\n params: [70, 'Maximum 70 characters are allowed'],\r\n },\r\n {\r\n type: 'email',\r\n params: ['Invalid email address'],\r\n },\r\n {\r\n type: 'matches',\r\n params: [\r\n /^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/,\r\n 'Invalid email Address',\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n handOverMethod: {\r\n props: {\r\n name: 'handOverMethod',\r\n label: 'Parcel handover method:',\r\n type: 'radio',\r\n },\r\n validation: {\r\n name: 'handOverMethod',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Name is required'],\r\n },\r\n ],\r\n },\r\n },\r\n servicePoint: {\r\n props: {\r\n name: 'servicePoint',\r\n label: 'Find ServicePoint',\r\n type: 'text',\r\n placeholder: 'Enter and Search',\r\n },\r\n validation: {\r\n name: 'servicePoint',\r\n validationType: 'string',\r\n\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['ServicePoint is required'],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n 'handOverMethod',\r\n (handOverMethod, schema) => {\r\n if (handOverMethod === 'servicePoint') {\r\n return testFunctionForPostCodeRegex(schema, 'Enter a correct postcode', '', true);\r\n }\r\n return schema;\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n what3Words: {\r\n props: {\r\n name: 'what3Words',\r\n label: 'What3Words',\r\n type: 'text',\r\n },\r\n },\r\n w3WCoordinates: {\r\n props: {\r\n name: 'w3WCoordinates',\r\n type: 'object',\r\n },\r\n }, \r\n shipmentMovement: {\r\n props: {\r\n name: 'shipmentMovement',\r\n label: 'Shipment Movement Type',\r\n type: 'select',\r\n displayField: 'name',\r\n hasDefaultValue: true,\r\n },\r\n validation: {\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Shipment Movement Type is required'],\r\n },\r\n ],\r\n },\r\n },\r\n clearanceDescriptionGoods: {\r\n props: {\r\n name: 'clearanceDescriptionGoods',\r\n label: 'Description of goods',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 90,\r\n },\r\n },\r\n validation: {\r\n name: 'clearanceDescriptionGoods',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Description of goods is required'],\r\n },\r\n {\r\n type: 'min',\r\n params: [3, 'Minimum of 3 characters are required'],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n 'shipmentMovement',\r\n (shipmentMovement,schema) => {\r\n return (shipmentMovement?.value === CLERANCE_DECLARATION.MOVEMENT_TYPE_C2C_VALUE)\r\n ? schema.required('Description of goods is required')\r\n : schema.notRequired();\r\n },\r\n ], \r\n },\r\n ],\r\n },\r\n },\r\n clearanceTotalValue: {\r\n props: {\r\n name: 'clearanceTotalValue',\r\n label: 'Total Value',\r\n type: 'number',\r\n isRequired: true,\r\n inputProps: {\r\n min: 0,\r\n max: 99999999,\r\n }\r\n },\r\n validation: {\r\n name: 'clearanceTotalValue',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'min',\r\n params: [0.01, 'Total Value cannot be less than 0.01'],\r\n },\r\n {\r\n type: 'max',\r\n params: [99999999.99, 'Total Value should be 99999999.99 or less'],\r\n },\r\n {\r\n type: 'required',\r\n params: ['Total Value is required'],\r\n },\r\n ],\r\n },\r\n },\r\n receipentUKIMS: {\r\n props: {\r\n name: 'receipentUKIMS',\r\n label: 'Recipient UKIMS number',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 32,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'matches',\r\n params: [/^[a-zA-Z0-9]{1,32}$/, 'Recipient UKIMS no. must be alphanumeric'],\r\n },\r\n {\r\n type: 'min',\r\n params: [32, `Recipient UKIMS no. must in the correct format (e.g. XIUKIM12345678910111213141516171)`],\r\n },\r\n ],\r\n }\r\n },\r\n shipperUKIMS: {\r\n props: {\r\n name: 'shipperUKIMS',\r\n label: `Shipper's UKIMS number`,\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 32,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n \r\n {\r\n type: 'matches',\r\n params: [/^[a-zA-Z0-9]{1,32}$/, `Shipper's UKIMS no. must be alphanumeric`],\r\n },\r\n\r\n {\r\n type: 'min',\r\n params: [32, `Shipper's UKIMS no. must be in the correct format (e.g. XIUKIM12345678910111213141516171)`],\r\n },\r\n ]\r\n }\r\n },\r\n shipperEORI: {\r\n props: {\r\n name: 'shipperEORI',\r\n label: `Shipper's EORI number`,\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 15,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'shipperUKIMS',\r\n (shipperUKIMS,schema) => {\r\n return (typeof(shipperUKIMS)) === 'string'\r\n ? schema.required(`Shipper's EORI no. is required`)\r\n : schema.notRequired();\r\n },\r\n ],\r\n \r\n },\r\n {\r\n type: 'max',\r\n params: [15, `Shipper's EORI no. must be in the correct format (e.g. AB123456789011)`],\r\n },\r\n {\r\n type: 'min',\r\n params: [14, `Shipper's EORI no. must be in the correct format (e.g. AB123456789011)`],\r\n },\r\n {\r\n type: 'matches',\r\n params: [/^[a-zA-Z0-9]*$/, `Shipper's EORI no. must be alphanumeric`],\r\n },\r\n ],\r\n },\r\n },\r\n reasonExport: {\r\n props: {\r\n name: 'reasonExport',\r\n label: 'Reason For Export',\r\n type: 'select',\r\n displayField: 'name',\r\n hasDefaultValue: true,\r\n isRequired: true,\r\n },\r\n validation: {\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n ['shipmentMovement', 'shipperUKIMS', 'receipentUKIMS'],\r\n (shipmentMovement, shipperUKIMS, receipentUKIMS, schema) => {\r\n return shipmentMovement?.value === CLERANCE_DECLARATION.MOVEMENT_TYPE_B2B_VALUE \r\n && (typeof(shipperUKIMS) != 'string')\r\n && (typeof(receipentUKIMS) != 'string')\r\n ? schema.required('Reason Export is required')\r\n : schema.notRequired();\r\n },\r\n ], \r\n },\r\n ],\r\n },\r\n },\r\n receipentEORI: {\r\n props: {\r\n name: 'receipentEORI',\r\n label: 'Recipient EORI number',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 15,\r\n },\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'receipentUKIMS',\r\n (receipentUKIMS,schema) => {\r\n return typeof(receipentUKIMS) === 'string' \r\n ? schema.required('Recipient EORI no. is required')\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n {\r\n type: 'max',\r\n params: [15, 'Recipient EORI no. must be in the correct format (e.g. AB123456789011)'],\r\n },\r\n {\r\n type: 'min',\r\n params: [14, 'Recipient EORI no. must be in the correct format (e.g. AB123456789011)'],\r\n },\r\n {\r\n type: 'matches',\r\n params: [/^[a-zA-Z0-9]*$/, 'Recipient EORI no. must be alphanumeric'],\r\n },\r\n ],\r\n },\r\n },\r\n shippingCharges: {\r\n props: {\r\n name: 'shippingCharges',\r\n label: 'Shipping Charges',\r\n type: 'number',\r\n inputProps: {\r\n min: 0,\r\n max: 99999999,\r\n },\r\n isRequired: true,\r\n },\r\n validation: {\r\n name: 'shippingCharges',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'shipperUKIMS',\r\n (shipperUKIMS,schema) => {\r\n return (typeof(shipperUKIMS) != 'string')\r\n ? schema.required('Shipping Charges is required')\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n 'receipentUKIMS',\r\n (receipentUKIMS,schema) => {\r\n return (typeof(receipentUKIMS) != 'string')\r\n ? schema.required('Shipping Charges is required')\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n {\r\n type: 'max',\r\n params: [99999999.99, 'Shipping Charges must be 99999999.99 or less'],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n ['shipmentMovement', 'shipperUKIMS', 'receipentUKIMS'],\r\n (shipmentMovement, shipperUKIMS, receipentUKIMS, schema) => {\r\n return shipmentMovement?.value === CLERANCE_DECLARATION.MOVEMENT_TYPE_B2B_VALUE \r\n && (typeof(shipperUKIMS) != 'string')\r\n && (typeof(receipentUKIMS) != 'string')\r\n ? schema.required('Shipping Charges is required')\r\n : schema.notRequired();\r\n },\r\n ], \r\n },\r\n ],\r\n },\r\n },\r\n shipperDeferment: {\r\n props: {\r\n name: 'shipperDeferment',\r\n label: `Shipper's deferment account number`,\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 20,\r\n },\r\n },\r\n validation: {\r\n name: 'shipperDeferment',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'min',\r\n params: [6, `Shipper's deferment account no. must be between 6 to 20 character`],\r\n },\r\n {\r\n type: 'max',\r\n params: [20, `Shipper's deferment account no. must be between 6 to 20 character`],\r\n },\r\n {\r\n type: 'matches',\r\n params: [/^[a-zA-Z0-9]*$/, `Shipper's deferment account no. must be alphanumeric`],\r\n },\r\n ],\r\n },\r\n },\r\n commodityDetails: {\r\n props: {\r\n name: 'commodityDetails',\r\n type: 'array',\r\n fields: {\r\n commodityCode: 'text',\r\n fullDescriptionOfGoods: 'text',\r\n weight: 'number',\r\n quantity: 'number',\r\n unitValue: 'number',\r\n countryOfOrigin: 'text',\r\n },\r\n },\r\n values: [],\r\n validation: {\r\n name: 'commodityDetails',\r\n validationType: 'array',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n ['fullDescriptionOfGoods', 'commodityCode', 'quantity'],\r\n (fullDescriptionOfGoods, commodityCode, quantity, schema) => {\r\n return (fullDescriptionOfGoods && commodityCode && quantity)\r\n ? schema\r\n .required('Commodity details are required')\r\n .min(1, 'Minimum of 1 item needs to be added')\r\n .max(20, 'Maximum 20 items are allowed')\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n },\r\n};\r\n\r\nexport default carriageForwardForm;\r\n","import React, { useState, useEffect } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport Grid from '@material-ui/core/Grid';\r\nimport { abortOnGoingCallsFor, axiosConfig, GET } from '../../../api/axios';\r\nimport { useSelector, useDispatch } from 'react-redux';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport {\r\n getDomesticAccounts,\r\n getWorkingDays,\r\n getFMDAccounts,\r\n getDriverCollectionAccounts,\r\n} from '../../../utils/helperFunctions';\r\nimport { doorStepInstructionOptions } from '../../../utils/constants/constants';\r\n\r\nconst Basicdetails = (props) => {\r\n const dispatch = useDispatch();\r\n const {\r\n formField: { returnType, accounts, collectionDate },\r\n setFieldValue,\r\n formikValues,\r\n } = props;\r\n\r\n let userAccounts = useSelector((state) => state.accounts.nonReturnuserAccounts);\r\n const loadedFrom = useSelector((state) => state.loadedFrom.loadedFrom);\r\n let [displayAccounts, setDisplayAccounts] = useState([]);\r\n let [domesticAccounts, setDomesticAccounts] = useState(userAccounts);\r\n const [isDisPatchDateVisible, setIsDispatchDateVisible] = useState(true);\r\n\r\n useEffect(() => {\r\n userAccounts = getDomesticAccounts(userAccounts);\r\n setDisplayAccounts(userAccounts);\r\n }, [userAccounts]);\r\n\r\n useEffect(() => {\r\n if (formikValues.handOverMethod === 'servicePoint') {\r\n setIsDispatchDateVisible(false);\r\n } else if (formikValues.handOverMethod === 'driverCollection') {\r\n setIsDispatchDateVisible(true);\r\n }\r\n }, [formikValues.handOverMethod])\r\n useEffect(() => {\r\n const { accountNumber } = props.formikValues;\r\n if (accountNumber) {\r\n dispatch(actions.setSelectedAccount(accountNumber));\r\n }\r\n }, [props.formikValues.accountNumber]);\r\n\r\n const [workingDays, setWorkingDays] = useState([]);\r\n\r\n const setActualWorkingDays = async () => {\r\n let holidayRegion = '';\r\n if (formikValues?.accountNumber?.sender?.postalCode) {\r\n abortOnGoingCallsFor(ServiceEndPoints.getPostcodeDistrict);\r\n await axiosConfig\r\n .get(`${ServiceEndPoints.getPostcodeDistrict}?postcode=${formikValues.accountNumber.sender.postalCode}`)\r\n .then((res) => {\r\n holidayRegion = res?.data?.ukHolidayRegion;\r\n })\r\n .catch((err) => console.log(err))\r\n };\r\n if (formikValues.accountNumber?.configuration) {\r\n abortOnGoingCallsFor(ServiceEndPoints.getPublicHolidays);\r\n axiosConfig.get(`${ServiceEndPoints.getPublicHolidays}?countryCode=GB`)\r\n .then((res) => {\r\n const publicHolidays = holidayRegion\r\n ? res.data?.publicHolidays.filter((holiday) => holiday.region === holidayRegion)\r\n : res.data?.publicHolidays;\r\n getWorkingDays(publicHolidays, setWorkingDays);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n setActualWorkingDays();\r\n }, [formikValues.accountNumber]);\r\n\r\n useEffect(() => {\r\n if (\r\n workingDays.length > 0 &&\r\n (!formikValues.collectionDate ||\r\n (formikValues.collectionDate &&\r\n new Date(formikValues.collectionDate).getTime() < new Date(workingDays[0]).getTime()))\r\n ) {\r\n setFieldValue('collectionDate', workingDays[0]);\r\n }\r\n }, [formikValues.collectionDate, setFieldValue, workingDays]);\r\n\r\n useEffect(() => {\r\n if (loadedFrom === '') {\r\n setFieldValue('collectionDate', workingDays.length > 0 ? workingDays[0] : '');\r\n }\r\n }, [workingDays]);\r\n\r\n useEffect(() => {\r\n const { handOverMethod } = props.formikValues;\r\n if (handOverMethod === 'driverCollection' && props.formikValues.accountNumber === '') {\r\n const domesticCollectionAccounts = getDriverCollectionAccounts(displayAccounts);\r\n domesticCollectionAccounts.length > 0 ? setFieldValue('accountNumber', domesticCollectionAccounts[0]) : setFieldValue('accountNumber', '');\r\n }\r\n }, [displayAccounts, props.formikValues.handOverMethod]);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nBasicdetails.propTypes = {\r\n setFieldValue: PropTypes.func,\r\n formField: PropTypes.object,\r\n returnType: PropTypes.object,\r\n accounts: PropTypes.object,\r\n collectionDate: PropTypes.object,\r\n accountNumber: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n};\r\n\r\nexport default Basicdetails;\r\n\r\nconst ReturnTypes = [\r\n {\r\n value: 'returnToSender',\r\n label: 'Return to sender',\r\n },\r\n {\r\n value: 'sendToThirdParty',\r\n label: 'Send to 3rd party',\r\n },\r\n];\r\n","import React, { useState, useEffect } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, IconButton, SvgIcon } from '@material-ui/core';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { useSelector } from 'react-redux';\r\nimport { ServicePointError, NoOfRows } from '../../../utils/constants/constants';\r\nimport { SearchIcon } from '@material-ui/data-grid';\r\nimport { axiosConfig } from '../../../api/axios';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport CustomModal from '../../../framework/modal/modal';\r\nimport CustomDataTable from '../../../framework/CustomDataTable/CustomDataTable';\r\nimport CustomDialog from '../../../framework/dialog/customDialog';\r\nimport { connect } from 'react-redux';\r\nimport * as actions from '../../../store/actions/index';\r\nconst ParcelHandover = (props) => {\r\n const {\r\n formField: { handOverMethod, servicePoint },\r\n setFieldValue,\r\n formikValues, errors,\r\n } = props;\r\n\r\n let userAccounts = useSelector((state) => state.accounts.nonReturnuserAccounts);\r\n\r\n const [servicePoints, setservicePoints] = React.useState([]);\r\n const [isAddressSelected, setIsAddressSelected] = useState(false);\r\n const [open, setOpen] = React.useState(false);\r\n const [isDialogOpen, setIsDialogOpen] = useState(false);\r\n\r\n //Set the handover method to drivercollection on intial load\r\n useEffect(() => {\r\n setFieldValue('handOverMethod', 'driverCollection');\r\n }, []);\r\n\r\n const isDriverCollection = () => {\r\n return (props.formikValues || {}).handOverMethod === 'driverCollection';\r\n };\r\n\r\n useEffect(() => {\r\n setFieldValue('handOverMethod', 'driverCollection');\r\n }, [])\r\n\r\n const rowClicked = (val) => {\r\n props.setServicePointData(val);\r\n setIsAddressSelected(true);\r\n const data = `${val.address.address1 || ''} ${val.address.address2 || ''} ${val.address.postalTown || ''}`;\r\n setFieldValue('servicePoint', data);\r\n handleModal(false);\r\n };\r\n\r\n const handleModal = (value) => {\r\n setOpen(value);\r\n };\r\n\r\n const handleClose = (value) => {\r\n setOpen(false);\r\n };\r\n\r\n\r\n const getServicePoints = () => {\r\n setservicePoints([]);\r\n props?.loader(true);\r\n const { servicePoint } = props.formikValues;\r\n const encodePostcodeURI = encodeURIComponent(servicePoint);\r\n const url = `${ServiceEndPoints.getServicePoints}?countryCode=GB&PostCode=${encodePostcodeURI}&ServicePointType=parcelshop`;\r\n axiosConfig\r\n .get(url)\r\n .then((res) => {\r\n setservicePoints(res.data.slice(0, NoOfRows));\r\n handleModal(true);\r\n })\r\n .catch((err) => {\r\n setservicePoints([]);\r\n props.setSnackBar({ type: 'error', msg: 'No service point found' });\r\n })\r\n .finally(() => {\r\n props?.loader(false);\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n if (formikValues.handOverMethod === 'servicePoint') {\r\n setIsAddressSelected(false);\r\n }\r\n }, [formikValues.handOverMethod]);\r\n\r\n useEffect(() => {\r\n if (formikValues.servicePoint === '') {\r\n setIsAddressSelected(false);\r\n }\r\n }, [formikValues.servicePoint]);\r\n\r\n useEffect(() => {\r\n // setFieldValue('servicePoint', formikValues?.accountNumber?.sender?.postalCode ?? '')\r\n if (formikValues.handOverMethod === 'driverCollection') {\r\n setFieldValue('servicePoint', '')\r\n setIsAddressSelected(false);\r\n }\r\n }, [formikValues.handOverMethod, formikValues?.accountNumber]);\r\n\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n {isDriverCollection() ? null :\r\n (\r\n \r\n \r\n \r\n \r\n ),\r\n }}\r\n fullWidth\r\n />\r\n \r\n \r\n \r\n \r\n )}\r\n \r\n \r\n );\r\n};\r\n\r\nParcelHandover.propTypes = {\r\n setFieldValue: PropTypes.func,\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n loadedFrom: state.loadedFrom.loadedFrom,\r\n };\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n setSnackBar: (data) => {\r\n dispatch(actions.setAppSnackBarData(data));\r\n },\r\n loader: (data) => {\r\n dispatch(actions.setLoaderLayOver(data));\r\n },\r\n setIossLimits: (data) => {\r\n dispatch(actions.setIossValueLimits(data));\r\n },\r\n setServicePointData: (data) => {\r\n dispatch(actions.setServiceLocationDetails(data));\r\n }\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(ParcelHandover);\r\n\r\nconst handOverOptions = [\r\n {\r\n value: 'driverCollection',\r\n label: 'Driver collection',\r\n },\r\n {\r\n value: 'servicePoint',\r\n label: 'Drop off at ServicePoint',\r\n },\r\n];","export const DeliveryTypeOptions = [\r\n {\r\n value: 'business',\r\n label: 'Business',\r\n },\r\n {\r\n value: 'residential',\r\n label: 'Residential',\r\n },\r\n];\r\n\r\nexport const SearchByOptions = [\r\n {\r\n value: 'customernumber',\r\n name: 'Customer number',\r\n },\r\n {\r\n value: 'recipientname',\r\n name: 'Recipient name',\r\n },\r\n {\r\n value: 'businessname',\r\n name: 'Business name',\r\n },\r\n {\r\n value: 'town',\r\n name: 'Town',\r\n },\r\n {\r\n value: 'postcode',\r\n name: 'Postal code',\r\n },\r\n];\r\n\r\nexport const PostalCodeTablecolumns = [\r\n { field: 'id', headerName: 'ID', width: 70 },\r\n { field: 'text', headerName: 'Text', width: 130 },\r\n { field: 'type', headerName: 'Type', width: 80 },\r\n { field: 'highlight', headerName: 'Highlight', width: 130 },\r\n { field: 'description', headerName: 'Description', width: 130 },\r\n];\r\n","import React, { useEffect } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Divider, Grid, IconButton } from '@material-ui/core';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { axiosConfig, GET } from '../../../api/axios';\r\nimport { useSelector } from 'react-redux';\r\nimport CustomDialog from '../../../framework/dialog/customDialog';\r\nimport CustomAddressTable from '../../../framework/CustomAddressTable/CustomAddressTable';\r\nimport { SearchIcon } from '@material-ui/data-grid';\r\nimport {\r\n formatPostalCodeValues,\r\n removeUndefinedProperties,\r\n getCustomerAccountID,\r\n getWorkingDays,\r\n setValuesToParcelDetails,\r\n} from '../../../utils/helperFunctions';\r\nimport { MIN_SEARCH_RESULTS_REQUIRED } from '../../../utils/constants/constants';\r\nimport { renderEmptyText } from '../../../utils/common';\r\nimport { DeliveryTypeOptions, SearchByOptions } from '../../../utils/constants/carriageForwardConstants';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport AddToAddressAndFav from '../../helperComponents/addToAddressAndFav';\r\nimport AddressSearch from '../../helperComponents/addessSearch/addressSearch';\r\nimport ParcelHandover from '../../carriageForward/parcelHandover/parcelHandover';\r\nimport { getServicepointWeight } from '../../../utils/utilsFunctions';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { connect } from 'react-redux';\r\nimport { getCustomDeclaration, getMaxWeightFullcustoms } from '../../../utils/utilsFunctions';\r\nimport { MISC_VALUES } from '../../../utils/constants/constants';\r\nimport { ERROR_MSG } from '../../../utils/constants/errorConstant';\r\n\r\nlet dimsValidation = {};\r\n\r\nconst CollectFrom = (props) => {\r\n const {\r\n formField,\r\n formField: {\r\n fromAddressType,\r\n fromSearchFor,\r\n fromBusinessName,\r\n fromCustomerNo,\r\n fromPostCode,\r\n fromContactName,\r\n fromAddressLine1,\r\n fromAddressLine2,\r\n fromAddressLine3,\r\n fromTown,\r\n fromCounty,\r\n fromTelephoneNumber,\r\n fromEmailAddress,\r\n fromCustomerReference,\r\n collectionInstructions,\r\n descriptionOfGoods,\r\n fromWeight,\r\n fromParcel,\r\n collectionDate,\r\n },\r\n setFieldValue,\r\n formikValues,\r\n errors,\r\n setValues,\r\n setFromAddressSearchObj,\r\n allProducts,\r\n } = props;\r\n const loadedFrom = useSelector((state) => state.loadedFrom.loadedFrom);\r\n const [openAddressBookModal, setOpenAddressBookModal] = React.useState(false);\r\n const [customerNumber, setCustomerNumber] = React.useState('');\r\n const [customerData, setCustomerData] = React.useState([]);\r\n const [postalSearchData, setPostalSearchData] = React.useState([]);\r\n const [isItemDisabled, setIsItemDisabled] = React.useState(false);\r\n const [workingDays, setWorkingDays] = React.useState([]);\r\n const [isDisPatchDateVisible, setIsDispatchDateVisible] = React.useState(true);\r\n let addressTypeData = [];\r\n let leftOverData = [];\r\n\r\n useEffect(() => {\r\n if (formikValues.handOverMethod === MISC_VALUES.SERVICE_POINT_HANDOVER_METHOD) {\r\n setIsDispatchDateVisible(false);\r\n } else if (formikValues.handOverMethod === MISC_VALUES.DRIVER_COLLECTION_HANDOVER_METHOD) {\r\n setIsDispatchDateVisible(true);\r\n }\r\n }, [formikValues.handOverMethod]);\r\n\r\n useEffect(async () => {\r\n let holidayRegion = '';\r\n formikValues?.accountNumber?.sender?.postalCode &&\r\n (await axiosConfig\r\n .get(`${ServiceEndPoints.getPostcodeDistrict}?postcode=${formikValues.accountNumber.sender.postalCode}`)\r\n .then((res) => {\r\n holidayRegion = res?.data?.ukHolidayRegion;\r\n })\r\n .catch((err) => console.log(err)));\r\n formikValues.accountNumber?.configuration &&\r\n GET(`${ServiceEndPoints.getPublicHolidays}?countryCode=gb`)\r\n .then((res) => {\r\n const publicHolidays = holidayRegion\r\n ? res.data?.publicHolidays.filter((holiday) => holiday.region === holidayRegion)\r\n : res.data?.publicHolidays;\r\n getWorkingDays(publicHolidays, setWorkingDays);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n }, [formikValues.accountNumber]);\r\n\r\n useEffect(() => {\r\n if (\r\n workingDays.length > 0 &&\r\n (!formikValues.collectionDate ||\r\n (formikValues.collectionDate &&\r\n new Date(formikValues.collectionDate).getTime() < new Date(workingDays[0]).getTime()))\r\n ) {\r\n setFieldValue('collectionDate', workingDays[0]);\r\n }\r\n }, [formikValues.collectionDate, setFieldValue, workingDays]);\r\n\r\n useEffect(() => {\r\n if (loadedFrom === '') {\r\n setFieldValue('collectionDate', workingDays.length > 0 ? workingDays[0] : '');\r\n }\r\n }, [workingDays]);\r\n\r\n useEffect(() => {\r\n if (formikValues.handOverMethod === MISC_VALUES.SERVICE_POINT_HANDOVER_METHOD) {\r\n setFieldValue('fromParcel', 1);\r\n setIsItemDisabled(true);\r\n } else {\r\n setFieldValue('fromParcel', 1);\r\n setIsItemDisabled(false);\r\n }\r\n }, [formikValues.handOverMethod]);\r\n\r\n useEffect(() => {\r\n setFieldValue('fromSearchBy', SearchByOptions[0]);\r\n }, [setFieldValue]);\r\n\r\n React.useEffect(() => {\r\n setFieldValue('fromSearchFor', '');\r\n }, [props.formikValues.fromSearchBy]);\r\n\r\n const getCustomerAddressBook = (event) => {\r\n event.preventDefault();\r\n const url = `${ServiceEndPoints.getAddressBook}?organization=${getCustomerAccountID()}&${\r\n formikValues.fromSearchBy.value\r\n }=${formikValues.fromSearchFor}&countryCode=GB`;\r\n axiosConfig\r\n .get(url)\r\n .then((res) => {\r\n if (\r\n formikValues.fromSearchBy.value === MISC_VALUES.CUSTOMER_NUMBER &&\r\n ((res.data || {}).addressBooks || []).length === 1\r\n ) {\r\n rowClicked(res.data.addressBooks[0]);\r\n } else {\r\n setOpenAddressBookModal(true);\r\n setCustomerData(res.data.addressBooks);\r\n }\r\n })\r\n .catch((err) => {\r\n setOpenAddressBookModal(true);\r\n setCustomerData([]);\r\n console.log(err);\r\n });\r\n };\r\n const rowClicked = (val) => {\r\n const address = val.deliveryAddress;\r\n setFromAddressSearchObj(val);\r\n setAddressToForm(address, true, val);\r\n setCustomerNumber(address.customerNumber);\r\n setOpenAddressBookModal(false);\r\n };\r\n\r\n const setAddressToForm = (address, isAddressBook = true, dimsDetails = null) => {\r\n const { RESIDENTIAL_ADDRESS_TYPE, COMMERCIAL_ADDRESS_TYPE, BUSINESS_ADDRESS_TYPE } = MISC_VALUES;\r\n let parcelDetails = {};\r\n const addressObj = {\r\n fromAddressType: isAddressBook\r\n ? address.recipientType === 1\r\n ? BUSINESS_ADDRESS_TYPE\r\n : RESIDENTIAL_ADDRESS_TYPE\r\n : address?.type === COMMERCIAL_ADDRESS_TYPE\r\n ? BUSINESS_ADDRESS_TYPE\r\n : RESIDENTIAL_ADDRESS_TYPE,\r\n fromTown: isAddressBook ? address?.town : address.city,\r\n fromAddressLine1: address?.line1,\r\n fromAddressLine2: address?.line2,\r\n fromAddressLine3: address?.line3,\r\n fromPostCode: isAddressBook ? address?.postCode?.toUpperCase() : address?.postalCode?.toUpperCase(),\r\n fromBusinessName: isAddressBook ? address?.businessName : address?.company,\r\n fromCustomerNo: address?.customerNumber,\r\n fromEmailAddress: address?.email,\r\n fromContactName: address?.recipientName,\r\n fromTelephoneNumber: address?.telephone,\r\n fromCounty: isAddressBook ? address?.county : address?.provinceName,\r\n fromCustomerReference: dimsDetails?.customerReference ?? '',\r\n collectionInstructions: dimsDetails?.collectionInstructions,\r\n descriptionOfGoods: dimsDetails?.descriptionOfGoodsToBeCollected,\r\n };\r\n //Set weight & items value\r\n if (dimsDetails) {\r\n if (formikValues.handOverMethod === MISC_VALUES.SERVICE_POINT_HANDOVER_METHOD) {\r\n parcelDetails = {\r\n fromWeight: dimsDetails.parcelDetails?.weight,\r\n };\r\n } else {\r\n parcelDetails = {\r\n fromParcel: dimsDetails.parcelDetails?.numberOfItems,\r\n fromWeight: dimsDetails.parcelDetails?.weight,\r\n };\r\n }\r\n }\r\n removeUndefinedProperties(addressObj);\r\n setValues({ ...formikValues, ...addressObj, ...parcelDetails });\r\n };\r\n const handleClose = () => {\r\n setOpenAddressBookModal(false);\r\n };\r\n\r\n const isResidential = () => {\r\n return formikValues.fromAddressType === MISC_VALUES.RESIDENTIAL_ADDRESS_TYPE;\r\n };\r\n\r\n const setValuesFromPostalSearch = (val) => {\r\n setAddressToForm(val, false);\r\n };\r\n const customerNumberBlurred = (eve) => {\r\n setCustomerNumber(eve.target.value);\r\n };\r\n\r\n useEffect(() => {\r\n setFieldValue('sendLabelEmailAddress', formikValues.fromEmailAddress);\r\n }, [formikValues.fromEmailAddress, setFieldValue]);\r\n\r\n useEffect(() => {\r\n if (formikValues.fromAddressType === MISC_VALUES.RESIDENTIAL_ADDRESS_TYPE) {\r\n setFieldValue('fromBusinessName', '');\r\n }\r\n }, [formikValues.fromAddressType]);\r\n const setAddressValues = (addressObj) => {\r\n const formObj = {\r\n fromTown: addressObj.city,\r\n fromAddressLine1: addressObj.line1,\r\n fromAddressLine2: addressObj.line2,\r\n fromAddressLine3: addressObj.line3,\r\n fromPostCode: addressObj.postalCode,\r\n fromCounty: addressObj.provinceName,\r\n fromBusinessName: addressObj.company,\r\n };\r\n\r\n setValues({ ...formikValues, ...formObj });\r\n };\r\n\r\n const handleAddressChangeByPostCode = (addressType) => {\r\n if (addressType) {\r\n if (addressType === MISC_VALUES.COMMERCIAL_ADDRESS_TYPE) {\r\n setFieldValue('fromAddressType', DeliveryTypeOptions[0].value);\r\n } else {\r\n setFieldValue('fromAddressType', DeliveryTypeOptions[1].value);\r\n }\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n const { MIN, MAX, REQUIRED } = MISC_VALUES;\r\n const { WEIGHT_REQUIRED, WEIGHT_OUTSIDE_PERMITTED_RANGE, MUST_VALUE_BETWEEN_ONE_TO } = ERROR_MSG;\r\n axiosConfig\r\n .get(`${ServiceEndPoints.productCountryFeature}?countrycode=GB`)\r\n .then((response) => {\r\n const nonPalletProducts = response.data.filter((val) => val.productCode !== 97 && val.productCode !== 98);\r\n\r\n let allMaxParcelsList = nonPalletProducts.map((x) => x.maximumParcels);\r\n let allMaxWeightList = nonPalletProducts.map((x) => x.maximumWeight);\r\n\r\n dimsValidation = {\r\n ...dimsValidation,\r\n maxParcels: Math.max(...allMaxParcelsList),\r\n maxWeight: Math.max(...allMaxWeightList),\r\n maximumWeightPerParcelWithFullCustoms: getMaxWeightFullcustoms(response.data),\r\n };\r\n\r\n fromParcel.validation.validations = fromParcel.validation.validations.filter(\r\n (x) => x.type !== MAX && x.type !== MIN,\r\n );\r\n fromParcel.validation.validations.push({\r\n type: MAX,\r\n params: [dimsValidation.maxParcels, `${MUST_VALUE_BETWEEN_ONE_TO} ${dimsValidation.maxParcels}`],\r\n });\r\n fromParcel.validation.validations.push({\r\n type: MIN,\r\n params: [1, `${MUST_VALUE_BETWEEN_ONE_TO} ${dimsValidation.maxParcels}`],\r\n });\r\n fromParcel.props.inputProps.max = dimsValidation.maxParcels;\r\n\r\n fromWeight.validation.validations = fromWeight.validation.validations.filter(\r\n (x) => x.type !== MAX && x.type !== MIN,\r\n );\r\n fromWeight.validation.validations.push({\r\n type: MAX,\r\n params: [dimsValidation.maxWeight, WEIGHT_OUTSIDE_PERMITTED_RANGE],\r\n });\r\n fromWeight.validation.validations.push({\r\n type: MIN,\r\n params: [1, WEIGHT_OUTSIDE_PERMITTED_RANGE],\r\n });\r\n fromWeight.validation.validations.push({\r\n type: REQUIRED,\r\n params: [WEIGHT_REQUIRED],\r\n });\r\n fromWeight.props.inputProps.max = dimsValidation.maxWeight;\r\n props.updateValidationSchema?.();\r\n\r\n // Set the service point details using the weight calculated from the response data in store\r\n props.setServicePointDetails(getServicepointWeight(response.data));\r\n\r\n // Set the Maximum weight for windsor using the maximumWeightPerParcelWithFullCustoms calculated from the response data in store\r\n props.setMaxWeightFullcustoms(getMaxWeightFullcustoms(response.data));\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (props.updateValidationSchema) {\r\n if (!formikValues?.accountNumber?.configuration?.consigneeEmailOptional) {\r\n !fromEmailAddress.validation.validations.find((x) => x.type === MISC_VALUES.REQUIRED) &&\r\n fromEmailAddress.validation.validations.push({\r\n type: MISC_VALUES.REQUIRED,\r\n params: [ERROR_MSG.EMAIL_REQUIRED],\r\n });\r\n fromEmailAddress.props.isRequired = true;\r\n } else {\r\n fromEmailAddress.validation.validations = fromEmailAddress.validation.validations.filter(\r\n (x) => x.type !== MISC_VALUES.REQUIRED,\r\n );\r\n fromEmailAddress.props.isRequired = false;\r\n }\r\n props.updateValidationSchema();\r\n }\r\n }, [formikValues.accountNumber]);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n\r\n {isDisPatchDateVisible ? (\r\n \r\n \r\n \r\n ) : null}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {allProducts && getCustomDeclaration(allProducts) && formikValues.fromWeight > (formikValues.fromParcel * dimsValidation.maximumWeightPerParcelWithFullCustoms) && (\r\n \r\n \r\n Parcel weight exceeded. Parcel weight limit is {formikValues.fromParcel * dimsValidation.maximumWeightPerParcelWithFullCustoms}kg for delivery address\r\n \r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n customerNumberBlurred(event)} fullWidth />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {isResidential() ? null : (\r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Collection details\r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nCollectFrom.propTypes = {\r\n formField: PropTypes.object,\r\n fromAddressType: PropTypes.object,\r\n fromSearchFor: PropTypes.object,\r\n fromBusinessName: PropTypes.object,\r\n fromCustomerNo: PropTypes.object,\r\n fromPostCode: PropTypes.object,\r\n fromContactName: PropTypes.object,\r\n fromAddressLine1: PropTypes.object,\r\n fromAddressLine2: PropTypes.object,\r\n fromAddressLine3: PropTypes.object,\r\n fromTown: PropTypes.object,\r\n fromCounty: PropTypes.object,\r\n fromTelephoneNumber: PropTypes.object,\r\n fromEmailAddress: PropTypes.object,\r\n fromCustomerReference: PropTypes.object,\r\n collectionInstructions: PropTypes.object,\r\n descriptionOfGoods: PropTypes.object,\r\n setFieldValue: PropTypes.func,\r\n formikValues: PropTypes.object,\r\n errors: PropTypes.object,\r\n};\r\n\r\nconst mapStateToProps = () => {};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n setServicePointDetails: (data) => {\r\n dispatch(actions.setServicePointWeight(data));\r\n },\r\n setMaxWeightFullcustoms: (data) => {\r\n dispatch(actions.setMaximumWeightPerParcelWithFullCustoms(data));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(CollectFrom);\r\n","export default __webpack_public_path__ + \"static/media/PhoneIcon.4e0b8235.svg\";","export default __webpack_public_path__ + \"static/media/EmailIcon.bdafd10b.svg\";","import React from 'react';\r\nimport { Grid } from '@material-ui/core';\r\nimport PhoneIcon from './../../assets/images/PhoneIcon.svg';\r\nimport EmailIcon from './../../assets/images/EmailIcon.svg';\r\nimport Word3WordsIcon from './../../assets/images/what3words.png';\r\nimport Divider from '@material-ui/core/Divider';\r\nimport './addressFormate.scss';\r\nconst AddressFormate = ({\r\n addressType,\r\n contactName,\r\n businessName,\r\n addressLine1,\r\n addressLine2,\r\n addressLine3,\r\n town,\r\n county,\r\n postCode,\r\n emailAddress,\r\n telephoneNumber,\r\n shipmentManagement,\r\n dashboardSummary,\r\n addShipmentSummary,\r\n what3Words,\r\n isDomestic\r\n}) => {\r\n return (\r\n <>\r\n \r\n {shipmentManagement || dashboardSummary || addShipmentSummary\r\n ? null\r\n : \r\n {addressType !== '' ? `Delivery type: ${addressType}` : null}\r\n \r\n \r\n}\r\n \r\n {contactName !== '' && contactName}\r\n \r\n {/* \r\n {businessName !== '' && businessName}\r\n */}\r\n \r\n {businessName !== '' && businessName !== null ? `${businessName}, ` : ''}\r\n {addressLine1 !== '' && addressLine1 !== null ? `${addressLine1}` : ''}\r\n \r\n {/* \r\n {addressLine2 !== '' && addressLine2}\r\n */}\r\n \r\n {addressLine2 !== '' && addressLine2 !== null ? `${addressLine2}, ` : ''}\r\n {addressLine3 !== '' && addressLine3 !== null ? `${addressLine3}` : ''}\r\n \r\n {/* \r\n {town !== '' && town}\r\n \r\n \r\n {county !== '' && county}\r\n */}\r\n \r\n {county ? `${county}, ` : ''}\r\n {town ? `${town}, ` : ''}\r\n {postCode !== '' && postCode}\r\n \r\n \r\n \r\n \r\n \r\n \r\n {emailAddress !== '' && {emailAddress} }\r\n
\r\n \r\n \r\n {telephoneNumber !== '' && {telephoneNumber} }\r\n
\r\n {isDomestic?\r\n \r\n {what3Words !== '' && {what3Words} }\r\n
:\"\"}\r\n \r\n {/* \r\n \r\n */}\r\n {/* \r\n \r\n {telephoneNumber !== '' && {telephoneNumber} }\r\n */}\r\n \r\n >\r\n );\r\n};\r\n\r\nexport default AddressFormate;\r\n","export default \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAk1BMVEX1ABP////1AAD1AA7//v71ABT1AA31AAn+//3//v/zAAD9xcj+ztH5dXr/+/v/9vf91NX6hYn6fIL8q7D+8vP1FB/6gIX3Iy35cHb+z9D5io72HiX4KjP4cXX+wsX3CBv2MDj+2934UFb7j5T7uLn8sbL4OEL5Zm37n6H6pqX/5OX4QEj8pKn6XWT7mZ/+3975S1U236Z3AAAIvklEQVR4nO2cfVPbOBDGLa1tOQESCAkBkhLe2nDlSvv9P93JDrTRSo8Q01OVu9lfZzr9Y5tZSat9VivbVSUIgiAIgiAIgiAIgiAIgiAIgiAIgiAIgiAIgiAIgiAIgiAIgiAIgpBKY//89yD7x/5NadZNlWhIu99MtM6I9YK0ZWzaBGvTm2qT8ruD6TjlR3Njx3f/8Pj54osev2+62D7d/LVd6ndXxujb2efHh3ujy65iH0Xj7Vc1cPUcc5x6r5/mg+XknHT8d/Xt0e5Hv87sjxbcu32E/q3eqC+x3zaYDd39NP26jg5Rf5uo7tX0sx0iFRyjftm5Ug/e3Ef8Jv39p9dKzZvIeutn9es31fm4YKCS+aL2mUfi1M5F/WZnR3oeWW99p0avliP7f77FQzorpB/3xlfX6gI5Q6SnzmSoCqVJ0tu9xbYcFx3hviejTl2N0SLqS3eAdjLCpk2lb1TnDHGVIi950Cf7jnSxMNVHbITnwJTMYq7cRfxRbhFdt+2WmbdghGY5TxxhZYOUsS02QlqwvYXX0AtSO0IgATZIGbEUnRcbpLXryzEqQbwgVWcoSvWEm5bbh77b12CEtJi4W0upDXDbBqk/bUUgaldzx2377wWQABakNlWewnh+dMdX29UuVdL4e+sUzDb1AuAM0bqNfnWyv4b2f01uSwUp8SDt+iANWlZaMQFQaxOOZzttLJxPdbEjlGb7xaaEoC8N083Yavd724n8Dqak/OhPvttob3mrjYK0XU256bLYEo493UJumw3XTbC3mt3edsIUrnZ2WsMHCFNCepD2e3s0ckxhSsqOddtLCYlBqlBKqgyvkjpVHZbcBzF8b1ndNKD08QTo6t3uTy76lOCu4WiNgvSSVyl2tdOLu4yDiBIKUmR6xE3P0MJobgmnLTeUHKStTUkj7veqDfeW7LS5aaaftkIlW9sLgBt74d4SebpZR1d7/ze7IUgL6b2fEo4iAtC5BTrq5tDGqUntvye3sC2SGz9IZ3CErl2XrptdQbnnblu5R8UVdxsGaeOV8kUzqa9b6XKPgtSseAsKnjfzw9we4SD15X4CmhJtaNoyjiFKnxJcpmsTzup+TYpW+7CC1JN7ONu+3KNWcGu88+aiXE16nOy2V9wpuGE/ccvjUmdfMmt3b9m53yC5v1T7ZUod6ZwdVJDO/NlGpjZI3UIsUTdLtqCsbh3z2Q4LQFMZrVjD0WZScKw4YZb4vJkds2Dj6xS4riB94a52bVNSMOc2PEi7Du7t7JANUgZMCXy1axikXgvKrnY5ufeCFMr9IqCbIUO/BdUVvBgNtKDWqCa94KZINwMtKDRt+eF7K5ZJr/gIcU3qtaAKtrqdIB3FgnTttaA2yS2ogkG6nLLDvT04QQFIddu/Fi0VpDTI/SjFbeJB2vVuI1lxLEf4BJId4jVpB/cW9brJdixq7/opyQpQmRZUM166t7l1pJSecbnvVzt8p8YEqOuDtFQL6kTV7sLgvXXMW1DI7XZRs709XYKUlJtQTQqrFF83QS+HeJDWBTOpabnbqJfiuR07JjPd7ErKfaAmDVvSB+Te6ibrdYfPm3+CD9SkS16TTpYok84UG+FxsRsn2vABglIaCED4R9OnLT99TerO9hF8CioQpKCXw8+bSrUlW1CsIQYz6XLC1F6hp/nT93Z2vBaU6ibhkpS43Hdx3XSo1UnRmtQZILhxIm+1OywAfU3q3qlNluNCFVsgJaDZNhW3rOHd/QXvVsEnHLNjVl5XGqbHGa+6wymp8Ur5sjXpGR/gTfreAi9jUOvp5rTYU1CkT/kI0TskxtfNsNzTTjf3FKhkC8q/Fp2iY6ov9/gSPLm4y4++TnU7IPcoJbVrFqQd1M38sCAdDUEaTOuGu60m8HR/OHLfu82qlCnqSvtXNzhID6cmHe4gau42uPj1irsTYEotnwu1SH0d9V+GWhakHdpbZA9OXgsK1ufJKSk/5tYGqes3bEGd8V7OTerVzbC3y8k9izycSU/Zq1lQN/vzpluTztH9YnZav+H3CfVJvRYUSkmBXk7BIPWOqTXQLfqYbrKWaqmDU6gmPYJVt1fcwROI14KaFGxBBWrS8BqaJT+BoOKO/BZUuSBlvZT+ZcoVegoqOUg/UMrnJz1IA6uNg5RbQgHKTy8AiW7fei2oiG4mrnZ2yLrNr0VRSmBNifpDq10qSGmYbbeXEpN7lmk+odcuG6cwsP9ruil0cGqS91ZDZsXnorY5N+h4n5IS28u5IbOuea8bLiHbW3V0tZ3f7A5K7nELip3uYQvKZlJ3zjp83sxOoJcCXpEnv7jDvZz04i47bcWlYo5Swm/I/aEF6e/K/SBAjKItqH0BGOHvOPhuT+F79/60FbsWNUvedp9vUE2aXKUEalJw3vwD6Ad3v9TqMV3uUSZtV3yAdakBNv0nf9wlBG5TNeimawqfEbr2G47FHgl+dt2u1SS9BfV4+DXpEKTdyPEbyT35J5AtfArKtetbUG2hRqk32x3MpK134wQ+6UWHJfdL7gsKUkou7sibtqItqB+JbleNPuemaLVJ848qTRflTvf+Z5uAMpM3wjmQeyIzZyenckFamed9R/oWFHrkoPJGiKsUu4ZuW7yc3Nv0sV+I2aR6A18g957rvox93IydNwt+4tJ5yLzuMylwhvg1+BS9UEBep/SxWE3a7677t9ENUXoXCSf9tNcKqNVDzHT3jam3Gu+52FvpgzMvr570O6e7jcx2X+D9qktjc1EN8/Z649pF5yI/NqSefqaZ6XPUF7P5pXNXFH3AUG9/7e8XVL3+CfqkQuPt3eDJ5HEZn2wy+mWndF+v3/tcsP7y+j7e928l08yORuvni6eX7fL9jxyTbu6vn67v2/fjzugvs6eXsx+6aIi+0Q6fZk66nh0+DZ20KnbFx71p8RV8hRI92Zkl2Vqj5jA+YX4YXgiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiC8L/lH50BXuVpPvM9AAAAAElFTkSuQmCC\"","import React, { useEffect } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { useDispatch, useSelector } from 'react-redux';\r\nimport { Grid } from '@material-ui/core';\r\nimport Divider from '@material-ui/core/Divider';\r\nimport './deliverTo.scss';\r\nimport { abortOnGoingCallsFor, axiosConfig } from '../../../api/axios';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport AddressFormate from '../../../framework/addressFormate/AddressFormate';\r\nimport { setDropdownValues, arrayToString, getDomesticAccounts } from '../../../utils/helperFunctions';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport ClearanceDeclaration from '../../../container/shipment/addShipment/clearanceDeclaration/clearanceDeclaration';\r\nimport { getCustomDeclaration } from '../../../utils/utilsFunctions';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { MISC_VALUES, DELIVER_TYPE } from '../../../utils/constants/constants';\r\nimport { useDebouncedCallback } from 'use-debounce';\r\n\r\nconst DeliverToSender = (props) => {\r\n const {\r\n formField: { toServiceRequired, specialInstructions, additionalInstruction },\r\n setFieldValue,\r\n formikValues,\r\n errors,\r\n servicePointAddress,\r\n updateValidationSchema,\r\n clearanceDecleration,\r\n populateClearance\r\n } = props;\r\n\r\n const allProducts = useSelector((state) => state.common.allProducts);\r\n const [services, setServices] = React.useState([]);\r\n const selectedAccount = useSelector((state) => state.accounts.selectedAccount);\r\n const userAccounts = useSelector((state) => state.accounts.nonReturnuserAccounts);\r\n const displayAccounts = getDomesticAccounts(userAccounts);\r\n const dispatch = useDispatch();\r\n\r\n\r\n\r\nconst fetchProducts = (params, dispatch, setServices) => {\r\n axiosConfig\r\n .get(params)\r\n .then((res) => {\r\n if (res.data.length > 0) {\r\n dispatch(actions.setAllAvailableProducts(res.data));\r\n let min = Math.min.apply(\r\n null,\r\n res.data.map((item) => item.sortOrder),\r\n );\r\n let minSortOrderData = res.data.find((services) => services.sortOrder === min);\r\n setServices(minSortOrderData?.deliveryCapabilities?.services || []);\r\n } else {\r\n dispatch(actions.setAllAvailableProducts([]));\r\n }\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n dispatch(actions.setAllAvailableProducts([]));\r\n setServices([]);\r\n });\r\n};\r\n\r\nconst debouncedFetchProducts = useDebouncedCallback(fetchProducts, 300); // Adjust the debounce delay as needed\r\n\r\nuseEffect(() => {\r\n if (formikValues.fromPostCode && formikValues.fromWeight) {\r\n const destinationAddressType =\r\n formikValues.deliveryType === DELIVER_TYPE.DELIVER_DOORSTEP\r\n ? DELIVER_TYPE.DOORSTEP\r\n : MISC_VALUES.SERVICE_POINT_HANDOVER_METHOD;\r\n\r\n const pickupAccount = `&pickupAccount=${selectedAccount?.accountId}`;\r\n abortOnGoingCallsFor(ServiceEndPoints.getProducts);\r\n const params = `${ServiceEndPoints.getProducts}DestinationPostalCode=${\r\n formikValues.returnType === 'returnToSender'\r\n ? selectedAccount?.sender?.postalCode\r\n : formikValues?.toPostCode\r\n }&DestinationCountryCode=GB&DestinationRecipientType=${\r\n formikValues.returnType === 'returnToSender' ? 'business' : formikValues.toAddressType\r\n }&weight=${formikValues?.fromWeight}&OriginPostalCode=${\r\n formikValues.fromPostCode\r\n }&OriginCountryCode=GB&parcels=${\r\n formikValues?.fromParcel\r\n }&destinationAddressType=${destinationAddressType}${pickupAccount}`;\r\n\r\n debouncedFetchProducts(params, dispatch, setServices);\r\n }\r\n}, [\r\n selectedAccount,\r\n formikValues?.fromWeight,\r\n formikValues?.fromParcel,\r\n formikValues.returnType,\r\n formikValues?.toPostCode,\r\n formikValues.toAddressType,\r\n formikValues.deliveryType,\r\n formikValues.fromPostCode,\r\n formikValues.doorStepInstructions,\r\n]);\r\n\r\n const loadedFrom = useSelector((state) => state.loadedFrom.loadedFrom);\r\n\r\n useEffect(() => {\r\n setFieldValue('toServiceRequired', setDropdownValues(services, 'name', 'Next day'));\r\n }, [services]);\r\n\r\n useEffect(() => {\r\n const loadedFromScreen = loadedFrom.loadedFrom;\r\n const loadedResponse = loadedFrom.loadedResponse;\r\n if (\r\n services?.length > 0 &&\r\n (loadedFromScreen === 'dropdownResponse' || loadedFromScreen === 'fromPreviewSummary') &&\r\n (loadedResponse || {}).service\r\n ) {\r\n const selectedService = setDropdownValues(services, 'name', loadedResponse.service?.description);\r\n setFieldValue('toServiceRequired', selectedService);\r\n }\r\n }, [services, loadedFrom]);\r\n\r\n const getDorStepInstructionsForParams = () => {\r\n const {\r\n DOORSTEP_ONLY,\r\n DELIVER_TO_NEIGHBOUR,\r\n NEIGHBOUR_DELIVERY,\r\n LEAVE_SAFE,\r\n SECURE_LOCATION_DELIVERY,\r\n } = MISC_VALUES;\r\n const DSI = formikValues?.doorStepInstructions;\r\n let instruction = DOORSTEP_ONLY;\r\n if (DSI?.value === DELIVER_TO_NEIGHBOUR) {\r\n instruction = NEIGHBOUR_DELIVERY;\r\n } else if (DSI?.value === LEAVE_SAFE) {\r\n instruction = SECURE_LOCATION_DELIVERY;\r\n }\r\n return instruction;\r\n };\r\n\r\n return (\r\n \r\n \r\n Delivery address \r\n \r\n \r\n {allProducts && getCustomDeclaration(allProducts) && (\r\n \r\n \r\n \r\n Clearance Declaration \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n Service details \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nDeliverToSender.propTypes = {\r\n formField: PropTypes.object,\r\n errors: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n setFieldValue: PropTypes.func,\r\n};\r\n\r\nexport default DeliverToSender;\r\n","import React, { useEffect } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, IconButton, Divider } from '@material-ui/core';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { abortOnGoingCallsFor, axiosConfig } from '../../../api/axios';\r\nimport CustomDialog from '../../../framework/dialog/customDialog';\r\nimport { SearchIcon } from '@material-ui/data-grid';\r\nimport {\r\n formatPostalCodeValues,\r\n removeUndefinedProperties,\r\n setDropdownValues,\r\n getCustomerAccountID,\r\n arrayToString,\r\n getDomesticAccounts,\r\n} from '../../../utils/helperFunctions';\r\nimport { doorStepInstructionOptions, MIN_SEARCH_RESULTS_REQUIRED } from '../../../utils/constants/constants';\r\nimport { SearchByOptions } from '../../../utils/constants/carriageForwardConstants';\r\nimport './deliverToThirdParty.scss';\r\nimport CustomAddressTable from '../../../framework/CustomAddressTable/CustomAddressTable';\r\nimport AddToAddressAndFav from '../../helperComponents/addToAddressAndFav';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport DeliveryOptions from '../../../container/shipment/addShipment/deliveryOptions/deliveryOptions';\r\nimport { useDispatch, useSelector } from 'react-redux';\r\nimport * as actions from '../../../store/actions/index';\r\nimport AddressSearch from '../../helperComponents/addessSearch/addressSearch';\r\nimport AutoSuggestW3W from '../../../container/shipment/addShipment/autoSuggestW3W/AutoSuggestW3W';\r\nimport ClearanceDeclaration from '../../../container/shipment/addShipment/clearanceDeclaration/clearanceDeclaration';\r\nimport { getCustomDeclaration } from '../../../utils/utilsFunctions';\r\nimport { MISC_VALUES, DELIVER_TYPE } from '../../../utils/constants/constants';\r\nimport { ERROR_MSG } from '../../../utils/constants/errorConstant';\r\n\r\nconst DeliverToThirdParty = (props) => {\r\n const {\r\n formField: {\r\n toAddressType,\r\n toSearchFor,\r\n toCustomerNo,\r\n toPostCode,\r\n toContactName,\r\n toBusinessName,\r\n toAddressLine1,\r\n toAddressLine2,\r\n toAddressLine3,\r\n toTown,\r\n toCounty,\r\n toTelephoneNumber,\r\n toEmailAddress,\r\n toServiceRequired,\r\n },\r\n servicePointAddress,\r\n setFieldValue,\r\n formikValues,\r\n errors,\r\n setValues,\r\n setToAddressSearchObj,\r\n updateValidationSchema,\r\n clearanceDecleration,\r\n populateClearance\r\n } = props;\r\n\r\n const allProducts = useSelector((state) => state.common.allProducts);\r\n\r\n const [services, setServices] = React.useState([]);\r\n const [customerData, setCustomerData] = React.useState([]);\r\n const [postalSearchData, setPostalSearchData] = React.useState([]);\r\n const [openAddressBookModal, setOpenAddressBookModal] = React.useState(false);\r\n const [customerNumber, setCustomerNumber] = React.useState('');\r\n const [shouldSetValues, setValuesToForm] = React.useState(false); \r\n\r\n let addressTypeData = [];\r\n let leftOverData = [];\r\n\r\n const selectedAccount = useSelector((state) => state.accounts.selectedAccount);\r\n const userAccounts = useSelector((state) => state.accounts.nonReturnuserAccounts);\r\n const displayAccounts = getDomesticAccounts(userAccounts);\r\n const dispatch = useDispatch();\r\n\r\n useEffect(() => {\r\n setFieldValue('toSearchBy', SearchByOptions[0]);\r\n }, [setFieldValue]);\r\n\r\n const getCustomerAddressBook = (event) => {\r\n event.preventDefault();\r\n const url = `${ServiceEndPoints.getAddressBook}?organization=${getCustomerAccountID()}&${\r\n formikValues.toSearchBy.value\r\n }=${formikValues.toSearchFor}&countryCode=GB`;\r\n axiosConfig\r\n .get(url)\r\n .then((res) => {\r\n if (formikValues.toSearchBy.value === 'customernumber' && ((res.data || {}).addressBooks || []).length === 1) {\r\n rowClicked(res.data.addressBooks[0]);\r\n } else {\r\n setCustomerData(res.data.addressBooks);\r\n setOpenAddressBookModal(true);\r\n }\r\n })\r\n .catch((err) => {\r\n setCustomerData([]);\r\n setOpenAddressBookModal(true);\r\n console.log(err);\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n setFieldValue('toSearchFor', '');\r\n }, [props.formikValues.toSearchBy]);\r\n\r\n const rowClicked = (val) => {\r\n const address = val.deliveryAddress;\r\n const options = val.deliveryOptions;\r\n setAddressToForm(address, true, options, val);\r\n setCustomerNumber(address.customerNumber);\r\n setOpenAddressBookModal(false);\r\n };\r\n\r\n const setAddressToForm = (address, isAddressBook = true, options, dimsDetails = null) => {\r\n const { RESIDENTIAL_ADDRESS_TYPE, COMMERCIAL_ADDRESS_TYPE, BUSINESS_ADDRESS_TYPE } = MISC_VALUES;\r\n const addressObj = {\r\n toAddressType: isAddressBook\r\n ? address.recipientType === 1\r\n ? BUSINESS_ADDRESS_TYPE\r\n : RESIDENTIAL_ADDRESS_TYPE\r\n : address?.type === COMMERCIAL_ADDRESS_TYPE\r\n ? BUSINESS_ADDRESS_TYPE\r\n : RESIDENTIAL_ADDRESS_TYPE,\r\n toTown: isAddressBook ? address?.town : address?.city,\r\n toAddressLine1: address?.line1,\r\n toAddressLine2: address?.line2,\r\n toAddressLine3: address?.line3,\r\n toPostCode: isAddressBook ? address?.postCode?.toUpperCase() : address?.postalCode?.toUpperCase(),\r\n toBusinessName: isAddressBook ? address.businessName : address?.company,\r\n toCustomerNo: address?.customerNumber,\r\n toEmailAddress: address?.email,\r\n toContactName: address?.recipientName,\r\n toTelephoneNumber: address?.telephone,\r\n toCounty: isAddressBook ? address?.county : address?.provinceName,\r\n deliveryType: options?.deliveryType === 2 ? DELIVER_TYPE.DELIVER_SERVICE_POINT : DELIVER_TYPE.DELIVER_DOORSTEP,\r\n doorStepInstructions: setDropdownValues(doorStepInstructionOptions, 'value', options?.doorStepInstructions),\r\n what3Words: address?.what3Words?.words,\r\n w3WCoordinates: address?.what3Words?.geo,\r\n };\r\n removeUndefinedProperties(addressObj);\r\n setValues({ ...formikValues, ...addressObj });\r\n dispatch(\r\n actions.setLoadedFrom({\r\n loadedFrom: 'dropdownResponse',\r\n loadedResponse: { ...dimsDetails },\r\n }),\r\n );\r\n setTimeout(() => {\r\n dispatch(\r\n actions.setLoadedFrom({\r\n loadedFrom: '',\r\n loadedResponse: {},\r\n }),\r\n );\r\n }, 5000);\r\n setValuesToForm(dimsDetails);\r\n };\r\n const handleClose = () => {\r\n setOpenAddressBookModal(false);\r\n };\r\n\r\n useEffect(() => {\r\n if (formikValues.fromPostCode && formikValues.fromWeight) {\r\n const destinationAddressType =\r\n formikValues.deliveryType === DELIVER_TYPE.DELIVER_DOORSTEP\r\n ? DELIVER_TYPE.DOORSTEP\r\n : MISC_VALUES.SERVICE_POINT_HANDOVER_METHOD;\r\n\r\n // Sending only selected account.\r\n const pickupAccount = `&pickupAccount=${selectedAccount?.accountId}`;\r\n\r\n abortOnGoingCallsFor(ServiceEndPoints.getProducts);\r\n axiosConfig\r\n .get(\r\n `${ServiceEndPoints.getProducts}DestinationPostalCode=${\r\n formikValues.returnType === 'returnToSender'\r\n ? selectedAccount?.sender?.postalCode\r\n : formikValues?.toPostCode\r\n }&DestinationCountryCode=GB&DestinationRecipientType=${\r\n formikValues.returnType === 'returnToSender' ? 'business' : formikValues.toAddressType\r\n }&weight=${formikValues?.fromWeight}&OriginPostalCode=${\r\n formikValues.fromPostCode\r\n }&OriginCountryCode=GB&parcels=${\r\n formikValues?.fromParcel\r\n }&destinationAddressType=${destinationAddressType}${pickupAccount}`,\r\n )\r\n .then((res) => {\r\n if (res.data.length > 0) {\r\n dispatch(actions.setAllAvailableProducts(res.data));\r\n let min = Math.min.apply(\r\n null,\r\n res.data.map((item) => item.sortOrder),\r\n );\r\n let minSortOrderData = res.data.find((services) => services.sortOrder === min);\r\n setServices(minSortOrderData?.deliveryCapabilities?.services || []);\r\n } else {\r\n dispatch(actions.setAllAvailableProducts([]));\r\n }\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n dispatch(actions.setAllAvailableProducts([]));\r\n setServices([]);\r\n });\r\n }\r\n }, [\r\n selectedAccount,\r\n formikValues?.fromWeight,\r\n formikValues?.fromParcel,\r\n formikValues.returnType,\r\n formikValues?.toPostCode,\r\n formikValues.toAddressType,\r\n formikValues.deliveryType,\r\n formikValues.fromPostCode,\r\n ]);\r\n\r\n useEffect(() => {\r\n if (allProducts.length > 0) {\r\n let products = allProducts;\r\n switch (formikValues.doorStepInstructions.value) {\r\n case MISC_VALUES.DELIVER_TO_NEIGHBOUR:\r\n products = allProducts.filter((p) => p.deliveryCapabilities.neighbourDelivery);\r\n break;\r\n case MISC_VALUES.LEAVE_SAFE:\r\n products = allProducts.filter((p) => p.deliveryCapabilities.secureLocationDelivery);\r\n break;\r\n case MISC_VALUES.DELIVER_DOORSTEP_ONLY:\r\n products = allProducts.filter(\r\n (p) => !p.deliveryCapabilities.neighbourDelivery && !p.deliveryCapabilities.secureLocationDelivery,\r\n );\r\n break;\r\n default:\r\n products = allProducts;\r\n }\r\n let min = Math.min.apply(\r\n null,\r\n products.map((item) => item.sortOrder),\r\n );\r\n let minSortOrderData = products.find((services) => services.sortOrder === min);\r\n setServices(minSortOrderData?.deliveryCapabilities?.services || []);\r\n }\r\n }, [allProducts, formikValues.doorStepInstructions]);\r\n\r\n const setValuesToPostalSearch = (val) => {\r\n const address = val.data[0];\r\n setToAddressSearchObj(val);\r\n setAddressToForm(address, false);\r\n };\r\n\r\n useEffect(() => {\r\n if (formikValues.toAddressType === MISC_VALUES.RESIDENTIAL_ADDRESS_TYPE) {\r\n setFieldValue('toBusinessName', '');\r\n }\r\n }, [formikValues.toAddressType]);\r\n\r\n const loadedFrom = useSelector((state) => state.loadedFrom.loadedFrom);\r\n\r\n useEffect(() => {\r\n setDefaultValues('toServiceRequired', setDropdownValues(services, 'name', 'Next day'));\r\n }, [services]);\r\n\r\n useEffect(() => {\r\n if (shouldSetValues) {\r\n const reqObj = {\r\n specialInstructions: shouldSetValues?.deliveryOptions?.specialInstructions ?? '',\r\n leaveSafeLocation: shouldSetValues?.deliveryOptions?.leaveSafeLocation ?? '',\r\n additionalInstruction: shouldSetValues?.deliveryOptions?.additionalInstruction ?? '',\r\n };\r\n setValues({ ...formikValues, ...reqObj });\r\n }\r\n }, [setValues, shouldSetValues]);\r\n\r\n useEffect(() => {\r\n if (shouldSetValues && services.length > 0) {\r\n const reqObj = {\r\n toServiceRequired: setDropdownValues(services, 'name', shouldSetValues?.service),\r\n };\r\n setValues({ ...formikValues, ...reqObj });\r\n setValuesToForm(false);\r\n }\r\n }, [shouldSetValues, services]);\r\n\r\n useEffect(() => {\r\n const loadedFromScreen = loadedFrom.loadedFrom;\r\n const loadedResponse = loadedFrom.loadedResponse;\r\n if (\r\n services?.length > 0 &&\r\n (loadedFromScreen === 'dropdownResponse' || loadedFromScreen === 'fromPreviewSummary') &&\r\n (loadedResponse || {}).service\r\n ) {\r\n const selectedService = setDropdownValues(services, 'name', loadedResponse.service?.description);\r\n setFieldValue('toServiceRequired', selectedService);\r\n }\r\n }, [services, loadedFrom]);\r\n\r\n useEffect(() => {\r\n if (updateValidationSchema) {\r\n if (!formikValues?.accountNumber?.configuration?.consigneeEmailOptional) {\r\n !toEmailAddress.validation.validations.find((x) => x.type === MISC_VALUES.REQUIRED) &&\r\n toEmailAddress.validation.validations.push({\r\n type: MISC_VALUES.REQUIRED,\r\n params: [ERROR_MSG.EMAIL_REQUIRED],\r\n });\r\n toEmailAddress.props.isRequired = true;\r\n } else {\r\n toEmailAddress.validation.validations = toEmailAddress.validation.validations.filter(\r\n (x) => x.type !== MISC_VALUES.REQUIRED,\r\n );\r\n toEmailAddress.props.isRequired = false;\r\n }\r\n updateValidationSchema();\r\n }\r\n }, [formikValues.accountNumber]);\r\n\r\n const isBusiness = () => {\r\n return (props.formikValues || {}).toAddressType === MISC_VALUES.BUSINESS_ADDRESS_TYPE;\r\n };\r\n\r\n const setDefaultValues = (key, value) => {\r\n setFieldValue(key, value);\r\n };\r\n\r\n const customerNumberBlurred = (eve) => {\r\n setCustomerNumber(eve.target.value);\r\n };\r\n\r\n const setAddressValues = (addressObj) => {\r\n const formObj = {\r\n toTown: addressObj.city,\r\n toAddressLine1: addressObj.line1,\r\n toAddressLine2: addressObj.line2,\r\n toAddressLine3: addressObj.line3,\r\n toPostCode: addressObj.postalCode,\r\n toCounty: addressObj.provinceName,\r\n toBusinessName: addressObj.company,\r\n };\r\n setValues({ ...formikValues, ...formObj });\r\n };\r\n\r\n const handleAddressChangeByPostCode = (addressTypes) => {\r\n if (addressTypes) {\r\n if (addressTypes === MISC_VALUES.COMMERCIAL_ADDRESS_TYPE) {\r\n setFieldValue('toAddressType', addressType[0].value);\r\n } else {\r\n setFieldValue('toAddressType', addressType[1].value);\r\n }\r\n }\r\n };\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n customerNumberBlurred(event)} fullWidth />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {isBusiness() ? (\r\n \r\n \r\n \r\n ) : null}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {allProducts && getCustomDeclaration(allProducts) && (\r\n \r\n \r\n \r\n Clearance Declaration \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n )}\r\n \r\n \r\n Delivery details \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Service details \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nDeliverToThirdParty.propTypes = {\r\n formField: PropTypes.object,\r\n errors: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n setFieldValue: PropTypes.func,\r\n};\r\n\r\nexport default DeliverToThirdParty;\r\n\r\nconst addressType = [\r\n {\r\n value: 'business',\r\n label: 'Business',\r\n },\r\n {\r\n value: 'residential',\r\n label: 'Residential',\r\n },\r\n];\r\n","import React, { useEffect } from 'react';\r\nimport { Grid } from '@material-ui/core';\r\nimport PropTypes from 'prop-types';\r\nimport DeliverToSender from './deliverToSender';\r\nimport DeliverToThirdParty from './deliverToThirdParty';\r\nimport './deliverTo.scss';\r\n\r\nconst DeliverTo = (props) => {\r\n const { formikValues } = props;\r\n return (\r\n \r\n {(formikValues || {}).returnType === 'returnToSender'\r\n ? (\r\n \r\n )\r\n : (\r\n \r\n )}\r\n \r\n );\r\n};\r\n\r\nDeliverTo.propTypes = {\r\n formikValues: PropTypes.object,\r\n returnType: PropTypes.string,\r\n};\r\n\r\nexport default DeliverTo;\r\n","import React, { useState, useEffect } from 'react';\r\nimport { useParams } from 'react-router-dom';\r\nimport { Grid } from '@material-ui/core';\r\nimport { Form, Formik } from 'formik';\r\nimport { getYupSchemaFromMetaData } from '../../../utils/yupSchema/yupSchemaGenerator';\r\nimport carriageForwardForm from '../../../utils/formConfig/carriageForwardForm/carriageForwardForm';\r\nimport Basicdetails from '../../../components/carriageForward/basicDetails/basicdetails';\r\nimport ParcelHandover from '../../../components/carriageForward/parcelHandover/parcelHandover';\r\nimport CustomAccordion from '../../../framework/accordion/customAccordion';\r\nimport CollectFrom from '../../../components/carriageForward/collectFrom/collectFrom';\r\nimport DeliverTo from '../../../components/carriageForward/deliverTo/deliverTo';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport './carriageForward.scss';\r\nimport {\r\n carriageForwardFormToFavReqObj,\r\n createCollectionReqObj,\r\n setValuesToCarriageForwardForm,\r\n saveCollectionReqObj,\r\n getCustomerAccountID,\r\n formatDateToUKFormat,\r\n formatDate,\r\n dynamicSort\r\n} from '../../../utils/helperFunctions';\r\nimport { connect, useDispatch, useSelector } from 'react-redux';\r\nimport { POST, GET, PUT, axiosConfig } from '../../../api/axios';\r\nimport { useHistory } from 'react-router';\r\nimport CustomDialog from '../../../framework/dialog/customDialog';\r\nimport PromptJSPMClientInstallation from '../../../components/addShipment/Printing/PromptJSPMClientInstallation';\r\nimport { printZplLabels } from '../../../utils/PrintHelper';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport ConfirmationDialog from '../../../components/addressBook/confirmation/confirmation';\r\nimport CustomModal from '../../../framework/dialog/customDialog';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { CLERANCE_DECLARATION, EmailParam, MISC_VALUES, DELIVER_TYPE } from '../../../utils/constants/constants';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { SearchByOptions } from '../../../utils/constants/carriageForwardConstants';\r\nimport { downloadPDF } from '../../../utils/PrintHelper';\r\nimport { getCustomDeclaration, getCommodityTotalWeight } from '../../../utils/utilsFunctions';\r\nimport { ERROR_MSG } from '../../../utils/constants/errorConstant';\r\n\r\nconst formikRef = React.createRef();\r\nlet orderSetupResponse = null;\r\n\r\nconst CarriageForward = ({ servicePointSelected, JSPMStatus, userDetails, printerConfiguration, onLoad, maxWeightFullcustoms }) => {\r\n const { formId, formField } = carriageForwardForm;\r\n const [fromAddressSearchObj, setFromAddressSearchObj] = useState({});\r\n const [toAddressSearchObj, setToAddressSearchObj] = useState(false);\r\n\r\n const [openJSPMPrompt, setJSPMPrompt] = useState(false);\r\n const [updatePageFlag, setupdatePageFlag] = useState(false);\r\n const [collection_id, setcollection_id] = useState(null);\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n const [collectionResponse, setCollectionResponse] = useState({});\r\n const [showEmailConfirmation, setShowEmailConfirmation] = useState(false);\r\n const [labelResponse, setLabelResponse] = useState('');\r\n const [labelEmail, setLabelEmail] = useState('');\r\n const [labelEmailDate, setLabelEmailDate] = useState('');\r\n const [servicePointAddress, setServicePointAddress] = React.useState({});\r\n const [clearanceDecleration, setClearanceDecleration] = React.useState({});\r\n const [populateClearance,setPopulateClearance] = React.useState(false);\r\n const [countries, setCountries] = React.useState([]);\r\n const [carriageForwardValidationSchema, setValidationSchema] = React.useState(getYupSchemaFromMetaData(formField, [], []));\r\n let { id, cf, isvalid } = useParams();\r\n const history = useHistory();\r\n const dispatch = useDispatch();\r\n const initialValues = {};\r\n const allProducts = useSelector((state) => state.common.allProducts);\r\n\r\n const updateValidationSchema = () => {\r\n setValidationSchema(getYupSchemaFromMetaData(formField, [], []));\r\n };\r\n\r\n for (let property in formField) {\r\n if (Object.prototype.hasOwnProperty.call(formField, property)) {\r\n const field = formField[property];\r\n initialValues[field.props.name] = field.value ?? '';\r\n if (field.props?.type === MISC_VALUES.CHECKBOX || field.props?.type === MISC_VALUES.RADIO) {\r\n initialValues[field.props.name] = field.value;\r\n } else if (field.props?.type === MISC_VALUES.ARRAY) {\r\n initialValues[field.props.name] = field.values;\r\n } else {\r\n initialValues[field.props.name] = field.value || '';\r\n }\r\n }\r\n }\r\n\r\n const isFormValid = (errors, values) => {\r\n if (values.handOverMethod === MISC_VALUES.SERVICE_POINT_HANDOVER_METHOD && servicePointSelected?.servicePointID) {\r\n delete errors.servicePoint;\r\n }\r\n if (values.handOverMethod === MISC_VALUES.DRIVER_COLLECTION_HANDOVER_METHOD) {\r\n delete errors.servicePoint;\r\n }\r\n delete errors.sendLabelEmailAddress;\r\n const { deliveryServicePoint, ...restControls } = errors;\r\n if (\r\n values?.deliveryType === DELIVER_TYPE.DELIVER_SERVICE_POINT &&\r\n values.returnType === MISC_VALUES.SEND_TO_THIRD_PARTY &&\r\n !servicePointSelected?.servicePointID\r\n ) {\r\n return false;\r\n }\r\n\r\n const {\r\n MOVEMENT_TYPE_B2B_VALUE,\r\n MOVEMENT_TYPE_C2C_VALUE,\r\n MOVEMENT_TYPE_C2B_VALUE,\r\n MOVEMENT_TYPE_B2C_VALUE,\r\n } = CLERANCE_DECLARATION;\r\n // Additional specific checks for shipmentMovement and related fields\r\n if (allProducts && getCustomDeclaration(allProducts)) {\r\n if (!values.shipmentMovement) {\r\n return false;\r\n }\r\n if (values.shipmentMovement.value === MOVEMENT_TYPE_C2C_VALUE) {\r\n if (!values.clearanceDescriptionGoods) {\r\n return false;\r\n } else if (!values.clearanceTotalValue) {\r\n return false;\r\n }\r\n } else if (values.shipmentMovement.value === MOVEMENT_TYPE_C2B_VALUE) {\r\n if (values.receipentUKIMS && !values.receipentEORI) {\r\n return false;\r\n } else if (!values.clearanceTotalValue) {\r\n return false;\r\n } else if (!values?.commodityDetails?.length) {\r\n return false;\r\n }\r\n } else if (values.shipmentMovement.value === MOVEMENT_TYPE_B2C_VALUE) {\r\n if (values.shipperUKIMS && !values.shipperEORI) {\r\n return false;\r\n } else if (!values.clearanceTotalValue) {\r\n return false;\r\n } else if (!values?.commodityDetails?.length) {\r\n return false;\r\n }\r\n } else if (values.shipmentMovement.value === MOVEMENT_TYPE_B2B_VALUE) {\r\n if (values.shipperUKIMS && !values.shipperEORI) {\r\n return false;\r\n } else if (values.receipentUKIMS && !values.receipentEORI) {\r\n return false;\r\n } else if (!values.clearanceTotalValue) {\r\n return false;\r\n } else if (!values.receipentUKIMS && !values.shipperUKIMS\r\n && (values.reasonExport === '' || values.shippingCharges === '')\r\n ) {\r\n if (!values.reasonExport) {\r\n return false;\r\n } else if (!values.shippingCharges) {\r\n return false;\r\n }\r\n } else if (!values?.commodityDetails?.length) {\r\n return false;\r\n }\r\n }\r\n\r\n if(values.fromWeight > (values.fromParcel * maxWeightFullcustoms)){\r\n return false;\r\n }\r\n } else {\r\n delete errors.shipmentMovement;\r\n delete errors.clearanceTotalValue;\r\n return Object.keys(errors).length === 0;\r\n }\r\n\r\n // To display the form error if (unit quantity*unit weight) total is greater than total weight shipment movement type\r\n const commodityTotalWeight = getCommodityTotalWeight(values);\r\n if(values.fromWeight < commodityTotalWeight){\r\n return false;\r\n }\r\n\r\n return Object.keys(restControls).length === 0;\r\n };\r\n\r\n const save_handleSubmit = (values, errors) => {\r\n dispatch(actions.setLoaderLayOver(true));\r\n PUT(ServiceEndPoints.saveOrder, saveCollectionReqObj(collectionResponse, values, servicePointSelected))\r\n .then((response) => {\r\n let isScanFlag = false;\r\n if (history.location && history.location.state !== undefined && history.location.state !== null) {\r\n isScanFlag = history.location.state.isScanFlag;\r\n }\r\n if (response.data.isValid === true) {\r\n history.push({\r\n pathname: '/shipment/processOrders',\r\n state: {\r\n isCollectionRequest: true,\r\n isReviewCollection: false,\r\n isScanFlag: isScanFlag,\r\n },\r\n });\r\n } else {\r\n history.push({\r\n pathname: '/shipment/processOrders',\r\n state: {\r\n isCollectionRequest: true,\r\n isReviewCollection: true,\r\n isScanFlag: isScanFlag,\r\n },\r\n });\r\n }\r\n dispatch(\r\n actions.setAppSnackBarData({\r\n msg: ERROR_MSG.COLLECTION_SAVED,\r\n }),\r\n );\r\n })\r\n .catch((err) => {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: `${ERROR_MSG.ERROR_IN_CREATING_COLLECTION} ${\r\n JSON.parse(err?.response?.data?.errorMessage)?.[0]?.title\r\n }\\n ${JSON.parse(err?.response?.data?.errorMessage)?.[0]?.detail}`,\r\n },\r\n ],\r\n }),\r\n );\r\n })\r\n .finally(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n });\r\n };\r\n\r\n const handleSubmit = (values, errors, setFieldTouched, setErrors, isEmail = false) => {\r\n const currentSelectedAccount = values.accountNumber;\r\n if (\r\n !(values.handOverMethod === MISC_VALUES.SERVICE_POINT_HANDOVER_METHOD && servicePointSelected?.servicePointID)\r\n ) {\r\n errors.servicePoint = ERROR_MSG.SERVICE_POINT_REQUIRED;\r\n setFieldTouched('servicePoint', true);\r\n }\r\n setTimeout(() => {\r\n setErrors(errors);\r\n }, 0);\r\n if (!isFormValid(errors, values)) {\r\n dispatch(actions.setBottomAlert({ msgs: [{ type: 'error', msg: ERROR_MSG.FORM_ERROR }] }));\r\n return;\r\n }\r\n if (isEmail && !showEmailConfirmation) {\r\n setShowEmailConfirmation(true);\r\n return;\r\n }\r\n showEmailConfirmation && setShowEmailConfirmation(false);\r\n dispatch(actions.setLoaderLayOver(true));\r\n const alertMsgs = [];\r\n let addressPromise = Promise.resolve();\r\n const reqObjArray = [];\r\n if (values.fromAddToaddressBook || values.updateFromAddToaddressBook) {\r\n reqObjArray.push(carriageForwardFormToFavReqObj(values, 'from', userDetails, fromAddressSearchObj));\r\n }\r\n if (values.toAddToaddressBook || values.updateToAddToaddressBook) {\r\n reqObjArray.push(carriageForwardFormToFavReqObj(values, 'to', userDetails, toAddressSearchObj));\r\n }\r\n if (reqObjArray.length > 0) {\r\n addressPromise = POST(ServiceEndPoints.postAddressBook, reqObjArray)\r\n .then((res) => {\r\n dispatch(actions.setAppSnackBarData({ msg: ERROR_MSG.CUSTOMER_SAVED_ADDRESSBOOK }));\r\n })\r\n .catch((err) => {\r\n alertMsgs.push({\r\n type: 'error',\r\n msg: ERROR_MSG.ERROR_WHILE_SAVING_CUSTOMER_DETAILS,\r\n });\r\n });\r\n } else if (values.fromAddToFavourites || values.toAddToFavourites) {\r\n const { userId } = userDetails;\r\n let payload = [];\r\n if (values.fromAddToFavourites) {\r\n payload.push(fromAddressSearchObj.id);\r\n }\r\n if (values.toAddToFavourites) {\r\n payload.push(toAddressSearchObj.id);\r\n }\r\n addressPromise = axiosConfig\r\n .post(`${ServiceEndPoints.postAddressBook}/favourite?userid=${userId}`, payload)\r\n .then((response) => {\r\n dispatch(actions.setAppSnackBarData({ msg: ERROR_MSG.CUSTOMER_DETAILS_SAVED_FAVOURITE }));\r\n })\r\n .catch((err) => {\r\n alertMsgs.push({\r\n type: 'error',\r\n msg: ERROR_MSG.NOT_ADD_ITEM_TO_FAVOURITE,\r\n });\r\n });\r\n }\r\n\r\n let pageSize =\r\n printerConfiguration?.pageSize === 0\r\n ? 0\r\n : printerConfiguration?.pageSize === null ||\r\n printerConfiguration?.pageSize === undefined ||\r\n printerConfiguration?.pageSize === ''\r\n ? 1\r\n : printerConfiguration?.pageSize;\r\n let manualShipment = false;\r\n if (!id && orderSetupResponse?.outputFileSetUp?.manualShipment) {\r\n manualShipment = true;\r\n }\r\n let url = `${ServiceEndPoints.shipmentLabelUrl}?includeLabel=INCLUDE&isOrderRequest=${updatePageFlag}&manualShipment=${manualShipment}`;\r\n if (isEmail) url += `&format=PDF`;\r\n if (printerConfiguration?.isDowloadLabelAsPDF) url += `&format=PDF`;\r\n if (updatePageFlag) {\r\n url += `&orderId=${collection_id}`;\r\n }\r\n\r\n if (isEmail) url += `&pageSize=${pageSize}`;\r\n const collectionPromise = axiosConfig\r\n .post(url, createCollectionReqObj(collectionResponse, values, servicePointSelected))\r\n .then((response) => {\r\n dispatch(actions.setServiceLocationDetails(null));\r\n if (isEmail) {\r\n alertMsgs.push({\r\n type: 'success',\r\n msg: `${ERROR_MSG.CREATE_LABEl_MSG}${response.data?.shipments?.[0]?.shipmentId}`,\r\n });\r\n setLabelEmailDate(values.collectionDate);\r\n setLabelEmail(values.sendLabelEmailAddress);\r\n formikRef.current.resetForm();\r\n setInitialFormValues(currentSelectedAccount, formikRef.current.setFieldValue);\r\n setLabelResponse(response?.data?.shipments[0]?.labels[0]);\r\n } else {\r\n alertMsgs.push({\r\n type: 'success',\r\n msg: `${ERROR_MSG.COLLECTION_SAVED_MSG} ${response.data?.shipments?.[0]?.shipmentId}`,\r\n });\r\n formikRef.current.resetForm();\r\n setInitialFormValues(currentSelectedAccount, formikRef.current.setFieldValue);\r\n }\r\n dispatch(actions.setAllAvailableProducts([]));\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n alertMsgs.push({\r\n type: 'error',\r\n msg: `${err?.response?.data?.[0]?.detail ?? ERROR_MSG.ERROR_OCCUR_WHILE_CREATING_COLLECTION}`,\r\n });\r\n });\r\n Promise.all([addressPromise, collectionPromise])\r\n .then(() => {\r\n if (alertMsgs.length > 0) {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: alertMsgs,\r\n }),\r\n );\r\n }\r\n })\r\n .finally(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n });\r\n };\r\n\r\n const setInitialFormValues = (account, setFieldValue) => {\r\n setFieldValue('fromSearchBy', SearchByOptions[0]);\r\n setFieldValue('handOverMethod', 'driverCollection');\r\n };\r\n\r\n useEffect(() => {\r\n if (labelResponse !== '' && labelEmail !== '') {\r\n let reqEmailObjArray = {\r\n fromEmailAddress: EmailParam.fromEmailAddress,\r\n toEmailAddresses: [labelEmail],\r\n subject: EmailParam.subject,\r\n body:\r\n labelEmailDate !== ''\r\n ? EmailParam.body.replace('(date)', formatDateToUKFormat(formatDate(labelEmailDate)))\r\n : EmailParam.body,\r\n attachments: [\r\n {\r\n content: labelResponse,\r\n type: EmailParam.type,\r\n fileName: EmailParam.fileName,\r\n },\r\n ],\r\n displayRecipients: EmailParam.displayRecipients,\r\n };\r\n POST(`${ServiceEndPoints.email}`, reqEmailObjArray)\r\n .then((response) => {\r\n setLabelEmail('');\r\n setLabelResponse('');\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n }\r\n }, [labelResponse, labelEmail]);\r\n\r\n const getOrderSetupResponse = () => {\r\n GET(`${ServiceEndPoints.orderSetup}?organization=${getCustomerAccountID()}`)\r\n .then((res) => {\r\n orderSetupResponse = res.data;\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n if (userDetails?.userId) {\r\n GET(ServiceEndPoints.getCountries)\r\n .then((res) => {\r\n setCountries(res.data.countries.sort(dynamicSort('name')));\r\n })\r\n .catch((err) => {\r\n setCountries([]);\r\n });\r\n\r\n if (id !== undefined && cf !== undefined && isvalid !== undefined) {\r\n populateCarriageForward();\r\n }\r\n getOrderSetupResponse();\r\n }\r\n\r\n }, [userDetails]);\r\n\r\n const handleCancel = () => {\r\n if (updatePageFlag) {\r\n setShowConfirmationDialog(true);\r\n } else {\r\n history.push('/shipment/addShipment');\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n if (Object.keys(collectionResponse).length > 0 && id !== undefined && cf !== undefined && isvalid !== undefined) {\r\n formikRef.current.setValues(\r\n setValuesToCarriageForwardForm(collectionResponse.shipmentModel, formikRef.current.values, userDetails),\r\n );\r\n setupdatePageFlag(true);\r\n setcollection_id(collectionResponse.id);\r\n const formatedResponse = {\r\n ...collectionResponse.shipmentModel,\r\n };\r\n\r\n onLoad({\r\n loadedFrom: 'dropdownResponse',\r\n loadedResponse: { ...formatedResponse },\r\n });\r\n setTimeout(() => {\r\n onLoad({ loadedFrom: '' });\r\n }, 15000);\r\n if (\r\n collectionResponse.shipmentModel.shipments[0]?.consigneeAddress?.addressType?.toLowerCase() ===\r\n MISC_VALUES.SERVICE_POINT_HANDOVER_METHOD\r\n ) {\r\n let consigneeAddress = collectionResponse.shipmentModel.shipments[0]?.consigneeAddress;\r\n let values = {\r\n servicePointID: consigneeAddress.locationId,\r\n address: {\r\n businessName: consigneeAddress.companyName,\r\n address1: consigneeAddress.address1,\r\n address2: consigneeAddress.address2,\r\n address3: consigneeAddress.address3,\r\n postalTown: consigneeAddress.city,\r\n zipcode: consigneeAddress.postalCode,\r\n addressType: consigneeAddress.locationType,\r\n county: consigneeAddress.state,\r\n },\r\n };\r\n setServicePointAddress(values);\r\n dispatch(actions.setServiceLocationDetails(values));\r\n }\r\n if (collectionResponse.shipmentModel.shipments[0]?.clearanceDeclaration) {\r\n let value = {\r\n descriptionOfGoodsShipment:collectionResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.descriptionOfGoods,\r\n numberOfItems:collectionResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.numberOfItems,\r\n reasonForExport:collectionResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.reasonForExport,\r\n recipientEORINumber:collectionResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.recipientEORINumber,\r\n recipientUKIMSNumber:collectionResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.recipientUKIMSNumber,\r\n sendersDefermentAccount:collectionResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.sendersDefermentAccount,\r\n sendersEORINumber:collectionResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.sendersEORINumber,\r\n sendersUKIMSNumber:collectionResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.sendersUKIMSNumber,\r\n shipmentMovementType:collectionResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.shipmentMovementType,\r\n shippingCharges:collectionResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.shippingCharges,\r\n totalValue:collectionResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.totalValue,\r\n items:collectionResponse.shipmentModel.shipments[0]?.clearanceDeclaration?.items,\r\n itemCountry:countries,\r\n accountNumber: collectionResponse.shipmentModel.pickupAccount\r\n }\r\n setPopulateClearance(true);\r\n setClearanceDecleration(value);\r\n }\r\n }\r\n }, [collectionResponse, countries]);\r\n\r\n const populateCarriageForward = () => {\r\n GET(\r\n `${\r\n ServiceEndPoints.getOrders\r\n }?organization=${getCustomerAccountID()}&id=${id}&isValid=${isvalid}&isCollectionRequest=${cf}`,\r\n )\r\n .then((res) => {\r\n setCollectionResponse(res.data?.orders?.[0]);\r\n if (res.data?.orders?.[0]?.errors?.length > 0) {\r\n const errorMessages = res.data.orders[0].errors.map((val) => {\r\n return {\r\n type: 'error',\r\n msg: val,\r\n };\r\n });\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: errorMessages,\r\n }),\r\n );\r\n }\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n };\r\n\r\n const handleClose = () => {\r\n setJSPMPrompt(false);\r\n let isScanFlag = false;\r\n if (history.location && history.location.state !== undefined && history.location.state !== null) {\r\n isScanFlag = history.location.state.isScanFlag;\r\n }\r\n if (updatePageFlag) {\r\n history.push({\r\n pathname: '/shipment/processOrders',\r\n state: {\r\n isCollectionRequest: true,\r\n isReviewCollection: !(isvalid === 'true'),\r\n isScanFlag: isScanFlag,\r\n },\r\n });\r\n }\r\n };\r\n\r\n const handleDialogClose = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n\r\n const onDialogConfirm = () => {\r\n let isScanFlag = false;\r\n if (history.location && history.location.state !== undefined && history.location.state !== null) {\r\n isScanFlag = history.location.state.isScanFlag;\r\n }\r\n history.push({\r\n pathname: '/shipment/processOrders',\r\n state: {\r\n isCollectionRequest: true,\r\n isReviewCollection: !(isvalid === 'true'),\r\n isScanFlag: isScanFlag,\r\n },\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n return () => {\r\n dispatch(actions.setAllAvailableProducts([]));\r\n };\r\n }, []);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n {({ values, setValues, setFieldValue, setErrors, setFieldTouched, errors }) => (\r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nCarriageForward.propTypes = {};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n servicePointSelected: state.addShipmentData.servicePointDelivery,\r\n JSPMStatus: state.common.isJSPMInstalled,\r\n userDetails: state.auth.userDetails,\r\n printerConfiguration: state.common.printerConfiguration,\r\n maxWeightFullcustoms: state.common.maxWeightFullcustoms\r\n };\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n onLoad: (loadedFrom) => {\r\n dispatch(actions.setLoadedFrom(loadedFrom));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(CarriageForward);\r\n","import React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport Grid from '@material-ui/core/Grid';\r\n\r\nconst TabPanel = (props) => {\r\n const { children, value, index, ...other } = props;\r\n return (\r\n \r\n {value === index && {children} }\r\n
\r\n );\r\n};\r\n\r\nTabPanel.propTypes = {\r\n value: PropTypes.number,\r\n index: PropTypes.number,\r\n};\r\nexport default TabPanel;\r\n","import { CompareArrowsOutlined } from '@material-ui/icons';\r\nimport { UK_POSTAL_CODE_REGEX } from '../../constants/constants';\r\nconst templateManagementForm = {\r\n formId: 'templateManagementForm',\r\n formField: {\r\n templateName: {\r\n props: {\r\n name: 'templateName',\r\n label: 'Template name',\r\n type: 'text',\r\n isRequired: true,\r\n },\r\n validation: {\r\n name: 'templateName',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Template name is required'],\r\n },\r\n ],\r\n },\r\n },\r\n destinationCountry: {\r\n props: {\r\n name: 'destinationCountry',\r\n label: 'Destination country',\r\n type: 'select',\r\n displayField: 'name',\r\n },\r\n },\r\n pallets: {\r\n props: {\r\n name: 'pallets',\r\n label: 'Pallets',\r\n type: 'number',\r\n //isDisabled: true,\r\n inputProps: {\r\n min: 0,\r\n max: 1,\r\n },\r\n },\r\n value: 1,\r\n\r\n validation: {\r\n name: 'pallets',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'min',\r\n params: [0, 'Pallets can not be less than 0'],\r\n },\r\n {\r\n type: 'max',\r\n params: [1, 'Pallets can not be greater than 1'],\r\n },\r\n ],\r\n },\r\n },\r\n addParcelDimensions: {\r\n props: {\r\n name: 'addParcelDimensions',\r\n label: 'Add parcel dimensions',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n noOfItems: {\r\n props: {\r\n name: 'noOfItems',\r\n label: 'No. of items',\r\n type: 'number',\r\n inputProps: {\r\n min: 1,\r\n max: 20,\r\n },\r\n restrictDecimal: true\r\n },\r\n value: 1,\r\n validation: {\r\n name: 'noOfItems',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n params: [1, 'Must be a value between 1 to 20'],\r\n type: 'min',\r\n },\r\n {\r\n type: 'max',\r\n params: [20, 'Must be a value between 1 to 20'],\r\n },\r\n ],\r\n },\r\n },\r\n weight: {\r\n props: {\r\n name: 'weight',\r\n label: 'Weight (Kg)',\r\n type: 'number',\r\n placeholder: 'Select',\r\n inputProps: {\r\n min: 0,\r\n max: 1000,\r\n step: 'any',\r\n },\r\n },\r\n validation: {\r\n name: 'weight',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n ['totalpieceWeight', 'addParcelDimensions'],\r\n (totalpieceWeight, addParcelDimensions, schema) => {\r\n if (totalpieceWeight > 0 && addParcelDimensions) {\r\n return schema.test('', 'Weight must be greater than or equal to piece weight', (value) => {\r\n return value >= totalpieceWeight;\r\n });\r\n } else {\r\n return schema;\r\n }\r\n },\r\n ],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Weight is outside permitted range'],\r\n },\r\n {\r\n type: 'max',\r\n params: [1000, 'Weight is outside permitted range'],\r\n },\r\n ],\r\n },\r\n },\r\n parcelDetails: {\r\n props: {\r\n name: 'parcelDetails',\r\n type: 'array',\r\n fields: {\r\n length: 'number',\r\n width: 'number',\r\n height: 'number',\r\n pieceWeight: 'number',\r\n volumetricWeight: 'number',\r\n id: 'number',\r\n },\r\n },\r\n values: [],\r\n },\r\n totalVolumetricWeight: {\r\n props: {\r\n name: 'totalVolumetricWeight',\r\n },\r\n value: 0.0,\r\n },\r\n length: {\r\n props: {\r\n name: 'length',\r\n label: 'Length (cm)',\r\n type: 'number',\r\n isRequired: true,\r\n inputProps: {\r\n min: 1,\r\n max: 200,\r\n },\r\n },\r\n validation: {\r\n name: 'length',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'typeError',\r\n params: ['Length must be number type'],\r\n },\r\n {\r\n type: 'required',\r\n params: ['Declared length must not be empty.'],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Declared length must be greater than 0'],\r\n },\r\n {\r\n type: 'max',\r\n params: [200, 'Declared length must be less than or equal to 200'],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n ['width', 'height'],\r\n (width, height, schema) => {\r\n if (width || height) {\r\n let highest = width || 0;\r\n if ((height || 0) > highest) highest = height;\r\n return schema.test('', 'Length must be longest side', (value) => {\r\n return value >= highest;\r\n });\r\n } else return schema;\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n width: {\r\n props: {\r\n name: 'width',\r\n label: 'Width (cm)',\r\n type: 'number',\r\n isRequired: true,\r\n\r\n inputProps: {\r\n min: 1,\r\n max: 120,\r\n },\r\n },\r\n validation: {\r\n name: 'width',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'typeError',\r\n params: ['Width must be number type'],\r\n },\r\n {\r\n type: 'required',\r\n params: ['Declared width must not be empty.'],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Declared width must be greater than 0'],\r\n },\r\n {\r\n type: 'max',\r\n params: [120, 'Declared width must be less than or equal to 120'],\r\n },\r\n ],\r\n },\r\n },\r\n height: {\r\n props: {\r\n name: 'height',\r\n label: 'Height (cm)',\r\n type: 'number',\r\n isRequired: true,\r\n inputProps: {\r\n min: 1,\r\n max: 120,\r\n },\r\n },\r\n validation: {\r\n name: 'height',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'typeError',\r\n params: ['Height must be number type'],\r\n },\r\n {\r\n type: 'required',\r\n params: ['Declared height must not be empty.'],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Declared height must be greater than 0'],\r\n },\r\n {\r\n type: 'max',\r\n params: [120, 'Declared height must be less than or equal to 120'],\r\n },\r\n ],\r\n },\r\n },\r\n deliveryType: {\r\n props: {\r\n name: 'deliveryType',\r\n label: 'Delivery type:',\r\n type: 'radio',\r\n },\r\n value: 'deliverToDoorStep',\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Delivery Type is required'],\r\n },\r\n ],\r\n },\r\n },\r\n doorStepInstructions: {\r\n props: {\r\n name: 'doorStepInstructions',\r\n label: 'Doorstep instructions',\r\n type: 'select',\r\n displayField: 'name',\r\n hasDefaultValue: true,\r\n },\r\n validation: {\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Doorstep instructions is required'],\r\n },\r\n ],\r\n },\r\n },\r\n leaveSafeLocation: {\r\n props: {\r\n name: 'leaveSafeLocation',\r\n label: 'Leave Safe location',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 60,\r\n },\r\n },\r\n validation: {\r\n name: 'leaveSafeLocation',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [60, 'Max 60 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n exchange: {\r\n props: {\r\n name: 'exchange',\r\n label: 'Exchange on delivery:',\r\n type: 'radio',\r\n },\r\n value: 'no',\r\n },\r\n specialInstructions: {\r\n props: {\r\n name: 'specialInstructions',\r\n label: 'Special instructions',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 30,\r\n },\r\n },\r\n validation: {\r\n name: 'specialInstructions',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [30, 'Max 30 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n additionalInstruction: {\r\n props: {\r\n name: 'additionalInstruction',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 30,\r\n },\r\n },\r\n },\r\n product: {\r\n props: {\r\n name: 'product',\r\n label: 'Product',\r\n type: 'select',\r\n displayField: 'productNameForUI',\r\n },\r\n },\r\n service: {\r\n props: {\r\n name: 'service',\r\n label: 'Service',\r\n type: 'select',\r\n displayField: 'name',\r\n },\r\n validation: {\r\n name: 'service',\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'destinationCountry',\r\n (destinationCountry, schema) => {\r\n return (destinationCountry || {}).code === 'GBR'\r\n ? schema.required('Service name required')\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n customerReference: {\r\n props: {\r\n name: 'customerReference',\r\n label: 'Customer reference',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 20,\r\n },\r\n },\r\n validation: {\r\n name: 'customerReference',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [20, 'Max 20 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n alternateReference: {\r\n props: {\r\n name: 'alternateReference',\r\n label: 'Alternative reference',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 20,\r\n },\r\n },\r\n validation: {\r\n name: 'alternateReference',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [20, 'Max 20 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n extendedCoverDomestic: {\r\n props: {\r\n name: 'extendedCoverDomestic',\r\n label: 'Extended liability',\r\n type: 'number',\r\n placeholder: 'Please select a level of extended liability, if required',\r\n inputProps: {\r\n min: 0,\r\n max: 5,\r\n },\r\n },\r\n validation: {\r\n name: 'extendedCoverDomestic',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n params: [0, 'Extended liability value should be between 0 - 5.'],\r\n type: 'min',\r\n },\r\n {\r\n params: [5, 'Extended liability value should be between 0 - 5.'],\r\n type: 'max',\r\n },\r\n ],\r\n },\r\n },\r\n mobileRecipient: {\r\n props: {\r\n name: 'mobileRecipient',\r\n label: 'Mobile',\r\n type: 'checkbox',\r\n },\r\n },\r\n emailRecipient: {\r\n props: {\r\n name: 'emailRecipient',\r\n label: 'Email',\r\n type: 'checkbox',\r\n },\r\n value: 'checked',\r\n },\r\n pieceWeight: {\r\n props: {\r\n name: 'pieceWeight',\r\n label: 'Weight (kg)',\r\n type: 'number',\r\n placeholder: 'Select',\r\n isRequired: true,\r\n },\r\n validation: {\r\n name: 'pieceWeight',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Weight is required'],\r\n },\r\n ],\r\n },\r\n },\r\n totalpieceWeight: {\r\n props: {\r\n name: 'totalpieceWeight',\r\n },\r\n value: 0.0,\r\n },\r\n //Addition of pallets.\r\n createPalletShipment: {\r\n props: {\r\n name: 'createPalletShipment',\r\n label: 'Create pallet shipment',\r\n type: 'radio',\r\n },\r\n value: 'no',\r\n },\r\n },\r\n};\r\n\r\nexport default templateManagementForm;\r\n","import React, { useEffect } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid } from '@material-ui/core';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nconst TemplateName = (props) => {\r\n const {\r\n formField: { templateName },\r\n formikValues,\r\n templateNameExist,\r\n templateNameEdited,\r\n getTemplate,\r\n } = props;\r\n\r\n useEffect(() => {\r\n if (formikValues.templateName.trim()) {\r\n getTemplate(formikValues.templateName);\r\n }\r\n }, [formikValues.templateName]);\r\n\r\n return (\r\n \r\n \r\n \r\n {templateNameEdited && templateNameExist\r\n? (\r\n ''\r\n )\r\n: (\r\n \r\n Template name already exists\r\n \r\n )}\r\n \r\n \r\n );\r\n};\r\n\r\nTemplateName.propTypes = {\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n templateNameExist: PropTypes.bool,\r\n getTemplate: PropTypes.func,\r\n};\r\n\r\nexport default TemplateName;\r\n","import React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Snackbar } from '@material-ui/core';\r\nimport MuiAlert from '@material-ui/lab/Alert';\r\n\r\nconst CustomSnackBar = ({\r\n snackBarMsg,\r\n setSnackBarMsg,\r\n autoHideDuration,\r\n verticalPosition,\r\n horizontalPostion,\r\n severity,\r\n}) => {\r\n const Alert = (props) => {\r\n return ;\r\n };\r\n\r\n return (\r\n setSnackBarMsg('')}\r\n autoHideDuration={autoHideDuration}\r\n >\r\n setSnackBarMsg('')} severity={severity}>\r\n {snackBarMsg}\r\n \r\n \r\n );\r\n};\r\n\r\nCustomSnackBar.propTypes = {\r\n horizontalPostion: PropTypes.oneOf(['left', 'center', 'right']),\r\n verticalPosition: PropTypes.oneOf(['top', 'bottom']),\r\n autoHideDuration: PropTypes.number,\r\n snackBarMsg: PropTypes.string.isRequired,\r\n setSnackBarMsg: PropTypes.func.isRequired,\r\n severity: PropTypes.oneOf(['error', 'warning', 'info', 'success']),\r\n};\r\n\r\nCustomSnackBar.defaultProps = {\r\n horizontalPostion: 'right',\r\n verticalPosition: 'top',\r\n autoHideDuration: 3000,\r\n severity: 'success',\r\n};\r\n\r\nexport default CustomSnackBar;\r\n","import React, { useEffect, useState, useRef } from 'react';\r\nimport { connect } from 'react-redux';\r\nimport { getYupSchemaFromMetaData } from '../../../../utils/yupSchema/yupSchemaGenerator';\r\nimport { Grid } from '@material-ui/core';\r\nimport { Form, Formik } from 'formik';\r\nimport DeliveryOptions from '../../addShipment/deliveryOptions/deliveryOptions';\r\nimport ProductAndServiceDetails from '../../addShipment/productAndServiceDetails/productAndServiceDetails';\r\nimport InputButton from '../../../../framework/Inputs/inputButton/inputButton';\r\nimport templateManagementForm from '../../../../utils/formConfig/templateManagementForm/templateManagementForm';\r\nimport CustomAccordion from '../../../../framework/accordion/customAccordion';\r\nimport AdditionalInfo from '../../addShipment/additionalInfo/additionalInfo';\r\nimport TemplateName from '../../../../components/addShipment/TemplateManagement/TemplateName';\r\nimport ParcelDetails from '../../addShipment/parcelDetails/parcelDetails';\r\nimport {\r\n formatTemplateModelForSave,\r\n setValuesToForm,\r\n dynamicSort,\r\n getCustomerAccountID,\r\n setDropdownValues,\r\n} from '../../../../utils/helperFunctions';\r\nimport { ServiceEndPoints } from '../../../../utils/constants/ApiConstant';\r\nimport { useHistory } from 'react-router-dom';\r\nimport { useDispatch } from 'react-redux';\r\nimport { abortOnGoingCallsFor, axiosConfig, GET } from '../../../../api/axios';\r\nimport './templateManagement.scss';\r\nimport * as actions from '../../../../store/actions/index';\r\nimport CustomModal from '../../../../framework/modal/modal';\r\nimport ConfirmationDialog from '../../../../components/addressBook/confirmation/confirmation';\r\nimport CustomSnackBar from '../../../../framework/snackBar/customSnackBar';\r\nimport { doorStepInstructionOptions } from '../../../../utils/constants/constants';\r\n\r\nconst { formId, formField } = templateManagementForm;\r\n\r\nconst TemplateManagement = (props) => {\r\n const history = useHistory();\r\n const { onLoad } = props;\r\n\r\n const formikRef = useRef();\r\n const dispatch = useDispatch();\r\n const [templateNameExist, setTemplateNameExist] = React.useState(false);\r\n const [templateDetails, setTemplateDetails] = useState({});\r\n const [countries, setCountries] = useState([]);\r\n const [templateNameEdited, setTemplateNameEdited] = React.useState(false);\r\n const [confirmationMsg, setConfirmationMsg] = useState('');\r\n const [snackBarMsg, setSnackBarMsg] = React.useState('');\r\n const [severity, setSeverity] = React.useState('success');\r\n\r\n const [showCancelConfirmationDialog, setShowCancelConfirmationDialog] = useState(false);\r\n\r\n const [templateManagementSchema, setTemplateManagementSchema] = useState(getYupSchemaFromMetaData(formField, [], []));\r\n\r\n const initialValues = {};\r\n\r\n const counrtyValue = {\r\n code: 'GBR',\r\n code2Digit: 'GB',\r\n code3Digit: '826',\r\n iossApplies: false,\r\n isEU: false,\r\n name: 'United Kingdom',\r\n postcodeMask: 'AN NAA or ANN NAA or AAN NAA or AANN NAA or ANA NAA or AANA NAA (spaces optional)',\r\n postcodeOptional: false,\r\n postcodeRegex:\r\n '([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9][A-Za-z]?))))\\\\s?[0-9][A-Za-z]{2})',\r\n paperlessTradeCapabilities: [\r\n { DHLDivision: 'express', currencyCode: 'USD', maximumDeclaredValue: 99999.99, inbound: true },\r\n ],\r\n };\r\n\r\n for (let property in formField) {\r\n if (Object.prototype.hasOwnProperty.call(formField, property)) {\r\n const field = formField[property];\r\n if (field.props.type === 'checkbox' || field.props.type === 'radio') {\r\n initialValues[field.props.name] = field.value;\r\n } else if (field.props.type === 'array') {\r\n initialValues[field.props.name] = field.values;\r\n } else {\r\n initialValues[field.props.name] = field.value || '';\r\n }\r\n }\r\n }\r\n initialValues[\"destinationCountry\"] = counrtyValue;\r\n\r\n useEffect(() => {\r\n if (history.location.search) {\r\n populateTemplate(history.location.search);\r\n getCountriesList();\r\n }\r\n }, []);\r\n\r\n const populateTemplate = (searchParams) => {\r\n searchParams = searchParams.replace('?', '');\r\n return axiosConfig\r\n .get(`${ServiceEndPoints.getTemplateBy}?organization=${getCustomerAccountID()}&isExactMatch=true&${searchParams}`)\r\n .then((res) => {\r\n setTemplateNameEdited(true);\r\n setTemplateDetails(res.data?.templates?.[0]);\r\n dispatch(\r\n actions.setShipmentId({\r\n shipmentId: res.data?.templates?.[0].templateName,\r\n }),\r\n );\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n };\r\n\r\n //Gets the list of All countries\r\n const getCountriesList = () => {\r\n GET(ServiceEndPoints.getCountries)\r\n .then((response) => {\r\n setCountries(response.data.countries.sort(dynamicSort('name')));\r\n })\r\n .catch((error) => {\r\n setCountries([]);\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n if (Object.keys(templateDetails).length > 0 && countries.length > 0) {\r\n templateDetails['destinationCountry'] = 'GBR';\r\n formikRef.current.setValues(setValuesToForm(templateDetails, formikRef.current.values, countries));\r\n onLoad({\r\n loadedFrom: 'dropdownResponse',\r\n loadedResponse: { ...templateDetails },\r\n });\r\n formikRef.current.setFieldValue('weight', templateDetails?.parcelDetails?.weight);\r\n setTimeout(() => {\r\n onLoad({ loadedFrom: '' });\r\n }, 10000);\r\n formikRef.current.setFieldValue(\r\n 'doorStepInstructions',\r\n setDropdownValues(doorStepInstructionOptions, 'value', templateDetails?.deliveryOptions?.doorStepInstructions),\r\n );\r\n }\r\n }, [templateDetails, countries]);\r\n\r\n const getTemplate = (templateName) => {\r\n abortOnGoingCallsFor(ServiceEndPoints.getTemplateBy);\r\n return axiosConfig\r\n .get(\r\n `${ServiceEndPoints.getTemplateBy\r\n }?organization=${getCustomerAccountID()}&isExactMatch=true&templateName=${templateName.trim().toLowerCase()}`,\r\n )\r\n .then((res) => {\r\n setTemplateNameExist(true);\r\n return true;\r\n })\r\n .catch((err) => {\r\n setTemplateNameExist(false);\r\n return false;\r\n });\r\n };\r\n\r\n const isFormValid = async (errors, values) => {\r\n if (errors.weight || errors.templateName || errors.noOfItems || errors.extendedCoverDomestic || (values?.createPalletShipment==='yes' && errors.pallets)) {\r\n return false;\r\n }\r\n\r\n if (!templateNameEdited && values.templateName.trim()) {\r\n return !(await getTemplate(values.templateName));\r\n } else {\r\n return true;\r\n }\r\n };\r\n\r\n const handleSubmit = async (values, errors, resetForm) => {\r\n if (await isFormValid(errors, values)) {\r\n dispatch(actions.setLoaderLayOver(true));\r\n const reqObj = formatTemplateModelForSave(values, true);\r\n axiosConfig\r\n .post(ServiceEndPoints.postTemplate, reqObj)\r\n .then((res) => {\r\n dispatch(actions.setAppSnackBarData({ msg: `Template saved successfully` }));\r\n resetForm();\r\n dispatch(actions.setActiveTab('myTemplates'));\r\n history.push(`/shipment/templateManagement`);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: `${err?.response?.data[0]?.detail ?? 'Error occurred while saving, please try again'}`,\r\n },\r\n ],\r\n }),\r\n );\r\n })\r\n .finally(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n });\r\n } else {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'The form has errors, please correct and try again',\r\n },\r\n ],\r\n }),\r\n );\r\n }\r\n };\r\n\r\n const cancelSchema = () => {\r\n setConfirmationMsg('Are you sure you want to cancel, all unsaved changes will be lost?');\r\n setShowCancelConfirmationDialog(true);\r\n };\r\n const handleDialogClose = () => {\r\n setShowCancelConfirmationDialog(false);\r\n };\r\n\r\n const onDialogCancel = () => {\r\n setShowCancelConfirmationDialog(false);\r\n };\r\n\r\n const onCancelDialogConfirm = () => {\r\n dispatch(actions.setActiveTab('myTemplates'));\r\n history.goBack();\r\n setShowCancelConfirmationDialog(false);\r\n };\r\n\r\n const updateValidationSchema = () => {\r\n setTemplateManagementSchema(getYupSchemaFromMetaData(formField, [], []));\r\n };\r\n\r\n useEffect(() => {\r\n if (Object.keys(props.selectedAccount).length > 0) {\r\n formikRef.current.setFieldValue('accountNumber', props.selectedAccount);\r\n }\r\n }, [props.selectedAccount]);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n {({ values, setFieldValue, setFieldTouched, setValues, errors, setErrors, resetForm }) => (\r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nTemplateManagement.propTypes = {};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n selectedAccount: state.accounts.selectedAccount,\r\n };\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n onLoad: (loadedFrom) => {\r\n dispatch(actions.setLoadedFrom(loadedFrom));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(TemplateManagement);\r\n","import React, { forwardRef } from 'react';\r\nimport MaterialTable, { MTableBody } from 'material-table';\r\n// import { forwardRef } from 'react';\r\n\r\nimport AddBox from '@material-ui/icons/AddBox';\r\n//import ArrowDownward from '@material-ui/icons/ArrowDownward';\r\nimport KeyboardArrowUpIcon from '@material-ui/icons/KeyboardArrowUp';\r\nimport Check from '@material-ui/icons/Check';\r\nimport ChevronLeft from '@material-ui/icons/ChevronLeft';\r\nimport ChevronRight from '@material-ui/icons/ChevronRight';\r\nimport Clear from '@material-ui/icons/Clear';\r\nimport DeleteOutline from '@material-ui/icons/DeleteOutline';\r\nimport Edit from '@material-ui/icons/Edit';\r\nimport FilterList from '@material-ui/icons/FilterList';\r\nimport FirstPage from '@material-ui/icons/FirstPage';\r\nimport LastPage from '@material-ui/icons/LastPage';\r\nimport Remove from '@material-ui/icons/Remove';\r\nimport SaveAlt from '@material-ui/icons/SaveAlt';\r\nimport Search from '@material-ui/icons/Search';\r\nimport ViewColumn from '@material-ui/icons/ViewColumn';\r\nimport { Hidden } from '@material-ui/core';\r\nimport { TablePagination } from '@material-ui/core';\r\nimport PropTypes from 'prop-types';\r\nimport { KeyboardArrowDown } from '@material-ui/icons';\r\n\r\nconst tableIcons = {\r\n Add: forwardRef((props, ref) => ),\r\n Check: forwardRef((props, ref) => ),\r\n Clear: forwardRef((props, ref) => ),\r\n Delete: forwardRef((props, ref) => ),\r\n DetailPanel: forwardRef((props, ref) => ),\r\n Edit: forwardRef((props, ref) => ),\r\n Export: forwardRef((props, ref) => ),\r\n Filter: forwardRef((props, ref) => ),\r\n FirstPage: forwardRef((props, ref) => ),\r\n LastPage: forwardRef((props, ref) => ),\r\n NextPage: forwardRef((props, ref) => ),\r\n PreviousPage: forwardRef((props, ref) => ),\r\n ResetSearch: forwardRef((props, ref) => ),\r\n Search: forwardRef((props, ref) => ),\r\n SortArrow: forwardRef((props, ref) => ),\r\n ThirdStateCheck: forwardRef((props, ref) => ),\r\n ViewColumn: forwardRef((props, ref) => ),\r\n};\r\nconst DynamicMaterialTable = (props) => {\r\n const {\r\n rows,\r\n columns,\r\n isSearchable,\r\n isSelectable,\r\n sorting,\r\n paging,\r\n pageSize,\r\n pageSizeOptions,\r\n empty_DataSource_Message,\r\n onSelectionChange = () => { },\r\n fixedColumns,\r\n filtering,\r\n onRowClicked,\r\n additionalProps,\r\n tableLayout,\r\n hideTotalCount,\r\n inBuiltEvents,\r\n mTableBody,\r\n customMaxHeight,\r\n } = props;\r\n const rowClicked = (event, rowData) => {\r\n if (onRowClicked) {\r\n onRowClicked(rowData);\r\n }\r\n };\r\n \r\n const sortOrderChange = (orderBy,orderDirection) =>{\r\n if(props.isProcesOrders){\r\n props.onClickSetSortOrder(orderDirection, columns[orderBy]?.field);\r\n }\r\n }\r\n\r\n return (\r\n \r\n
{\r\n // console.log(a, 'page');\r\n // }}\r\n // onChangeRowsPerPage={(a) => {\r\n // console.log('rows per page');\r\n // }}\r\n options={{\r\n search: isSearchable,\r\n selection: isSelectable,\r\n sorting,\r\n paging,\r\n emptyRowsWhenPaging: false,\r\n pageSize,\r\n pageSizeOptions,\r\n maxBodyHeight: customMaxHeight || '350px',\r\n overflowY: 'auto',\r\n overflowX: 'auto',\r\n headerStyle: {\r\n position: 'sticky',\r\n top: 0,\r\n fontWeight: 'bold',\r\n whiteSpace: 'nowrap',\r\n height: 56,\r\n maxHeight: 56,\r\n paddingTop: 0,\r\n paddingBottom: 0,\r\n },\r\n rowStyle: {\r\n height: 48,\r\n maxHeight: 48,\r\n padding: 0,\r\n },\r\n tableLayout: tableLayout ? tableLayout : 'auto',\r\n cellStyle: {\r\n // whiteSpace: \"nowrap\",\r\n // textOverflow: \"ellipsis\",\r\n // // display: \"block\",\r\n // overflow: \"hidden\",\r\n // // maxWidth: '100px'\r\n },\r\n toolbar: false,\r\n showFirstLastPageButtons: false,\r\n paginationType: 'stepped',\r\n filtering,\r\n ...additionalProps,\r\n }}\r\n {...props}\r\n {...additionalProps}\r\n localization={{\r\n pagination: {\r\n labelRowsSelect: '',\r\n labelRowsPerPage: 'Showing results',\r\n },\r\n body: {\r\n emptyDataSourceMessage: empty_DataSource_Message ? empty_DataSource_Message : 'No records to display',\r\n },\r\n }}\r\n onRowClick={rowClicked}\r\n onOrderChange={sortOrderChange}\r\n onSelectionChange={onSelectionChange}\r\n components={{\r\n mTableBody,\r\n Pagination: (paginationProps) => (\r\n \r\n (hideTotalCount !== true ? `${from}-${to} of ${count} results` : `${from}-${to} results`)\r\n }\r\n SelectProps={{\r\n IconComponent: () => ,\r\n }}\r\n />\r\n ),\r\n }}\r\n {...props}\r\n />\r\n \r\n );\r\n};\r\n\r\nDynamicMaterialTable.propTypes = {\r\n isSelectable: PropTypes.bool,\r\n isSearchable: PropTypes.bool,\r\n sorting: PropTypes.bool,\r\n paging: PropTypes.bool,\r\n pageSize: PropTypes.number,\r\n pageSizeOptions: PropTypes.arrayOf(PropTypes.number),\r\n columns: PropTypes.array,\r\n filtering: PropTypes.bool,\r\n empty_DataSource_Message: PropTypes.string,\r\n};\r\n\r\nDynamicMaterialTable.defaultProps = {\r\n isSelectable: true,\r\n isSearchable: false,\r\n sorting: true,\r\n paging: true,\r\n pageSize: 10,\r\n pageSizeOptions: [10, 25, 50],\r\n columns: [],\r\n filtering: false,\r\n};\r\n\r\nexport default DynamicMaterialTable;\r\n","import React, { useState } from 'react';\r\nimport { Grid } from '@material-ui/core';\r\nimport { PropTypes } from 'prop-types';\r\nimport DynamicMaterialTable from '../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\nimport InputButton from '../../framework/Inputs/inputButton/inputButton';\r\nimport ConfirmationDialog from '../addressBook/confirmation/confirmation';\r\nimport CustomModal from '../../framework/dialog/customDialog';\r\nimport { useHistory } from 'react-router-dom';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../store/actions/index';\r\n\r\nexport default function MyTemplate(props) {\r\n const {\r\n rows,\r\n columns,\r\n isSearchable,\r\n isSelectable,\r\n sorting,\r\n paging,\r\n pageSize,\r\n pageSizeOptions,\r\n Dialogtitle,\r\n confirmationMessage,\r\n emptyDataSourceMessage,\r\n } = props;\r\n const [selectedRows, setSelectedRows] = useState([]);\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n let history = useHistory();\r\n const dispatch = useDispatch();\r\n\r\n const addSelectedRows = (selRows) => {\r\n setSelectedRows(selRows);\r\n };\r\n const handleDialogClose = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n const onDialogConfirm = () => {\r\n props.deleteSelectedTemplates(selectedRows);\r\n setShowConfirmationDialog(false);\r\n setSelectedRows([]);\r\n };\r\n const onDialogCancel = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n\r\n const onRowClicked = (res) => {\r\n dispatch(\r\n actions.setActiveTab(\"\"),\r\n );\r\n history.push(`/shipment/templateManagement/editTemplate?templateName=${res.templateName}`);\r\n };\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n setShowConfirmationDialog(true)}\r\n />\r\n \r\n \r\n \r\n );\r\n}\r\n\r\nMyTemplate.propTypes = {\r\n rows: PropTypes.any,\r\n columns: PropTypes.any,\r\n isSearchable: PropTypes.bool,\r\n isSelectable: PropTypes.bool,\r\n sorting: PropTypes.any,\r\n paging: PropTypes.any,\r\n pageSize: PropTypes.number,\r\n pageSizeOptions: PropTypes.any,\r\n title: PropTypes.string,\r\n confirmationMessage: PropTypes.string,\r\n emptyDataSourceMessage: PropTypes.string,\r\n deleteSelectedTemplates: PropTypes.bool,\r\n};\r\n","import React, { useState, useEffect } from 'react';\r\nimport { PropTypes } from 'prop-types';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport Grid from '@material-ui/core/Grid';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { SearchIcon } from '@material-ui/data-grid';\r\nimport { IconButton } from '@material-ui/core';\r\nimport ClearIcon from '@material-ui/icons/Clear';\r\n\r\nconst useStyles = makeStyles(() => ({\r\n SearchTemplatesField: {\r\n marginTop: '0',\r\n paddingRight: '10px',\r\n },\r\n}));\r\n\r\nconst SearchTemplates = (props) => {\r\n const classes = useStyles();\r\n const dispatch = useDispatch();\r\n let [isClearBtn, setIsClearBtn] = useState(false);\r\n\r\n const {\r\n formField: { templateSearchFor },\r\n setFieldValue,\r\n onAddressChange,\r\n formikValues,\r\n } = props;\r\n\r\n const getClear = (event = null) => {\r\n if (event) {\r\n event.preventDefault();\r\n }\r\n setIsClearBtn(false);\r\n setFieldValue('templateSearchFor', '');\r\n dispatch(actions.setAddressBookSearchParams('&templateName='));\r\n onAddressChange(true);\r\n };\r\n\r\n const getAddresses = (event = null) => {\r\n if (event) {\r\n event.preventDefault();\r\n }\r\n setIsClearBtn(true);\r\n onAddressChange(true);\r\n };\r\n\r\n useEffect(() => {\r\n dispatch(actions.setAddressBookSearchParams(`&templateName=${formikValues.templateSearchFor}`));\r\n }, [dispatch, formikValues]);\r\n\r\n useEffect(() => {\r\n setFieldValue('templateSearchFor', '');\r\n }, [setFieldValue]);\r\n\r\n return (\r\n \r\n \r\n \r\n getClear(event)}>\r\n \r\n \r\n ) \r\n : (\r\n getAddresses(event, '')}>\r\n \r\n \r\n ),\r\n }}\r\n fullWidth\r\n />\r\n\r\n {/* \r\n getAddresses(event, '')}>\r\n \r\n \r\n ),\r\n }}\r\n fullWidth\r\n /> */}\r\n \r\n \r\n
\r\n );\r\n};\r\n\r\nSearchTemplates.propTypes = {\r\n formField: PropTypes.object,\r\n templateSearchFor: PropTypes.string,\r\n setFieldValue: PropTypes.func,\r\n onAddressChange: PropTypes.func,\r\n formikValues: PropTypes.object,\r\n};\r\n\r\nexport default SearchTemplates;\r\n","import React from 'react';\r\nimport { Form, Formik } from 'formik';\r\nimport PropTypes from 'prop-types';\r\nimport SearchTemplates from './SearchTemplates';\r\nimport { getYupSchemaFromMetaData } from '../../../utils/yupSchema/yupSchemaGenerator';\r\n\r\nconst SearchMyTemplates = (props) => {\r\n const formField = searchForm;\r\n const newSearchValidationSchema = getYupSchemaFromMetaData(formField, [], []);\r\n\r\n const initialValues = {\r\n templateSearchFor: '',\r\n };\r\n\r\n return (\r\n \r\n \r\n {({ values, setFieldValue, errors, setFieldTouched }) => (\r\n \r\n )}\r\n \r\n
\r\n );\r\n};\r\n\r\nexport default SearchMyTemplates;\r\n\r\nconst searchForm = {\r\n templateSearchFor: {\r\n props: {\r\n name: 'templateSearchFor',\r\n label: 'Search by',\r\n type: 'text',\r\n placeholder: 'Template name',\r\n },\r\n },\r\n};\r\n\r\nSearchMyTemplates.propTypes = {\r\n onAddressChange: PropTypes.func,\r\n};\r\n","import React from 'react';\r\nimport { connect } from 'react-redux';\r\nimport { AppBar, Tabs, Tab } from '@material-ui/core/';\r\nimport Grid from '@material-ui/core/Grid';\r\nimport './templateManagement.scss';\r\nimport TabPanel from '../../../components/shared/tabPanel';\r\nimport TemplateManagement from './CreateNewTemplate/TemplateManagement';\r\nimport MyTemplate from '../../../components/MyTemplate/MyTemplate';\r\nimport SearchMyTemplates from '../../../components/MyTemplate/searchTemplates/SearchMyTemplates';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { axiosConfig } from '../../../api/axios';\r\nimport { getCustomerAccountID } from '../../../utils/helperFunctions';\r\nimport * as actions from \"../../../store/actions/index\"\r\nconst tableRef = React.createRef();\r\nclass templateManagement extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n tabIndex: 0,\r\n // isSearched: false,\r\n columns: [\r\n { title: 'id', field: 'id', hidden: true, width: '0%' },\r\n { title: 'Template name', field: 'templateName', sorting: false, width: '97%' },\r\n ],\r\n rows: [],\r\n };\r\n this.onAddressChange = this.onAddressChange.bind(this);\r\n }\r\n\r\n onAddressChange(value) {\r\n // this.setState({ isSearched: value });\r\n tableRef.current && tableRef.current.onQueryChange();\r\n }\r\n\r\n deleteSelectedTemplates = (templateIds) => {\r\n const itemsToBeDeleted = templateIds.map((template) => {\r\n return template.id;\r\n });\r\n const payload = itemsToBeDeleted;\r\n axiosConfig\r\n .post(`${ServiceEndPoints.deleteTemplate}`, payload)\r\n .then((response) => {\r\n this.props.setSnackBar({ msg: \"Template(s) deleted successfully\" })\r\n tableRef.current && tableRef.current.onQueryChange();\r\n })\r\n .catch((error) => {\r\n alert('Items were not deleted, please try again.');\r\n });\r\n };\r\n\r\n handleTabChange = (event, index) => {\r\n this.setState({ tabIndex: index }, () => {\r\n tableRef.current && tableRef.current.onQueryChange();\r\n });\r\n };\r\n\r\n _MyTemplate = (query) => {\r\n return this.getMyTemplateResults(query);\r\n };\r\n\r\n getMyTemplateResults = (query) => {\r\n return new Promise((resolve, reject) => {\r\n const url = this.getUrl(query);\r\n axiosConfig.get(url)\r\n .then((res) => {\r\n this.formatMyTemplateData(query, resolve, res.data);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n this.formatMyTemplateData(query, resolve, {});\r\n });\r\n });\r\n };\r\n\r\n getUrl = (query) => {\r\n let url = `${ServiceEndPoints.getTemplateBy}?organization=${getCustomerAccountID()}`;\r\n url += '&offset=' + query.page * query.pageSize;\r\n url += '&limit=' + query.pageSize;\r\n url += this.props.addressBookSearchParams;\r\n return url;\r\n };\r\n\r\n formatMyTemplateData = (query, resolve, result) => {\r\n let final_data = [];\r\n ((result || {}).templates || []).map((element, index) => {\r\n final_data.push({\r\n id: element.id,\r\n templateName: element.templateName,\r\n });\r\n });\r\n resolve({\r\n data: final_data,\r\n page: query.page,\r\n totalCount: result?.totalRecords ? result.totalRecords : 0,\r\n });\r\n };\r\n\r\n componentDidMount() {\r\n if (this.props.activeTab === \"myTemplates\") {\r\n this.setState({ tabIndex: 1 });\r\n }\r\n this.props.setActiveTab(\"\");\r\n }\r\n\r\n render() {\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {this.state.tabIndex == 1 && (\r\n \r\n \r\n \r\n )}\r\n \r\n \r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n \r\n \r\n );\r\n }\r\n}\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n userDetails: state.auth.userDetails,\r\n addressBookSearchParams: state.searchParams,\r\n activeTab: state.common.activeTab,\r\n };\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n setSnackBar: (data) => {\r\n dispatch(actions.setAppSnackBarData(data))\r\n },\r\n setActiveTab: (value) => {\r\n dispatch(actions.setActiveTab(value))\r\n }\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(templateManagement);\r\n","import React, { useEffect, useRef, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, makeStyles } from '@material-ui/core';\r\nimport { connect } from 'react-redux';\r\nimport { withRouter } from 'react-router-dom';\r\nimport DynamicMaterialTable from '../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\nimport InputButton from '../../framework/Inputs/inputButton/inputButton';\r\nimport ConfirmationDialog from '../../components/addressBook/confirmation/confirmation';\r\nimport CustomModal from '../../framework/dialog/customDialog';\r\nimport { CSVLink } from 'react-csv';\r\nimport { GET } from '../../api/axios';\r\nimport { ServiceEndPoints } from '../../utils/constants/ApiConstant';\r\nimport { getCustomerAccountID } from '../../utils/helperFunctions'\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../store/actions/index';\r\nconst useStyles = makeStyles((theme) => ({\r\n exportButton: {\r\n // padding: '12px 43px !important',\r\n // borderRadius: '5px',\r\n // border: '1px solid #d40511 ',\r\n // marginBottom: '8px',\r\n },\r\n exportLink: {\r\n // textDecoration: 'none',\r\n // color: '#d40511 !important',\r\n // opacity: '1 !important',\r\n // fontWeight: 'bold',\r\n },\r\n}));\r\n\r\nfunction MyAddressBook(props) {\r\n const {\r\n rows,\r\n columns,\r\n isSearchable,\r\n isSelectable,\r\n sorting,\r\n paging,\r\n pageSize,\r\n pageSizeOptions,\r\n isFavourites,\r\n title,\r\n confirmationMessage,\r\n userDetails,\r\n onRowClicked,\r\n isSearched,\r\n page\r\n } = props;\r\n\r\n const csvLink = useRef();\r\n const classes = useStyles();\r\n\r\n const [selectedRows, setSelectedRows] = useState([]);\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n const [confirmationMsg, setConfirmationMsg] = useState(confirmationMessage);\r\n\r\n const [ExporttableRawData, setExportTableRawData] = useState([]);\r\n const dispatch = useDispatch();\r\n\r\n const addSelectedRows = (selectedRows) => {\r\n setSelectedRows(selectedRows);\r\n };\r\n\r\n const handleDialogClose = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n\r\n const Export_Data = () => {\r\n csvLink.current.link.click();\r\n dispatch(actions.setAppSnackBarData({ msg: \"Addressbook data exported susccessfully\" }));\r\n };\r\n\r\n const onDialogConfirm = () => {\r\n if (isFavourites) {\r\n props.removeAddressFromFavourite(selectedRows);\r\n } else {\r\n props.deleteSelectedAddress(selectedRows);\r\n }\r\n setShowConfirmationDialog(false);\r\n setSelectedRows([]);\r\n };\r\n\r\n const onDialogCancel = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n\r\n const deleteAddressBookEntry = () => {\r\n let isFavPresent = false;\r\n selectedRows.forEach((address) => {\r\n if (((address || {}).favouriteUsers || []).some((id) => id === (userDetails || {}).userId)) {\r\n isFavPresent = true;\r\n }\r\n });\r\n isFavPresent\r\n ? setConfirmationMsg(\r\n 'Are you sure you want to delete the selected address book entries? Note: The entries will also be removed from favourites',\r\n )\r\n : setConfirmationMsg('Are you sure you want to delete the selected address book entries?');\r\n setShowConfirmationDialog(true);\r\n };\r\n\r\n const onDataUpdate = async () => {\r\n let url = `${ServiceEndPoints.getAddressBook}?organization=${getCustomerAccountID()}`\r\n if (props.addressBookSearchParams) {\r\n url += props.addressBookSearchParams\r\n }\r\n await GET(url)\r\n .then((res) => {\r\n let ExportData = [];\r\n ((res.data || {}).addressBooks || []).forEach((element, index) => {\r\n const customer = element?.deliveryAddress;\r\n const customerCustomDeclaration = element?.customDeclaration;\r\n const customerDeliveryOptions = element?.deliveryOptions;\r\n const customerParcelDimensions = element?.parcelDetails?.parcelDimensions\r\n ExportData.push({\r\n id: element.id,\r\n customerNumber: customer?.customerNumber,\r\n IsBusiness: (customer?.recipientType === 1) ? 'YES' : 'NO',\r\n receiverName: customer?.recipientName,\r\n businessName: customer?.businessName,\r\n line1: customer?.line1,\r\n line2: customer?.line2,\r\n line3: customer?.line3,\r\n town: customer?.town,\r\n county: customer?.county,\r\n postCode: customer?.postCode,\r\n country: element?.destinationCountry,\r\n telephone: customer?.telephone,\r\n email: customer?.email,\r\n items: element?.parcelDetails?.numberOfItems,\r\n weight: element?.parcelDetails?.weight,\r\n customerReference: element?.customerReference,\r\n alternativeReference: element?.alternativeRefernce,\r\n extendedLiability: element?.extendedLiability?.extendedLiability,\r\n leaveSafeLocation: customerDeliveryOptions?.leaveSafeLocation,\r\n specialInstructions1: customerDeliveryOptions?.specialInstructions,\r\n specialInstructions2: customerDeliveryOptions?.additionalInstruction,\r\n length: customerParcelDimensions?.[0]?.length,\r\n width: customerParcelDimensions?.[0]?.width,\r\n height: customerParcelDimensions?.[0]?.height,\r\n value: customerCustomDeclaration?.totalValue,\r\n currency: customerCustomDeclaration?.currency,\r\n what3Words:customer?.what3Words?.words,\r\n });\r\n });\r\n setExportTableRawData(ExportData);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n setExportTableRawData([]);\r\n });\r\n };\r\n\r\n const headers = [\r\n { label: 'Customer number', key: 'customerNumber' },\r\n { label: 'Is Business', key: 'IsBusiness' },\r\n { label: 'Recipient name', key: 'receiverName' },\r\n { label: 'Business name', key: 'businessName' },\r\n { label: 'Address1', key: 'line1' },\r\n { label: 'Address2', key: 'line2' },\r\n { label: 'Address3', key: 'line3' },\r\n { label: 'Town', key: 'town' },\r\n { label: 'County', key: 'county' },\r\n { label: 'Postal code', key: 'postCode' },\r\n { label: 'Country', key: 'country' },\r\n { label: 'Telephone number', key: 'telephone' },\r\n { label: 'Email address', key: 'email' },\r\n { label: 'Items', key: 'items' },\r\n { label: 'Weight (Kg)', key: 'weight' },\r\n { label: 'Customer Reference', key: 'customerReference' },\r\n { label: 'Alternative Reference', key: 'alternativeReference' },\r\n { label: 'Extended Liability', key: 'extendedLiability' },\r\n { label: ' Leave safe location', key: ' leaveSafeLocation' },\r\n { label: 'Special instructions 1', key: 'specialInstructions1' },\r\n { label: 'Special instructions 2', key: 'specialInstructions2' },\r\n { label: 'Length (cm)', key: 'length' },\r\n { label: 'Width (cm)', key: 'width' },\r\n { label: 'Height (cm)', key: 'height' },\r\n { label: ' Value', key: 'value' },\r\n { label: 'Currency', key: 'currency' },\r\n { label: 'What3Words', key: 'what3Words' },\r\n ];\r\n\r\n useEffect(() => {\r\n onDataUpdate();\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (isSearched || !(ExporttableRawData.length>0)){\r\n onDataUpdate();\r\n }\r\n }, [props.addressBookSearchParams, isSearched, pageSize, page]);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n {isFavourites\r\n ? [\r\n \r\n \r\n setShowConfirmationDialog(true)}\r\n />\r\n \r\n ,\r\n ]\r\n : [\r\n \r\n \r\n deleteAddressBookEntry()}\r\n />\r\n \r\n {/* \r\n {/* */}\r\n\r\n {/* { dispatch(actions.setAppSnackBarData({ msg: \"Addressbook data exported susccessfully\" })) }}\r\n >\r\n Export\r\n \r\n // */}\r\n \r\n \r\n \r\n \r\n \r\n props.addFavouriteAddress(selectedRows)}\r\n />\r\n \r\n ,\r\n ]}\r\n \r\n );\r\n}\r\n\r\nMyAddressBook.propTypes = {\r\n rows: PropTypes.array,\r\n columns: PropTypes.array,\r\n isSearchable: PropTypes.bool,\r\n isSelectable: PropTypes.bool,\r\n sorting: PropTypes.bool,\r\n paging: PropTypes.bool,\r\n pageSize: PropTypes.object,\r\n pageSizeOptions: PropTypes.object,\r\n isFavourites: PropTypes.bool,\r\n title: PropTypes.string,\r\n confirmationMessage: PropTypes.string,\r\n removeAddressFromFavourite: PropTypes.func,\r\n deleteSelectedAddress: PropTypes.func,\r\n addFavouriteAddress: PropTypes.func,\r\n};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n addressBookSearchParams: state.searchParams,\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, null)(withRouter(MyAddressBook));","import React from \"react\";\r\nimport \"./dividerWithText.scss\";\r\n\r\n\r\n const DividerWithText = ({ children }) => {\r\n return (\r\n \r\n \r\n
\r\n
\r\n {children}\r\n \r\n
\r\n
\r\n \r\n );\r\n};\r\nexport default DividerWithText","import React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Dialog, DialogContent, DialogTitle, Grid, makeStyles } from '@material-ui/core';\r\nimport ClearIcon from '@material-ui/icons/Clear';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport DividerWithText from '../../../framework/dividerWithText/dividerWithText';\r\n\r\nimport './addressBookModal.scss';\r\n\r\nconst useStyles = makeStyles({\r\n dialog: {},\r\n Paper: {\r\n maxWidth: 1000,\r\n },\r\n});\r\n\r\nconst CustomDialog = (props) => {\r\n const classes = useStyles();\r\n const { onClose, selectedValue, open, title, maxWidth, onAddNewButtonClick, totalRecords } = props;\r\n\r\n const handleClose = () => {\r\n onClose(selectedValue);\r\n };\r\n return (\r\n \r\n \r\n \r\n \r\n {title}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Or \r\n {props.children} \r\n \r\n );\r\n};\r\n\r\nCustomDialog.propTypes = {\r\n onClose: PropTypes.func.isRequired,\r\n open: PropTypes.bool.isRequired,\r\n children: PropTypes.element,\r\n header: PropTypes.string,\r\n selectedValue: PropTypes.object,\r\n title: PropTypes.object,\r\n maxWidth: PropTypes.string,\r\n totalRecords: PropTypes.string,\r\n};\r\nCustomDialog.defaultProps = {\r\n maxWidth: 'md',\r\n header: 'Service Point',\r\n};\r\n\r\nexport default CustomDialog;\r\n","import React from 'react'\r\nimport { CSVLink } from \"react-csv\";\r\n\r\n\r\nconst SampleCSVFile = () => {\r\n const headers = [\r\n { label: \"Customer number\", key: \"customernumber\" },\r\n { label: \"Is Business\", key: \"isbusiness\" },\r\n { label: \"Recipient name\", key: \"receivername\" },\r\n { label: \"Business Name\", key: \"businessname\" },\r\n { label: \"Address1\", key: \"address1\" },\r\n\r\n { label: \"Address2\", key: \"address2\" },\r\n\r\n { label: \"Address3\", key: \"address3\" },\r\n\r\n { label: \"Town\", key: \"town\" },\r\n\r\n { label: \"County\", key: \"county\" },\r\n\r\n { label: \"Postal code\", key: \"postalcode\" },\r\n\r\n { label: \"Country\", key: \"country\" },\r\n { label: \"Telephone number\", key: \"telephonenumber\" },\r\n { label: \"Email address\", key: \"emailaddress\" },\r\n { label: \"Items\", key: \"items\" },\r\n { label: \"Weight (Kg)\", key: \"weight(Kg)\" },\r\n { label: \"Customer Reference\", key: \"customerreference\" },\r\n { label: \"Alternative Reference\", key: \"alternativeReference\" },\r\n { label: \"Extended Liability\", key: \"extendedliability\" },\r\n { label: \"Leave safe location\", key: \"leavesafelocation\" },\r\n { label: \"Special instructions 1\", key: \"specialinstructions1\" },\r\n { label: \"Special instructions 2\", key: \"specialinstructions2\" },\r\n { label: \"Length (cm)\", key: \"length(cm)\" },\r\n { label: \"Width (cm)\", key: \"width(cm)\" },\r\n { label: \"Height (cm)\", key: \"height(cm)\" },\r\n { label: \"Value\", key: \"value\" },\r\n { label: \"Currency\", key: \"currency\" },\r\n { label: \"Collection instructions\", key: \"collectionInstructions\" },\r\n { label: \"Description of goods to be collected\", key: \"descriptionOfGoodsToBeCollected\" },\r\n // changes made by vibhaas on 14-Dec-2023\r\n { label: \"What3Words\", key: \"what3Words\"},\r\n // changes over\r\n ];\r\n\r\n const csvData = [];\r\n return (\r\n \r\n Download Sample \r\n
\r\n )\r\n}\r\n\r\nexport default SampleCSVFile\r\n","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, Checkbox, FormControlLabel } from '@material-ui/core';\r\nimport { withStyles } from '@material-ui/core/styles';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport { ADDRESSBOOK_MODAL_CONTENT } from '../../../utils/constants/constants';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { toBase64 } from '../../../utils/common';\r\nimport { POST } from '../../../api/axios';\r\nimport './AddressBookModalContent.scss';\r\nimport SampleCSVFile from '../../sampleCSVFile/SampleCSVFile';\r\nimport ConfirmationDialog from '../confirmation/confirmation';\r\nimport CustomModal from '../../../framework/dialog/customDialog';\r\nimport { getCustomerAccountID, setDropdownValues } from '../../../utils/helperFunctions';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { exportToTextFile } from '../../../utils/common';\r\nconst CustomCheckBox = withStyles({\r\n root: {\r\n '&$checked': {\r\n color: 'black',\r\n },\r\n },\r\n checked: {},\r\n})((props) => );\r\n\r\nconst AddressBookModalContent = (props) => {\r\n const {\r\n // formField: { addressImportType },\r\n // addressImportTypeOptions,\r\n setFieldValue,\r\n formikValues,\r\n } = props;\r\n\r\n const dispatch = useDispatch();\r\n\r\n const [state, setState] = useState({\r\n ignoreFirstRow: false,\r\n overwriteDuplicates: false,\r\n isClearExistingAddress: false,\r\n });\r\n const [uploadFile, setUploadFile] = useState('No file selected');\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n\r\n const handleChange = (event) => {\r\n setState({ ...state, [event.target.name]: event.target.checked });\r\n };\r\n\r\n const handleImport = () => {\r\n let uploadedFile = document.getElementById('addressBook').files[0];\r\n const lastIndex = uploadedFile.name.lastIndexOf(\".\");\r\n if (uploadedFile && uploadedFile.name.slice(lastIndex + 1)?.toLowerCase() === 'csv'\r\n // ((props.formikValues.addressImportType?.value !== \"consignor\" && uploadedFile.name.slice(lastIndex + 1)?.toLowerCase() === 'csv') ||\r\n // (props.formikValues.addressImportType?.value === \"consignor\" && uploadedFile.name.slice(lastIndex + 1)?.toLowerCase() === \"txt\")\r\n // )\r\n ) {\r\n dispatch(actions.setLoaderLayOver(true));\r\n toBase64(uploadedFile)\r\n .then((result) => {\r\n let payload = result.split(',');\r\n postAddressData({ addressbookData: payload[1] });\r\n })\r\n .catch((error) => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Failed to import file',\r\n },\r\n ],\r\n }),\r\n );\r\n // dispatch(actions.setAppSnackBarData({type:\"error\",msg:\"Failed to import file\"}))\r\n clearFile();\r\n });\r\n } else {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'File format is invalid',\r\n },\r\n ],\r\n }),\r\n );\r\n // dispatch(actions.setAppSnackBarData({ type: 'error', msg: 'File format is invalid' }));\r\n clearFile();\r\n }\r\n };\r\n\r\n const uponUpload = (event) => {\r\n setUploadFile(event.target.files[0].name);\r\n };\r\n\r\n const postAddressData = (payload) => {\r\n let queryParams = `?ignoreFirstRow=${state.ignoreFirstRow}&overwriteDuplicates=${state.overwriteDuplicates\r\n }&isClearExistingAddress=${state.isClearExistingAddress}&organization=${getCustomerAccountID()}&importFileType=ship`;\r\n // &importFileType=${props.formikValues.addressImportType?.value}`;\r\n const postUrl = ServiceEndPoints.postAddressBookCsv + queryParams;\r\n\r\n POST(postUrl, payload)\r\n .then((response) => {\r\n if (response.data.errors === null) {\r\n dispatch(actions.setAppSnackBarData({ msg: `${response.data.success}` }));\r\n props.onClose();\r\n props.refreshData();\r\n }\r\n else {\r\n exportToTextFile(response.data.errors.join('\\n'), 'AddressBookImportErrors.txt');\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: `${response.data.success}`,\r\n },\r\n ],\r\n }),\r\n );\r\n }\r\n })\r\n .catch((err) => {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: `Failed to update the data :${err?.response?.data?.[0]?.detail}`,\r\n },\r\n ],\r\n }),\r\n );\r\n })\r\n .finally(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n clearFile();\r\n props.refreshData();\r\n });\r\n };\r\n\r\n const clearFile = () => {\r\n document.getElementById('addressBook').value = [];\r\n setUploadFile('No file selected');\r\n };\r\n\r\n const handleDialogClose = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n const onDialogConfirm = () => {\r\n setShowConfirmationDialog(false);\r\n handleImport();\r\n };\r\n const onDialogCancel = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n\r\n useEffect(() => {\r\n // setFieldValue('addressImportType', setDropdownValues(addressImportTypeOptions, 'value', 'domestic'));\r\n setState({ ...state, ignoreFirstRow: true });\r\n }, []);\r\n\r\n // useEffect(() => {\r\n // if (formikValues.addressImportType?.value !== 'consignor') {\r\n // setState({ ...state, ignoreFirstRow: true });\r\n // } else {\r\n // setState({ ...state, ignoreFirstRow: false });\r\n // }\r\n // }, [formikValues.addressImportType]);\r\n\r\n var confirmationMessage = `The address book contains ${props.totalRecords} entries. Are you sure you want to clear them?`;\r\n return (\r\n \r\n {/* \r\n \r\n */}\r\n {/* {props.formikValues.addressImportType && ( */}\r\n {/* {ADDRESSBOOK_MODAL_CONTENT(`${props.formikValues.addressImportType.value}`)} */}\r\n {/* )} */}\r\n {ADDRESSBOOK_MODAL_CONTENT('ship')} \r\n \r\n \r\n \r\n \r\n Choose file\r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n {/* {props.formikValues.addressImportType?.value === 'ship' && ( */}\r\n \r\n \r\n \r\n {/* )} */}\r\n \r\n \r\n \r\n \r\n }\r\n label=\"Clear existing addresses.\"\r\n />\r\n \r\n \r\n }\r\n label=\"Ignore first row.\"\r\n />\r\n \r\n \r\n \r\n }\r\n label=\"Overwrite duplicates.\"\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n (state.isClearExistingAddress ? setShowConfirmationDialog(true) : handleImport())}\r\n buttonType=\"submit\"\r\n label=\"Import\"\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nAddressBookModalContent.propTypes = {\r\n tableRef: PropTypes.object,\r\n totalRecords: PropTypes.string,\r\n onClose: PropTypes.func,\r\n\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n setFieldValue: PropTypes.func,\r\n setFieldTouched: PropTypes.func,\r\n};\r\n\r\nexport default AddressBookModalContent;\r\n","import React, { useState, useEffect } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { useHistory } from 'react-router-dom';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport Grid from '@material-ui/core/Grid';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../../store/actions/index';\r\nimport CustomizedDialogs from '../addressBookModal/addressBookModal';\r\nimport AddressBookModalContent from '../AddressBookModalContent/AddressBookModalContent';\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n SearchAddressField: {\r\n marginTop: '10px',\r\n paddingRight: '13px',\r\n },\r\n}));\r\n\r\nconst SearchAddress = (props) => {\r\n const classes = useStyles();\r\n const dispatch = useDispatch();\r\n let history = useHistory();\r\n const inputRef = React.useRef();\r\n const {\r\n formField: { addressSearchFor, favoriteSearchFor },\r\n setFieldValue,\r\n formikValues,\r\n setValues,\r\n tabIndex,\r\n searchByOptions,\r\n errors,\r\n setFieldTouched,\r\n // addressImportTypeOptions,\r\n } = props;\r\n\r\n let [isClearBtn, setIsClearBtn] = useState(false);\r\n const [open, setOpen] = React.useState(false);\r\n const [addressBookSearchForFlag, setAddressBookSearchForFlag] =React.useState(false);\r\n\r\n const handleClickOpen = () => {\r\n setOpen(true);\r\n };\r\n const handleClose = () => {\r\n // setFieldValue('addressImportType', addressImportTypeOptions[0]);\r\n setOpen(false);\r\n };\r\n\r\n const getClear = (event = null, queryParams = '') => {\r\n if (event) {\r\n event.preventDefault();\r\n }\r\n setIsClearBtn(false);\r\n setFieldValue('favoriteSearchFor', '');\r\n setFieldValue('addressSearchFor', '');\r\n setFieldTouched('addressSearchFor', false);\r\n setFieldTouched('favoriteSearchFor', false);\r\n dispatch(actions.setAddressBookSearchParams(''));\r\n props.onAddressChange(false);\r\n };\r\n\r\n const getAddresses = (event = null) => {\r\n setAddressBookSearchForFlag(true);\r\n if (event) {\r\n event.preventDefault();\r\n }\r\n props.onAddressChange(true);\r\n setIsClearBtn(true);\r\n };\r\n const onAddNewButtonClick = () => {\r\n history.push('/addressBook/Addnew');\r\n };\r\n\r\n useEffect(() => {\r\n if (tabIndex === 0) {\r\n const encodedAddressSearchFor = encodeURIComponent(props.formikValues?.addressSearchFor);\r\n dispatch(\r\n actions.setAddressBookSearchParams(`&${props.formikValues.addressSearchBy.value}=${encodedAddressSearchFor}`),\r\n );\r\n } else {\r\n const encodedFavoriteSearchFor = encodeURIComponent(props.formikValues?.favoriteSearchFor);\r\n dispatch(\r\n actions.setAddressBookSearchParams(`&${props.formikValues.favoriteSearchBy.value}=${encodedFavoriteSearchFor}`),\r\n );\r\n }\r\n }, [dispatch, props.formikValues, tabIndex]);\r\n\r\n useEffect(() => {\r\n setValues({\r\n addressSearchFor: '',\r\n favoriteSearchFor:\"\",\r\n addressSearchBy: searchByOptions[0],\r\n favoriteSearchBy: searchByOptions[0],\r\n });\r\n setFieldTouched('shipmentManagementSearchFor', false);\r\n }, [tabIndex]);\r\n\r\n\r\n // useEffect(() => {\r\n // setFieldValue('addressSearchFor', '');\r\n // setIsClearBtn(false);\r\n // }, [tabIndex, setFieldValue]);\r\n\r\n useEffect(() => {\r\n setIsClearBtn(false);\r\n }, [props.formikValues.addressSearchFor]);\r\n\r\n useEffect(() => {\r\n setIsClearBtn(false);\r\n }, [props.formikValues.favoriteSearchFor]);\r\n\r\n useEffect(() => {\r\n setFieldValue('addressSearchFor', '');\r\n setFieldTouched('addressSearchFor', true);\r\n inputRef.current.focus();\r\n if(props.formikValues.addressSearchFor || addressBookSearchForFlag)\r\n {\r\n getClear();\r\n setAddressBookSearchForFlag(false);\r\n }\r\n }, [props.formikValues.addressSearchBy]);\r\n\r\n useEffect(() => {\r\n setFieldValue('favoriteSearchFor', '');\r\n setFieldTouched('favoriteSearchFor', true);\r\n inputRef.current.focus();\r\n if(props.formikValues.favoriteSearchFor || addressBookSearchForFlag){\r\n getClear();\r\n setAddressBookSearchForFlag(false);\r\n }\r\n }, [props.formikValues.favoriteSearchBy]);\r\n\r\n return (\r\n \r\n
\r\n \r\n {tabIndex === 0 ? (\r\n getAddresses(event, '')}\r\n onClearSearch={(event) => getClear(event, '')}\r\n isIconDisabled={errors.addressSearchFor || formikValues.addressSearchFor?.trim() === ''}\r\n selectProps={addressSearchFor.selectProps.props}\r\n textProps={addressSearchFor.textProps.props}\r\n isClearBtn={isClearBtn}\r\n inputRef={inputRef}\r\n {...addressSearchFor.props}\r\n />\r\n ) : (\r\n getAddresses(event, '')}\r\n onClearSearch={(event) => getClear(event, '')}\r\n isIconDisabled={errors.favoriteSearchFor}\r\n selectProps={favoriteSearchFor.selectProps.props}\r\n textProps={favoriteSearchFor.textProps.props}\r\n isClearBtn={isClearBtn}\r\n inputRef={inputRef}\r\n {...favoriteSearchFor.props}\r\n />\r\n )}\r\n \r\n {tabIndex ? null : (\r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n );\r\n};\r\n\r\nSearchAddress.propTypes = {\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n onAddressChange: PropTypes.func,\r\n totalRecords: PropTypes.string,\r\n setFieldValue: PropTypes.func,\r\n tabIndex: PropTypes.object,\r\n setFieldTouched: PropTypes.func,\r\n};\r\n\r\nexport default SearchAddress;\r\n","import React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Form, Formik } from 'formik';\r\nimport SearchAddress from './SearchAddress';\r\nimport { getYupSchemaFromMetaData } from '../../../utils/yupSchema/yupSchemaGenerator';\r\n\r\nconst SearchAddressBook = (props) => {\r\n const formField = searchForm;\r\n const newSearchValidationSchema = getYupSchemaFromMetaData(formField, [], []);\r\n\r\n const initialValues = {\r\n addressSearchFor: '',\r\n favoriteSearchFor: '',\r\n addressSearchBy: searchByOptions[0],\r\n favoriteSearchBy: searchByFavouriteOptions[0],\r\n // addressImportType: addressImportTypeOptions[0],\r\n };\r\n return (\r\n \r\n\r\n \r\n {({ values, setFieldValue, setValues, errors, setFieldTouched }) => (\r\n \r\n )}\r\n \r\n
\r\n );\r\n};\r\n\r\n\r\nSearchAddressBook.propTypes = {\r\n tabIndex:PropTypes.string,\r\n onAddressChange: PropTypes.func,\r\n}\r\n\r\nexport default SearchAddressBook;\r\n\r\nconst searchForm = {\r\n addressSearchFor: {\r\n props: {\r\n name: 'addressSearchFor',\r\n type: 'searchControl',\r\n },\r\n selectProps: {\r\n props: {\r\n name: 'addressSearchBy',\r\n label: 'Search For',\r\n placeholder: \"Enter Customer's Number\",\r\n },\r\n },\r\n textProps: {\r\n props: {\r\n name: 'addressSearchFor',\r\n label: 'Search For',\r\n placeholder: \"Enter Customer's Number\",\r\n },\r\n \r\n },\r\n validation: {\r\n name: 'addressSearchFor',\r\n validationType: 'string',\r\n // validations: [\r\n // {\r\n // type: 'required',\r\n // params: ['Search for is required'],\r\n // },\r\n // ],\r\n },\r\n },\r\n favoriteSearchFor: {\r\n props: {\r\n name: 'favoriteSearchFor',\r\n type: 'searchControl',\r\n },\r\n selectProps: {\r\n props: {\r\n name: 'favoriteSearchBy',\r\n label: 'Search For',\r\n placeholder: \"Enter Customer's Number\",\r\n },\r\n },\r\n textProps: {\r\n props: {\r\n name: 'favoriteSearchFor',\r\n label: 'Search For',\r\n placeholder: \"Enter Customer's Number\",\r\n },\r\n },\r\n validation: {\r\n name: 'favoriteSearchFor',\r\n validationType: 'string',\r\n // validations: [\r\n // {\r\n // type: 'required',\r\n // params: ['Search for is required'],\r\n // },\r\n // ],\r\n },\r\n },\r\n // addressImportType: {\r\n // props: {\r\n // name: 'addressImportType',\r\n // label: 'Address import type',\r\n // type: 'select',\r\n // displayField: 'name',\r\n // hasDefaultValue: true,\r\n // isRequired: true,\r\n // },\r\n // validation: {\r\n // name: 'addressImportType',\r\n // validationType: 'object',\r\n // validations: [\r\n // {\r\n // type: 'required',\r\n // params: ['Address import type is required'],\r\n // },\r\n // ],\r\n // },\r\n // },\r\n};\r\n\r\nconst searchByOptions = [\r\n {\r\n value: 'customernumber',\r\n name: 'Customer number',\r\n },\r\n {\r\n value: 'recipientname',\r\n name: 'Recipient name',\r\n },\r\n {\r\n value: 'businessname',\r\n name: 'Business name',\r\n },\r\n {\r\n value: 'town',\r\n name: 'Town',\r\n },\r\n {\r\n value: 'postcode',\r\n name: 'Postal code',\r\n },\r\n];\r\n\r\nconst searchByFavouriteOptions = [\r\n {\r\n value: 'customernumber',\r\n name: 'Customer number',\r\n },\r\n {\r\n value: 'recipientname',\r\n name: 'Recipient name',\r\n },\r\n {\r\n value: 'businessname',\r\n name: 'Business name',\r\n },\r\n];\r\n\r\n// const addressImportTypeOptions = [\r\n// {\r\n// value: 'domestic',\r\n// name: 'iConsign domestic import'\r\n// },\r\n// {\r\n// value: 'international',\r\n// name: 'iConsign international import'\r\n// },\r\n// {\r\n// value: 'consignor',\r\n// name: 'Consignor import'\r\n// },\r\n// {\r\n// value: 'ship',\r\n// name: 'Ship import'\r\n// }\r\n// ]\r\n","import React from 'react';\r\nimport { connect } from 'react-redux';\r\nimport { AppBar, Tabs, Tab } from '@material-ui/core/';\r\nimport Grid from '@material-ui/core/Grid';\r\n\r\nimport './AddressBook.scss';\r\nimport TabPanel from '../../components/shared/tabPanel';\r\nimport MyAddressBook from '../../components/MyAddressBook/MyAddressBook';\r\nimport SearchAddressBook from '../../components/addressBook/searchAddress/SearchAddressBook';\r\nimport { ServiceEndPoints } from '../../utils/constants/ApiConstant';\r\nimport { customTableSort, getCustomerAccountID } from '../../utils/helperFunctions';\r\nimport { withRouter } from 'react-router-dom';\r\nimport * as actions from '../../store/actions/index';\r\nimport { axiosConfig } from '../../api/axios';\r\n\r\n// const tableRef = React.createRef();\r\nclass AddressBook extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n tabIndex: 0,\r\n totalRecords: 0,\r\n isSearched: false,\r\n columns: [\r\n { title: 'id', field: 'id', hidden: true, width: 0 },\r\n {\r\n title: 'Customer no.',\r\n field: 'customerNumber',\r\n customSort: (a, b) => customTableSort(a.customerNumber, b.customerNumber),\r\n width: 200,\r\n },\r\n {\r\n title: 'Business/Recipient name',\r\n field: 'contactName',\r\n sorting: false,\r\n width: 210,\r\n },\r\n {\r\n title: 'Address',\r\n field: 'line1',\r\n sorting: false,\r\n width: 200,\r\n },\r\n {\r\n title: 'Town',\r\n field: 'town',\r\n sorting: false,\r\n width: 150,\r\n },\r\n {\r\n title: 'County',\r\n field: 'country',\r\n sorting: false,\r\n width: 150,\r\n },\r\n {\r\n title: 'Postal code',\r\n field: 'postCode',\r\n sorting: false,\r\n width: 100,\r\n },\r\n {\r\n title: 'Telephone no',\r\n field: 'telephone',\r\n sorting: false,\r\n width: 150,\r\n },\r\n {\r\n title: 'Email address',\r\n field: 'email',\r\n sorting: false,\r\n width: 200,\r\n },\r\n {\r\n title: 'What3Words',\r\n field: 'what3Words',\r\n sorting: false,\r\n width: 150,\r\n },\r\n ],\r\n rows: [],\r\n addressBook_pageDetails: {\r\n offset: 0,\r\n limit: 0,\r\n totalRecordsLength: 0,\r\n },\r\n addressBook_final_data: [],\r\n addressBook_totalCount: 0,\r\n favurites_pageDetails: {\r\n offset: 0,\r\n limit: 0,\r\n totalRecordsLength: 0,\r\n },\r\n favurites_final_data: [],\r\n favurites_totalCount: 0,\r\n pageNumber: 0,\r\n pageSize: 10,\r\n isLoading: false,\r\n };\r\n this.onAddressChange = this.onAddressChange.bind(this);\r\n }\r\n\r\n customerNumberClicked = (rowData) => {\r\n if (this.state.tabIndex === 1) {\r\n this.props.setActiveTab('addressbookFavourites');\r\n }\r\n this.props.history.push('/addressBook/editAddress?id=' + rowData.id);\r\n };\r\n\r\n onAddressChange(value) {\r\n this.setState({ isSearched: true, pageNumber: 0, pageSize: this.state.pageSize ? this.state.pageSize : 10 }, () => {\r\n this.getAddressBookDetails();\r\n });\r\n }\r\n\r\n deleteSelectedAddress = (addressIds) => {\r\n const itemsToBeDeleted = addressIds.map((address) => {\r\n return address.id;\r\n });\r\n const payload = itemsToBeDeleted;\r\n axiosConfig\r\n .post(`${ServiceEndPoints.postAddressBook}/delete`, payload)\r\n .then((response) => {\r\n this.props.setSnackBar({ msg: 'Address deleted successfully' });\r\n this.onAddressChange();\r\n })\r\n .catch((error) => {\r\n alert('Items were not deleted, please try again.');\r\n });\r\n };\r\n\r\n addFavouriteAddress = (addressIds) => {\r\n const { userId } = this.props.userDetails;\r\n const payload = addressIds.map((address) => {\r\n return address.id;\r\n });\r\n\r\n axiosConfig\r\n .post(`${ServiceEndPoints.postAddressBook}/favourite?userid=${userId}`, payload)\r\n .then((response) => {\r\n this.props.setSnackBar({ msg: 'Address added as favourite' });\r\n this.onAddressChange();\r\n })\r\n .catch((err) => {\r\n alert('Could not add items to favourites.');\r\n });\r\n };\r\n\r\n removeAddressFromFavourite = (addressIds) => {\r\n const { userId } = this.props.userDetails;\r\n const itemsToBeRemoved = addressIds.map((address) => {\r\n return address.id;\r\n });\r\n const payload = itemsToBeRemoved;\r\n axiosConfig\r\n .post(`${ServiceEndPoints.postAddressBook}/favourite/delete?userid=${userId}`, payload)\r\n .then((response) => {\r\n this.props.setSnackBar({ msg: 'Address removed from favourites' });\r\n this.onAddressChange();\r\n })\r\n .catch((error) => {\r\n alert('Items were not removed, please try again.');\r\n });\r\n };\r\n\r\n handleTabChange = (event, index) => {\r\n this.setState({ tabIndex: index, isSearched: true, pageNumber: 0, pageSize: 10 }, () => {\r\n this.getAddressBookDetails();\r\n });\r\n };\r\n\r\n refreshTableData = () => {\r\n this.setState({ pageNumber: 0, pageSize: this.state.pageSize ? this.state.pageSize : 10 }, () => {\r\n this.getAddressBookDetails();\r\n });\r\n }\r\n\r\n getAddressBookDetails() {\r\n this.setState({ isLoading: true });\r\n const isFavourites = this.state.tabIndex === 1;\r\n const offset = this.state.pageNumber * this.state.pageSize;\r\n const limit = this.state.pageSize;\r\n axiosConfig\r\n .get(this.getUrl(offset, limit))\r\n .then((res) => {\r\n this.setState({\r\n [isFavourites ? 'favurites_pageDetails' : 'addressBook_pageDetails']: {\r\n offset,\r\n limit,\r\n totalRecordsLength: (res.data || {}).totalRecords,\r\n },\r\n isSearched: false,\r\n });\r\n this.setState({ totalRecords: res.data?.totalRecords ? res.data?.totalRecords : 0 });\r\n this.formatAddressBookData(res.data, isFavourites);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n this.formatAddressBookData([], isFavourites);\r\n this.setState({ totalRecords: 0 });\r\n this.setState({\r\n [isFavourites ? 'favurites_pageDetails' : 'addressBook_pageDetails']: {\r\n totalRecordsLength: 0,\r\n },\r\n });\r\n })\r\n .finally(() => {\r\n this.setState({ isLoading: false });\r\n });\r\n }\r\n\r\n getUrl = (offset, limit) => {\r\n const { userId } = this.props.userDetails;\r\n let url = `${ServiceEndPoints.getAddressBook}?organization=${getCustomerAccountID()}`;\r\n url += '&offset=' + offset;\r\n url += '&limit=' + limit;\r\n url += this.props.addressBookSearchParams;\r\n if (this.state.tabIndex === 1) {\r\n url += '&userid=' + userId;\r\n }\r\n return url;\r\n };\r\n\r\n formatAddressBookData = (result, isFav = false) => {\r\n let final_data = [];\r\n ((result || {}).addressBooks || []).forEach((element, index) => {\r\n const customer = element?.deliveryAddress;\r\n final_data.push({\r\n id: element.id,\r\n customerNumber: customer?.customerNumber,\r\n contactName: customer?.recipientType == 1 ? customer?.businessName : customer?.recipientName,\r\n line1: customer?.line1,\r\n town: customer?.town,\r\n country: customer?.county,\r\n postCode: customer?.postCode,\r\n telephone: customer?.telephone,\r\n email: customer?.email,\r\n favouriteUsers: element?.favouriteUsers,\r\n what3Words:customer?.what3Words?.words,\r\n });\r\n });\r\n if (isFav) {\r\n this.setState({\r\n favurites_final_data: final_data,\r\n favurites_totalCount: result.totalRecords ? result.totalRecords : 0,\r\n });\r\n } else {\r\n this.setState({\r\n addressBook_final_data: final_data,\r\n addressBook_totalCount: result.totalRecords ? result.totalRecords : 0,\r\n });\r\n }\r\n };\r\n\r\n componentDidMount() {\r\n this.getAddressBookDetails();\r\n if (this.props.activeTab === 'addressbookFavourites') {\r\n this.setState({ tabIndex: 1 ,pageNumber: 0, pageSize: this.state.pageSize ? this.state.pageSize : 10 }, () => {\r\n this.getAddressBookDetails();\r\n });\r\n }\r\n this.props.setActiveTab('');\r\n }\r\n\r\n onPageNumChange(pageNum) {\r\n this.setState({ pageNumber: pageNum }, () => {\r\n this.getAddressBookDetails();\r\n });\r\n }\r\n\r\n onPageSizeChange(pageSize) {\r\n this.setState({ pageSize: pageSize }, () => {\r\n this.getAddressBookDetails();\r\n });\r\n }\r\n\r\n render() {\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n <>\r\n \r\n this.onPageSizeChange(e),\r\n onChangePage: (a) => this.onPageNumChange(a),\r\n }}\r\n page={this.state.pageNumber}\r\n isSearched={this.state.isSearched}\r\n />\r\n \r\n \r\n this.onPageSizeChange(e),\r\n onChangePage: (a) => this.onPageNumChange(a),\r\n }}\r\n page={this.state.pageNumber}\r\n />\r\n \r\n >\r\n \r\n );\r\n }\r\n}\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n userDetails: state.auth.userDetails,\r\n addressBookSearchParams: state.searchParams,\r\n activeTab: state.common.activeTab,\r\n };\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n onLoad: (loadedFrom) => {\r\n dispatch(actions.setLoadedFrom(loadedFrom));\r\n },\r\n setSnackBar: (data) => {\r\n dispatch(actions.setAppSnackBarData(data));\r\n },\r\n setActiveTab: (value) => {\r\n dispatch(actions.setActiveTab(value));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(withRouter(AddressBook));\r\n","import React from 'react';\r\nimport { Grid } from '@material-ui/core';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\n\r\nconst CollectionDetails = (props) => {\r\n\r\n const {\r\n formField: {\r\n collectionInstructions,\r\n descriptionOfGoodsToBeCollected,\r\n },\r\n } = props;\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n )\r\n}\r\n\r\nexport default CollectionDetails;","import { GET } from '../../../api/axios';\r\nimport { ServiceEndPoints } from '../../constants/ApiConstant';\r\nimport { testFunctionForPostCodeRegex, getCustomerAccountID } from '../../helperFunctions';\r\n\r\nlet doesCustNumExist = false;\r\nconst addNewAddressForm = {\r\n formId: 'addNewAddressForm',\r\n formField: {\r\n destinationCountry: {\r\n props: {\r\n name: 'destinationCountry',\r\n label: 'Destination country',\r\n type: 'select',\r\n displayField: 'name',\r\n isRequired: true,\r\n hasDefaultValue: true,\r\n },\r\n validation: {\r\n name: 'destinationCountry',\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Destination country is required'],\r\n },\r\n ],\r\n },\r\n },\r\n\r\n addParcelDimensions: {\r\n props: {\r\n name: 'addParcelDimensions',\r\n label: 'Add parcel dimensions',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n noOfItems: {\r\n props: {\r\n name: 'noOfItems',\r\n label: 'No. of items',\r\n type: 'number',\r\n inputProps: {\r\n min: 1,\r\n max: 20,\r\n },\r\n restrictDecimal: true\r\n },\r\n value: 1,\r\n validation: {\r\n name: 'noOfItems',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n params: [1, 'Must be a value between 1 to 20'],\r\n type: 'min',\r\n },\r\n {\r\n type: 'max',\r\n params: [20, 'Must be a value between 1 to 20'],\r\n },\r\n ],\r\n },\r\n },\r\n weight: {\r\n props: {\r\n name: 'weight',\r\n label: 'Weight (Kg)',\r\n type: 'number',\r\n placeholder: 'Select',\r\n inputProps: {\r\n min: 0,\r\n max: 1000,\r\n step: 'any',\r\n },\r\n },\r\n validation: {\r\n name: 'weight',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n ['totalpieceWeight', 'destinationCountry', 'addParcelDimensions'],\r\n (totalpieceWeight, destinationCountry, addParcelDimensions, schema) => {\r\n if (destinationCountry && destinationCountry.code === 'GBR' && addParcelDimensions) {\r\n return schema.test('', 'Weight must be greater than or equal to piece weight', (value) => {\r\n return value >= totalpieceWeight;\r\n });\r\n } else {\r\n return schema;\r\n }\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n parcelDetails: {\r\n props: {\r\n name: 'parcelDetails',\r\n type: 'array',\r\n fields: {\r\n length: 'number',\r\n width: 'number',\r\n height: 'number',\r\n pieceWeight: 'number',\r\n volumetricWeight: 'number',\r\n id: 'number',\r\n },\r\n },\r\n values: [],\r\n },\r\n totalVolumetricWeight: {\r\n props: {\r\n name: 'totalVolumetricWeight',\r\n },\r\n value: 0.0,\r\n },\r\n length: {\r\n props: {\r\n name: 'length',\r\n label: 'Length (cm)',\r\n type: 'number',\r\n },\r\n validation: {\r\n name: 'length',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'typeError',\r\n params: ['Length must be number type'],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n ['width', 'height'],\r\n (width, height, schema) => {\r\n if (width || height) {\r\n let highest = width || 0;\r\n if ((height || 0) > highest) highest = height;\r\n return schema.test('', 'Length must be longest side', (value) => {\r\n return value >= highest;\r\n });\r\n } else return schema;\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n width: {\r\n props: {\r\n name: 'width',\r\n label: 'Width (cm)',\r\n type: 'number',\r\n },\r\n validation: {\r\n name: 'width',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'typeError',\r\n params: ['Width must be number type'],\r\n },\r\n ],\r\n },\r\n },\r\n height: {\r\n props: {\r\n name: 'height',\r\n label: 'Height (cm)',\r\n type: 'number',\r\n },\r\n validation: {\r\n name: 'height',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'typeError',\r\n params: ['Height must be number type'],\r\n },\r\n ],\r\n },\r\n },\r\n addressType: {\r\n props: {\r\n name: 'addressType',\r\n label: 'Address type:',\r\n type: 'radio',\r\n },\r\n value: 'residential',\r\n validation: {\r\n name: 'addressType',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Choose any one of address'],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n ['createPalletShipment', 'destinationCountry'],\r\n (createPalletShipment, destinationCountry, schema) => {\r\n if (createPalletShipment === 'yes' && destinationCountry.code === 'GBR') {\r\n return schema.test('', 'Residential address not allowed for pallets.', (value) => {\r\n return value !== 'residential';\r\n });\r\n }\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n // TODO: check the below and remove it\r\n searchFor: {\r\n props: {\r\n type: 'searchControl',\r\n name: 'searchFor',\r\n },\r\n selectProps: {\r\n props: {\r\n name: 'searchBy',\r\n label: 'Search By',\r\n },\r\n value: '',\r\n },\r\n textProps: {\r\n props: {\r\n name: 'searchFor',\r\n placeholder: \"Enter Customer's Number\",\r\n },\r\n },\r\n validation: {\r\n name: 'searchFor',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n ['destinationCountry', 'searchBy'],\r\n (destinationCountry, searchBy, schema) => {\r\n return (destinationCountry || {}).code && (searchBy || {}).value === 'postCode'\r\n ? schema\r\n .required('Postal code is required')\r\n .matches((destinationCountry || {}).postcodeRegex, 'Invalid postal code')\r\n : schema.required('Address is required');\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n backupCustNum: {\r\n props: {\r\n name: 'backupCustNum',\r\n label: 'backupCustNum',\r\n type: 'text',\r\n },\r\n },\r\n\r\n customerNumber: {\r\n props: {\r\n name: 'customerNumber',\r\n label: 'Customer number',\r\n type: 'text',\r\n isRequired: true,\r\n placeholder: 'Enter',\r\n inputProps: {\r\n maxLength: 30,\r\n },\r\n },\r\n validation: {\r\n name: 'customerNumber',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Customer number is required'],\r\n },\r\n // {\r\n // type: 'strict',\r\n // params: [''],\r\n // },\r\n // {\r\n // type: 'trim',\r\n // params: [''],\r\n // },\r\n {\r\n type: 'when',\r\n params: [\r\n 'backupCustNum',\r\n (backupCustNum, schema) => {\r\n return schema.test(\r\n 'checkDuplCustomerNumber',\r\n 'Customer number already in use, please choose another.',\r\n (customerNumberValue) => {\r\n if (window.location.href.indexOf('editAddress') > 1) {\r\n return true;\r\n } else if (\r\n customerNumberValue?.trim?.() &&\r\n backupCustNum?.trim?.() !== customerNumberValue?.trim?.()\r\n ) {\r\n return new Promise((resolve, reject) => {\r\n GET(\r\n `${ServiceEndPoints.getAddressBook\r\n }?organization=${getCustomerAccountID()}&offSet=0&limit=1&isExactMatch=true&customernumber=${customerNumberValue}`,\r\n )\r\n .then((res) => {\r\n if ((res.data?.addressBooks || []).length > 0) {\r\n doesCustNumExist = false;\r\n resolve(false);\r\n } else {\r\n doesCustNumExist = true;\r\n resolve(true);\r\n }\r\n })\r\n .catch(() => {\r\n doesCustNumExist = true;\r\n resolve(true);\r\n });\r\n });\r\n }\r\n return doesCustNumExist;\r\n },\r\n );\r\n },\r\n ],\r\n },\r\n {\r\n type: 'test',\r\n params: [\r\n 'checkIfBlankSpaces',\r\n 'Customer number should not contain blank spaces',\r\n (customerNumberValue) => {\r\n if (customerNumberValue?.length > 0 && !customerNumberValue?.trim?.()) {\r\n return false;\r\n }\r\n return true;\r\n },\r\n ],\r\n },\r\n // {\r\n // type: 'matches',\r\n // params: [/^(\\s+$)/g, 'Whitespaces not allowed'],\r\n // },\r\n ],\r\n },\r\n },\r\n postalCode: {\r\n props: {\r\n name: 'postalCode',\r\n label: 'Postal code',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 15,\r\n minLength: 3,\r\n },\r\n },\r\n validation: {\r\n name: 'searchFor',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'destinationCountry',\r\n (destinationCountry, schema) => {\r\n if (!destinationCountry?.postcodeOptional) {\r\n return schema.required('Postal code is required')\r\n }\r\n }\r\n ],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n 'destinationCountry',\r\n (destinationCountry, schema) => {\r\n if (destinationCountry?.postcodeRegex) {\r\n return testFunctionForPostCodeRegex(\r\n schema,\r\n `Postal code should match ${destinationCountry?.postcodeMask} format`,\r\n destinationCountry?.postcodeRegex,\r\n false,\r\n );\r\n }\r\n },\r\n ],\r\n },\r\n {\r\n type: 'max',\r\n params: [15, 'Maximum of 15 characters are allowed'],\r\n },\r\n {\r\n type: 'min',\r\n params: [3, 'Minimum of 3 characters are required'],\r\n },\r\n ],\r\n },\r\n },\r\n recipientName: {\r\n props: {\r\n name: 'recipientName',\r\n label: 'Recipient full name',\r\n isRequired: true,\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n name: 'recipientName',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Recipient name is required'],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n ['addressType', 'destinationCountry'],\r\n (addressType, destinationCountry, schema) => {\r\n return addressType === 'residential' || (destinationCountry || {}).code !== 'GBR'\r\n ? schema.required('Recipient name is required').max(50, 'Recipient name is required')\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum 35 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n businessName: {\r\n props: {\r\n name: 'businessName',\r\n label: 'Business name',\r\n placeholder: 'Business 1',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n name: 'businessName',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'addressType',\r\n (addressType, schema) => {\r\n return addressType === 'business'\r\n ? schema.required('Business name is required').max(35, 'Maximum of 35 characters allowed')\r\n : schema;\r\n },\r\n ],\r\n },\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum 35 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n addressLine1: {\r\n props: {\r\n name: 'addressLine1',\r\n label: 'Address line 1',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n name: 'addressLine1',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Address is required'],\r\n },\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum of 100 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n addressLine2: {\r\n props: {\r\n name: 'addressLine2',\r\n label: 'Address line 2',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n name: 'addressLine2',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum of 35 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n addressLine3: {\r\n props: {\r\n name: 'addressLine3',\r\n label: 'Address line 3',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n name: 'addressLine3',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum of 35 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n town: {\r\n props: {\r\n name: 'town',\r\n label: 'Town',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n name: 'town',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Town is required'],\r\n },\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum of 35 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n county: {\r\n props: {\r\n name: 'county',\r\n label: 'County',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n name: 'county',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum of 35 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n telephone: {\r\n props: {\r\n name: 'telephone',\r\n label: 'Telephone number',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n name: 'telephone',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'destinationCountry',\r\n (destinationCountry, schema) => {\r\n return destinationCountry?.code !== 'GBR' ? schema.required('Phone number is required') : schema;\r\n },\r\n ],\r\n },\r\n // {\r\n // type: 'min',\r\n // params: [10, 'Invalid phone number'],\r\n // },\r\n // {\r\n // type: 'max',\r\n // params: [35, 'Invalid phone number'],\r\n // },\r\n // {\r\n // type: 'matches',\r\n // params: [/^[0-9,(,),+,\\-,.,[,\\] ].{9,35}/, 'Invalid phone number'],\r\n // },\r\n {\r\n type: 'when',\r\n params: [\r\n ['destinationCountry'],\r\n (destinationCountry, schema) => {\r\n return schema.test(\"\", \"Invalid phone number\", (value) => {\r\n if (value?.trim()?.length > 0) {\r\n return destinationCountry?.code === \"GBR\" ? /^[0-9()+\\-.[\\], ]{0,35}$/.test(value) : /^[0-9()+\\- ]{9,35}$/.test(value)\r\n }\r\n else return schema\r\n }\r\n )\r\n },\r\n ],\r\n }\r\n ],\r\n },\r\n },\r\n emailAddress: {\r\n props: {\r\n name: 'emailAddress',\r\n label: 'Email address',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 70,\r\n },\r\n },\r\n validation: {\r\n name: 'emailAddress',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Email address is required'],\r\n },\r\n {\r\n type: 'email',\r\n params: ['Invalid email address'],\r\n },\r\n {\r\n type: 'max',\r\n params: [70, 'Maximum of 70 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n deliveryType: {\r\n props: {\r\n name: 'deliveryType',\r\n label: 'Delivery type:',\r\n type: 'radio',\r\n },\r\n value: 'deliverToDoorStep',\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n // {\r\n // type: 'required',\r\n // params: ['Delivery Type is required'],\r\n // },\r\n ],\r\n },\r\n },\r\n doorStepInstructions: {\r\n props: {\r\n name: 'doorStepInstructions',\r\n label: 'Doorstep instructions',\r\n type: 'select',\r\n displayField: 'name',\r\n hasDefaultValue: true,\r\n },\r\n validation: {\r\n validationType: 'object',\r\n validations: [\r\n // {\r\n // type: 'required',\r\n // params: ['Doorstep Instructions is required'],\r\n // },\r\n ],\r\n },\r\n },\r\n deliveryServicePoint: {\r\n props: {\r\n name: 'deliveryServicePoint',\r\n label: 'Search for ServicePoint',\r\n type: 'text',\r\n placeholder: 'Search For ServicePoint',\r\n },\r\n validation: {\r\n name: 'postalCode',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['ServicePoint is required'],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n 'destinationCountry',\r\n (destinationCountry, schema) => {\r\n if (destinationCountry?.postcodeRegex) {\r\n return testFunctionForPostCodeRegex(\r\n schema,\r\n 'Please enter a correct postal code',\r\n destinationCountry?.postcodeRegex,\r\n );\r\n }\r\n },\r\n ],\r\n },\r\n // {\r\n // type: 'when',\r\n // params: [\r\n // 'destinationCountry',\r\n // (destinationCountry, schema) => {\r\n // return (destinationCountry || {}).code\r\n // ? destinationCountry.code !== 'GBR'\r\n // ? schema.matches((destinationCountry || {}).postcodeRegex, 'Please enter a correct postcode')\r\n // : schema.matches((destinationCountry || {}).postcodeRegex, 'Please enter a correct postcode')\r\n // : schema;\r\n // },\r\n // ],\r\n // },\r\n ],\r\n },\r\n },\r\n exchange: {\r\n props: {\r\n name: 'exchange',\r\n label: 'Exchange on delivery:',\r\n type: 'radio',\r\n },\r\n value: 'no',\r\n },\r\n specialInstructions: {\r\n props: {\r\n name: 'specialInstructions',\r\n label: 'Special instructions',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 30,\r\n },\r\n },\r\n validation: {\r\n name: 'emailAddress',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [60, 'Maximum of 60 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n additionalInstruction: {\r\n props: {\r\n name: 'additionalInstruction',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 30,\r\n },\r\n },\r\n },\r\n leaveSafeLocation: {\r\n props: {\r\n name: 'leaveSafeLocation',\r\n label: 'Leave Safe location',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 60,\r\n },\r\n },\r\n validation: {\r\n name: 'emailAddress',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [60, 'Maximum of 60 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n product: {\r\n props: {\r\n name: 'product',\r\n label: 'Product',\r\n type: 'select',\r\n displayField: 'productNameForUI',\r\n // isRequired: true,\r\n },\r\n },\r\n service: {\r\n props: {\r\n name: 'service',\r\n label: 'Service',\r\n type: 'select',\r\n displayField: 'name',\r\n // isRequired: true,\r\n },\r\n validation: {\r\n name: 'service',\r\n validationType: 'object',\r\n validations: [\r\n // {\r\n // type: 'when',\r\n // params: [\r\n // 'destinationCountry',\r\n // (destinationCountry, schema) => {\r\n // return (destinationCountry || {}).code === 'GBR'\r\n // ? schema.required('Service name required')\r\n // : schema.notRequired();\r\n // },\r\n // ],\r\n // },\r\n ],\r\n },\r\n },\r\n customerReference: {\r\n props: {\r\n name: 'customerReference',\r\n label: 'Customer reference',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 20,\r\n },\r\n },\r\n validation: {\r\n name: 'customerReference',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [20, 'Max 20 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n alternateReference: {\r\n props: {\r\n name: 'alternateReference',\r\n label: 'Alternative reference',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 20,\r\n },\r\n },\r\n validation: {\r\n name: 'alternateReference',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [20, 'Max 20 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n extendedCoverDomestic: {\r\n props: {\r\n name: 'extendedCoverDomestic',\r\n label: 'Extended liability',\r\n type: 'number',\r\n placeholder: 'Please select a level of extended liability, if required',\r\n inputProps: {\r\n min: 0,\r\n max: 5,\r\n },\r\n },\r\n validation: {\r\n name: 'extendedCoverDomestic',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'min',\r\n params: [0, 'Extended liability value should be between 0 - 5.'],\r\n },\r\n {\r\n type: 'max',\r\n params: [5, 'Extended liability value should be between 0 - 5.'],\r\n },\r\n ],\r\n },\r\n },\r\n extendedCoverInternational: {\r\n props: {\r\n name: 'extendedCoverInternational',\r\n label: 'Extended liability',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n mobileRecipient: {\r\n props: {\r\n name: 'mobileRecipient',\r\n label: 'Mobile',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n emailRecipient: {\r\n props: {\r\n name: 'emailRecipient',\r\n label: 'Email',\r\n type: 'checkbox',\r\n },\r\n value: true,\r\n },\r\n invoiceTypeLabel: {\r\n props: {\r\n name: 'invoiceTypeLabel',\r\n label: 'Invoice Type',\r\n type: 'radio',\r\n // isRequired: 'true',\r\n },\r\n value: 'commercial',\r\n },\r\n addToFavCutomerList: {\r\n props: {\r\n name: 'addToFavCutomerList',\r\n label: 'Add to my favourites',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n descriptionOfGoods: {\r\n props: {\r\n name: 'descriptionOfGoods',\r\n label: 'Description of goods',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 50,\r\n },\r\n // isRequired: true,\r\n },\r\n validation: {\r\n name: 'descriptionOfGoods',\r\n validationType: 'string',\r\n validations: [\r\n // {\r\n // type: 'required',\r\n // params: ['Description of goods is required'],\r\n // },\r\n {\r\n type: 'min',\r\n params: [1, 'Minimum 1 character is required'],\r\n },\r\n {\r\n type: 'matches',\r\n params: [/(.*[a-zA-Z0-9$&+,:;=?@#|'<>.^*()%!-]){3}/i, 'Description must be at least 3 non blank characters'],\r\n },\r\n {\r\n type: 'max',\r\n params: [50, 'Maximum of 50 characters are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n customDeclarationCurrency: {\r\n props: {\r\n name: 'customDeclarationCurrency',\r\n label: 'Currency',\r\n type: 'select',\r\n displayField: 'name',\r\n // isRequired: true,\r\n },\r\n validation: {\r\n name: 'customDeclarationCurrency',\r\n validationType: 'object',\r\n validations: [\r\n // {\r\n // type: 'required',\r\n // params: ['Currency is required'],\r\n // },\r\n ],\r\n },\r\n },\r\n customDeclarationValue: {\r\n props: {\r\n name: 'customDeclarationValue',\r\n label: 'Value',\r\n type: 'number',\r\n // isRequired: true,\r\n inputProps: {\r\n min: 1,\r\n max: 10000,\r\n },\r\n },\r\n validation: {\r\n name: 'customDeclarationValue',\r\n validationType: 'number',\r\n validations: [\r\n // {\r\n // type: 'required',\r\n // params: ['Value is required'],\r\n // },\r\n {\r\n type: 'min',\r\n params: [1, 'Value must be greater than 0'],\r\n },\r\n {\r\n type: 'max',\r\n params: [10000, 'Value should not exceed 10000'],\r\n },\r\n ],\r\n },\r\n },\r\n customDeclarationShippingCharges: {\r\n props: {\r\n name: 'customDeclarationShippingCharges',\r\n label: 'Shipping charges(£)',\r\n type: 'text',\r\n // isRequired: true,\r\n inputProps: {\r\n maxLength: 10,\r\n },\r\n },\r\n validation: {\r\n name: 'customDeclarationShippingCharges',\r\n validationType: 'string',\r\n validations: [\r\n // {\r\n // type: 'required',\r\n // params: ['Shipping charges are required'],\r\n // },\r\n {\r\n type: 'max',\r\n params: [10, 'Maximum 10 digits are allowed for shipping charges'],\r\n },\r\n {\r\n type: 'matches',\r\n params: [/^[+]?([0-9]+(?:[\\.][0-9]*)?|\\.[0-9]+)$/, 'Shipping charges must be a positive number'],\r\n },\r\n ],\r\n },\r\n },\r\n commodityDetails: {\r\n props: {\r\n name: 'commodityDetails',\r\n type: 'array',\r\n fields: {\r\n commodityCode: 'text',\r\n description: 'text',\r\n weight: 'number',\r\n quantity: 'number',\r\n unitValue: 'number',\r\n countryOfOrigin: 'text',\r\n },\r\n },\r\n values: [],\r\n validation: {\r\n name: 'commodityDetails',\r\n validationType: 'array',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [20, 'Maximum 20 items are allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n subTotal: {\r\n props: {\r\n name: 'subTotal',\r\n },\r\n value: 0,\r\n },\r\n totalValue: {\r\n props: {\r\n name: 'totalValue',\r\n },\r\n value: 0,\r\n },\r\n pieceWeight: {\r\n props: {\r\n name: 'pieceWeight',\r\n label: 'Weight (kg)',\r\n type: 'number',\r\n placeholder: 'Select',\r\n isRequired: true,\r\n inputProps: {\r\n min: 0,\r\n max: 999,\r\n step: 'any',\r\n },\r\n },\r\n validation: {\r\n name: 'pieceWeight',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Weight is required'],\r\n },\r\n ],\r\n },\r\n },\r\n totalpieceWeight: {\r\n props: {\r\n name: 'totalpieceWeight',\r\n },\r\n value: 0.0,\r\n },\r\n isFullCustomDetails: {\r\n props: {\r\n name: 'isFullCustomDetails',\r\n label: '',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n //Addition of pallets.\r\n createPalletShipment: {\r\n props: {\r\n name: 'createPalletShipment',\r\n label: 'Create pallet shipment',\r\n type: 'radio',\r\n },\r\n value: 'no',\r\n },\r\n pallets: {\r\n props: {\r\n name: 'pallets',\r\n label: 'Pallets',\r\n type: 'number',\r\n // isDisabled: true,\r\n inputProps: {\r\n min: 0,\r\n max: 1,\r\n },\r\n },\r\n value: 1,\r\n\r\n validation: {\r\n name: 'pallets',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'min',\r\n params: [0, 'Pallets can not be less than 0'],\r\n },\r\n {\r\n type: 'max',\r\n params: [1, 'Pallets can not be greater than 1'],\r\n },\r\n ],\r\n },\r\n },\r\n //Express Changes for international shipment.\r\n intlParcelDetails: {\r\n props: {\r\n name: 'intlParcelDetails',\r\n type: 'array',\r\n fields: {\r\n length: 'number',\r\n width: 'number',\r\n height: 'number',\r\n pieceWeight: 'number',\r\n pieceRefId: 'string',\r\n volumetricWeight: 'number',\r\n id: 'number',\r\n },\r\n },\r\n values: [],\r\n },\r\n collectionInstructions: {\r\n props: {\r\n name: 'collectionInstructions',\r\n label: 'Collection instructions',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 60,\r\n },\r\n },\r\n },\r\n descriptionOfGoodsToBeCollected: {\r\n props: {\r\n name: 'descriptionOfGoodsToBeCollected',\r\n label: 'Description of goods to be collected',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 60,\r\n },\r\n },\r\n },\r\n totalWeightExceed: {\r\n props: {\r\n name: 'totalWeightExceed',\r\n type: 'number',\r\n },\r\n value: 0,\r\n validation: {\r\n name: 'totalWeightExceed',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n ['weight','destinationCountry'],\r\n (weight, destinationCountry, schema) => {\r\n if (destinationCountry?.code !== 'GBR') {\r\n return schema\r\n .test('', 'Total Weight of Pieces exceeds the Declared Weight', (value) => {\r\n return (value ? value : 0) <= (weight ? weight : 0);\r\n });\r\n } else {\r\n return schema;\r\n }\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n what3Words: {\r\n props: {\r\n name: 'what3Words',\r\n label: 'What3Words',\r\n type: 'text',\r\n },\r\n },\r\n w3WCoordinates: {\r\n props: {\r\n name: 'w3WCoordinates',\r\n type: 'object',\r\n },\r\n },\r\n duplicateParcelDimensions: {\r\n props: {\r\n name: 'duplicateParcelDimensions',\r\n label: 'Duplicate parcel dimensions',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n },\r\n};\r\n\r\nexport default addNewAddressForm;\r\n","import React from 'react';\r\nimport { Grid } from '@material-ui/core';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport PropTypes from 'prop-types';\r\n\r\nconst DestinationCountry = (props) => {\r\n const {\r\n formField: { destinationCountry },\r\n setFieldValue,\r\n countries,\r\n isUpdateAddressBook,\r\n } = props;\r\n if (\r\n countries.length > 0 &&\r\n (props.formikValues.destinationCountry === undefined || props.formikValues.destinationCountry === '')\r\n ) {\r\n if(!isUpdateAddressBook){\r\n setFieldValue(\r\n 'destinationCountry',\r\n countries.find((country) => country.code === 'GBR'),\r\n );\r\n }\r\n }\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nDestinationCountry.propTypes = {\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n setFieldValue: PropTypes.func,\r\n errors: PropTypes.object,\r\n countries: PropTypes.array,\r\n};\r\n\r\nexport default DestinationCountry;\r\n","import React, { useEffect, useRef, useState } from 'react';\r\n\r\nimport { Form, Formik } from 'formik';\r\nimport { Grid } from '@material-ui/core';\r\nimport { GET, POST } from '../../../api/axios';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { useHistory } from 'react-router-dom';\r\nimport CustomAccordion from '../../../framework/accordion/customAccordion';\r\nimport DeliveryOptions from '../../shipment/addShipment/deliveryOptions/deliveryOptions';\r\nimport AdditionalInfo from '../../shipment/addShipment/additionalInfo/additionalInfo';\r\nimport CollectionDetails from '../CollectionDetails/collectionDetails';\r\n\r\nimport addNewAddressFrom from '../../../utils/formConfig/addNewAddressForm/addNewAddressForm';\r\nimport ParcelDetails from '../../shipment/addShipment/parcelDetails/parcelDetails';\r\nimport DestinationCountry from '../../../components/addressBook/AddNew/DestinationCountry';\r\nimport ProductAndServiceDetails from '../../shipment/addShipment/productAndServiceDetails/productAndServiceDetails';\r\nimport InternationalDeliveryOption from '../../../components/addShipment/DeliveryOptions/InternationalDeliveryOption';\r\nimport './addNewAddress.scss';\r\nimport DeliveryAddress from '../../shipment/addShipment/deliveryAddress/deliveryAddress';\r\nimport CustomsDeclaration from '../../shipment/addShipment/customsDeclaration/customsDeclaration';\r\n\r\nimport { getYupSchemaFromMetaData } from '../../../utils/yupSchema/yupSchemaGenerator';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport {\r\n formatAddToFavReqObj,\r\n setValuesToForm,\r\n setValuesToCollectionDetailsFromAddressBook,\r\n dynamicSort,\r\n getCustomerAccountID,\r\n setDropdownValues,\r\n} from '../../../utils/helperFunctions';\r\nimport { connect, useDispatch } from 'react-redux';\r\nimport * as actions from '../../../store/actions/index';\r\nimport CustomModal from '../../../framework/modal/modal';\r\nimport ConfirmationDialog from '../../../components/addressBook/confirmation/confirmation';\r\nimport { abortOnGoingCallsFor } from '../../../api/axios';\r\nimport { axiosConfig } from '../../../api/axios';\r\n\r\nconst AddNewAddress = (props) => {\r\n const { formId, formField } = addNewAddressFrom;\r\n const { onLoad, setLoaderLayOver } = props;\r\n const [countries, setCountries] = useState([]);\r\n const [currencies, setCurrencies] = useState([]);\r\n const [isUpdateAddressBook, setisUpdateAddressBook] = useState('');\r\n const [addressBookResponse, setAddressBookResponse] = useState({});\r\n const [showDeliveryOptions, setShowDeliveryOptions] = React.useState(true);\r\n const [showAllAddressFields, setShowAllAddressFields] = React.useState(false);\r\n const [addNewAddressValidationSchema, setNewAddressValidationSchema] = useState(\r\n getYupSchemaFromMetaData(formField, [], []),\r\n );\r\n const formikRef = useRef();\r\n const history = useHistory();\r\n const dispatch = useDispatch();\r\n const [confirmationMsg, setConfirmationMsg] = useState('');\r\n const [showCancelConfirmationDialog, setShowCancelConfirmationDialog] = useState(false);\r\n\r\n useEffect(() => {\r\n setisUpdateAddressBook(history.location.search);\r\n getCountriesList();\r\n getCurrenciesList();\r\n if (history.location.search) {\r\n populateAddressBook(history.location.search);\r\n }\r\n }, []);\r\n\r\n const populateAddressBook = (searchParams) => {\r\n searchParams = searchParams.replace('?', '');\r\n setLoaderLayOver(true);\r\n GET(`${ServiceEndPoints.getAddressBook}?organization=${getCustomerAccountID()}&${searchParams}&offset=0&limit=1`)\r\n .then((res) => {\r\n setAddressBookResponse(res.data?.addressBooks?.[0]);\r\n if(res.data?.addressBooks?.[0]?.deliveryAddress?.postCode){\r\n let postalCode = res.data?.addressBooks?.[0]?.deliveryAddress?.postCode;\r\n abortOnGoingCallsFor(ServiceEndPoints.getPostcodeDistrict);\r\n axiosConfig\r\n .get(`${ServiceEndPoints.getPostcodeDistrict}?postcode=${postalCode}`)\r\n .then((res) => {\r\n dispatch(actions.setPostalCodeDistrict(res?.data));\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n return null;\r\n });\r\n \r\n }\r\n \r\n\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n setLoaderLayOver(false);\r\n });\r\n };\r\n\r\n //Gets the list of All countries\r\n const getCountriesList = () => {\r\n GET(ServiceEndPoints.getCountries)\r\n .then((response) => {\r\n setCountries(response.data.countries.sort(dynamicSort('name')));\r\n })\r\n .catch((error) => {\r\n setCountries([]);\r\n });\r\n };\r\n const getCurrenciesList = () => {\r\n GET(ServiceEndPoints.getCurrencies)\r\n .then((response) => {\r\n setCurrencies(response.data.currencies);\r\n })\r\n .catch((error) => {\r\n setCurrencies([]);\r\n });\r\n };\r\n\r\n const isFormValid = (errors, formikValues) => {\r\n const { searchFor, deliveryServicePoint, ...restControls } = errors;\r\n if (restControls.weight && formikValues.weight === 0) {\r\n delete restControls?.weight;\r\n }\r\n if ((restControls.length && formikValues.length === '')||formikValues.destinationCountry.code2Digit !== 'GB') {\r\n delete restControls?.length;\r\n }\r\n if (formikValues.destinationCountry.code !== 'GBR' && formikValues.intlParcelDetails.filter(x => x.isValid === false).length>0) {\r\n return false;\r\n }\r\n delete restControls?.pieceWeight;\r\n if (errors.addressLine1 !== undefined ||\r\n errors.addressLine2 !== undefined ||\r\n errors.addressLine3 !== undefined ||\r\n errors.postalCode !== undefined ||\r\n errors.town !== undefined ||\r\n errors.county !== undefined ||\r\n (formikValues.destinationCountry?.code === 'USA' && errors.county !== undefined)) {\r\n setShowAllAddressFields(true);\r\n return false;\r\n } else {\r\n setShowAllAddressFields(false);\r\n }\r\n return Object.keys(restControls).length === 0;\r\n };\r\n\r\n const handleSubmit = (formikValues, errors, resetForm) => {\r\n if (isFormValid(errors, formikValues)) {\r\n setLoaderLayOver(true);\r\n const reqObj = formatAddToFavReqObj(formikValues);\r\n POST(ServiceEndPoints.postAddressBook, reqObj)\r\n .then((res) => {\r\n const successMsg = isUpdateAddressBook\r\n ? 'Address book entry updated successfully'\r\n : 'Address book entry saved successfully';\r\n dispatch(actions.setAppSnackBarData({ msg: successMsg }));\r\n resetForm();\r\n setTimeout(() => {\r\n if(isUpdateAddressBook) {history.push('/addressBook')};\r\n }, 0);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: `${err?.response?.data[0]?.detail ?? 'Error occurred while saving, please try again'}`,\r\n },\r\n ],\r\n }),\r\n );\r\n })\r\n .finally(() => {\r\n setLoaderLayOver(false);\r\n });\r\n } else {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [{ type: 'error', msg: 'The form has errors, please correct and try again' }],\r\n }),\r\n );\r\n // dispatch(actions.setAppSnackBarData({ type: 'error', msg: 'The form has errors, please correct and try again' }));\r\n }\r\n };\r\n\r\n const initialValues = {};\r\n\r\n for (let property in formField) {\r\n if (Object.prototype.hasOwnProperty.call(formField, property)) {\r\n const field = formField[property];\r\n if (field.props.type === 'checkbox' || field.props.type === 'radio') {\r\n initialValues[field.props.name] = field.value;\r\n } else if (field.props.type === 'array') {\r\n initialValues[field.props.name] = field.values;\r\n } else {\r\n initialValues[field.props.name] = field.value || '';\r\n }\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n if (countries.length > 0 && currencies.length > 0 && Object.keys(addressBookResponse).length > 0) {\r\n let formValues = { ...setValuesToForm(addressBookResponse, formikRef.current.values, countries, currencies, true), ...setValuesToCollectionDetailsFromAddressBook(addressBookResponse) }\r\n delete formValues.reasonForExport;\r\n formikRef.current.setValues(formValues);\r\n // setTimeout(() => {\r\n onLoad({\r\n loadedFrom: 'dropdownResponse',\r\n loadedResponse: { ...addressBookResponse },\r\n });\r\n setTimeout(() => {\r\n setLoaderLayOver(false)\r\n onLoad({ loadedFrom: '' });\r\n }, 2000);\r\n formikRef.current?.setFieldValue('weight', addressBookResponse?.parcelDetails?.weight);\r\n // }, 0);\r\n }\r\n }, [countries, currencies, addressBookResponse]);\r\n\r\n const updateValidationSchema = () => {\r\n setNewAddressValidationSchema(getYupSchemaFromMetaData(formField, [], []));\r\n };\r\n\r\n const handleClear = (resetForm, setFieldValue) => {\r\n resetForm();\r\n setFieldValue('destinationCountry', setDropdownValues(countries, 'code2Digit', 'GB'));\r\n setFieldValue('customerNumber', addressBookResponse?.deliveryAddress?.customerNumber ?? '');\r\n };\r\n\r\n const handleCancel = () => {\r\n setConfirmationMsg('Are you sure you want to cancel, all unsaved changes will be lost?');\r\n setShowCancelConfirmationDialog(true);\r\n };\r\n\r\n const handleDialogClose = () => {\r\n setShowCancelConfirmationDialog(false);\r\n };\r\n\r\n const onDialogCancel = () => {\r\n setShowCancelConfirmationDialog(false);\r\n };\r\n\r\n const onCancelDialogConfirm = () => {\r\n // dispatch(\r\n // actions.setActiveTab(\"myTemplates\"),\r\n // );\r\n history.goBack();\r\n setShowCancelConfirmationDialog(false);\r\n };\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n {({ values, setValues, setFieldValue, errors, setFieldTouched, isValid, resetForm }) => {\r\n const isDomestic = ((values || {}).destinationCountry || {}).code === 'GBR';\r\n return (\r\n \r\n );\r\n }}\r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n onLoad: (loadedFrom) => {\r\n dispatch(actions.setLoadedFrom(loadedFrom));\r\n },\r\n setLoaderLayOver: (value) => {\r\n dispatch(actions.setLoaderLayOver(value))\r\n }\r\n };\r\n};\r\n\r\nexport default connect(null, mapDispatchToProps)(AddNewAddress);\r\n","import React, { useRef, useEffect } from 'react';\r\nimport { CSVLink } from 'react-csv';\r\nimport FormRenderer from '../../framework/Inputs/formRenderer/formRenderer';\r\nimport InputButton from '../../framework/Inputs/inputButton/inputButton';\r\nimport { Grid } from '@material-ui/core';\r\n\r\nconst TableExport = (props) => {\r\n const csvLink = useRef();\r\n const Export_Data = async () => {\r\n await props.onDataUpdate();\r\n csvLink.current.link.click();\r\n };\r\n let is_Disabled = true;\r\n let Enabled = false;\r\n let sortOptions;\r\n if (props.tabIndex === undefined && props.dashboard === false) {\r\n if (\r\n (props.formikValues.startDate !== '' && props.formikValues.endDate !== '') ||\r\n props.formikValues.exportTo.value !== ''\r\n ) {\r\n is_Disabled = false;\r\n }\r\n } else if (props.tabIndex === 0 || props.tabIndex === 1) {\r\n if (!(props.formikValues.exportTo.value === '')) {\r\n {\r\n is_Disabled = false;\r\n }\r\n }\r\n }\r\n if (props.dashboard === true && props.formikValues.exportTo.value !== '') {\r\n is_Disabled = false;\r\n }\r\n if (props.myshipment === true && props.formikValues.exportTo.value !== '') {\r\n Enabled = true;\r\n }\r\n if(props.dashboard === true)\r\n { \r\n sortOptions = props.headers.filter((ele) => ele.key !== 'weight' && ele.key !== 'ETA');\r\n }\r\n else if(props.myshipment === true)\r\n {\r\n sortOptions = props.headers.filter((ele) => ele.key !== 'weight' && ele.key !== 'product' && ele.key !== 'service');\r\n if (props.isBookedCollections)\r\n {\r\n sortOptions = sortOptions.filter( (ele) => ele.key !== 'alternativeReference' && ele.key !== 'returnShipmentnumber' && ele.key !== 'numberOfParcels')\r\n }\r\n }\r\n useEffect(() => {\r\n props.setFieldValue('exportTo', ExportOptions[0]);\r\n props.setFieldValue('orderOptions', OrderOptions[0]);\r\n props.setFieldValue('sortByOptions', props.headers[0]);\r\n }, []);\r\n\r\n useEffect(()=>{\r\n if((props.myshipment || props.dashboard) && props.formikValues?.sortByOptions?.key !== '' && props.formikValues?.orderOptions?.value !== '')\r\n {\r\n props.setSortByOrder(`&sortBy=${props.formikValues?.sortByOptions?.key}&sortIn=${props.formikValues?.orderOptions?.value}`);\r\n }\r\n }, [props.formikValues.sortByOptions, props.formikValues.orderOptions]);\r\n \r\n return (\r\n \r\n {props.myshipment === true || props.dashboard === true ? (<>\r\n \r\n \r\n \r\n \r\n >) : ''}\r\n \r\n \r\n \r\n \r\n 0 && !is_Disabled))) : !(props.data.length > 0 && !is_Disabled)) || props.disableExportButton}\r\n />\r\n \r\n \r\n \r\n );\r\n};\r\n\r\nexport default TableExport;\r\n\r\nconst formField = {\r\n exportTo: {\r\n props: {\r\n name: 'exportTo',\r\n label: 'Export to',\r\n type: 'select',\r\n displayField: 'name',\r\n hasDefaultValue: true,\r\n },\r\n },\r\n orderOptions: {\r\n props: {\r\n name: 'orderOptions',\r\n label: 'Sort in',\r\n type: 'select',\r\n displayField: 'name',\r\n hasDefaultValue: true,\r\n },\r\n },\r\n sortByOptions: {\r\n props: {\r\n name: 'sortByOptions',\r\n label: 'Sort by',\r\n type: 'select',\r\n displayField: 'label',\r\n hasDefaultValue: true,\r\n },\r\n },\r\n};\r\n\r\nconst ExportOptions = [\r\n {\r\n name: 'Select',\r\n value: '',\r\n },\r\n {\r\n name: 'PDF',\r\n value: 'pdf',\r\n },\r\n {\r\n name: 'CSV',\r\n value: 'csv',\r\n },\r\n];\r\n\r\nconst OrderOptions = [\r\n {\r\n name: 'Select',\r\n value: '',\r\n },\r\n {\r\n name: 'Ascending',\r\n value: 'ascending',\r\n },\r\n {\r\n name: 'Descending',\r\n value: 'descending',\r\n },\r\n];","import React, { useState } from 'react';\r\nimport { Grid, Checkbox, FormControlLabel } from '@material-ui/core';\r\nimport { Form, Formik } from 'formik';\r\nimport TableExport from '../TableExport/TableExport';\r\nimport CustomModal from '../../framework/dialog/customDialog';\r\n\r\nexport default function TableExportPopup(props) {\r\n const {\r\n headers,\r\n myshipment,\r\n data,\r\n filename,\r\n onDataUpdate,\r\n onClick,\r\n disableExportButton,\r\n setSortByOrder,\r\n showExportDialog,\r\n ExportTitle,\r\n dashboard,\r\n tableData,\r\n handleDialogClose\r\n } = props;\r\n\r\n const initialValues = {\r\n exportTo: ''\r\n };\r\n\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n {({ values, setFieldValue }) => {\r\n return (\r\n \r\n );\r\n }}\r\n \r\n \r\n \r\n \r\n )\r\n\r\n}","import React, { useState } from 'react';\r\nimport { Grid, Checkbox, FormControlLabel } from '@material-ui/core';\r\nimport DynamicMaterialTable from '../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\nimport InputButton from '../../framework/Inputs/inputButton/inputButton';\r\nimport ConfirmationDialog from '../addressBook/confirmation/confirmation';\r\nimport CustomModal from '../../framework/dialog/customDialog';\r\n\r\nimport { Form, Formik } from 'formik';\r\nimport { axiosConfig, GET } from '../../api/axios';\r\nimport { useDispatch, useSelector } from 'react-redux';\r\nimport TableExport from '../../../src/components/TableExport/TableExport';\r\nimport TableExportPopup from '../../../src/components/TableExport/TableExportPopup';\r\nimport { ServiceEndPoints } from '../../utils/constants/ApiConstant';\r\nimport * as actions from '../../store/actions/index';\r\nimport jsPDF from 'jspdf';\r\nimport { arrayToString, formatDate} from '../../utils/helperFunctions';\r\nimport { useHistory } from 'react-router-dom';\r\nimport { CLERANCE_DECLARATION } from '../../utils/constants/constants';\r\n\r\n\r\nexport default function MyShipmentManagement(props) {\r\n const history = useHistory();\r\n\r\n const {\r\n rows,\r\n columns,\r\n isSearchable,\r\n isSelectable,\r\n sorting,\r\n paging,\r\n pageSize,\r\n pageSizeOptions,\r\n Dialogtitle,\r\n confirmationMessage,\r\n reprintTitle,\r\n totalCount\r\n } = props;\r\n\r\n const initialValues = {\r\n exportTo: ''\r\n };\r\n\r\n const headers = [\r\n { label: 'Customer reference', key: 'customerReferenceNumber' },\r\n { label: \"Alternative reference\", key: \"alternativeReference\" },\r\n { label: 'Shipment number', key: 'Shipmentnumber' },\r\n { label: 'Return shipment number', key: 'returnShipmentnumber' },\r\n { label: 'Collection date', key: 'collectionDate' },\r\n { label: 'Business/Recipient name', key: 'recipientName' },\r\n { label: 'Postal code', key: 'destinationPostalCode' },\r\n { label: 'Number of items', key: 'numberOfParcels' },\r\n { label: 'Weight', key: 'weight' },\r\n { label: 'Product', key: 'product' },\r\n { label: 'Service', key: 'service' }\r\n\r\n ];\r\n\r\n const userAccounts = useSelector((state) => state.accounts.userAccounts);\r\n const [pageNumber, setPageNumber] = useState(0);\r\n const [tableHeaderColumns, setTableHeaderColumns] = useState(headers);\r\n const [ExporttableRawData, setExportTableRawData] = useState([]);\r\n const dispatch = useDispatch();\r\n const isBookedCollections = props.tabIndex === 1;\r\n\r\n const [selectedRows, setSelectedRows] = useState([]);\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n const [showPrintDialog, setshowPrintDialog] = useState(false);\r\n const [showExportDialog, setshowExportDialog] = useState(false);\r\n const [sortByOrder, setSortByOrder] = useState('');\r\n const [state, setState] = useState({\r\n reprintLabel: false,\r\n reprintCustomsInvoice: false,\r\n });\r\n\r\n\r\n const onDataUpdate = async () => {\r\n dispatch(actions.setLoaderLayOver(true));\r\n\r\n let url = `${ServiceEndPoints.getShipmentManagement}isCollectionRequest=${isBookedCollections}`;\r\n const offset = pageNumber * pageSize;\r\n await GET(getUrl(url, offset))\r\n .then((res) => {\r\n let ExportData = [];\r\n res.data.shipmentModels.forEach((data) => {\r\n ExportData.push({\r\n customerReferenceNumber: data?.customerReferenceNumber,\r\n alternativeReference: data?.shipments?.[0]?.shipmentDetails?.customerRef2,\r\n Shipmentnumber: data?.shipmentId,\r\n returnShipmentnumber: data?.shipments?.[0]?.return?.returnShipmentId,\r\n collectionDate: formatDate(data?.collectionDate, '/', 'dd/mm/yyyy'),\r\n recipientName: data?.businessName != '' ? data?.businessName : data?.receiverName,\r\n destinationPostalCode: data?.destinationPostalCode,\r\n numberOfParcels: data?.numberOfParcels,\r\n weight: data?.shipments?.[0]?.shipmentDetails?.totalWeight ?? \"\",\r\n product: data?.product?.productNameForUI ?? \"\",\r\n service: data?.service?.description ?? \"\"\r\n });\r\n });\r\n setExportTableRawData(ExportData);\r\n dispatch(actions.setAppSnackBarData({ msg: `Data exported successfully` }));\r\n setshowExportDialog(false);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n setExportTableRawData([]);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in exporting data, please try again later',\r\n },\r\n ],\r\n }),\r\n );\r\n setshowExportDialog(false);\r\n })\r\n .finally(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n setshowExportDialog(false);\r\n });\r\n };\r\n\r\n const getUrl = (url, offset) => {\r\n\r\n url += `&${arrayToString(userAccounts, 'accounts', 'accountId')}&status=Order received`;\r\n\r\n url += props.shipmentSearchParams;\r\n url += `&offset=${offset}`;\r\n if (sortByOrder) {\r\n url += sortByOrder;\r\n }\r\n return url;\r\n }\r\n\r\n\r\n const printDocument = async () => {\r\n try {\r\n dispatch(actions.setLoaderLayOver(true));\r\n const url = `${ServiceEndPoints.getShipmentManagement}isCollectionRequest=${isBookedCollections}`;\r\n const offset = pageNumber * pageSize;\r\n await axiosConfig.get(getUrl(url, offset)).then(async (res) => {\r\n\r\n let data = res.data?.shipmentModels ?? [];\r\n const unit = 'pt';\r\n const size = 'A4'; // Use A1, A2, A3 or A4\r\n const orientation = 'landscape'; // portrait or landscape\r\n const doc = new jsPDF(orientation, unit, size);\r\n const title = 'My Updated Awesome Report';\r\n const updatedHeaderColumns = [...headers];\r\n\r\n data = data.map((elt) => [\r\n elt.customerReferenceNumber,\r\n elt.shipments?.[0]?.shipmentDetails?.customerRef2,\r\n elt.shipmentId,\r\n elt.shipments?.[0]?.return?.returnShipmentId,\r\n formatDate(elt.collectionDate, '/', 'dd/mm/yyyy'),\r\n elt.businessName != '' ? elt?.businessName : elt?.receiverName,\r\n elt.destinationPostalCode,\r\n elt.numberOfParcels,\r\n elt.shipments?.[0]?.shipmentDetails?.totalWeight,\r\n elt?.product?.productNameForUI ?? \"\",\r\n elt?.service?.description ?? \"\"\r\n ]);\r\n\r\n const _headers = [updatedHeaderColumns.map((headers) => headers.label)];\r\n\r\n let content = {\r\n head: _headers,\r\n body: data,\r\n columnStyles: {\r\n 0: {\r\n columnWidth: 100\r\n },\r\n 1: {\r\n columnWidth: 80,\r\n },\r\n 5: {\r\n columnWidth: 100,\r\n },\r\n 6: {\r\n columnWidth: 40,\r\n },\r\n 7: {\r\n columnWidth: 30,\r\n }\r\n },\r\n styles: {\r\n cellWidth: 'wrap',\r\n fontSize: 6,\r\n cellPadding: 2,\r\n overflowColumns: 'linebreak',\r\n },\r\n };\r\n doc.autoTable(content);\r\n doc.save('BookedShipments.pdf');\r\n dispatch(actions.setAppSnackBarData({ msg: `Data exported successfully` }));\r\n setshowExportDialog(false);\r\n });\r\n } catch (err) {\r\n console.log(err);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in exporting data, please try again later',\r\n },\r\n ],\r\n }),\r\n );\r\n } finally {\r\n dispatch(actions.setLoaderLayOver(false));\r\n }\r\n };\r\n\r\n\r\n const addSelectedRows = (selectedRows) => {\r\n setSelectedRows(selectedRows);\r\n };\r\n const handleDialogClose = () => {\r\n setShowConfirmationDialog(false);\r\n setshowPrintDialog(false);\r\n setshowExportDialog(false);\r\n resetReprintState();\r\n };\r\n const onDialogConfirm = () => {\r\n props.cancelSelectedShipment(selectedRows);\r\n setShowConfirmationDialog(false);\r\n setSelectedRows([]);\r\n };\r\n const onDialogCancel = () => {\r\n setShowConfirmationDialog(false);\r\n setshowPrintDialog(false);\r\n resetReprintState();\r\n };\r\n const savePrintDialog = () => {\r\n setshowPrintDialog(false);\r\n const values = { reprintLabel: state.reprintLabel, reprintCustomsInvoice: state.reprintCustomsInvoice };\r\n props.handlePrintSubmit(values, selectedRows);\r\n resetReprintState();\r\n };\r\n const resetReprintState = () => {\r\n setState({ ...state, reprintLabel: false, reprintCustomsInvoice: false });\r\n };\r\n const handleChange = (event) => {\r\n setState({ ...state, [event.target.name]: event.target.checked });\r\n };\r\n\r\n const goToAmmendPage = () => {\r\n history.push(`/shipment/addShipment/${selectedRows[0].id}`)\r\n }\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n }\r\n label=\"Label\"\r\n />\r\n \r\n \r\n \r\n }\r\n label=\"Customs Invoice\"\r\n />\r\n \r\n \r\n Customs invoice will be printed only if applicable for a shipment \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n setshowExportDialog(true)}\r\n isDisabled={totalCount === 0 ? true : false}\r\n />\r\n \r\n \r\n \r\n \r\n { goToAmmendPage() }}\r\n />\r\n \r\n\r\n \r\n setShowConfirmationDialog(true)}\r\n />\r\n \r\n \r\n setshowPrintDialog(true)}\r\n />\r\n \r\n \r\n \r\n \r\n );\r\n}\r\n","/* eslint-disable no-useless-constructor */\r\nimport React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport DateRangePicker from 'react-daterange-picker';\r\nimport 'react-daterange-picker/dist/css/react-calendar.css';\r\nimport { FormControl, TextField } from '@material-ui/core';\r\nimport EventIcon from '@material-ui/icons/Event';\r\nimport IconButton from '@material-ui/core/IconButton';\r\nimport InputAdornment from '@material-ui/core/InputAdornment';\r\n\r\nconst InputDateRange = (props) => {\r\n const { showTextField, minimumDate, maximumDate, label } = props;\r\n return (\r\n \r\n {showTextField\r\n ? (\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n ),\r\n }}\r\n />\r\n \r\n
\r\n )\r\n : null}\r\n\r\n
\r\n
\r\n );\r\n};\r\n\r\nInputDateRange.propTypes = {\r\n showTextField: PropTypes.bool,\r\n};\r\n\r\nInputDateRange.defaultProps = {\r\n showTextField: true,\r\n};\r\n\r\nexport default InputDateRange;\r\n","import React, { useState, useEffect } from 'react';\r\nimport { useHistory } from 'react-router-dom';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { GET } from '../../../api/axios';\r\nimport { useSelector } from 'react-redux';\r\nimport Grid from '@material-ui/core/Grid';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { shipmentManagementDateFilter } from '../../../utils/constants/constants';\r\nimport { formatDate } from '../../../utils/helperFunctions';\r\nimport DateRangePicker from '../../../framework/date-range/dateRange';\r\nimport CustomDialog from '../../../framework/dialog/customDialog';\r\nimport originalMoment from 'moment';\r\nimport { extendMoment } from 'moment-range';\r\n// import CustomizedDialogs from '../addressBookModal/addressBookModal'\r\n// import CustomAddressTable from '../../../framework/CustomAddressTable/CustomAddressTable';\r\nimport { Divider } from '@material-ui/core';\r\nconst useStyles = makeStyles((theme) => ({\r\n SearchAddressField: {\r\n marginTop: '3px',\r\n // paddingRight: '3px',\r\n },\r\n}));\r\n\r\nconst SearchShipment = (props) => {\r\n const classes = useStyles();\r\n const {\r\n formField: { shipmentManagementSearchFor, deliveryStatusForAccounts },\r\n setFieldValue,\r\n formikValues,\r\n searchByOptions,\r\n errors,\r\n setFieldTouched,\r\n tabChanged,\r\n resetForm,\r\n setValues,\r\n } = props;\r\n const inputRef = React.useRef();\r\n const moment = extendMoment(originalMoment);\r\n let [isClearBtn, setIsClearBtn] = useState(false);\r\n const [renderVal, setRenderVal] = useState('');\r\n const [open, setOpen] = useState(false);\r\n const [datepickerValue, setDatepickerValue] = useState(moment.range(new Date(), new Date()));\r\n const [shipmentManagementSearchForFlag, setShipmentManagementSearchForFlag] = useState(false);\r\n let [fromCollectionDate, setfromCollectionDate] = useState(formatDate(new Date()));\r\n let [collectedToDate, setcollectedToDate] = useState(formatDate(new Date()));\r\n // let [isdatesearch, setIsdatesearch] = useState(false);\r\n\r\n const getClear = (event = null, queryParams = '') => {\r\n if (event) {\r\n event.preventDefault();\r\n }\r\n // if (tabChanged == 0) {\r\n setTimeout(() => {\r\n props.setShipmentSearchParams(\r\n `&fromCollectionDate=${fromCollectionDate}&toCollectionDate=${collectedToDate}`,\r\n );\r\n }, 0);\r\n // } else {\r\n // props.setShipmentSearchParams(`&${props.formikValues.shipmentManagementSearchBy.value}=`);\r\n // }\r\n setFieldValue('shipmentManagementSearchFor', '');\r\n setFieldTouched('shipmentManagementSearchFor', false);\r\n setIsClearBtn(false);\r\n props.onShipmentChange(false);\r\n };\r\n\r\n const getShipments = (event = null) => {\r\n setShipmentManagementSearchForFlag(true);\r\n if (event) {\r\n event.preventDefault();\r\n }\r\n props.onShipmentChange(true);\r\n setIsClearBtn(true);\r\n };\r\n\r\n function getNumberOfDays(start, end) {\r\n if (start < end) {\r\n return (end - start) / 1000 / 60 / 60 / 24;\r\n }\r\n }\r\n\r\n const onSelect = (value) => {\r\n const count = getNumberOfDays(value.start, value.end);\r\n if (count > 30) {\r\n setDatepickerValue(moment.range(value.start._d, value.end._d));\r\n } else {\r\n setDatepickerValue(moment.range(value.start._d, value.end._d));\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n // if (tabChanged == 0) {\r\n // props.setShipmentSearchParams(\r\n // `&${props.formikValues.shipmentManagementSearchBy.value}=${encodeURIComponent(props.formikValues.shipmentManagementSearchFor)}&fromCollectionDate=${fromCollectionDate}&toCollectionDate=${collectedToDate}`,\r\n // );\r\n // } else {\r\n // if (!isdatesearch) {\r\n props.setShipmentSearchParams(\r\n `&${props.formikValues.shipmentManagementSearchBy.value}=${encodeURIComponent(props.formikValues.shipmentManagementSearchFor)}`,\r\n );\r\n // }\r\n // setIsdatesearch(false)\r\n // }\r\n }, [props.formikValues?.shipmentManagementSearchBy, props.formikValues?.shipmentManagementSearchFor]);\r\n\r\n useEffect(() => {\r\n setIsClearBtn(false);\r\n }, [props.formikValues.shipmentManagementSearchFor]);\r\n\r\n useEffect(() => {\r\n // if (tabChanged === 0) {\r\n props.setShipmentSearchParams(`&${props.formikValues.shipmentManagementSearchBy.value}=&fromCollectionDate=${fromCollectionDate}&toCollectionDate=${collectedToDate}`);\r\n // } else {\r\n // props.setShipmentSearchParams(`&${props.formikValues.shipmentManagementSearchBy.value}=`);\r\n // }\r\n setValues({\r\n shipmentManagementSearchFor: '',\r\n shipmentManagementSearchBy: searchByOptions[0],\r\n });\r\n setFieldTouched('shipmentManagementSearchFor', false);\r\n setFieldValue('deliveryStatusForAccounts', shipmentManagementDateFilter[0]);\r\n }, [tabChanged]);\r\n\r\n useEffect(() => {\r\n setFieldValue('shipmentManagementSearchFor', '');\r\n setFieldTouched('shipmentManagementSearchFor', true);\r\n inputRef.current.focus();\r\n if (props.formikValues.shipmentManagementSearchFor || shipmentManagementSearchForFlag) {\r\n getClear()\r\n setShipmentManagementSearchForFlag(false);\r\n }\r\n }, [props.formikValues.shipmentManagementSearchBy]);\r\n\r\n useEffect(() => {\r\n // if (tabChanged == 0) {\r\n // if (props.formikValues.shipmentManagementSearchFor != '') {\r\n // props.setShipmentSearchParams(\r\n // `&${props.formikValues.shipmentManagementSearchBy.value}=${encodeURIComponent(props.formikValues.shipmentManagementSearchFor)}&fromCollectionDate=${fromCollectionDate}&toCollectionDate=${collectedToDate}`,\r\n // );\r\n // } else {\r\n // props.setShipmentSearchParams(\r\n // `&${props.formikValues.shipmentManagementSearchBy.value}=&fromCollectionDate=${fromCollectionDate}&toCollectionDate=${collectedToDate}`,\r\n // );\r\n // }\r\n // getClear();\r\n // setIsdatesearch(true)\r\n setFieldValue('shipmentManagementSearchFor', '');\r\n setFieldTouched('shipmentManagementSearchFor', false);\r\n setIsClearBtn(false);\r\n setTimeout(() => {\r\n props.setShipmentSearchParams(\r\n `&fromCollectionDate=${fromCollectionDate}&toCollectionDate=${collectedToDate}`,\r\n );\r\n }, 0);\r\n getShipments();\r\n // }\r\n }, [fromCollectionDate, collectedToDate]);\r\n\r\n const handleDateClose = (value) => {\r\n setOpen(false);\r\n let _fromCollectionDate = formatDate(datepickerValue.start._i);\r\n let _collectedToDate = formatDate(datepickerValue.end._d);\r\n setfromCollectionDate(_fromCollectionDate)\r\n setcollectedToDate(_collectedToDate)\r\n setRenderVal(`${moment(_fromCollectionDate).format('DD/MM/YYYY')}-${moment(_collectedToDate).format('DD/MM/YYYY')}`);\r\n };\r\n\r\n const dateRange = (selectedValue) => {\r\n if (selectedValue === 'daterange') {\r\n setOpen(true);\r\n }\r\n };\r\n\r\n const dateRangeInSelect = () => {\r\n setOpen(true);\r\n };\r\n\r\n useEffect(() => {\r\n shipmentManagementDateFilter[1].clickEvent = dateRangeInSelect;\r\n if (formikValues.deliveryStatusForAccounts.value === 'daterange') {\r\n dateRange('daterange');\r\n }\r\n else if (props.formikValues?.deliveryStatusForAccounts?.value === 'today') {\r\n let _fromCollectionDate = formatDate(new Date());\r\n let _collectedToDate = formatDate(new Date());\r\n setfromCollectionDate(_fromCollectionDate)\r\n setcollectedToDate(_collectedToDate)\r\n setOpen(false);\r\n shipmentManagementDateFilter[1].name = 'Date range';\r\n }\r\n else {\r\n setOpen(false);\r\n shipmentManagementDateFilter[1].name = 'Date range';\r\n }\r\n }, [formikValues.deliveryStatusForAccounts]);\r\n\r\n return (\r\n \r\n \r\n {/* {tabChanged == 0 ? */}\r\n \r\n dateRange(e)}\r\n fullWidth\r\n renderVal={renderVal}\r\n />\r\n \r\n {/* : null} */}\r\n \r\n getShipments(event, '')}\r\n onClearSearch={(event) => getClear(event, '')}\r\n isIconDisabled={Boolean(errors.shipmentManagementSearchFor) || formikValues.shipmentManagementSearchFor?.trim() === ''}\r\n selectProps={shipmentManagementSearchFor.selectProps.props}\r\n textProps={shipmentManagementSearchFor.textProps.props}\r\n isClearBtn={isClearBtn}\r\n inputRef={inputRef}\r\n {...shipmentManagementSearchFor.props}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n );\r\n};\r\n\r\nexport default SearchShipment;\r\n","import React from 'react';\r\nimport { Form, Formik } from 'formik';\r\nimport SearchShipment from './SearchShipment';\r\nimport { getYupSchemaFromMetaData } from '../../../utils/yupSchema/yupSchemaGenerator';\r\nimport { shipmentManagementDateFilter } from '../../../utils/constants/constants';\r\n\r\nconst SearchShipmentManagement = (props) => {\r\n const formField = searchForm;\r\n const newSearchValidationSchema = getYupSchemaFromMetaData(formField, [], []);\r\n\r\n const initialValues = {\r\n shipmentManagementSearchFor: '',\r\n shipmentManagementSearchBy: searchByOptions[0],\r\n deliveryStatusForAccounts: shipmentManagementDateFilter[0],\r\n };\r\n\r\n return (\r\n \r\n \r\n {({ values, setFieldValue, errors, setFieldTouched, resetForm, setValues }) => (\r\n \r\n )}\r\n \r\n
\r\n );\r\n};\r\n\r\nexport default SearchShipmentManagement;\r\n\r\nconst searchForm = {\r\n shipmentManagementSearchFor: {\r\n props: {\r\n name: 'shipmentManagementSearchFor',\r\n type: 'searchControl',\r\n },\r\n selectProps: {\r\n props: {\r\n name: 'shipmentManagementSearchBy',\r\n label: 'Search For',\r\n placeholder: \"Enter Customer's Number\",\r\n },\r\n },\r\n textProps: {\r\n props: {\r\n name: 'shipmentManagementSearchFor',\r\n label: 'Search For',\r\n placeholder: \"Enter Customer's Number\",\r\n },\r\n },\r\n validation: {\r\n name: 'shipmentManagementSearchFor',\r\n validationType: 'string',\r\n // validations: [\r\n // {\r\n // type: 'required',\r\n // params: ['SearchFor Number is required'],\r\n // },\r\n // ],\r\n },\r\n },\r\n deliveryStatusForAccounts: {\r\n props: {\r\n name: 'deliveryStatusForAccounts',\r\n // label: 'Select despatch date',\r\n type: 'select',\r\n isRequired: true,\r\n displayField: 'name',\r\n hasDefaultValue: true,\r\n },\r\n value: shipmentManagementDateFilter[0],\r\n },\r\n};\r\n\r\nconst searchByOptions = [\r\n {\r\n value: 'customerrefnumber',\r\n name: 'Customer reference',\r\n },\r\n {\r\n value: 'shipmentnumber',\r\n name: 'Shipment number',\r\n },\r\n // {\r\n // value: 'customernumber',\r\n // name: 'Customer number',\r\n // },\r\n {\r\n value: 'recipientname',\r\n name: 'Recipient name',\r\n },\r\n {\r\n value: 'businessname',\r\n name: 'Business name',\r\n },\r\n {\r\n value: 'postcode',\r\n name: 'Postal code',\r\n },\r\n];\r\n","import React, { useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid } from '@material-ui/core';\r\nimport DynamicMaterialTable from '../../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\nimport CustomModal from '../../../framework/modal/modal';\r\nimport ConfirmationDialog from '../../addressBook/confirmation/confirmation';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport TableExportPopup from '../../TableExport/TableExportPopup';\r\nimport * as actions from '../../../store/actions/index'\r\nimport { axiosConfig, GET } from '../../../api/axios';\r\nimport { useDispatch, useSelector } from 'react-redux';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { arrayToString, formatDate } from '../../../utils/helperFunctions';\r\nimport jsPDF from 'jspdf';\r\n\r\nconst BookedCollections = (props) => {\r\n const {\r\n rows,\r\n columns,\r\n isSearchable,\r\n isSelectable,\r\n sorting,\r\n paging,\r\n pageSize,\r\n pageSizeOptions,\r\n title,\r\n confirmationMessage,\r\n cancelCollection,\r\n totalCount,\r\n } = props;\r\n const [selectedRows, setSelectedRows] = useState([]);\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n const [ExporttableRawData, setExportTableRawData] = useState([]);\r\n const [showExportDialog, setshowExportDialog] = useState(false);\r\n const [sortByOrder, setSortByOrder] = useState('');\r\n const dispatch = useDispatch();\r\n const userAccounts = useSelector((state) => state.accounts.userAccounts);\r\n const [pageNumber, setPageNumber] = useState(0);\r\n const isBookedCollections = props.tabIndex === 1;\r\n\r\n const headers = [\r\n { label: 'Customer reference', key: 'customerReferenceNumber' },\r\n // { label: \"Alternative reference\", key: \"alternativeReference\" },\r\n { label: 'Shipment number', key: 'Shipmentnumber' },\r\n { label: 'Collection date', key: 'collectionDate' },\r\n { label: 'Business/Recipient name', key: 'recipientName' },\r\n { label: 'Collection postal code', key: 'destinationPostalCode' },\r\n { label: 'Number of items', key: 'numberOfParcels' },\r\n { label: 'Weight', key: 'weight' },\r\n // { label: 'Product', key: 'product' },\r\n { label: 'Service', key: 'service' }\r\n ];\r\n\r\n const addSelectedRows = (selectedRows) => {\r\n setSelectedRows(selectedRows);\r\n };\r\n\r\n const handleDialogClose = () => {\r\n setShowConfirmationDialog(false);\r\n setshowExportDialog(false);\r\n };\r\n\r\n const onDialogConfirm = () => {\r\n cancelCollection(selectedRows);\r\n handleDialogClose();\r\n setSelectedRows([]);\r\n };\r\n\r\n const openConfirmtionPopup = () => {\r\n setShowConfirmationDialog(true);\r\n };\r\n\r\n const onDataUpdate = async () => {\r\n dispatch(actions.setLoaderLayOver(true));\r\n\r\n let url = `${ServiceEndPoints.getShipmentManagement}isCollectionRequest=${isBookedCollections}`;\r\n const offset = pageNumber * pageSize;\r\n await GET(getUrl(url, offset))\r\n .then((res) => {\r\n let ExportData = [];\r\n res.data.shipmentModels.forEach((data) => {\r\n ExportData.push({\r\n customerReferenceNumber: data.shipments?.[0]?.shipmentDetails?.customerRef1,\r\n // alternativeReference: data?.shipments?.[0]?.shipmentDetails?.customerRef2,\r\n Shipmentnumber: data?.shipmentId,\r\n collectionDate: formatDate(data?.pickup?.date, '/', 'dd/mm/yyyy'),\r\n recipientName: data.pickupAddress?.companyName || data.pickupAddress.name,\r\n destinationPostalCode: data?.pickupAddress?.postalCode,\r\n numberOfParcels: data?.numberOfParcels,\r\n weight: data?.shipments?.[0]?.shipmentDetails?.totalWeight ?? \"\",\r\n // product: data?.product?.productNameForUI ?? \"\",\r\n service: data?.service?.description ?? \"\"\r\n });\r\n });\r\n setExportTableRawData(ExportData);\r\n dispatch(actions.setAppSnackBarData({ msg: `Data exported successfully` }));\r\n setshowExportDialog(false);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n setExportTableRawData([]);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in exporting data, please try again later',\r\n },\r\n ],\r\n }),\r\n );\r\n setshowExportDialog(false);\r\n })\r\n .finally(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n setshowExportDialog(false);\r\n });\r\n };\r\n\r\n const printDocument = async () => {\r\n try {\r\n dispatch(actions.setLoaderLayOver(true));\r\n const url = `${ServiceEndPoints.getShipmentManagement}isCollectionRequest=${isBookedCollections}`;\r\n const offset = pageNumber * pageSize;\r\n await axiosConfig.get(getUrl(url, offset)).then(async (res) => {\r\n\r\n let data = res.data?.shipmentModels ?? [];\r\n const unit = 'pt';\r\n const size = 'A4'; // Use A1, A2, A3 or A4\r\n const orientation = 'landscape'; // portrait or landscape\r\n const doc = new jsPDF(orientation, unit, size);\r\n const title = 'My Updated Awesome Report';\r\n const updatedHeaderColumns = [...headers];\r\n\r\n data = data.map((elt) => [\r\n elt.shipments?.[0]?.shipmentDetails?.customerRef1,\r\n // elt.shipments?.[0]?.shipmentDetails?.customerRef2,\r\n elt.shipmentId,\r\n formatDate(elt?.pickup?.date, '/', 'dd/mm/yyyy'),\r\n elt.pickupAddress?.companyName || elt.pickupAddress.name,\r\n elt.pickupAddress?.postalCode,\r\n elt.numberOfParcels,\r\n elt.shipments?.[0]?.shipmentDetails?.totalWeight,\r\n // elt?.product?.productNameForUI ?? \"\",\r\n elt?.service?.description ?? \"\"\r\n ]);\r\n\r\n const _headers = [updatedHeaderColumns.map((headers) => headers.label)];\r\n\r\n let content = {\r\n head: _headers,\r\n body: data,\r\n columnStyles: {\r\n 0: {\r\n columnWidth: 100\r\n },\r\n 1: {\r\n columnWidth: 80,\r\n },\r\n 5: {\r\n columnWidth: 80,\r\n },\r\n 6: {\r\n columnWidth: 60,\r\n },\r\n 7: {\r\n columnWidth: 50,\r\n }\r\n },\r\n styles: {\r\n cellWidth: 'wrap',\r\n fontSize: 6,\r\n cellPadding: 2,\r\n overflowColumns: 'linebreak',\r\n },\r\n };\r\n doc.autoTable(content);\r\n doc.save('BookedCollections.pdf');\r\n dispatch(actions.setAppSnackBarData({ msg: `Data exported successfully` }));\r\n setshowExportDialog(false);\r\n });\r\n } catch (err) {\r\n console.log(err);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in exporting data, please try again later',\r\n },\r\n ],\r\n }),\r\n );\r\n } finally {\r\n dispatch(actions.setLoaderLayOver(false));\r\n }\r\n };\r\n\r\n const getUrl = (url, offset) => {\r\n\r\n url += `&${arrayToString(userAccounts, 'accounts', 'accountId')}&status=Order received`;\r\n\r\n url += props.shipmentSearchParams;\r\n url += `&offset=${offset}`;\r\n if (sortByOrder) {\r\n url += sortByOrder;\r\n }\r\n return url;\r\n }\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n setshowExportDialog(true)}\r\n isDisabled={totalCount === 0 ? true : false}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nBookedCollections.propTypes = {};\r\n\r\nexport default BookedCollections;\r\n","import React from 'react';\r\nimport { connect } from 'react-redux';\r\nimport { AppBar, Tabs, Tab } from '@material-ui/core/';\r\nimport { Link } from 'react-router-dom';\r\nimport { Grid } from '@material-ui/core';\r\nimport './shipmentManagement.scss';\r\nimport TabPanel from '../../../components/shared/tabPanel';\r\nimport MyShipmentManagement from '../../../components/MyShipmentManagement/MyShipmentManagement';\r\nimport SearchShipmentManagement from '../../../components/shipmentManagement/searchShipment/SearchShipmentManagement';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport BookedCollections from '../../../components/shipmentManagement/bookedCollections/bookedCollections';\r\nimport { abortOnGoingCallsFor, axiosConfig } from '../../../api/axios';\r\nimport {\r\n basicSort,\r\n arrayToString,\r\n remove_duplicates,\r\n customTableSort,\r\n customTableShipmentNoSort,\r\n formatDate,\r\n} from '../../../utils/helperFunctions';\r\nimport { printZplLabels, printPDF, downloadPDF } from '../../../utils/PrintHelper';\r\nimport PromptJSPMClientInstallation from '../../../components/addShipment/Printing/PromptJSPMClientInstallation';\r\nimport CustomDialog from '../../../framework/dialog/customDialog';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { formatDateToUKFormat } from '../../../utils/helperFunctions';\r\n\r\nclass ShipmentManagement extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n tabIndex: 0,\r\n columns: [\r\n { title: 'id', field: 'id', hidden: true },\r\n {\r\n title: 'Customer ref.',\r\n field: 'customerRef',\r\n // customSort: (a, b) => customTableSort(a?.customerRef, b?.customerRef),\r\n render: (row) => (\r\n \r\n {row.customerRef}\r\n \r\n ),\r\n width: 150,\r\n sorting: true,\r\n },\r\n {\r\n title: 'Alternative ref.',\r\n field: 'alternativeRef',\r\n // customSort: (a, b) => customTableSort(a?.alternativeRef, b?.alternativeRef),\r\n render: (row) => (\r\n \r\n {row.alternativeRef}\r\n \r\n ),\r\n width: 150,\r\n sorting: true,\r\n },\r\n {\r\n title: 'Shipment no.',\r\n field: 'shipmentNumber',\r\n // customSort: (a, b) => customTableShipmentNoSort(a?.shipmentNumber, b?.shipmentNumber),\r\n render: (row) => (\r\n \r\n {row.shipmentNumber}\r\n \r\n ),\r\n width: 150,\r\n sorting: true,\r\n },\r\n {\r\n title: 'Return shipment no.',\r\n field: 'returnShipmentNumber',\r\n // customSort: (a, b) => customTableShipmentNoSort(a?.returnShipmentNumber, b?.returnShipmentNumber),\r\n render: (row) => (\r\n \r\n {row.returnShipmentNumber}\r\n \r\n ),\r\n width: 150,\r\n sorting: true,\r\n },\r\n {\r\n title: 'Collection date',\r\n field: 'collectionDate',\r\n customSort: (a, b) =>\r\n basicSort(new Date(a?.collectionDate)?.getTime(), new Date(b?.collectionDate)?.getTime()),\r\n render: (row) => {\r\n let dateFormate = formatDateToUKFormat(row.collectionDate);\r\n return (\r\n \r\n {dateFormate}\r\n \r\n );\r\n },\r\n width: 80,\r\n },\r\n {\r\n title: 'Business/Recipient name',\r\n field: 'businessName',\r\n // customSort: (a, b) => customTableSort(a?.businessName, b?.businessName),\r\n render: (row) => (\r\n \r\n {row.businessName}\r\n \r\n ),\r\n width: 150,\r\n sorting: true,\r\n },\r\n {\r\n title: 'Postal code',\r\n field: 'collectionPostalCode',\r\n // customSort: (a, b) => customTableSort(a?.collectionPostalCode, b?.collectionPostalCode),\r\n render: (row) => (\r\n \r\n {row.collectionPostalCode}\r\n \r\n ),\r\n width: 100,\r\n sorting: true,\r\n },\r\n {\r\n title: 'No. of items',\r\n field: 'noOfItems',\r\n // customSort: (a, b) => customTableSort(a?.noOfItems, b?.noOfItems),\r\n render: (row) => (\r\n \r\n {row.noOfItems}\r\n \r\n ),\r\n width: 150,\r\n sorting: true,\r\n },\r\n ],\r\n\r\n bookedCollectionColumn: [\r\n { title: 'id', field: 'id', hidden: true },\r\n {\r\n title: 'Customer ref.',\r\n field: 'customerRef',\r\n // customSort: (a, b) => customTableSort(a?.customerRef, b?.customerRef),\r\n render: (row) => (\r\n \r\n {row.customerRef}\r\n \r\n ),\r\n width: 150,\r\n sorting: true,\r\n },\r\n {\r\n title: 'Shipment no.',\r\n field: 'shipmentNumber',\r\n // customSort: (a, b) => customTableSort(a?.shipmentNumber, b?.shipmentNumber),\r\n render: (row) => (\r\n \r\n {row.shipmentNumber}\r\n \r\n ),\r\n width: 200,\r\n sorting: true,\r\n },\r\n {\r\n title: 'Collection date',\r\n field: 'collectionDate',\r\n\r\n customSort: (a, b) =>\r\n basicSort(new Date(a?.collectionDate)?.getTime(), new Date(b?.collectionDate)?.getTime()),\r\n render: (row) => {\r\n let dateFormate = formatDateToUKFormat(row.collectionDate);\r\n return (\r\n \r\n {dateFormate}\r\n \r\n );\r\n },\r\n width: 80,\r\n },\r\n {\r\n title: 'Business/Recipient name',\r\n field: 'businessName',\r\n // customSort: (a, b) => customTableSort(a?.businessName, b?.businessName),\r\n render: (row) => (\r\n \r\n {row.businessName}\r\n \r\n ),\r\n width: 190,\r\n sorting: true,\r\n },\r\n {\r\n title: 'Collection postal code',\r\n field: 'collectionPostalCode',\r\n // customSort: (a, b) => customTableSort(a?.collectionPostalCode, b?.collectionPostalCode),\r\n render: (row) => (\r\n \r\n {row.collectionPostalCode}\r\n \r\n ),\r\n width: 80,\r\n sorting: true,\r\n },\r\n { title: 'consigneePostCode', field: 'consigneePostCode', hidden: true },\r\n ],\r\n shipmentSearchParams: '',\r\n bookedCollection_pageDetails: {\r\n offset: 0,\r\n limit: 0,\r\n totalRecordsLength: 0,\r\n },\r\n bookedCollection_final_data: [],\r\n bookedCollection_totalCount: 0,\r\n shipment_pageDetails: {\r\n offset: 0,\r\n limit: 0,\r\n totalRecordsLength: 0,\r\n },\r\n shipment_final_data: [],\r\n shipment_totalCount: 0,\r\n shipment_offset: 0,\r\n openJSPMPrompt: false,\r\n shipmentCancelItems: [],\r\n bookedCollectionCancelItems: [],\r\n shipmentIsMessage: false,\r\n bookedCollectionIsMessage: false,\r\n userAccounts: props.userAccounts,\r\n shipmentManagementData: [],\r\n bookedCollectionsData: [],\r\n isLoading: false,\r\n pageNumber: 0,\r\n pageSize: 10,\r\n };\r\n this.onShipmentChange = this.onShipmentChange.bind(this);\r\n }\r\n\r\n onShipmentChange(value) {\r\n this.setState({ search: true, pageSize: this.state.pageSize || 10, pageNumber: 0 }, () => {\r\n this.getShipmentData();\r\n });\r\n }\r\n\r\n handlePrintSubmit = (values, selectedShipments, errors) => {\r\n const itemsToBeReprinted = selectedShipments.map((shipment) => {\r\n return shipment.id;\r\n });\r\n let printFormat\r\n const payload = itemsToBeReprinted;\r\n if (this.props.printerConfiguration?.isDowloadLabelAsPDF) {\r\n printFormat = 'PDF';\r\n } else {\r\n printFormat = this.props.printerConfiguration?.labelType === 1 ? 'ZPL' : 'PDF';\r\n }\r\n let pageSize = this.props.printerConfiguration?.pageSize ? this.props.printerConfiguration?.pageSize : 0\r\n axiosConfig\r\n .post(\r\n `${ServiceEndPoints.reprintShipments}?isLabel=${values.reprintLabel}&pageSize=${pageSize}&isCustomsInvoice=${values.reprintCustomsInvoice}&format=${printFormat}`,\r\n payload,\r\n )\r\n .then((response) => {\r\n if (!this.props.JSPMStatus && !this.props.printerConfiguration?.isDowloadLabelAsPDF) {\r\n this.setState({ openJSPMPrompt: true });\r\n } else {\r\n let labelResponse = response?.data[0]?.labelResponse;\r\n let customsInvoiceResponse = response?.data[0]?.customsInvoiceResponse;\r\n\r\n labelResponse?.map((lblResponse, labelIndex) => {\r\n lblResponse?.labels?.map((lblValue, index) => {\r\n if (this.props.printerConfiguration?.isDowloadLabelAsPDF === true) {\r\n let lableName = '';\r\n if (index === 0) {\r\n lableName = '_Label.pdf';\r\n } else if (index === 1) {\r\n lableName = '_ReturnLabel.pdf';\r\n } else {\r\n lableName = '_ReturnInstructions.pdf';\r\n }\r\n downloadPDF(lblValue.label, lableName, response.data[0], labelIndex);\r\n }\r\n else {\r\n if (this.props.printerConfiguration?.labelType == 1) {\r\n printZplLabels(lblValue.label, this.props.printerConfiguration?.labelPrinter);\r\n } else {\r\n printPDF(lblValue.label, this.props.printerConfiguration?.labelPrinter, \"Label\");\r\n }\r\n }\r\n this.props.setAppSnackBarData({ msg: 'Shipment successfully reprinted' });\r\n });\r\n });\r\n if (this.props.genralConfiguration && this.props.genralConfiguration.printCustomInvoice) {\r\n customsInvoiceResponse?.map((customResponse, customIndex) => {\r\n customResponse?.customsInvoice?.map((customValue, index) => {\r\n if (this.props.printerConfiguration?.isDowloadLabelAsPDF === true) {\r\n let lableName = '';\r\n if (index === 0) {\r\n lableName = '_CustomsInvoice.pdf';\r\n } else if (index === 1) {\r\n lableName = '_CustomsInvoice.pdf';\r\n } else {\r\n lableName = '_CustomsInvoice.pdf';\r\n }\r\n downloadPDF(customValue, lableName, response?.data[0], customIndex);\r\n }\r\n else {\r\n printPDF(customValue, this.props.printerConfiguration?.otherReportsPrinter, \"Invoice\");\r\n }\r\n this.props.setAppSnackBarData({ msg: 'Shipment successfully reprinted' });\r\n\r\n });\r\n });\r\n }\r\n this.setState({ search: true }, () => {\r\n this.getShipmentData();\r\n });\r\n }\r\n })\r\n .catch((error) => {\r\n console.log(error);\r\n var failedReprintShipment = '';\r\n payload.map((invdata) => (failedReprintShipment = failedReprintShipment + invdata + ','));\r\n this.props.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in reprinting the shipment:' + failedReprintShipment.slice(0, -1),\r\n },\r\n ],\r\n });\r\n });\r\n };\r\n\r\n cancelSelectedShipment = (shipmentIds) => {\r\n const itemsToBeSelected = shipmentIds.map((shipment) => {\r\n const item = {\r\n pickupAccount: shipment?.pickupAccount,\r\n shipmentId: shipment?.id,\r\n postalCode: shipment?.collectionPostalCode ? shipment?.collectionPostalCode : null,\r\n };\r\n return item;\r\n });\r\n\r\n const payload = itemsToBeSelected;\r\n this.setState({ shipmentCancelItems: itemsToBeSelected });\r\n axiosConfig\r\n .post(ServiceEndPoints.cancelShipment, payload)\r\n .then((response) => {\r\n this.setState({ search: true }, () => {\r\n this.getShipmentData();\r\n });\r\n this.props.setAppSnackBarData({ msg: 'Shipment successfully cancelled' });\r\n })\r\n .catch((error) => {\r\n var failedShipment = '';\r\n payload.map((invdata) => (failedShipment = failedShipment + invdata.shipmentId + ','));\r\n this.props.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in cancelling the shipment:' + failedShipment.slice(0, -1),\r\n },\r\n ],\r\n });\r\n });\r\n };\r\n\r\n handleTabChange = (event, index) => {\r\n this.setState({ tabIndex: index, search: true, pageNumber: 0, pageSize: 10 }, () => {\r\n setTimeout(() => {\r\n this.getShipmentData();\r\n }, 100);\r\n });\r\n };\r\n\r\n setShipmentSearchParams = (values) => {\r\n this.setState({ shipmentSearchParams: values });\r\n };\r\n\r\n // _MyShipmentManagement = (query) => {\r\n // return this.getShipmentManagementResults(query);\r\n // };\r\n\r\n getShipmentData = () => {\r\n this.setState({ isLoading: true });\r\n const isBookedCollections = this.state.tabIndex === 1;\r\n const offset = this.state.pageNumber * this.state.pageSize;\r\n abortOnGoingCallsFor(ServiceEndPoints.getShipmentManagement);\r\n const url = `${ServiceEndPoints.getShipmentManagement}isCollectionRequest=${isBookedCollections}`;\r\n setTimeout(() => {\r\n this.state.userAccounts?.length > 0 ? axiosConfig\r\n .get(this.getUrl(url, offset, this.state.pageSize))\r\n .then((res) => {\r\n isBookedCollections ? this.formatBookingDetails(res) : this.formatShipmentManagementData(res);\r\n\r\n this.setState({\r\n [isBookedCollections ? 'bookedCollection_pageDetails' : 'shipment_pageDetails']: {\r\n offset: offset,\r\n limit: this.state.pageSize,\r\n totalRecordsLength: res.data?.totalRecords,\r\n },\r\n search: false,\r\n });\r\n })\r\n .catch((err) => {\r\n isBookedCollections ? this.formatBookingDetails([]) : this.formatShipmentManagementData([]);\r\n this.setState({ shipmentManagementData: [] });\r\n this.setState({\r\n shipment_pageDetails: {\r\n offset: 0,\r\n limit: 10,\r\n totalRecordsLength: 0,\r\n },\r\n bookedCollection_pageDetails: {\r\n offset: 0,\r\n limit: 10,\r\n totalRecordsLength: 0,\r\n },\r\n search: false,\r\n });\r\n })\r\n .finally(() => {\r\n this.setState({ isLoading: false });\r\n }) : this.setState({ isLoading: false });\r\n }, 0);\r\n };\r\n\r\n getUrl(url, offset, limit) {\r\n url += `&${arrayToString(this.state.userAccounts, 'accounts', 'accountId')}&status=Order received`;\r\n // if(this.state.tabIndex !== 1 || (this.state.tabIndex === 1 && this.state.shipmentSearchParams.split('&')[1].split('=')[0] !== 'fromCollectionDate')){\r\n url += this.state.shipmentSearchParams;\r\n // }\r\n url += `&offset=${offset}`;\r\n return (url += `&limit=${limit}`);\r\n }\r\n\r\n formatShipmentManagementData = (result) => {\r\n let final_data = [];\r\n (((result || {}).data || {}).shipmentModels || []).map((element, index) => {\r\n const shipments = element.shipments;\r\n const pickup = element.pickup;\r\n const pickupAccount = element.pickupAccount;\r\n final_data.push({\r\n id: shipments[0].shipmentDetails.shipmentId,\r\n noOfItems: element.numberOfParcels,\r\n customerRef: shipments[0].shipmentDetails?.customerRef1 ?? '',\r\n customerNumber: shipments[0].consigneeAddress?.idNumber ?? '',\r\n alternativeRef: shipments[0].shipmentDetails?.customerRef2 ?? '',\r\n shipmentNumber: shipments[0].shipmentDetails?.shipmentId ?? '',\r\n returnShipmentNumber: shipments[0]?.return?.returnShipmentId ?? '',\r\n collectionDate: formatDate(pickup && pickup.date, '-', 'yy/mm/dd'),\r\n exchangeOnDelivery: shipments[0].shipmentDetails?.exchangeOnDelivery,\r\n customsLevel:shipments[0]?.customsLevel,\r\n businessName:\r\n // shipments[0].consigneeAddress?.recipientType === 1\r\n shipments[0].consigneeAddress?.companyName !== ''\r\n ? shipments[0].consigneeAddress?.companyName ?? ''\r\n : shipments[0].consigneeAddress?.name ?? '',\r\n collectionPostalCode: shipments[0].consigneeAddress?.postalCode ?? '',\r\n isDomestic: shipments[0].consigneeAddress?.country === 'GB' ? true : false,\r\n pickupAccount,\r\n });\r\n });\r\n if (this.state.shipmentCancelItems.length > 0) {\r\n final_data = remove_duplicates(final_data, this.state.shipmentCancelItems, 'id', 'shipmentId');\r\n let _search_params = this.state.shipmentSearchParams;\r\n _search_params = _search_params.substring(_search_params.indexOf('=') + 1);\r\n if (final_data?.length === 0 && _search_params === '') {\r\n this.setState({ shipmentIsMessage: true });\r\n } else {\r\n this.setState({ shipmentIsMessage: false });\r\n }\r\n }\r\n this.setState({ shipmentManagementData: final_data });\r\n };\r\n\r\n formatBookingDetails(response) {\r\n let final_data = response?.data?.shipmentModels?.map((shippingModel, index) => {\r\n const consigneeAddress = shippingModel?.shipments?.[0]?.consigneeAddress;\r\n const shipmentDetails = shippingModel?.shipments?.[0]?.shipmentDetails;\r\n const pickupAddress = shippingModel?.pickupAddress ?? {};\r\n return {\r\n id: shippingModel?.shipmentId,\r\n customerRef: shipmentDetails?.customerRef1,\r\n customerNumber: consigneeAddress?.idNumber,\r\n alternativeRef: shipmentDetails?.customerRef2,\r\n shipmentNumber: shippingModel.shipmentId,\r\n collectionDate: formatDate(shippingModel?.pickup?.date, '-', 'yy/mm/dd'),\r\n businessName: pickupAddress?.companyName || pickupAddress.name,\r\n collectionPostalCode: pickupAddress?.postalCode,\r\n consigneePostCode: consigneeAddress?.postalCode,\r\n pickupAccount: shippingModel?.pickupAccount,\r\n };\r\n });\r\n if (this.state.bookedCollectionCancelItems.length > 0) {\r\n final_data = remove_duplicates(final_data, this.state.bookedCollectionCancelItems, 'id', 'shipmentId');\r\n let _search_params = this.state.shipmentSearchParams;\r\n _search_params = _search_params.substring(_search_params.indexOf('=') + 1);\r\n if (final_data?.length === 0 && _search_params === '') {\r\n this.setState({ bookedCollectionIsMessage: true });\r\n } else {\r\n this.setState({ bookedCollectionIsMessage: false });\r\n }\r\n }\r\n this.setState({ bookedCollectionsData: final_data });\r\n }\r\n\r\n cancelCollection = (shipmentIds) => {\r\n const itemsToBeSelected = shipmentIds.map((shipment) => {\r\n const item = {\r\n pickupAccount: shipment?.pickupAccount,\r\n shipmentId: shipment?.id,\r\n postalCode: shipment?.consigneePostCode ? shipment?.consigneePostCode : null,\r\n };\r\n return item;\r\n });\r\n this.setState({ bookedCollectionCancelItems: itemsToBeSelected });\r\n const payload = itemsToBeSelected;\r\n axiosConfig\r\n .post(ServiceEndPoints.cancelShipment, payload)\r\n .then((response) => {\r\n this.setState({ search: true }, () => {\r\n this.getShipmentData();\r\n });\r\n this.props.setAppSnackBarData({ msg: 'Collection successfully cancelled' });\r\n })\r\n .catch((error) => {\r\n var failedCollection = '';\r\n payload.map((invdata) => (failedCollection = failedCollection + invdata.shipmentId + ','));\r\n this.props.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in cancelling the collection:' + failedCollection.slice(0, -1),\r\n },\r\n ],\r\n });\r\n });\r\n };\r\n\r\n componentDidMount() {\r\n // this.getShipmentData();\r\n if (this.props.activeTab === 'bookedCollection') {\r\n this.setState({ tabIndex: 1 }, () => {\r\n this.getShipmentData();\r\n });\r\n }\r\n this.props.setActiveTab('');\r\n if (\r\n this.props.history.location &&\r\n this.props.history.location.state !== undefined &&\r\n this.props.history.location.state !== null\r\n ) {\r\n if (this.props.history.location.state.shipmentSummary) {\r\n this.setState({ shipmentCancelItems: this.props.history.location.state.itemsToBeSelected });\r\n } else {\r\n this.setState({ bookedCollectionCancelItems: this.props.history.location.state.itemsToBeSelected });\r\n }\r\n }\r\n }\r\n\r\n componentWillReceiveProps(nextProps) {\r\n if (this.props.userAccounts.length !== nextProps.userAccounts.length) {\r\n this.setState({ userAccounts: nextProps.userAccounts }, () => {\r\n this.getShipmentData();\r\n });\r\n }\r\n }\r\n\r\n handleClose = () => {\r\n this.setState({ openJSPMPrompt: false });\r\n };\r\n\r\n onPageNumChange(pageNum) {\r\n this.setState({ pageNumber: pageNum }, () => {\r\n this.getShipmentData();\r\n });\r\n }\r\n\r\n onPageSizeChange(pageSize) {\r\n this.setState({ pageSize: pageSize }, () => {\r\n this.getShipmentData();\r\n });\r\n }\r\n\r\n render() {\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n <>\r\n \r\n this.onPageSizeChange(e),\r\n onChangePage: (a) => this.onPageNumChange(a),\r\n }}\r\n page={this.state.pageNumber}\r\n />\r\n \r\n \r\n this.onPageSizeChange(e),\r\n onChangePage: (a) => this.onPageNumChange(a),\r\n }}\r\n page={this.state.pageNumber}\r\n shipmentSearchParams={this.state.shipmentSearchParams}\r\n tabIndex={this.state.tabIndex}\r\n />\r\n \r\n >\r\n \r\n \r\n \r\n \r\n \r\n );\r\n }\r\n}\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n activeTab: state.common.activeTab,\r\n userAccounts: state.accounts.userAccounts,\r\n JSPMStatus: state.common.isJSPMInstalled,\r\n printerConfiguration: state.common.printerConfiguration,\r\n availablePrinter: state.common.availablePrinter,\r\n genralConfiguration: state.common.commonConfiguration,\r\n };\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n setAppSnackBarData: (data) => {\r\n dispatch(actions.setAppSnackBarData(data));\r\n },\r\n setBottomAlert: (data) => {\r\n dispatch(actions.setBottomAlert(data));\r\n },\r\n setActiveTab: (value) => {\r\n dispatch(actions.setActiveTab(value));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(ShipmentManagement);\r\n","import React from 'react';\r\nimport { Grid, Typography, Box } from '@material-ui/core';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\nconst useStyles = makeStyles((theme) => ({\r\n customHeader: {\r\n borderBottom: '1px solid RGBA(112,112,112,0.18)',\r\n // padding:\"10px\",\r\n },\r\n customTitle: {\r\n color: '#000000E6',\r\n paddingBottom: '10px',\r\n paddingTop: '5px',\r\n },\r\n customText: {\r\n paddingTop: '10px',\r\n paddingBottom: '10px',\r\n },\r\n}));\r\nconst CustomHeader = ({ heading, children }) => {\r\n const classes = useStyles();\r\n\r\n return (\r\n \r\n \r\n {heading} \r\n \r\n \r\n {children}\r\n \r\n \r\n );\r\n};\r\n\r\nexport default CustomHeader;\r\n","import React from 'react';\r\nimport { Typography } from '@material-ui/core';\r\n\r\nconst CustomCaption = ({ title, value }) => {\r\n return (\r\n <>\r\n \r\n {title}\r\n \r\n \r\n {value ? value : '-'}\r\n \r\n >\r\n );\r\n};\r\n\r\nexport default CustomCaption;\r\n","import React from 'react'\r\nimport { Grid } from '@material-ui/core';\r\nimport CustomCaption from './CustomCaption';\r\n\r\nconst SetupSummary = ({ data }) => {\r\n\r\n return (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n )\r\n}\r\n\r\nexport default SetupSummary\r\n","import React, { useState, useEffect } from 'react';\r\nimport { Box } from '@material-ui/core';\r\nimport CustomCaption from './CustomCaption';\r\nimport { getParsedFloatValues } from '../../utils/helperFunctions';\r\nimport { useSelector } from 'react-redux';\r\n// const useStyles = makeStyles({\r\n// flexContainer: {\r\n// flexGrow: 1,\r\n// flexShrink: 1,\r\n// flexBasis: 0,\r\n// },\r\n// });\r\nconst ParcelSummary = ({ shipmentSummary, shipmentmanagement }) => {\r\n // const classes = useStyles();\r\n const [parcelDetails, setParcelDetails] = useState({});\r\n const [volumetricWeight, setVolumetricWeight] = useState(0.0);\r\n const [volumetricWeightDivisor, setVolumetricWeightDivisor] = useState(4000);\r\n\r\n // const [parcelDimensionsChecked, setParcelDimensionsChecked] = useState(false);\r\n const userDetails = useSelector((state) => state.auth.userDetails);\r\n useEffect(() => {\r\n setParcelDetails(shipmentSummary?.parcelDetail);\r\n }, [shipmentSummary]);\r\n\r\n useEffect(() => {\r\n let volumetricWeight = 0;\r\n parcelDetails?.pieces?.forEach((row) => {\r\n volumetricWeight += getCaluclatedVolumetricWeight(row);\r\n });\r\n setVolumetricWeight(parseFloat(volumetricWeight).toFixed(2));\r\n }, [parcelDetails, volumetricWeightDivisor]);\r\n\r\n useEffect(() => {\r\n const shipmentAcc = userDetails?.accounts?.find((user) => user.accountId === shipmentSummary.accountNumber);\r\n setVolumetricWeightDivisor(shipmentAcc?.configuration?.volumetricWeightDivisor || 4000);\r\n }, [userDetails, shipmentSummary.accountNumber]);\r\n\r\n const getCaluclatedVolumetricWeight = (row) => {\r\n return getParsedFloatValues((row.length * row.height * row.width) / volumetricWeightDivisor);\r\n };\r\n return (\r\n <>\r\n \r\n \r\n {/* {parcelDetails?.servicePoint === undefined && shipmentmanagement ? null : (\r\n \r\n \r\n \r\n )} */}\r\n {shipmentSummary.productDetail?.product === 'Pallet' ? (\r\n \r\n ) : (parcelDetails?.numberOfItems === undefined && shipmentmanagement ? null : (\r\n \r\n \r\n \r\n ))}\r\n {parcelDetails?.totalWeight === undefined && shipmentmanagement ? null : (\r\n \r\n \r\n \r\n )}\r\n {/* \r\n \r\n */}\r\n \r\n \r\n \r\n \r\n
\r\n >\r\n );\r\n};\r\n\r\nexport default ParcelSummary;\r\n","import React, { useState, useEffect } from 'react'\r\n \r\nimport CustomCaption from './CustomCaption';\r\n \r\nimport { Grid, Typography } from '@material-ui/core';\r\n \r\nconst DeliveryOptionsSummary = ({ deliveryOptions, servicePoint ,deliveryChoice}) => {\r\n const [doorStepInstructionsValue, setDoorStepInstructionsValue] = useState('')\r\n useEffect(() => {\r\n if (deliveryOptions.addressType && deliveryOptions.addressType !== null && deliveryOptions.addressType.toLowerCase() === 'doorstep') {\r\n if (deliveryChoice === \"NYN/PIN\") {\r\n setDoorStepInstructionsValue('Deliver to doorstep with PIN');\r\n } \r\n else if (deliveryChoice === \"NYN/AGE\") {\r\n setDoorStepInstructionsValue('Deliver to doorstep with AGE verification');\r\n } else {\r\n if (deliveryOptions.neighbourDelivery) {\r\n setDoorStepInstructionsValue('Deliver to neighbour if no answer at doorstep');\r\n } \r\n else if (deliveryOptions.secureLocationDelivery) {\r\n setDoorStepInstructionsValue('Leave safe if no answer at doorstep');\r\n } \r\n else {\r\n setDoorStepInstructionsValue('Deliver to doorstep only');\r\n }\r\n }\r\n }\r\n\r\n }, [deliveryOptions, deliveryChoice])\r\n return (\r\n \r\n \r\n \r\n {(deliveryOptions || {}).addressType !== ''\r\n ? `Delivery type: ${((deliveryOptions || {}).addressType !== null && (deliveryOptions || {}).addressType !== undefined) ? ((deliveryOptions || {}).addressType.toLowerCase() === 'servicepoint' ? 'Deliver to ServicePoint' : 'Deliver to doorstep') : ''}`\r\n : null}\r\n \r\n \r\n \r\n \r\n {(deliveryOptions?.addressType)?.toLowerCase() === 'servicepoint'\r\n ?\r\n (\r\n \r\n \r\n )\r\n :\r\n (\r\n \r\n \r\n )\r\n }\r\n {(deliveryOptions?.leaveSafeLocation !== '') ?\r\n \r\n \r\n \r\n :\r\n \r\n \r\n \r\n }\r\n \r\n \r\n \r\n \r\n {(deliveryOptions || {}).exchangeOnDelivery !== ''\r\n ? `Exchange on delivery: ${((deliveryOptions || {}).exchangeOnDelivery !== null && (deliveryOptions || {}).exchangeOnDelivery !== undefined) ? ((deliveryOptions || {}).exchangeOnDelivery ? 'Yes' : 'No') : ''}`\r\n : null}\r\n \r\n \r\n \r\n \r\n )\r\n}\r\n \r\nexport default DeliveryOptionsSummary","import React from 'react';\r\nimport { Grid } from '@material-ui/core';\r\nimport CustomCaption from './CustomCaption';\r\n\r\nconst AdditionalInfoSummary = (props) => {\r\n const { additionalInfo, destinationCountry } = props;\r\n\r\n return (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {/* */}\r\n \r\n \r\n \r\n >\r\n );\r\n};\r\n\r\nexport default AdditionalInfoSummary;\r\n","import React from 'react';\r\nimport { FormControlLabel, Checkbox } from '@material-ui/core';\r\nimport './ReadOnlyCheckbox.scss';\r\nconst ReadOnlyCheckbox = ({ label, checked }) => {\r\n return (\r\n \r\n }\r\n label={label}\r\n />\r\n
\r\n );\r\n};\r\n\r\nexport default ReadOnlyCheckbox;\r\n","import React, { useState, useEffect } from 'react'\r\n\r\nimport { Grid } from '@material-ui/core';\r\n\r\n\r\nimport CustomCaption from './CustomCaption';\r\nimport ReadOnlyCheckbox from '../readOnlyCheckbox/ReadOnlyCheckbox';\r\n\r\nconst ReturnOptionsSummary = ({ data }) => {\r\n const [state, setstate] = useState(false);\r\n useEffect(() => {\r\n setstate((data || {}).returnLabelIncluded)\r\n\r\n }, [data])\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n )\r\n}\r\n\r\nexport default ReturnOptionsSummary\r\n","import React, { useEffect, useState } from 'react';\r\nimport { Grid, Typography } from '@material-ui/core';\r\nimport CustomCaption from './CustomCaption';\r\n\r\nconst ProductAndServiceSummary = ({data}) => {\r\n // const [productName, setProductName] = useState();\r\n\r\n // const ProductForInterNational = () => {\r\n // if (data.shipmentDetails && data.shipmentDetails.orderedProduct == '101') {\r\n // setProductName('Worldwide Air');\r\n // } else if (data.shipmentDetails && data.shipmentDetails.orderedProduct == '204') {\r\n // setProductName('International Road Economy');\r\n // }\r\n // };\r\n\r\n // useEffect(() => {\r\n // ProductForInterNational();\r\n // }, []);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nexport default ProductAndServiceSummary;\r\n","import React, { useState } from 'react';\r\nimport {\r\n Grid,\r\n Table,\r\n TableCell,\r\n TableRow,\r\n TableHead,\r\n TableFooter,\r\n TableBody,\r\n Paper,\r\n TableContainer,\r\n} from '@material-ui/core';\r\nimport './commodityDetailsSummary.scss';\r\nimport { DASHBOARD_COMMODITY, CLERANCE_DECLARATION } from '../../../../utils/constants/constants';\r\n\r\nconst CommodityDetailsSummary = ({ shipmentDetails, isClearance, shipmentMovementType, isInternational }) => {\r\n const [isAddNewAddress, setIsAddNewAddress] = useState(false);\r\n return (\r\n \r\n \r\n \r\n {DASHBOARD_COMMODITY.ITEM_DETAILS} \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {DASHBOARD_COMMODITY.COMMODITY_CODE} \r\n \r\n \r\n {isInternational ? DASHBOARD_COMMODITY.FULL_DESCRIPTION_GOODS : DASHBOARD_COMMODITY.DESCRIPTION_GOODS} \r\n \r\n {isInternational ||\r\n (!isInternational && shipmentMovementType === CLERANCE_DECLARATION.MOVEMENT_TYPE_B2B) ? (\r\n <>\r\n \r\n {isInternational ? DASHBOARD_COMMODITY.WEIGHT : DASHBOARD_COMMODITY.UNIT_WEIGHT} \r\n \r\n \r\n {isInternational ? DASHBOARD_COMMODITY.QUANTITY : DASHBOARD_COMMODITY.UNIT_QUANTITY} \r\n \r\n \r\n {DASHBOARD_COMMODITY.UNIT_VALUE} \r\n \r\n \r\n {isInternational ? DASHBOARD_COMMODITY.COUNTRY_ORIGIN : DASHBOARD_COMMODITY.COUNTRY_MANUFACTURE} \r\n \r\n >\r\n ) : null}\r\n {isInternational ? null : (\r\n <>\r\n {shipmentMovementType !== CLERANCE_DECLARATION.MOVEMENT_TYPE_B2B ? (\r\n \r\n {isInternational ? DASHBOARD_COMMODITY.QUANTITY : DASHBOARD_COMMODITY.UNIT_QUANTITY} \r\n \r\n ) : null}\r\n >\r\n )}\r\n \r\n \r\n \r\n {shipmentDetails?.commodityDetails?.map((row, index) => (\r\n \r\n \r\n {row.commodityCode ? row.commodityCode : '-'}\r\n \r\n {row.fullDescriptionOfGoods} \r\n\r\n {isInternational ||\r\n (!isInternational && shipmentMovementType === CLERANCE_DECLARATION.MOVEMENT_TYPE_B2B) ? (\r\n <>\r\n {row.weight} kg \r\n {row.quantity} \r\n {row.unitValue} \r\n \r\n {(row.countryOfOrigin || {}).code}\r\n \r\n >\r\n ) : null}\r\n {isInternational ? null : (\r\n <>\r\n {shipmentMovementType !== CLERANCE_DECLARATION.MOVEMENT_TYPE_B2B ? (\r\n \r\n {row.quantity}\r\n \r\n ) : null}\r\n >\r\n )}\r\n \r\n ))}\r\n \r\n {!isClearance ? (\r\n \r\n {!isAddNewAddress ? (\r\n <>\r\n {' '}\r\n \r\n {DASHBOARD_COMMODITY.SUB_TOTAL} \r\n \r\n \r\n \r\n \r\n\r\n \r\n {shipmentDetails.subTotal}\r\n \r\n \r\n \r\n {DASHBOARD_COMMODITY.SHIPPING_COST} \r\n \r\n \r\n \r\n \r\n\r\n \r\n {isNaN(shipmentDetails.customDeclarationShippingCharges) ||\r\n parseInt(shipmentDetails.customDeclarationShippingCharges) < 0\r\n ? 0\r\n : shipmentDetails.customDeclarationShippingCharges}\r\n \r\n \r\n >\r\n ) : null}\r\n \r\n \r\n {CLERANCE_DECLARATION.TOTAL_VALUE} \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n {shipmentDetails.totalValue} \r\n \r\n \r\n \r\n ) : null}\r\n
\r\n \r\n \r\n );\r\n};\r\n\r\nexport default CommodityDetailsSummary;\r\n","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, makeStyles, Typography } from '@material-ui/core';\r\nimport CustomCaption from '../../../../framework/summaryFormate/CustomCaption';\r\nimport { formatDate } from '../../../../utils/helperFunctions';\r\nimport CommodityDetailsSummary from '../../../../container/shipment/addShipment/addShipmentSummary/CommodityDetailsSummary';\r\nimport { useSelector } from 'react-redux';\r\nimport { useDispatch } from 'react-redux';\r\n\r\nconst useStyles = makeStyles({\r\n flexContainer: {\r\n flexGrow: 1,\r\n flexShrink: 1,\r\n flexBasis: 0,\r\n },\r\n rowDiff: {\r\n marginTop: '5px',\r\n marginBottom: '10px',\r\n },\r\n});\r\n\r\nconst CustomDetailsSummary = ({ shipmentData }) => {\r\n const classes = useStyles();\r\n const dispatch = useDispatch();\r\n let userAccounts = useSelector((state) => state.auth.userDetails);\r\n const [commodityDetails, setCommodityDetails] = useState({});\r\n const [iossFieldName, setiossFieldName] = useState('');\r\n const [iossFieldvalue, setiossFieldvalue] = useState('');\r\n\r\n const parseCommodityDetails = () => {\r\n return shipmentData?.articles?.article.map((commodity) => {\r\n return {\r\n ...commodity,\r\n fullDescriptionOfGoods: commodity.descriptionofGoods,\r\n weight: commodity?.unitWeight,\r\n countryOfOrigin: {\r\n code: commodity?.countryOfManufacture,\r\n },\r\n };\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n const newCommodityDetails = {\r\n commodityDetails: parseCommodityDetails(),\r\n subTotal: shipmentData?.totalValue,\r\n customDeclarationShippingCharges: shipmentData?.shippingCharges,\r\n totalValue: shipmentData?.shippingCharges + shipmentData?.totalValue,\r\n };\r\n setCommodityDetails(newCommodityDetails);\r\n let result = userAccounts.accounts.filter(accounts => accounts.accountId == shipmentData.accountNumber);\r\n setiossFieldName(\"IOSS number\")\r\n if (!shipmentData?.iossShipment) {\r\n setiossFieldvalue('-')\r\n }\r\n else if (result[0]?.configuration?.iossDHLAccountAllowed) {\r\n setiossFieldvalue(\"Using DHL IOSS number\")\r\n }\r\n else if (result[0]?.customsRegistration?.iossNumber) {\r\n setiossFieldvalue(shipmentData.sender.shippersIOSS)\r\n }\r\n else {\r\n setiossFieldvalue(shipmentData.sender.shippersIOSS)\r\n }\r\n }, [shipmentData]);\r\n return (\r\n \r\n \r\n \r\n Invoice type: {shipmentData?.invoiceCategory ?? '-'}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nCustomDetailsSummary.propTypes = {\r\n shipmentData: PropTypes.object.isRequired,\r\n};\r\n\r\nexport default CustomDetailsSummary;\r\n","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from \"react\";\n\nvar _ref2 = /*#__PURE__*/React.createElement(\"path\", {\n id: \"Icon_metro-eye\",\n \"data-name\": \"Icon metro-eye\",\n d: \"M17.995,7.712a17.276,17.276,0,0,0-15.424,9.64,17.159,17.159,0,0,0,30.849,0,17.276,17.276,0,0,0-15.424-9.64ZM25.6,12.825a14.668,14.668,0,0,1,4.5,4.528,14.668,14.668,0,0,1-4.5,4.528,14.135,14.135,0,0,1-15.21,0,14.668,14.668,0,0,1-4.5-4.528,14.668,14.668,0,0,1,4.5-4.528c.118-.075.237-.148.357-.22a7.712,7.712,0,1,0,14.5,0q.18.107.357.22ZM17.995,14.46A2.892,2.892,0,1,1,15.1,11.568,2.892,2.892,0,0,1,17.995,14.46Z\",\n transform: \"translate(-2.571 -7.712)\"\n});\n\nfunction SvgEyes(_ref, svgRef) {\n var title = _ref.title,\n titleId = _ref.titleId,\n props = _objectWithoutProperties(_ref, [\"title\", \"titleId\"]);\n\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 30.849,\n height: 19.28,\n viewBox: \"0 0 30.849 19.28\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, _ref2);\n}\n\nvar ForwardRef = /*#__PURE__*/React.forwardRef(SvgEyes);\nexport default __webpack_public_path__ + \"static/media/eyes.1bec1aef.svg\";\nexport { ForwardRef as ReactComponent };","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, makeStyles, Typography } from '@material-ui/core';\r\nimport CustomCaption from '../../../../framework/summaryFormate/CustomCaption';\r\nimport CommodityDetailsSummary from '../../../../container/shipment/addShipment/addShipmentSummary/CommodityDetailsSummary';\r\nimport { CLERANCE_DECLARATION } from '../../../../utils/constants/constants';\r\n\r\nconst useStyles = makeStyles({\r\n flexContainer: {\r\n flexGrow: 1,\r\n flexShrink: 1,\r\n flexBasis: 0,\r\n paddingLeft: '10px',\r\n },\r\n rowDiff: {\r\n marginTop: '5px',\r\n marginBottom: '10px',\r\n },\r\n});\r\n\r\nconst ClearanceDeclarationSummary = ({ shipmentData }) => {\r\n const {\r\n shipmentMovementType,\r\n totalValue,\r\n recipientUKIMSNumber,\r\n recipientEORINumber,\r\n sendersEORINumber,\r\n sendersUKIMSNumber,\r\n shippingCharges,\r\n reasonForExport,\r\n sendersDefermentAccount = shipmentData.shipper.defermentAccount,\r\n } = shipmentData || {};\r\n const classes = useStyles();\r\n const [commodityDetails, setCommodityDetails] = useState({});\r\n const CustomGridItem = ({ title, value }) => (\r\n \r\n \r\n \r\n );\r\n\r\n /**\r\n * Method to parse the commodity details\r\n * @returns - object\r\n */\r\n const parseCommodityDetails = () => {\r\n return shipmentData?.clearanceItems?.map((commodity) => {\r\n return {\r\n ...commodity,\r\n commodityCode: commodity?.commodityCode,\r\n fullDescriptionOfGoods: commodity?.descriptionOfGoods,\r\n weight: commodity?.weight,\r\n unitValue: commodity?.value,\r\n quantity: commodity?.quantity,\r\n countryOfOrigin: {\r\n code: commodity?.countryOfManufacture,\r\n },\r\n };\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n const newCommodityDetails = {\r\n commodityDetails: parseCommodityDetails(),\r\n };\r\n setCommodityDetails(newCommodityDetails);\r\n }, [shipmentData]);\r\n\r\n const getDescriptionOfGoods = (shipmentData) => {\r\n if (shipmentData && shipmentData?.clearanceItems && shipmentData?.clearanceItems?.length > 0) {\r\n return shipmentData?.clearanceItems[0]?.descriptionOfGoods;\r\n } else {\r\n return '-';\r\n }\r\n };\r\n\r\n if (shipmentData?.recipient?.clearanceRegistrations) {\r\n shipmentData.recipient.clearanceRegistrations.forEach((registration) => {\r\n if (registration?.type === CLERANCE_DECLARATION.EORI_CONST) {\r\n shipmentData.recipientEORINumber = registration?.value;\r\n } else if (registration?.type === CLERANCE_DECLARATION.UKIMS_CONST) {\r\n shipmentData.recipientUKIMSNumber = registration?.value;\r\n }\r\n });\r\n }\r\n\r\n if (shipmentData?.shipper?.clearanceRegistrations) {\r\n shipmentData.shipper.clearanceRegistrations.forEach((registration) => {\r\n if (registration?.type === CLERANCE_DECLARATION.EORI_CONST) {\r\n shipmentData.sendersEORINumber = registration?.value;\r\n } else if (registration?.type === CLERANCE_DECLARATION.UKIMS_CONST) {\r\n shipmentData.sendersUKIMSNumber = registration?.value;\r\n }\r\n });\r\n }\r\n\r\n return (\r\n \r\n \r\n \r\n {CLERANCE_DECLARATION.SHIPMENT_MOVEMENT_TYPE} {shipmentMovementType ?? '-'}\r\n \r\n \r\n\r\n {shipmentMovementType === CLERANCE_DECLARATION.MOVEMENT_TYPE_C2C && (\r\n <>\r\n \r\n \r\n >\r\n )}\r\n\r\n {shipmentMovementType === CLERANCE_DECLARATION.MOVEMENT_TYPE_C2B && (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n )}\r\n\r\n {shipmentMovementType === CLERANCE_DECLARATION.MOVEMENT_TYPE_B2B && (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n )}\r\n\r\n {shipmentMovementType === CLERANCE_DECLARATION.MOVEMENT_TYPE_B2C && (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n )}\r\n\r\n {shipmentMovementType !== CLERANCE_DECLARATION.MOVEMENT_TYPE_C2C && (\r\n \r\n \r\n \r\n )}\r\n\r\n {shipmentMovementType === CLERANCE_DECLARATION.MOVEMENT_TYPE_B2B && !sendersUKIMSNumber && (\r\n <>\r\n \r\n \r\n \r\n >\r\n )}\r\n \r\n );\r\n};\r\n\r\nClearanceDeclarationSummary.propTypes = {\r\n shipmentData: PropTypes.object.isRequired,\r\n};\r\n\r\nexport default ClearanceDeclarationSummary;\r\n","import React, { useEffect, useState } from 'react';\r\nimport { useHistory, useParams } from 'react-router-dom';\r\nimport AddressFormate from '../../../framework/addressFormate/AddressFormate';\r\nimport CustomHeader from '../../../framework/summaryFormate/CustomHeader';\r\n\r\nimport { Grid, Box, makeStyles, Checkbox, FormControlLabel, SvgIcon } from '@material-ui/core';\r\n\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { axiosConfig } from '../../../api/axios';\r\n\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport SetupSummary from '../../../framework/summaryFormate/SetupSummary';\r\nimport ParcelSummary from '../../../framework/summaryFormate/ParcelSummary';\r\nimport DeliveryOptionsSummary from '../../../framework/summaryFormate/DeliveryOptionsSummary';\r\nimport AdditionalInfoSummary from '../../../framework/summaryFormate/AdditionalInfoSummary';\r\nimport ReturnOptionsSummary from '../../../framework/summaryFormate/ReturnOptionsSummary';\r\nimport ProductAndServiceSummary from '../../../framework/summaryFormate/ProductAndServiceSummary';\r\nimport { connect, useDispatch } from 'react-redux';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { setDropdownValues } from '../../../utils/helperFunctions';\r\nimport CustomModal from '../../../framework/dialog/customDialog';\r\nimport { printZplLabels, printPDF, downloadPDF } from '../../../utils/PrintHelper';\r\nimport PromptJSPMClientInstallation from '../../../components/addShipment/Printing/PromptJSPMClientInstallation';\r\nimport CustomDialog from '../../../framework/dialog/customDialog';\r\nimport './ShipmentSummary.scss';\r\nimport CustomDetailsSummary from '../../../components/shipmentManagement/shipmentSummary/customDetailsSummary/customDetailsSummary';\r\nimport { ReactComponent as EyesIcon } from '../../../assets/images/eyes.svg';\r\nimport ConfirmationDialog from '../../../components/addressBook/confirmation/confirmation';\r\nimport CustomCaption from '../../../framework/summaryFormate/CustomCaption';\r\nimport ClearanceDeclarationSummary from '../../../components/shipmentManagement/shipmentSummary/clearanceDeclarationSummary/clearanceDeclarationSummary';\r\nimport { getClearanceDeclarationDetails } from '../../../utils/utilsFunctions';\r\nimport { CLERANCE_DECLARATION, DASHBOARD_SUMMARY } from '../../../utils/constants/constants';\r\n\r\nconst useStyles = makeStyles({\r\n boxContainer: {\r\n '& :last-child': {\r\n borderBottom: 'unset',\r\n },\r\n },\r\n});\r\n\r\nconst ShipmentSummary = (props) => {\r\n const dispatch = useDispatch();\r\n const { id } = useParams();\r\n const classes = useStyles();\r\n const [list, setlist] = useState({});\r\n const [accountDetails, setAccountDetails] = useState({});\r\n const [isDomestic, setisDomestic] = useState(true);\r\n const [showPrintDialog, setshowPrintDialog] = useState(false);\r\n const [confirmationMsg, setConfirmationMsg] = useState('');\r\n const [fullCustom, setFullCustom] = useState(false);\r\n const [showCancelConfirmationDialog, setShowCancelConfirmationDialog] = useState(false);\r\n const [showClearanceDeclarationDetails, setShowClearanceDeclarationDetails] = useState(false);\r\n const [clearanceDeclarationDetails, setClearanceDeclarationDetails] = useState({});\r\n const [state, setState] = useState({\r\n reprintLabel: false,\r\n reprintCustomsInvoice: false,\r\n });\r\n const [showCustomDetails, setShowCustomDetails] = useState(false);\r\n const [customsDetails, setCustomsDetails] = useState({});\r\n\r\n const [openJSPMPrompt, setOpenJSPMPrompt] = useState(false);\r\n\r\n const history = useHistory();\r\n\r\n const handleChange = (event) => {\r\n setState({ ...state, [event.target.name]: event.target.checked });\r\n };\r\n\r\n const handlePrintSubmit = (values, selectedShipment, errors) => {\r\n const payload = [selectedShipment];\r\n\r\n const printFormat =\r\n props.printerConfiguration?.isDowloadLabelAsPDF === true\r\n ? DASHBOARD_SUMMARY.PDF\r\n : props.printerConfiguration?.labelType === 1\r\n ? DASHBOARD_SUMMARY.ZPL\r\n : DASHBOARD_SUMMARY.PDF;\r\n\r\n const selctedPrinter = props.availablePrinter?.findIndex((x) => x === props.printerConfiguration?.labelPrinter);\r\n axiosConfig\r\n .post(\r\n `${ServiceEndPoints.reprintShipments}?isLabel=${values.reprintLabel}&isCustomsInvoice=${values.reprintCustomsInvoice}&format=${printFormat}`,\r\n payload,\r\n )\r\n .then((response) => {\r\n if (!props.JSPMStatus && !props.printerConfiguration?.isDowloadLabelAsPDF) {\r\n setOpenJSPMPrompt(true);\r\n } else {\r\n let labelResponse = response?.data[0]?.labelResponse;\r\n let customsInvoiceResponse = response?.data[0]?.customsInvoiceResponse;\r\n let hasLabelValue = false;\r\n\r\n labelResponse?.map((lblResponse) => {\r\n lblResponse?.labels?.map((lblValue, index) => {\r\n if (props.printerConfiguration?.isDowloadLabelAsPDF === true) {\r\n let lableName = '';\r\n if (index === 0) {\r\n lableName = '_Label.pdf';\r\n } else if (index === 1) {\r\n lableName = '_ReturnLabel.pdf';\r\n } else {\r\n lableName = '_ReturnInstructions.pdf';\r\n }\r\n downloadPDF(lblValue.label, lableName, response.data);\r\n hasLabelValue = true;\r\n } else {\r\n if (props.printerConfiguration?.labelType == 1) {\r\n printZplLabels(lblValue.label, props.printerConfiguration?.labelPrinter);\r\n hasLabelValue = true;\r\n } else {\r\n printPDF(lblValue.label, props.printerConfiguration?.labelPrinter, 'Label');\r\n hasLabelValue = true;\r\n }\r\n }\r\n });\r\n });\r\n\r\n customsInvoiceResponse?.map((customResponse) => {\r\n customResponse?.customsInvoice?.map((customValue, index) => {\r\n if (props.printerConfiguration?.isDowloadLabelAsPDF === true) {\r\n let lableName = '';\r\n if (index === 0) {\r\n lableName = '_CustomsInvoice.pdf';\r\n } else if (index === 1) {\r\n lableName = '_CustomsInvoice.pdf';\r\n } else {\r\n lableName = '_CustomsInvoice.pdf';\r\n }\r\n downloadPDF(customValue, lableName, response.data);\r\n hasLabelValue = true;\r\n } else {\r\n printPDF(customValue, props.printerConfiguration?.otherReportsPrinter, 'Invoice');\r\n hasLabelValue = true;\r\n }\r\n });\r\n });\r\n hasLabelValue && dispatch(actions.setAppSnackBarData({ msg: 'Shipment successfully reprinted' }));\r\n }\r\n })\r\n .catch((error) => {\r\n console.log(error);\r\n var failedReprintShipment = '';\r\n payload.map((invdata) => (failedReprintShipment = failedReprintShipment + invdata + ','));\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in reprinting the shipment:' + failedReprintShipment.slice(0, -1),\r\n },\r\n ],\r\n }),\r\n );\r\n });\r\n };\r\n\r\n const resetReprintState = () => {\r\n setState({ ...state, reprintLabel: false, reprintCustomsInvoice: false });\r\n };\r\n\r\n const handleDialogClose = () => {\r\n setshowPrintDialog(false);\r\n resetReprintState();\r\n };\r\n\r\n const handleClose = () => {\r\n setOpenJSPMPrompt(false);\r\n };\r\n const onDialogCancel = () => {\r\n setshowPrintDialog(false);\r\n resetReprintState();\r\n };\r\n const savePrintDialog = () => {\r\n setshowPrintDialog(false);\r\n const values = { reprintLabel: state.reprintLabel, reprintCustomsInvoice: state.reprintCustomsInvoice };\r\n handlePrintSubmit(values, id);\r\n resetReprintState();\r\n };\r\n\r\n const getShipmentList = () => {\r\n axiosConfig\r\n .get(`${ServiceEndPoints.getShipment}/${id}`)\r\n .then((res) => {\r\n if (res.data.destinationCountry !== DASHBOARD_SUMMARY.DESTINATION_COUNTRY_UK) {\r\n setisDomestic(false);\r\n }\r\n setlist(res.data);\r\n setSelectedAccountDetails(res.data?.accountNumber);\r\n dispatch(\r\n actions.setShipmentId({\r\n shipmentId: res.data?.shipmentNumber,\r\n }),\r\n );\r\n getProductDetails(res.data);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n };\r\n\r\n const setSelectedAccountDetails = (accountId) => {\r\n setAccountDetails(setDropdownValues(props.userDetails.accounts, 'accountId', accountId));\r\n };\r\n\r\n useEffect(() => {\r\n getShipmentList();\r\n }, []);\r\n\r\n const backToBookedCollection = () => {\r\n dispatch(actions.setActiveTab(''));\r\n history.push('/shipment/shipmentmanagement');\r\n };\r\n\r\n const cancelShipment = () => {\r\n const itemsToBeSelected = [];\r\n const item = {\r\n pickupAccount: list?.accountNumber,\r\n shipmentId: list?.shipmentNumber,\r\n postalCode: list?.deliveryAddress?.postalCode,\r\n };\r\n itemsToBeSelected.push(item);\r\n const payload = itemsToBeSelected;\r\n axiosConfig\r\n .post(ServiceEndPoints.cancelShipment, payload)\r\n .then((response) => {\r\n dispatch(actions.setAppSnackBarData({ msg: 'Shipment successfully cancelled' }));\r\n history.push({\r\n pathname: '/shipment/shipmentmanagement',\r\n state: {\r\n itemsToBeSelected: itemsToBeSelected,\r\n shipmentSummary: true,\r\n },\r\n });\r\n })\r\n .catch((error) => {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in cancelling the shipment:' + payload[0].shipmentId,\r\n },\r\n ],\r\n }),\r\n );\r\n });\r\n };\r\n const getCustomsDetails = () => {\r\n axiosConfig\r\n .get(`${ServiceEndPoints.getCustomsDeclaration}?shipmentId=${id}`)\r\n .then((res) => {\r\n setCustomsDetails(res.data);\r\n setShowCustomDetails(true);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in fetching customs details',\r\n },\r\n ],\r\n }),\r\n );\r\n });\r\n };\r\n\r\n const handleCancel = () => {\r\n setConfirmationMsg('Are you sure you want to cancel the shipment?');\r\n setShowCancelConfirmationDialog(true);\r\n };\r\n\r\n const handleCancelDialogClose = () => {\r\n setShowCancelConfirmationDialog(false);\r\n };\r\n\r\n const onCancelDialogConfirm = () => {\r\n setShowCancelConfirmationDialog(false);\r\n cancelShipment();\r\n };\r\n\r\n const getProductDetails = (details) => {\r\n axiosConfig\r\n .get(\r\n `${ServiceEndPoints.productCountryFeature}?countrycode=${details?.deliveryAddress?.countryCode}&orderedProduct=${details?.productDetail?.orderedProduct}`,\r\n )\r\n .then((res) => {\r\n if (res.data[0]?.customsLevel === DASHBOARD_SUMMARY.SET_CUSTOM_LEVEL) {\r\n setFullCustom(true);\r\n }\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n };\r\n\r\n const goToAmmendPage = () => {\r\n history.push(`/shipment/addShipment/${list?.shipmentNumber}`);\r\n };\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {!isDomestic &&\r\n (fullCustom ? (\r\n \r\n \r\n }\r\n onClick={getCustomsDetails}\r\n isDisabled={showCustomDetails}\r\n style={{ color: '#000000 !important' }}\r\n />\r\n \r\n \r\n \r\n ) : (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n\r\n \r\n \r\n >\r\n ))}\r\n {showCustomDetails && (\r\n <>\r\n \r\n \r\n \r\n >\r\n )}\r\n\r\n {/* To view Clearance Declaration details for Domestic*/}\r\n {isDomestic && list?.clearanceDeclaration && (\r\n <>\r\n \r\n \r\n }\r\n onClick={getClearanceDeclarationDetails(\r\n id,\r\n setClearanceDeclarationDetails,\r\n setShowClearanceDeclarationDetails,\r\n dispatch,\r\n )}\r\n isDisabled={showClearanceDeclarationDetails}\r\n />\r\n \r\n \r\n {showClearanceDeclarationDetails && (\r\n \r\n \r\n \r\n )}\r\n >\r\n )}\r\n \r\n\r\n \r\n \r\n backToBookedCollection()}\r\n />\r\n \r\n {list?.destinationCountry?.toLowerCase() === \"united kingdom\" \r\n && !(list?.deliveryOptions?.exchangeOnDelivery) \r\n && !(list?.customsLevel === CLERANCE_DECLARATION.FULL) && (\r\n \r\n {\r\n goToAmmendPage();\r\n }}\r\n />\r\n \r\n )}\r\n \r\n \r\n \r\n \r\n setshowPrintDialog(true)}\r\n buttonType=\"submit\"\r\n label=\"Reprint\"\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n }\r\n label=\"Label\"\r\n />\r\n \r\n \r\n \r\n }\r\n label=\"Customs Invoice\"\r\n />\r\n \r\n \r\n Customs invoice will be printed only if applicable for a shipment \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n userDetails: state.auth.userDetails,\r\n JSPMStatus: state.common.isJSPMInstalled,\r\n printerConfiguration: state.common.printerConfiguration,\r\n availablePrinter: state.common.availablePrinter,\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, null)(ShipmentSummary);\r\n","import React, { useState, useEffect } from 'react';\r\nimport { Grid, makeStyles, Typography } from '@material-ui/core';\r\nimport CustomCaption from '../../../../framework/summaryFormate/CustomCaption';\r\n\r\nconst useStyles = makeStyles({\r\n flexContainer: {\r\n flexGrow: 1,\r\n flexShrink: 1,\r\n flexBasis: 0,\r\n },\r\n parcelHandover: {\r\n paddingBottom: '20px',\r\n },\r\n});\r\n\r\nconst ParcelAddShipment = ({ shipmentDetails }) => {\r\n const classes = useStyles();\r\n\r\n return (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {/* \r\n \r\n \r\n \r\n \r\n */}\r\n {/* \r\n \r\n */}\r\n {/* \r\n \r\n */}\r\n \r\n \r\n \r\n \r\n >\r\n );\r\n};\r\n\r\nexport default ParcelAddShipment;\r\n","import React, {useState, useEffect} from 'react'\r\nimport { Grid, makeStyles, Typography} from '@material-ui/core';\r\nimport CustomCaption from '../../../../framework/summaryFormate/CustomCaption';\r\n\r\nconst useStyles = makeStyles({\r\n flexContainer: {\r\n flexGrow: 1, \r\n flexShrink: 1,\r\n flexBasis: 0,\r\n },\r\n parcelHandover:{\r\n paddingBottom:'20px',\r\n },\r\n});\r\n\r\nconst ProductInternational = ({shipmentDetails}) => {\r\n const classes = useStyles();\r\n return (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n >\r\n )\r\n}\r\n\r\nexport default ProductInternational\r\n","import React, { useState, useEffect } from 'react';\r\nimport { Grid, makeStyles, Typography } from '@material-ui/core';\r\nimport CustomCaption from '../../../../framework/summaryFormate/CustomCaption';\r\nimport ReadOnlyCheckbox from '../../../../framework/readOnlyCheckbox/ReadOnlyCheckbox';\r\n\r\nconst useStyles = makeStyles({\r\n flexContainer: {\r\n flexGrow: 1,\r\n flexShrink: 1,\r\n flexBasis: 0,\r\n },\r\n parcelHandover: {\r\n paddingBottom: '20px',\r\n },\r\n});\r\n\r\nconst MoreInfoSummary = ({ shipmentDetails }) => {\r\n const classes = useStyles();\r\n const [state, setstate] = useState(false);\r\n\r\n useEffect(() => {\r\n setstate((shipmentDetails || {}).inboxReturnLabel);\r\n }, [shipmentDetails]);\r\n\r\n return (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {shipmentDetails?.accountNumber?.returnConfiguration?.inboxReturnAllowed &&\r\n shipmentDetails?.product?.deliveryCapabilities?.inBoxReturn ? (\r\n <>\r\n \r\n {state === \"false\" ?\r\n (\r\n \r\n ) :\r\n (\r\n \r\n )\r\n }\r\n \r\n \r\n \r\n \r\n >\r\n ) : null}\r\n\r\n \r\n \r\n \r\n \r\n >\r\n );\r\n};\r\n\r\nexport default MoreInfoSummary;\r\n","import React, { useEffect, useState } from 'react';\r\nimport { Grid, makeStyles, Typography } from '@material-ui/core';\r\nimport CustomCaption from '../../../../framework/summaryFormate/CustomCaption';\r\nimport CommodityDetailsSummary from './CommodityDetailsSummary';\r\nimport { formatDate } from '../../../../utils/helperFunctions';\r\n\r\nconst useStyles = makeStyles({\r\n flexContainer: {\r\n flexGrow: 1,\r\n flexShrink: 1,\r\n flexBasis: 0,\r\n },\r\n rowDiff: {\r\n marginTop: '5px',\r\n marginBottom: '10px',\r\n },\r\n});\r\n\r\nconst CustomsDeclarationSummary = ({ shipmentDetails }) => {\r\n const classes = useStyles();\r\n const [iossFieldName, setiossFieldName] = useState('');\r\n const [iossFieldvalue, setiossFieldvalue] = useState('');\r\n useEffect(() => {\r\n if (!shipmentDetails.applyIossNumber) {\r\n setiossFieldName(\"Shipper's IOSS number\");\r\n setiossFieldvalue('-');\r\n } else if (shipmentDetails.iossType === 'shippersNo') {\r\n setiossFieldName(\"Shipper's IOSS number\");\r\n setiossFieldvalue(shipmentDetails.iossNumber);\r\n } else if (shipmentDetails.iossType === 'marketNo') {\r\n setiossFieldName('Marketplace IOSS number');\r\n setiossFieldvalue(shipmentDetails.marketplaceIossNo);\r\n } else if (shipmentDetails.iossType === 'dhlIossNo') {\r\n setiossFieldName('DHL IOSS number');\r\n setiossFieldvalue(shipmentDetails.iossNumber);\r\n } else {\r\n setiossFieldName(\"Shipper's IOSS number\");\r\n setiossFieldvalue('-');\r\n }\r\n }, [shipmentDetails]);\r\n return (\r\n \r\n \r\n \r\n \r\n {(shipmentDetails || {}).invoiceTypeLabel !== ''\r\n ? `Invoice type: ${(shipmentDetails || {}).invoiceTypeLabel}`\r\n : null}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {shipmentDetails.applyIossNumber === 'true' && (\r\n \r\n \r\n \r\n )}\r\n {/* */}\r\n \r\n \r\n \r\n );\r\n};\r\n\r\nexport default CustomsDeclarationSummary;\r\n","import React, { useEffect, useState } from 'react';\r\nimport { Box, Grid, makeStyles, Typography } from '@material-ui/core';\r\nimport { useHistory } from 'react-router-dom';\r\n\r\nimport CustomHeader from '../../../../framework/summaryFormate/CustomHeader';\r\nimport AddressFormate from '../../../../framework/addressFormate/AddressFormate';\r\nimport InputButton from '../../../../framework/Inputs/inputButton/inputButton';\r\nimport ParcelAddShipment from './ParcelAddShipment';\r\nimport ProductInternational from './ProductInternational';\r\nimport MoreInfoSummary from './MoreInfoSummary';\r\nimport CustomsDeclarationSummary from './CustomsDeclarationSummary';\r\nimport ReadOnlyCheckbox from '../../../../framework/readOnlyCheckbox/ReadOnlyCheckbox';\r\nimport CustomCaption from '../../../../framework/summaryFormate/CustomCaption';\r\n\r\nconst useStyles = makeStyles({\r\n boxContainer: {\r\n '& :last-child': {\r\n borderBottom: 'unset',\r\n },\r\n },\r\n});\r\n\r\nconst InternationalSummary = ({ shipmentDetails }) => {\r\n const classes = useStyles();\r\n let history = useHistory();\r\n const [state, setstate] = useState(false);\r\n\r\n useEffect(() => {\r\n setstate((shipmentDetails || {}).addToAddressBook || (shipmentDetails || {}).addToFavCutomerList);\r\n }, [shipmentDetails]);\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {shipmentDetails.isFullCustomDetails\r\n ? (\r\n \r\n )\r\n : (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n\r\n \r\n \r\n >\r\n )}\r\n \r\n\r\n {/* \r\n \r\n */}\r\n \r\n \r\n \r\n history.push({ pathname: history.location.state.prevPath, state: { ...history.location.state, fromPreview: true } })} />\r\n \r\n \r\n \r\n );\r\n};\r\n\r\nexport default InternationalSummary;\r\n","import React from 'react';\r\nimport { Grid, Typography } from '@material-ui/core';\r\nimport CustomCaption from '../../../../framework/summaryFormate/CustomCaption';\r\n\r\nconst ProductAndServiceSummary = ({ shipmentDetails }) => {\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nexport default ProductAndServiceSummary;\r\n","import React, { useState, useEffect } from 'react';\r\nimport { Grid, makeStyles, Typography } from '@material-ui/core';\r\nimport CustomCaption from '../../../../framework/summaryFormate/CustomCaption';\r\nimport ReadOnlyCheckbox from '../../../../framework/readOnlyCheckbox/ReadOnlyCheckbox';\r\nimport { formatDate } from '../../../../../src/utils/helperFunctions';\r\n\r\nconst useStyles = makeStyles({\r\n flexContainer: {\r\n flexGrow: 1,\r\n flexShrink: 1,\r\n flexBasis: 0,\r\n },\r\n parcelHandover: {\r\n paddingBottom: '20px',\r\n },\r\n});\r\n\r\nconst DetailsSummary = ({ shipmentDetails }) => {\r\n const classes = useStyles();\r\n const [state, setstate] = useState(false);\r\n\r\n const pieceslength = () => {\r\n if ((shipmentDetails.parcelDetails || []).length > 0) {\r\n setstate(true);\r\n } else {\r\n setstate(false);\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n pieceslength();\r\n }, [shipmentDetails]);\r\n\r\n return (\r\n <>\r\n \r\n \r\n {(shipmentDetails || {}).handOverMethod !== ''\r\n ? `Parcel handover method: ${shipmentDetails?.handOverMethod === 'driverCollection'\r\n ? 'Driver collection'\r\n : 'Drop off at Service Point'\r\n }`\r\n : null}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {shipmentDetails.createPalletShipment===\"yes\"?\r\n \r\n :\r\n \r\n \r\n }\r\n \r\n \r\n \r\n {/* \r\n \r\n */}\r\n \r\n \r\n \r\n \r\n >\r\n );\r\n};\r\n\r\nexport default DetailsSummary;\r\n","import React from 'react'\r\nimport ReadOnlyCheckbox from '../../../../framework/readOnlyCheckbox/ReadOnlyCheckbox'\r\nimport CustomCaption from '../../../../framework/summaryFormate/CustomCaption'\r\nimport { Grid, Typography, makeStyles } from '@material-ui/core'\r\n\r\nconst useStyles = makeStyles({\r\n flexContainer: {\r\n flexGrow: 1,\r\n flexShrink: 1,\r\n flexBasis: 0,\r\n },\r\n});\r\n\r\n\r\nconst AddShipmentAdditionalInfo = ({ shipmentDetails }) => {\r\n const classes = useStyles();\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {/* Delivery notification\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n */}\r\n\r\n \r\n \r\n \r\n )\r\n}\r\n\r\nexport default AddShipmentAdditionalInfo\r\n","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, makeStyles, Typography } from '@material-ui/core';\r\nimport CustomCaption from '../../../../framework/summaryFormate/CustomCaption';\r\nimport CommodityDetailsSummary from '../../../../container/shipment/addShipment/addShipmentSummary/CommodityDetailsSummary';\r\nimport { CLERANCE_DECLARATION } from '../../../../utils/constants/constants';\r\n\r\nconst useStyles = makeStyles({\r\n flexContainer: {\r\n flexGrow: 1,\r\n flexShrink: 1,\r\n flexBasis: 0,\r\n paddingLeft: '10px',\r\n },\r\n rowDiff: {\r\n marginTop: '5px',\r\n marginBottom: '10px',\r\n },\r\n});\r\n\r\nconst ClearanceDeclarationSummary = ({ shipmentData }) => {\r\n const {\r\n shipmentMovement: { name: shipmentMovement } = {},\r\n descriptionOfGoods,\r\n clearanceTotalValue,\r\n receipentUKIMS,\r\n receipentEORI,\r\n shipperEORI,\r\n shipperUKIMS,\r\n shippingCharges,\r\n reasonForExport,\r\n shipperDeferment,\r\n } = shipmentData || {};\r\n const classes = useStyles();\r\n const [commodityDetails, setCommodityDetails] = useState({});\r\n const CustomGridItem = ({ title, value }) => (\r\n \r\n \r\n \r\n );\r\n\r\n /**\r\n * Method to parse the commodity details\r\n * @returns - object\r\n */\r\n const parseCommodityDetails = () => {\r\n return shipmentData?.commodityDetails?.map((commodity) => {\r\n return {\r\n ...commodity,\r\n commodityCode: commodity?.commodityCode,\r\n fullDescriptionOfGoods: commodity.fullDescriptionOfGoods,\r\n weight: commodity?.unitWeight,\r\n unitValue: commodity?.unitValue,\r\n quantity: commodity?.quantity,\r\n countryOfOrigin: {\r\n code: commodity?.countryOfOrigin.code,\r\n },\r\n };\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n const newCommodityDetails = {\r\n commodityDetails: parseCommodityDetails(),\r\n };\r\n setCommodityDetails(newCommodityDetails);\r\n }, [shipmentData]);\r\n\r\n return (\r\n \r\n \r\n \r\n {CLERANCE_DECLARATION.SHIPMENT_MOVEMENT_TYPE} {shipmentMovement ?? '-'}\r\n \r\n \r\n\r\n {shipmentMovement === CLERANCE_DECLARATION.MOVEMENT_TYPE_C2C && (\r\n <>\r\n \r\n \r\n >\r\n )}\r\n\r\n {shipmentMovement === CLERANCE_DECLARATION.MOVEMENT_TYPE_C2B && (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n )}\r\n\r\n {shipmentMovement === CLERANCE_DECLARATION.MOVEMENT_TYPE_B2B && (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n )}\r\n\r\n {shipmentMovement === CLERANCE_DECLARATION.MOVEMENT_TYPE_B2C && (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n )}\r\n\r\n {shipmentMovement !== CLERANCE_DECLARATION.MOVEMENT_TYPE_C2C && (\r\n \r\n \r\n \r\n )}\r\n\r\n {shipmentMovement === CLERANCE_DECLARATION.MOVEMENT_TYPE_B2B && !shipperUKIMS && (\r\n <>\r\n \r\n \r\n \r\n >\r\n )}\r\n \r\n );\r\n};\r\n\r\nClearanceDeclarationSummary.propTypes = {\r\n shipmentData: PropTypes.object.isRequired,\r\n};\r\n\r\nexport default ClearanceDeclarationSummary;\r\n","import React from 'react';\r\nimport { Grid, Box, Typography, makeStyles } from '@material-ui/core';\r\nimport { useHistory } from 'react-router-dom';\r\nimport AddressFormate from '../../../../framework/addressFormate/AddressFormate';\r\nimport CustomCaption from '../../../../framework/summaryFormate/CustomCaption';\r\nimport CustomHeader from '../../../../framework/summaryFormate/CustomHeader';\r\nimport InputButton from '../../../../framework/Inputs/inputButton/inputButton';\r\nimport ProductAndServiceSummary from './ProductAndServiceSummary';\r\nimport DetailsSummary from './DetailsSummary';\r\nimport AddShipmentAdditionalInfo from './AddShipmentAdditionalInfo';\r\n// import { useSelector } from 'react-redux';\r\nimport { doorStepInstructionOptions } from '../../../../utils/constants/constants';\r\nimport CustomsDeclarationSummary from './CustomsDeclarationSummary';\r\nimport ClearanceDeclarationSummary from './ClearanceDeclarationSummary'\r\n\r\nconst useStyles = makeStyles({\r\n boxContainer: {\r\n '& :last-child': {\r\n borderBottom: 'unset',\r\n },\r\n },\r\n});\r\n\r\nconst DomesticSummary = ({ shipmentDetails }) => {\r\n const classes = useStyles();\r\n let history = useHistory();\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {shipmentDetails.deliveryType === 'deliverToDoorStep' ? (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {shipmentDetails.doorStepInstructions.value === doorStepInstructionOptions[0].value && (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n )}\r\n {shipmentDetails.doorStepInstructions.value === doorStepInstructionOptions[1].value && (\r\n <>\r\n {shipmentDetails.exchange === 'no' ? (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n {shipmentDetails.createPalletShipment !== 'yes' && (\r\n \r\n \r\n \r\n )}\r\n >\r\n ) : (\r\n <>\r\n \r\n \r\n \r\n {shipmentDetails.createPalletShipment !== 'yes' && (\r\n \r\n \r\n \r\n )}\r\n >\r\n )}\r\n >\r\n )}\r\n {shipmentDetails.doorStepInstructions.value === doorStepInstructionOptions[2].value && (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n )}\r\n \r\n ) : (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {shipmentDetails?.accountNumber?.returnConfiguration?.inboxReturnAllowed &&\r\n shipmentDetails?.product?.deliveryCapabilities?.inBoxReturn ? (\r\n \r\n \r\n \r\n \r\n {shipmentDetails.inboxReturnLabel !== ''\r\n ? `Include inbox return label: ${shipmentDetails.inboxReturnLabel === 'true' ? 'Yes' : 'No'}`\r\n : null}\r\n \r\n \r\n \r\n \r\n {shipmentDetails.returnReference !== '' && shipmentDetails.returnReference !== undefined\r\n ? `Return reference : ${shipmentDetails.returnReference}`\r\n : null}\r\n \r\n \r\n \r\n \r\n \r\n ) : null}\r\n \r\n {shipmentDetails && shipmentDetails?.shipmentMovement && (\r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n \r\n history.push({\r\n pathname: history.location.state.prevPath,\r\n state: { ...history.location.state, fromPreview: true },\r\n })\r\n }\r\n />\r\n \r\n \r\n \r\n );\r\n};\r\n\r\nexport default DomesticSummary;\r\n","import React, { useEffect } from 'react';\r\nimport InternationalSummary from './InternationalSummary';\r\nimport { useDispatch, useSelector } from 'react-redux';\r\nimport DomesticSummary from './DomesticSummary';\r\nimport * as actions from '../../../../store/actions/index';\r\n\r\nconst AddShipmentSummary = () => {\r\n const shipmentDetails = useSelector((state) => state.addShipmentData.shipmentDetails);\r\n const isDomestic = (shipmentDetails.destinationCountry || {}).code === 'GBR';\r\n const dispatch = useDispatch();\r\n\r\n useEffect(() => {\r\n return () => {\r\n dispatch(actions.setLoadedFrom({ loadedFrom: 'fromPreviewSummary', loadedResponse: shipmentDetails }));\r\n };\r\n }, []);\r\n\r\n return (\r\n \r\n {isDomestic\r\n? (\r\n \r\n )\r\n: (\r\n \r\n )}\r\n
\r\n );\r\n};\r\n\r\nexport default AddShipmentSummary;\r\n","import { deliveryStatusForDashboard } from '../../constants/constants';\r\n\r\nconst dashboardForm = {\r\n formId: 'dashboardForm',\r\n formField: {\r\n accounts: {\r\n props: {\r\n name: 'accounts',\r\n label: 'Select account',\r\n type: 'multiSelect',\r\n displayField: 'displayName',\r\n _className: \"dashBoard-account-selectBox\",\r\n isRequired: true,\r\n hasDefaultValue: false\r\n },\r\n value: [],\r\n validation: {\r\n name: 'accounts',\r\n validationType: 'array',\r\n validations: [\r\n {\r\n type: 'min',\r\n params: [1, 'Select an account to view the data'],\r\n },\r\n ],\r\n },\r\n },\r\n internationalAccounts: {\r\n props: {\r\n name: 'internationalAccounts',\r\n label: 'Select account',\r\n type: 'multiSelect',\r\n displayField: 'accountId',\r\n isRequired: true,\r\n hasDefaultValue: false\r\n },\r\n value: [],\r\n validation: {\r\n name: 'internationalAccounts',\r\n validationType: 'array',\r\n validations: [\r\n {\r\n type: 'min',\r\n params: [1, 'Select an account to view the data'],\r\n },\r\n ],\r\n },\r\n },\r\n deliveryStatusForAccounts: {\r\n props: {\r\n name: 'deliveryStatusForAccounts',\r\n label: 'Select delivery status',\r\n type: 'select',\r\n isRequired: true,\r\n displayField: 'name',\r\n hasDefaultValue: true,\r\n },\r\n value: deliveryStatusForDashboard[0],\r\n },\r\n dashboardSearchBy: {\r\n props: {\r\n name: 'dashboardSearchFor',\r\n type: 'searchControl',\r\n },\r\n selectProps: {\r\n props: {\r\n name: 'dashboardSearchBy',\r\n label: 'Search For',\r\n placeholder: \"Enter Customer's ref.no\",\r\n },\r\n },\r\n textProps: {\r\n props: {\r\n name: 'dashboardSearchFor',\r\n label: 'Search For',\r\n placeholder: \"Enter Customer's ref.no\",\r\n },\r\n },\r\n validation: {\r\n name: 'dashboardSearchFor',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'dashboardSearchBy',\r\n (dashboardSearchBy, schema) => {\r\n if (dashboardSearchBy) {\r\n return dashboardSearchBy.value === 'recipientName'\r\n ? schema.matches(/[a-zA-Z]+([\\s][a-zA-Z]+)*/, 'Recipient name must be alphabets')\r\n : dashboardSearchBy.value === 'telephoneNumber'\r\n ? schema.matches(/^[0-9,(,),+,\\-,.,[,\\] ].{9,35}/, 'Telephone number is invalid')\r\n : schema;\r\n }\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n selectdateRange: {\r\n props: {\r\n name: 'selectdateRange',\r\n label: 'Date range',\r\n type: 'date',\r\n },\r\n },\r\n collectionDate: {\r\n props: {\r\n name: 'collectionDate',\r\n label: 'Collection Date',\r\n type: 'date',\r\n },\r\n },\r\n domesticProduct: {\r\n props: {\r\n name: 'domesticProduct',\r\n label: 'Product',\r\n type: 'select',\r\n displayField: 'name',\r\n },\r\n },\r\n domesticService: {\r\n props: {\r\n name: 'domesticService',\r\n label: 'Service',\r\n type: 'select',\r\n displayField: 'serviceName',\r\n },\r\n },\r\n internationalCountry: {\r\n props: {\r\n name: 'internationalCountry',\r\n label: 'Country',\r\n type: 'select',\r\n displayField: 'name',\r\n },\r\n },\r\n internationalProduct: {\r\n props: {\r\n name: 'internationalProduct',\r\n label: 'Product',\r\n type: 'select',\r\n displayField: 'name',\r\n },\r\n },\r\n\r\n product: {\r\n props: {\r\n name: 'product',\r\n label: 'Product',\r\n type: 'select',\r\n displayField: 'productName',\r\n },\r\n },\r\n service: {\r\n props: {\r\n name: 'service',\r\n label: 'Service',\r\n type: 'select',\r\n displayField: 'name',\r\n isRequired: true,\r\n },\r\n validation: {\r\n name: 'service',\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'destinationCountry',\r\n (destinationCountry, schema) => {\r\n return (destinationCountry || {}).code === 'GBR'\r\n ? schema.required('Service name required')\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n fromCollectionDate: {\r\n props: {\r\n name: 'fromCollectionDate',\r\n type: 'date',\r\n },\r\n },\r\n toCollectionDate: {\r\n props: {\r\n name: 'toCollectionDate',\r\n type: 'date',\r\n },\r\n },\r\n isDomestic: {\r\n props: {\r\n name: 'isDomestic',\r\n type: 'checkbox',\r\n },\r\n value: true,\r\n },\r\n },\r\n};\r\n\r\nexport default dashboardForm;\r\n","/* eslint-disable no-restricted-globals */\r\n/* eslint-disable no-redeclare */\r\n/* eslint-disable no-unused-vars */\r\n/* eslint-disable no-undef */\r\n/* eslint-disable no-useless-concat */\r\nimport * as React from 'react';\r\nimport { Doughnut } from 'react-chartjs-2';\r\nimport './doughnut.scss';\r\nimport { startOfDay } from 'date-fns';\r\nimport { useHistory, withRouter } from 'react-router';\r\n\r\nimport * as actions from '../../store/actions/index';\r\nimport { connect } from 'react-redux';\r\nimport { getDefaultDashboardValues } from '../../utils/helperFunctions';\r\nimport { arrayValuesToQueryStringParam } from '../../utils/common';\r\nimport ReactHtmlParser from 'react-html-parser';\r\n\r\nChart.pluginService.register({\r\n beforeDraw: function (chart) {\r\n if (chart.config.options.elements.center) {\r\n // Get ctx from string\r\n var ctx = chart.chart.ctx;\r\n\r\n // Get options from the center object in options\r\n var centerConfig = chart.config.options.elements.center;\r\n var fontStyle = centerConfig.fontStyle || 'Arial';\r\n var txt = centerConfig.text;\r\n var color = '#000';\r\n var maxFontSize = centerConfig.maxFontSize || 75;\r\n var sidePadding = centerConfig.sidePadding || 20;\r\n var sidePaddingCalculated = (sidePadding / 100) * (chart.innerRadius * 2);\r\n // Start with a base font of 30px\r\n ctx.font = '17px ' + fontStyle;\r\n // Get the width of the string and also the width of the element minus 10 to give it 5px side padding\r\n var stringWidth = ctx.measureText(txt).width;\r\n var elementWidth = chart.innerRadius * 2 - sidePaddingCalculated;\r\n\r\n // Find out how much the font can grow in width.\r\n var widthRatio = elementWidth / stringWidth;\r\n var newFontSize = Math.floor(30 * widthRatio);\r\n var elementHeight = chart.innerRadius * 2;\r\n\r\n // Pick a new font size so it will not be larger than the height of label.\r\n var fontSizeToUse = Math.min(newFontSize, elementHeight, maxFontSize);\r\n var minFontSize = centerConfig.minFontSize;\r\n var lineHeight = centerConfig.lineHeight || 25;\r\n var wrapText = false;\r\n\r\n if (minFontSize === undefined) {\r\n minFontSize = 20;\r\n }\r\n\r\n if (minFontSize && fontSizeToUse < minFontSize) {\r\n fontSizeToUse = minFontSize;\r\n wrapText = true;\r\n }\r\n\r\n // Set font settings to draw it correctly.\r\n ctx.textAlign = 'center';\r\n ctx.textBaseline = 'middle';\r\n var centerX = (chart.chartArea.left + chart.chartArea.right) / 2;\r\n var centerY = (chart.chartArea.top + chart.chartArea.bottom) / 2;\r\n ctx.font = fontSizeToUse + 'px ' + fontStyle;\r\n ctx.fillStyle = color;\r\n\r\n if (!wrapText) {\r\n ctx.fillText(txt, centerX, centerY);\r\n return;\r\n }\r\n\r\n var words = txt.split(' ');\r\n var line = '';\r\n var lines = [];\r\n // Break words up into multiple lines if necessary\r\n for (var n = 0; n < words.length; n++) {\r\n var testLine = line + words[n] + ' ';\r\n var metrics = ctx.measureText(testLine);\r\n var testWidth = metrics.width;\r\n if (testWidth > elementWidth && n > 0) {\r\n lines.push(line);\r\n line = words[n] + ' ';\r\n } else {\r\n line = testLine;\r\n }\r\n }\r\n\r\n // Move the center up depending on line height and number of lines\r\n centerY -= (lines.length / 2) * lineHeight;\r\n\r\n for (var n = 0; n < lines.length; n++) {\r\n ctx.fillText(lines[n], centerX, centerY);\r\n centerY += lineHeight;\r\n }\r\n //Draw text in center\r\n ctx.fillText(line, centerX, centerY);\r\n }\r\n },\r\n});\r\n\r\n// var statusForRouting=data.datasets.map((datas=>datas.labelss));\r\n\r\nexport const valueAsPercentage = (value, total) => `${(value / total) * 100}%`;\r\n\r\nclass DoughnutChart extends React.Component {\r\n myRef;\r\n\r\n constructor(props) {\r\n super(props);\r\n\r\n this.myRef = null;\r\n this.state = { legend: <>no legend> };\r\n\r\n this.createMarkup = this.createMarkup.bind(this);\r\n this.onClickFunc = this.onClickFunc.bind(this);\r\n }\r\n\r\n componentDidMount() {\r\n const leg = this.generateLegend();\r\n this.setState({ legend: leg });\r\n }\r\n\r\n setTextInputRef(element) {\r\n this.myRef = element;\r\n }\r\n\r\n generateLegend() {\r\n if (!this.myRef) return null;\r\n return this.myRef.chartInstance.generateLegend();\r\n }\r\n\r\n createMarkup() {\r\n return this.state.legend;\r\n }\r\n\r\n componentDidUpdate(prevProps, prevState) {\r\n if (prevProps.data !== this.props.data) {\r\n const leg = this.generateLegend();\r\n let listItemsCollection = document.getElementsByClassName('list-items');\r\n this.setState({ legend: leg } , ()=> {\r\n for(let i=0;i {this.onClickFunc(i)});\r\n }\r\n });\r\n }\r\n}\r\n\r\n onClickFunc = (index)=> {\r\n // let index = elems[0]._index;\r\n let label = this.props.data.datasets[0].label[index];\r\n this.props.dispatch({\r\n loadedFrom: 'onChartClick',\r\n loadedResponse: this.props.formikValues,\r\n dashboardQueryParams: getDefaultDashboardValues(this.props.formikValues) + '&status=' + label,\r\n accountsParams: arrayValuesToQueryStringParam(this.props.formikValues.accounts),\r\n tabIndex: this.props.tabIndex,\r\n products: this.props.productData,\r\n countries: this.props.countries,\r\n services: this.props.serviceData,\r\n status:label,\r\n });\r\n this.props.history.push('/dashboard/dashboardDetailsSummary');\r\n }\r\n\r\n render() {\r\n let segment;\r\n return (\r\n \r\n
\r\n {this.props.text ? '' : 'No data available for current selection'}\r\n
\r\n
this.setTextInputRef(element)}\r\n data={this.props.data}\r\n onElementsClick={(elems, chart) => {\r\n if (elems && (elems || []).length > 0) {\r\n let index = elems[0]._index;\r\n let label = this.props.data.datasets[0].label[index];\r\n this.props.dispatch({\r\n loadedFrom: 'onChartClick',\r\n loadedResponse: this.props.formikValues,\r\n dashboardQueryParams: getDefaultDashboardValues(this.props.formikValues) + '&status=' + label,\r\n accountsParams: arrayValuesToQueryStringParam(this.props.formikValues.accounts),\r\n tabIndex: this.props.tabIndex,\r\n products: this.props.productData,\r\n countries: this.props.countries,\r\n services: this.props.serviceData,\r\n status:label,\r\n });\r\n this.props.history.push('/dashboard/dashboardDetailsSummary');\r\n }\r\n }}\r\n options={{\r\n showAllTooltips: true,\r\n tooltips: {\r\n mode: 'label',\r\n callbacks: {\r\n label: function (tooltipItem, data) {\r\n var dataset = data.datasets[tooltipItem.datasetIndex];\r\n return dataset.label[tooltipItem.index] + ':' + dataset.data[tooltipItem.index];\r\n },\r\n },\r\n },\r\n responsive: true,\r\n aspectRatio: 1,\r\n\r\n legend: {\r\n display: false,\r\n position: 'right',\r\n align: 'start',\r\n },\r\n //onHover: function (evt, elements) {\r\n // if (elements && elements.length) {\r\n // segment = elements[0];\r\n // this.chart.update();\r\n // let selectedIndex = segment['_index'];\r\n // segment._model.outerRadius += 10;\r\n // } else {\r\n // if (segment) {\r\n // segment._model.outerRadius -= 10;\r\n // }\r\n // segment = null;\r\n // }\r\n // },\r\n elements: {\r\n center: {\r\n text: `${this.props.text ? 'Total ' + this.props.text : ''}`,\r\n color: '#FF6384',\r\n minimumuFontSize: 30,\r\n maxFontSize: 24,\r\n sidePadding: 20,\r\n },\r\n },\r\n legendCallback: function (chart) {\r\n if (chart.config.data.datasets.length > 0) {\r\n var legendHtml = [];\r\n legendHtml.push('');\r\n legendHtml.push('
');\r\n var item = chart.config.data.datasets[0];\r\n for (var i = 0; i < item.data.length; i++) {\r\n legendHtml.push('');\r\n legendHtml.push(\r\n ' ',\r\n );\r\n // legendHtml.push('' + item.data[i] + ' person - '+chart.data.labels[i]+' times ');\r\n // legendHtml.push(`'' ${chart.data.labels[i].percentage}' ' ''${item.backgroundColor[i]} ' '''${chart.data.labels[i].lable} ' '`);\r\n legendHtml.push(`\r\n ${(chart.data.labels[i].percentage === 'NaN%')?'0.00%':chart.data.labels[i].percentage} \r\n \r\n
\r\n
${chart.data.labels[i].label} \r\n ${chart.data.labels[i].StatusCount}
\r\n `);\r\n legendHtml.push(' ');\r\n }\r\n\r\n legendHtml.push(' ');\r\n legendHtml.push('
');\r\n return legendHtml.join('');\r\n }\r\n },\r\n }}\r\n />\r\n\r\n {/*
*/}\r\n {ReactHtmlParser(this.createMarkup())}
\r\n \r\n );\r\n }\r\n}\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n dispatch: (data) => {\r\n dispatch(actions.setDashboardTracking(data));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(null, mapDispatchToProps)(withRouter(DoughnutChart));\r\n","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from \"react\";\n\nvar _ref2 = /*#__PURE__*/React.createElement(\"g\", {\n id: \"Icon_feather-arrow-left\",\n \"data-name\": \"Icon feather-arrow-left\",\n transform: \"translate(22.119 22.533) rotate(180)\",\n opacity: 0.6\n}, /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_42960\",\n \"data-name\": \"Path 42960\",\n d: \"M21.119,18H7.5\",\n transform: \"translate(0 -3.69)\",\n fill: \"none\",\n stroke: \"#000\",\n strokeLinecap: \"round\",\n strokeLinejoin: \"round\",\n strokeWidth: 2\n}), /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_42961\",\n \"data-name\": \"Path 42961\",\n d: \"M14.31,21.119,7.5,14.31,14.31,7.5\",\n transform: \"translate(0 0)\",\n fill: \"none\",\n stroke: \"#000\",\n strokeLinecap: \"round\",\n strokeLinejoin: \"round\",\n strokeWidth: 2\n}));\n\nfunction SvgArrowDetails(_ref, svgRef) {\n var title = _ref.title,\n titleId = _ref.titleId,\n props = _objectWithoutProperties(_ref, [\"title\", \"titleId\"]);\n\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 15.619,\n height: 16.448,\n viewBox: \"0 0 15.619 16.448\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, _ref2);\n}\n\nvar ForwardRef = /*#__PURE__*/React.forwardRef(SvgArrowDetails);\nexport default __webpack_public_path__ + \"static/media/arrow_details.99ba6e91.svg\";\nexport { ForwardRef as ReactComponent };","export default __webpack_public_path__ + \"static/media/pdfIcon.93f022bc.svg\";","/* eslint-disable react-hooks/exhaustive-deps */\r\n/* eslint-disable jsx-a11y/alt-text */\r\n/* eslint-disable no-unused-vars */\r\nimport React, { useEffect } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid } from '@material-ui/core';\r\nimport FormRenderer from '../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { fullSearchDashboardByOptions } from '../../../../utils/constants/constants';\r\nimport './findShipment.scss';\r\nimport { GET } from '../../../../api/axios';\r\nimport { ServiceEndPoints } from '../../../../utils/constants/ApiConstant';\r\nimport { useHistory } from 'react-router-dom';\r\nimport { arrayValuesToQueryStringParam } from '../../../../utils/common';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../../../store/actions/index';\r\nimport { getDefaultDashboardValues, getDefaultDashboardFindValues } from '../../../../utils/helperFunctions';\r\nimport { useSelector } from 'react-redux';\r\nconst FindShipment = (props) => {\r\n const {\r\n formField: { dashboardSearchBy, collectionDate },\r\n setFieldValue,\r\n formikValues,\r\n errors,\r\n userAccounts,\r\n tabIndex,\r\n products,\r\n services,\r\n countries,\r\n } = props;\r\n let history = useHistory();\r\n const dispatch = useDispatch();\r\n let dashboardFindShipment = useSelector((state) => state.dashboardTracking.dashboardFindShipment);\r\n\r\n const searchShipment = (event = null) => {\r\n event.preventDefault();\r\n let searchedValue = props.formikValues.dashboardSearchFor.trim();\r\n let searchedParams = props.formikValues.dashboardSearchBy.value;\r\n let accountsValue = '';\r\n accountsValue = arrayValuesToQueryStringParam(formikValues.accounts);\r\n\r\n const isCollectionDatesReq = searchedParams === 'dispatchDate';\r\n if (isCollectionDatesReq) {\r\n searchedParams = '';\r\n searchedParams += `fromCollectionDate=${searchedValue}`;\r\n searchedParams += `&toCollectionDate=${searchedValue}`;\r\n }\r\n let url = '';\r\n let _temp_userAccounts = [];\r\n userAccounts.map((element) => {\r\n _temp_userAccounts.push(element.accountId);\r\n });\r\n if (isCollectionDatesReq) {\r\n url = `${ServiceEndPoints.getShipmentDashboard}?${getDefaultDashboardFindValues(\r\n formikValues,\r\n _temp_userAccounts,\r\n true,\r\n false,\r\n )}${searchedParams}`;\r\n } else {\r\n url = `${ServiceEndPoints.getShipmentDashboard}?${getDefaultDashboardFindValues(\r\n formikValues,\r\n _temp_userAccounts,\r\n false,\r\n false,\r\n )}${searchedParams}=${searchedValue}`;\r\n }\r\n url = `${url}&offset=0&limit=10`;\r\n GET(url)\r\n .then((res) => {\r\n if ((((res || {}).data || {}).shipmentModels || []).length === 1) {\r\n history.push(`/dashboard/Tracking?id=${res.data.shipmentModels[0].shipmentId}`);\r\n } else {\r\n // dispatch(actions.setDashboardTracking({ loadedFrom: 'findshipment', loadedResponse: formikValues }));\r\n dispatch(\r\n actions.setDashboardTracking({\r\n loadedFrom: 'findshipment',\r\n loadedResponse: formikValues,\r\n userAccounts: _temp_userAccounts,\r\n dashboardQueryParams: isCollectionDatesReq\r\n ? `${getDefaultDashboardFindValues(\r\n formikValues,\r\n _temp_userAccounts,\r\n true,\r\n // false,\r\n )}${searchedParams}`\r\n : `${getDefaultDashboardFindValues(\r\n formikValues,\r\n _temp_userAccounts,\r\n false,\r\n // false,\r\n )}${searchedParams}=${searchedValue}`,\r\n accountsParams: arrayValuesToQueryStringParam(formikValues.accounts),\r\n tabIndex,\r\n products,\r\n countries,\r\n services,\r\n }),\r\n );\r\n history.push('/dashboard/dashboardDetailsBreakdown');\r\n }\r\n })\r\n .catch((err) => {\r\n alert('Shipment not found');\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n // need to change hard coded index values\r\n if (\r\n formikValues.dashboardSearchBy &&\r\n (formikValues.dashboardSearchBy.value === fullSearchDashboardByOptions[8].value ||\r\n formikValues.dashboardSearchBy.value === fullSearchDashboardByOptions[9].value)\r\n ) {\r\n setFieldValue('dashboardSearchFor', new Date().toISOString()\r\n.slice(0, 10));\r\n } else {\r\n setFieldValue('dashboardSearchFor', '');\r\n }\r\n if (props.formikValues.dashboardSearchBy) {\r\n dispatch(\r\n actions.setDashboardFindShipment(\r\n props.formikValues.dashboardSearchBy\r\n ))\r\n }\r\n else if (dashboardFindShipment) {\r\n dispatch(\r\n actions.setDashboardFindShipment(\r\n dashboardFindShipment\r\n ))\r\n } else {\r\n dispatch(\r\n actions.setDashboardFindShipment(\r\n fullSearchDashboardByOptions[0]\r\n ))\r\n }\r\n }, [formikValues.dashboardSearchBy]);\r\n\r\n useEffect(() => {\r\n if (dashboardFindShipment) {\r\n setTimeout(() => {\r\n setFieldValue('dashboardSearchBy', dashboardFindShipment)\r\n }, 1000);\r\n } else {\r\n setFieldValue('dashboardSearchBy', fullSearchDashboardByOptions[0])\r\n }\r\n }, [dashboardFindShipment]);\r\n\r\n return (\r\n \r\n \r\n Find shipment\r\n \r\n \r\n searchShipment(event, '')}\r\n isIconDisabled={\r\n errors.dashboardSearchFor ||\r\n // formikValues.accounts.length === 0 ||\r\n formikValues.dashboardSearchFor.trim() === ''\r\n }\r\n {...dashboardSearchBy.props}\r\n />\r\n \r\n {/* {(props.formikValues.dashboardSearchBy && props.formikValues.dashboardSearchBy.value === \"dispatchdeliverydate\") &&\r\n \r\n } */}\r\n \r\n );\r\n};\r\n\r\nFindShipment.propTypes = {\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n setFieldValue: PropTypes.func,\r\n errors: PropTypes.object,\r\n};\r\n\r\nexport default FindShipment;\r\n","/* eslint-disable no-undef */\r\nimport React from 'react';\r\nimport { Bar } from 'react-chartjs-2';\r\nimport { useDispatch } from 'react-redux';\r\nimport { useHistory } from 'react-router';\r\nimport './barChart.scss';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { getDefaultDashboardValues } from '../../../utils/helperFunctions';\r\nimport DeliveryFont from '../../../assets/fonts/Delivery_W_Rg.woff';\r\nimport { arrayValuesToQueryStringParam } from '../../../utils/common';\r\n//./assets/fonts/Delivery_W_Rg.woff\r\n\r\nconst DeliveryTheme = {\r\n fontFamily: 'Delivery Regular',\r\n fontStyle: 'normal',\r\n src: `local('Delivery'),\r\n local('Delivery-Regular')\r\n url(${DeliveryFont}) format('woff')\r\n `,\r\n fontFamily: 'Delivery Light',\r\n fontStyle: 'normal',\r\n src: `local('Delivery'),\r\n local('Delivery_W_Lt')\r\n url(${DeliveryFont}) format('woff')\r\n `,\r\n};\r\n\r\nChart.pluginService.register({\r\n beforeDraw(chart) {\r\n if (chart.config.options.elements.center) {\r\n // Get ctx from string\r\n var ctx = chart.chart.ctx;\r\n\r\n // Get options from the center object in options\r\n var centerConfig = chart.config.options.elements.center;\r\n var fontStyle = centerConfig.fontStyle || 'Arial';\r\n var txt = centerConfig.text;\r\n var color = '#717171';\r\n var maxFontSize = centerConfig.maxFontSize || 75;\r\n var sidePadding = centerConfig.sidePadding || 20;\r\n var sidePaddingCalculated = (sidePadding / 100) * (chart.innerRadius * 2);\r\n // Start with a base font of 30px\r\n ctx.font = `17px ${fontStyle}`;\r\n\r\n // Get the width of the string and also the width of the element minus 10 to give it 5px side padding\r\n var stringWidth = ctx.measureText(txt).width;\r\n var elementWidth = chart.innerRadius * 2 - sidePaddingCalculated;\r\n\r\n // Find out how much the font can grow in width.\r\n var widthRatio = elementWidth / stringWidth;\r\n var newFontSize = Math.floor(30 * widthRatio);\r\n var elementHeight = chart.innerRadius * 2;\r\n\r\n // Pick a new font size so it will not be larger than the height of label.\r\n var fontSizeToUse = Math.min(newFontSize, elementHeight, maxFontSize);\r\n var minFontSize = centerConfig.minFontSize;\r\n var lineHeight = centerConfig.lineHeight || 25;\r\n var wrapText = false;\r\n\r\n if (minFontSize === undefined) {\r\n minFontSize = 20;\r\n }\r\n\r\n if (minFontSize && fontSizeToUse < minFontSize) {\r\n fontSizeToUse = minFontSize;\r\n wrapText = true;\r\n }\r\n\r\n // Set font settings to draw it correctly.\r\n ctx.textAlign = 'center';\r\n ctx.textBaseline = 'middle';\r\n var centerX = (chart.chartArea.left + chart.chartArea.right) / 2;\r\n var centerY = (chart.chartArea.top + chart.chartArea.bottom) / 2;\r\n ctx.font = `${fontSizeToUse}px ${fontStyle}`;\r\n ctx.fillStyle = color;\r\n\r\n if (!wrapText) {\r\n ctx.fillText(txt, centerX, centerY);\r\n return;\r\n }\r\n\r\n var words = txt.split(' ');\r\n var line = '';\r\n var lines = [];\r\n\r\n // Break words up into multiple lines if necessary\r\n for (var n = 0; n < words.length; n++) {\r\n var testLine = `${line + words[n]} `;\r\n var metrics = ctx.measureText(testLine);\r\n var testWidth = metrics.width;\r\n if (testWidth > elementWidth && n > 0) {\r\n lines.push(line);\r\n line = `${words[n]} `;\r\n } else {\r\n line = testLine;\r\n }\r\n }\r\n\r\n // Move the center up depending on line height and number of lines\r\n centerY -= (lines.length / 2) * lineHeight;\r\n\r\n for (var m = 0; m < lines.length; m++) {\r\n ctx.fillText(lines[m], centerX, centerY);\r\n centerY += lineHeight;\r\n }\r\n //Draw text in center\r\n ctx.fillText(line, centerX, centerY);\r\n }\r\n },\r\n});\r\n\r\nconst BarChartComponent = (props) => {\r\n const { labels, values, totalCount, formikValues, colors } = props;\r\n const history = useHistory();\r\n const dispatch = useDispatch();\r\n let segment;\r\n const data = {\r\n labels,\r\n datasets: [\r\n {\r\n showScale: false,\r\n data: values,\r\n barPercentage: 0.99,\r\n borderColor: colors,\r\n backgroundColor: colors,\r\n },\r\n ],\r\n };\r\n\r\n const options = {\r\n events: ['mousemove', 'mouseout', 'touchstart', 'touchmove'],\r\n tooltips: {\r\n displayColors: false,\r\n // backgroundColor: '#fff',\r\n titleFontColor: '#fff',\r\n // titleFontStyle:'inherit',\r\n // titleFontSize:'14',\r\n callbacks: {\r\n label: function (tooltipItem) {\r\n if (tooltipItem.yLabel === 1) {\r\n return Number(tooltipItem.yLabel) + ' Shipment';\r\n } else {\r\n return Number(tooltipItem.yLabel) + ' Shipments';\r\n }\r\n },\r\n labelTextColor: function (context) {\r\n return '#fff';\r\n },\r\n },\r\n },\r\n onHover(evt, elements) {\r\n if (elements && elements.length) {\r\n segment = elements[0];\r\n this.chart.update();\r\n let selectedIndex = segment['_index'];\r\n segment._model.outerRadius += 10;\r\n } else {\r\n if (segment) {\r\n segment._model.outerRadius -= 10;\r\n }\r\n segment = null;\r\n }\r\n },\r\n onClick: (e) => e.stopPropagation(),\r\n responsive: true,\r\n barRoundness: 0.3,\r\n legend: {\r\n display: false,\r\n },\r\n scaleShowLabels: false,\r\n title: {\r\n display: false,\r\n },\r\n maintainAspectRatio: false,\r\n layout: {\r\n padding: {\r\n left: 1,\r\n right: 2,\r\n top: 2,\r\n bottom: 0,\r\n },\r\n },\r\n scales: {\r\n yAxes: [\r\n {\r\n ticks: {\r\n min: 0,\r\n max: totalCount,\r\n stepSize: 1,\r\n padding: 20,\r\n fontFamily: 'Delivery Light',\r\n fontColor: '#717171',\r\n fontSize: 10,\r\n // minRotation: 0,\r\n },\r\n gridLines: {\r\n drawBorder: true,\r\n tickMarkLength: false,\r\n },\r\n },\r\n ],\r\n xAxes: [\r\n {\r\n maxBarThickness: 20,\r\n // barPercentage: 0.5\r\n ticks: {\r\n // autoSkip: false,\r\n // maxRotation: 0,\r\n // minRotation: 0,\r\n // maxTicksLimit: 20,\r\n // autoSkip: true,\r\n display: true,\r\n // autoSkipPadding: 15,\r\n fontFamily: 'Delivery Regular',\r\n fontColor: '#717171',\r\n fontSize: 12,\r\n maxRotation: 0,\r\n // precision: 2,\r\n // suggestedMin: 0,\r\n wordWrap: false,\r\n wordBreak: false,\r\n flexWrap: false,\r\n padding: 10,\r\n minRotation: 60,\r\n },\r\n time: {\r\n displayFormats: {\r\n millisecond: 'HH:mm:ss',\r\n second: 'HH:mm:ss',\r\n minute: 'HH:mm:ss',\r\n hour: 'HH:mm:ss',\r\n day: 'HH:mm:ss',\r\n week: 'HH:mm:ss',\r\n month: 'HH:mm:ss',\r\n quarter: 'HH:mm:ss',\r\n year: 'HH:mm:ss',\r\n },\r\n },\r\n gridLines: {\r\n // display: false,\r\n // drawBorder: true,\r\n // borderSkipped:'yes',\r\n tickMarkLength: 40,\r\n offsetGridLines: true,\r\n display: true,\r\n drawTicks: false,\r\n drawOnChartArea: false,\r\n },\r\n\r\n 'dataset.maxBarThickness': 5,\r\n },\r\n ],\r\n },\r\n };\r\n\r\n return (\r\n \r\n {\r\n if (elems && (elems || []).length > 0) {\r\n let filterUrl = '';\r\n let index = elems[0]._index;\r\n let label = labels[index];\r\n let labelProperty = 'status';\r\n if (formikValues.isDomestic && !formikValues.domesticService?.value) {\r\n labelProperty = 'service';\r\n } else if (!formikValues.isDomestic && !formikValues.product?.value) {\r\n labelProperty = 'product';\r\n }\r\n if (labelProperty === 'status' && formikValues?.domesticService?.value) {\r\n filterUrl = `${labelProperty}=${label}&product=${formikValues?.product?.productName}&service=${formikValues?.domesticService?.serviceName}`;\r\n } else if ((labelProperty === 'status' || labelProperty === 'service') && formikValues?.product?.value) {\r\n filterUrl = `${labelProperty}=${label}&product=${formikValues?.product?.productName}`;\r\n } else {\r\n filterUrl = `${labelProperty}=${label}`;\r\n }\r\n dispatch(\r\n actions.setDashboardTracking({\r\n loadedFrom: `onChartClick`,\r\n loadedResponse: formikValues,\r\n dashboardQueryParams: `${getDefaultDashboardValues(formikValues)}&${filterUrl}`,\r\n accountsParams: arrayValuesToQueryStringParam(formikValues.accounts),\r\n status:label\r\n }),\r\n );\r\n history.push('/dashboard/dashboardDetailsBreakdown');\r\n }\r\n }}\r\n options={options}\r\n />\r\n
\r\n );\r\n};\r\n\r\nexport default BarChartComponent;\r\n","/* eslint-disable react-hooks/exhaustive-deps */\r\nimport React, { useEffect, useState } from 'react';\r\nimport { Grid, SvgIcon } from '@material-ui/core';\r\nimport CustomAccordion from '../../../../framework/accordion/customAccordion';\r\nimport FormRenderer from '../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport BarChartComponent from '../../../../framework/charts/barChart/BarChartComponent';\r\nimport { abortOnGoingCallsFor, axiosConfig } from '../../../../api/axios';\r\nimport { useHistory } from 'react-router';\r\nimport { useDispatch } from 'react-redux';\r\nimport { setDropdownValues } from '../../../../utils/helperFunctions';\r\nimport InputButton from '../../../../framework/Inputs/inputButton/inputButton';\r\nimport { ReactComponent as ArrowDetails } from '../../../../assets/images/arrow_details.svg';\r\n\r\nimport { Link as RouterLink } from 'react-router-dom';\r\nimport { ServiceEndPoints } from '../../../../utils/constants/ApiConstant';\r\n\r\nimport * as actions from '../../../../store/actions/index';\r\nimport { getDefaultDashboardValues, getBackGroundColor } from '../../../../utils/helperFunctions';\r\nimport { useDebouncedCallback } from 'use-debounce/lib';\r\nimport { arrayValuesToQueryStringParam } from '../../../../utils/common';\r\n\r\nconst BreakDownDashboard = (props) => {\r\n const {\r\n formField: { product, domesticService },\r\n setFieldValue,\r\n formikValues,\r\n countries,\r\n setProductData,\r\n setServiceData,\r\n } = props;\r\n\r\n const history = useHistory();\r\n const dispatch = useDispatch();\r\n const [serviceName, setServiceName] = useState([]);\r\n const [serviceCount, setServiceCount] = useState([]);\r\n const [totalCountForDomestic, setTotalCountForDomestic] = useState(8);\r\n const [serviceColorsArray, setServiceColors] = useState([]);\r\n const [products, setProducts] = useState([]);\r\n const [services, setServices] = useState([]);\r\n\r\n useEffect(() => {\r\n if (formikValues.fromCollectionDate && formikValues.toCollectionDate && formikValues.accounts.length > 0) {\r\n getBreakdownValues();\r\n }\r\n }, [\r\n formikValues.accounts,\r\n formikValues.fromCollectionDate,\r\n formikValues.toCollectionDate,\r\n formikValues.isDomestic,\r\n formikValues.internationalCountry,\r\n countries,\r\n ]);\r\n\r\n const getBreakdownValues = useDebouncedCallback(() => {\r\n setServiceName([]);\r\n setServiceCount([]);\r\n setServiceColors([]);\r\n let url = `${ServiceEndPoints.getBreakDownDetails}breakdown?${getDefaultDashboardValues(\r\n formikValues,\r\n )}&${arrayValuesToQueryStringParam(formikValues.accounts)}`;\r\n abortOnGoingCallsFor(url);\r\n axiosConfig(url)\r\n .then((res) => {\r\n const rawProducts = [];\r\n rawProducts.unshift({ productName: 'Select', value: '' });\r\n res.data.shipmentByProducts.forEach((singleProduct) => {\r\n singleProduct.value = singleProduct?.productName?.replace(/ /g, '');\r\n rawProducts.push(singleProduct);\r\n });\r\n setProducts(rawProducts);\r\n setProductData(rawProducts);\r\n // setTimeout(() => {\r\n // }, 2000);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n setProducts([]);\r\n setServices([]);\r\n setServiceName([]);\r\n setServiceCount([]);\r\n setServiceColors([]);\r\n })\r\n .finally(()=> {\r\n dispatch(\r\n actions.setDashboardTracking({\r\n loadedFrom: 'detailView',\r\n loadedResponse: formikValues,\r\n dashboardQueryParams: getDefaultDashboardValues(formikValues),\r\n accountsParams: arrayValuesToQueryStringParam(formikValues.accounts),\r\n }),\r\n )});\r\n }, 400);\r\n\r\n useEffect(() => {\r\n const serviceNames = [];\r\n const serviceGraphValues = [];\r\n const serviceColorArray = [];\r\n const rawServices = [];\r\n if (formikValues.product && formikValues.isDomestic) {\r\n if (rawServices.length > 0) {\r\n rawServices.unshift({ serviceName: 'Select', value: '' });\r\n }\r\n setTotalCountForDomestic((formikValues.product || {}).totalCount || 8);\r\n ((formikValues.product || {}).shipmentByServices || []).forEach((service) => {\r\n service.value = service.serviceName.replace(/ /g, '');\r\n rawServices.push(service);\r\n serviceNames.push(service.serviceName);\r\n serviceGraphValues.push(service.totalCount);\r\n serviceColorArray.push(getBackGroundColor(service.serviceName));\r\n });\r\n } else if (!(formikValues.product || {}).value && !formikValues.isDomestic) {\r\n const slicedProducts = [...products].slice(1);\r\n let maxCount = 0;\r\n slicedProducts.forEach((product) => {\r\n serviceNames.push(product.productName);\r\n serviceGraphValues.push(product.totalCount);\r\n serviceColorArray.push(getBackGroundColor(product.productName));\r\n maxCount = product.totalCount > maxCount ? product.totalCount : maxCount;\r\n });\r\n setTotalCountForDomestic(maxCount);\r\n } else if ((formikValues.product || {}).value && !formikValues.isDomestic) {\r\n setTotalCountForDomestic((formikValues.product || {}).totalCount);\r\n ((formikValues.product || {}).shipmentByStatuses || []).forEach((status) => {\r\n serviceNames.push(status.status);\r\n serviceGraphValues.push(status.totalCount);\r\n serviceColorArray.push(getBackGroundColor(status.status));\r\n });\r\n }\r\n setServices(rawServices);\r\n setServiceName(serviceNames);\r\n setServiceCount(serviceGraphValues);\r\n setServiceColors(serviceColorArray);\r\n }, [formikValues.isDomestic, formikValues.product, products, formikValues.internationalCountry]);\r\n\r\n useEffect(() => {\r\n if (formikValues.isDomestic) {\r\n const parcelObj = setDropdownValues(products, 'value', 'Parcels');\r\n setFieldValue('product', parcelObj ? parcelObj : products[0]);\r\n } else {\r\n const parcelObj = setDropdownValues(products, 'value', '');\r\n setFieldValue('product', parcelObj ? parcelObj : products[0]);\r\n }\r\n const responseFormikValues = props.dashboardDetails.loadedResponse;\r\n if (\r\n props.dashboardDetails.loadedFrom === 'dashboardDetails' &&\r\n products.length > 0 &&\r\n responseFormikValues?.product\r\n ) {\r\n setFieldValue('product', setDropdownValues(products, 'value', (responseFormikValues.product || {}).value));\r\n }\r\n }, [products]);\r\n\r\n useEffect(() => {\r\n const responseFormikValues = props.dashboardDetails.loadedResponse;\r\n const serviceObj = setDropdownValues(services, 'serviceName', 'Select');\r\n setFieldValue('domesticService', serviceObj);\r\n if (\r\n props.dashboardDetails.loadedFrom === 'dashboardDetails' &&\r\n services.length > 0 &&\r\n responseFormikValues?.domesticService\r\n ) {\r\n setFieldValue(\r\n 'domesticService',\r\n setDropdownValues(services, 'value', responseFormikValues.domesticService.value),\r\n );\r\n }\r\n }, [services]);\r\n\r\n useEffect(() => {\r\n const labels = [];\r\n const serviceGraphValues = [];\r\n const serviceColorArray = [];\r\n if ((formikValues.domesticService || {}).value && formikValues.isDomestic) {\r\n setTotalCountForDomestic((formikValues.domesticService || {}).totalCount);\r\n ((formikValues.domesticService || {}).shipmentByStatuses || []).forEach((status) => {\r\n labels.push(status.status);\r\n serviceGraphValues.push(status.totalCount);\r\n serviceColorArray.push(getBackGroundColor(status.status));\r\n });\r\n } else if (formikValues.isDomestic && !(formikValues.domesticService || {}).value) {\r\n ((formikValues.product || {}).shipmentByServices || []).forEach((service) => {\r\n labels.push(service.serviceName);\r\n serviceGraphValues.push(service.totalCount);\r\n serviceColorArray.push(getBackGroundColor(service.serviceName));\r\n });\r\n setTotalCountForDomestic((formikValues.product || {}).totalCount || 8);\r\n }\r\n setServiceName(labels);\r\n setServiceCount(serviceGraphValues);\r\n setServiceColors(serviceColorArray);\r\n }, [formikValues.domesticService]);\r\n\r\n const dispatchingAction = () => {\r\n let breakDownQueryParams = formikValues.product\r\n ? formikValues.product?.productName !== undefined && formikValues.product?.productName?.toLowerCase() !== 'select'\r\n ? `&product=${formikValues.product?.productName}`\r\n : ''\r\n : '';\r\n if (formikValues.isDomestic) {\r\n breakDownQueryParams += formikValues.product?.productName\r\n ? formikValues.domesticService?.serviceName !== undefined &&\r\n formikValues.domesticService?.serviceName?.toLowerCase() !== 'select'\r\n ? `&service=${formikValues.domesticService?.serviceName}`\r\n : ''\r\n : '';\r\n }\r\n dispatch(\r\n actions.setDashboardTracking({\r\n loadedFrom: 'detailView',\r\n loadedResponse: formikValues,\r\n dashboardQueryParams: getDefaultDashboardValues(formikValues) + breakDownQueryParams,\r\n accountsParams: arrayValuesToQueryStringParam(formikValues.accounts),\r\n products: [...products].slice(1),\r\n countries,\r\n services: [...services].slice(1),\r\n }),\r\n );\r\n history.push('/dashboard/dashboardDetailsBreakdown');\r\n };\r\n\r\n useEffect(() => {\r\n setServiceData([...services].slice(1));\r\n setProductData([...products].slice(1));\r\n }, [products, services]);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n {formikValues.isDomestic ? (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {(formikValues || {}).accounts.length > 0 ? (\r\n \r\n ) : null}\r\n \r\n ) : (\r\n \r\n \r\n \r\n \r\n {(formikValues || {}).accounts.length > 0 ? (\r\n \r\n ) : null}\r\n \r\n )}\r\n \r\n \r\n \r\n \r\n }\r\n component={RouterLink}\r\n onClick={dispatchingAction}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nexport default BreakDownDashboard;\r\n","/* eslint-disable react-hooks/exhaustive-deps */\r\nimport React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport DateRangePicker from '../../../../framework/date-range/dateRange';\r\nimport ReactToPrint from 'react-to-print';\r\nimport { useHistory } from 'react-router';\r\nimport { Grid, SvgIcon, Tab, Tabs, Box, withStyles } from '@material-ui/core';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\n\r\nimport { connect } from 'react-redux';\r\nimport FormRenderer from '../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport ToggleButton from '@material-ui/lab/ToggleButton';\r\nimport ToggleButtonGroup from '@material-ui/lab/ToggleButtonGroup';\r\nimport { useDispatch } from 'react-redux';\r\nimport originalMoment from 'moment';\r\nimport { extendMoment } from 'moment-range';\r\nimport './accountsForDashboard.scss';\r\nimport { deliveryStatusForDashboard, MISC_VALUES } from '../../../../utils/constants/constants';\r\nimport CustomAccordion from '../../../../framework/accordion/customAccordion';\r\nimport Doughnut from '../../../../framework/charts/doughnut';\r\nimport { ReactComponent as ArrowDetails } from '../../../../assets/images/arrow_details.svg';\r\nimport PdfIcon from '../../../../assets/images/pdfIcon.svg';\r\nimport { abortOnGoingCallsFor, axiosConfig } from '../../../../api/axios';\r\nimport Typography from '@material-ui/core/Typography';\r\nimport {\r\n getDefaultDashboardValues,\r\n getDomesticAccounts,\r\n getBackGroundColor,\r\n setDropdownValues,\r\n getDriverCollectionAccounts,\r\n getInternationalRoadAccounts,\r\n} from '../../../../utils/helperFunctions';\r\nimport { getInternationalAccounts } from '../../../../utils/helperFunctions';\r\nimport { formatDate } from '../../../../utils/helperFunctions';\r\nimport { firstBusinessDayOfMonth } from '../../../../utils/helperFunctions';\r\nimport { firstDayOfPreviousMonth } from '../../../../utils/helperFunctions';\r\nimport { lastDayOfPreviousMonth } from '../../../../utils/helperFunctions';\r\nimport { ServiceEndPoints } from '../../../../utils/constants/ApiConstant';\r\nimport { yesterdayDate1 } from '../../../../utils/helperFunctions';\r\nimport { weekDay } from '../../../../utils/helperFunctions';\r\nimport FindShipment from '../findShipment/findShipment';\r\nimport BreakDownDashboard from '../breakDownDashboard/BreakDownDashboard';\r\nimport * as actions from '../../../../store/actions/index';\r\nimport InputButton from '../../../../framework/Inputs/inputButton/inputButton';\r\nimport { Link as RouterLink } from 'react-router-dom';\r\nimport CustomDialog from '../../../../framework/dialog/customDialog';\r\nimport { useDebouncedCallback } from 'use-debounce/lib';\r\nimport html2canvas from 'html2canvas';\r\nimport jsPDF from 'jspdf';\r\nimport Pdf from 'react-to-pdf';\r\nimport { arrayValuesToQueryStringParam } from '../../../../utils/common';\r\n\r\nfunction TabPanel(props) {\r\n const { children, value, index, ...other } = props;\r\n return (\r\n \r\n {value === index && (\r\n \r\n {children} \r\n \r\n )}\r\n
\r\n );\r\n}\r\nfunction a11yProps(index) {\r\n return {\r\n id: `simple-tab-${index}`,\r\n 'aria-controls': `simple-tabpanel-${index}`,\r\n };\r\n}\r\nconst AccountsForDashboard = (props) => {\r\n const history = useHistory();\r\n const dispatch = useDispatch();\r\n const {\r\n formField: { accounts, deliveryStatusForAccounts, internationalCountry },\r\n setFieldValue,\r\n formikValues,\r\n setValues,\r\n userAccounts,\r\n } = props;\r\n const moment = extendMoment(originalMoment);\r\n const todayDate = moment();\r\n var last6months = moment().subtract(6, 'months');\r\n var last12months = moment().subtract(12, 'months');\r\n var lastDay = moment().subtract(1, 'days');\r\n const [tabIndex, setTabIndex] = useState(0);\r\n const domesticUserAccounts = getDomesticAccounts(userAccounts);\r\n const internatonalUserAccounts = getInternationalAccounts(userAccounts);\r\n const internationalRoadAccounts = getInternationalRoadAccounts(userAccounts);\r\n const domesticDriverCollectionAccounts = getDriverCollectionAccounts(userAccounts);\r\n const [countryAccount, setcountryAccount] = useState('domestic');\r\n const [doughnutChartData, setdoughnutChartData] = useState({});\r\n const [totalCount, settotalCount] = useState();\r\n const [publicHolidays, setPublicHolidays] = useState([]);\r\n const [userAccountsData, setUserAccountsData] = useState([]);\r\n const [open, setOpen] = useState(false);\r\n const [datepickerValue, setDatepickerValue] = useState(moment.range(new Date(), new Date()));\r\n\r\n const [productData, setProductData] = useState([]);\r\n const [serviceData, setServiceData] = useState([]);\r\n const [renderVal, setRenderVal] = useState('');\r\n\r\n var fromCollectionDate;\r\n let collectedToDate = formatDate(new Date());\r\n let total = 0;\r\n let status = [];\r\n let statusCount = [];\r\n\r\n useEffect(() => {\r\n axiosConfig\r\n .get(`${ServiceEndPoints.getPublicHolidays}?countryCode=gb`)\r\n .then((res) => {\r\n setPublicHolidays(res.data.publicHolidays);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n setPublicHolidays([]);\r\n });\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (tabIndex === 0) {\r\n fromCollectionDate = formatDate(yesterdayDate1(publicHolidays));\r\n collectedToDate = formatDate(yesterdayDate1(publicHolidays));\r\n } else {\r\n fromCollectionDate = formatDate(new Date());\r\n collectedToDate = formatDate(new Date());\r\n }\r\n if (formikValues.deliveryStatusForAccounts.value === MISC_VALUES.THIS_MONTH) {\r\n fromCollectionDate = formatDate(\r\n firstBusinessDayOfMonth(new Date().getFullYear(), new Date().getMonth()),\r\n );\r\n collectedToDate = formatDate(new Date());\r\n } else if (formikValues.deliveryStatusForAccounts.value === MISC_VALUES.PREVIOUS_MONTH) {\r\n fromCollectionDate = formatDate(\r\n firstDayOfPreviousMonth(new Date().getFullYear(), new Date().getMonth()),\r\n );\r\n collectedToDate = formatDate(\r\n lastDayOfPreviousMonth(new Date().getFullYear(), new Date().getMonth()),\r\n );\r\n } else if (formikValues.deliveryStatusForAccounts.value === MISC_VALUES.THIS_WEEK) {\r\n fromCollectionDate = formatDate(weekDay(new Date()));\r\n collectedToDate = formatDate(new Date());\r\n }\r\n const dateValues = {\r\n fromCollectionDate,\r\n toCollectionDate: collectedToDate,\r\n };\r\n setValues({ ...formikValues, ...dateValues });\r\n }, [formikValues.deliveryStatusForAccounts, formikValues.isDomestic, publicHolidays]);\r\n\r\n const handleTabIndexChange = (event, value) => {\r\n setTabIndex(value);\r\n };\r\n\r\n useEffect(() => {\r\n if (tabIndex === 0) {\r\n fromCollectionDate = formatDate(yesterdayDate1(publicHolidays));\r\n collectedToDate = formatDate(yesterdayDate1(publicHolidays));\r\n } else {\r\n fromCollectionDate = formatDate(new Date());\r\n collectedToDate = formatDate(new Date());\r\n }\r\n const dateValues = {\r\n fromCollectionDate,\r\n toCollectionDate: collectedToDate,\r\n };\r\n setValues({ ...formikValues, ...dateValues });\r\n }, [tabIndex]);\r\n\r\n const getDoughnutChartData = useDebouncedCallback(() => {\r\n abortOnGoingCallsFor(`${ServiceEndPoints.getBreakDownDetails}summary`);\r\n axiosConfig\r\n .get(\r\n `${ServiceEndPoints.getBreakDownDetails}summary?${getDefaultDashboardValues(\r\n formikValues,\r\n )}&${arrayValuesToQueryStringParam(formikValues.accounts)}`,\r\n )\r\n .then((res) => {\r\n for (const dataObj of res.data?.shipmentByStatuses) {\r\n total = res.data.shipmentTotalCount;\r\n status.push(dataObj.status);\r\n statusCount.push(dataObj.totalCount);\r\n }\r\n let percentage = status.map((label, index) => (statusCount[index] / total) * 100);\r\n\r\n\r\n let customLabels = status.map((label, index) => {\r\n let validPercentage = `${percentage[index] >= 1 ? `${percentage[index] >= 10 ? parseFloat(percentage[index]).toFixed(1) : '0' + parseFloat(percentage[index]).toFixed(1)}` : parseFloat(percentage[index]).toFixed(2)}`\r\n\r\n return {\r\n percentage: `${validPercentage}%`,\r\n label: `${label}`,\r\n StatusCount: `${statusCount[index]}`,\r\n };\r\n });\r\n\r\n let labelForView = status.map((label) => `${label}`);\r\n let backgroundColorForLabel = labelForView.map((label) => getBackGroundColor(label));\r\n setdoughnutChartData({\r\n labels: customLabels,\r\n datasets: [\r\n {\r\n backgroundColor: backgroundColorForLabel,\r\n hoverBackgroundColor: backgroundColorForLabel,\r\n data: statusCount,\r\n label: labelForView,\r\n },\r\n ],\r\n });\r\n settotalCount(total);\r\n })\r\n .catch((err) => {\r\n setdoughnutChartData({});\r\n settotalCount();\r\n });\r\n }, 400);\r\n\r\n useEffect(() => {\r\n if (formikValues.fromCollectionDate && formikValues.toCollectionDate && formikValues.accounts.length > 0) {\r\n getDoughnutChartData();\r\n }\r\n }, [\r\n formikValues.isDomestic,\r\n formikValues.fromCollectionDate,\r\n formikValues.toCollectionDate,\r\n formikValues.accounts,\r\n formikValues.internationalCountry,\r\n ]);\r\n\r\n const handleAccounts = (event, newAccount) => {\r\n if (newAccount !== null) {\r\n setcountryAccount(newAccount);\r\n }\r\n if (newAccount === MISC_VALUES.DOMESTIC) {\r\n const defaultAccountSelected = selectDefaultAccount(userAccountsData, domesticDriverCollectionAccounts);\r\n setFieldValue('accounts', [defaultAccountSelected]);\r\n setFieldValue('isDomestic', true);\r\n } else {\r\n setFieldValue('isDomestic', false);\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n setFieldValue('deliveryStatusForDomesticAccounts', deliveryStatusForDashboard[0]);\r\n }, []);\r\n\r\n useEffect(() => {\r\n if ((domesticUserAccounts || []).length <= 0) {\r\n setFieldValue('isDomestic', false);\r\n\r\n setcountryAccount('international');\r\n } else if ((internatonalUserAccounts || []).length <= 0) {\r\n setcountryAccount('domestic');\r\n setFieldValue('isDomestic', true);\r\n }\r\n }, [domesticUserAccounts]);\r\n\r\n const dispatchingAction = () => {\r\n dispatch(\r\n actions.setDashboardTracking({\r\n loadedFrom: 'detailView',\r\n loadedResponse: formikValues,\r\n dashboardQueryParams: `${getDefaultDashboardValues(formikValues)}`,\r\n accountsParams: arrayValuesToQueryStringParam(formikValues.accounts),\r\n tabIndex,\r\n products: productData,\r\n countries: props.countries,\r\n services: serviceData,\r\n }),\r\n );\r\n history.push('/dashboard/dashboardDetailsSummary');\r\n };\r\n\r\n useEffect(() => {\r\n if (userAccounts) {\r\n let _userAccounts = userAccounts;\r\n _userAccounts =\r\n _userAccounts.map((account) => {\r\n return {\r\n ...account,\r\n displayName: `${account.accountId}-${account.accountName}${(account.configuration.firstMileDropOffAllowed) ? '-FMD' : ''}`,\r\n };\r\n }) ?? [];\r\n if (formikValues.isDomestic) {\r\n setUserAccountsData(getDomesticAccounts(userAccounts));\r\n // _userAccounts = getDomesticAccounts(userAccounts)\r\n } else {\r\n setUserAccountsData(getInternationalAccounts(userAccounts));\r\n // _userAccounts = getInternationalAccounts(userAccounts)\r\n setFieldValue('internationalCountry', setDropdownValues(props.countries, 'code2Digit', ''));\r\n }\r\n }\r\n setFieldValue('deliveryStatusForAccounts', deliveryStatusForDashboard[0]);\r\n }, [formikValues.isDomestic, userAccounts]);\r\n\r\n useEffect(() => {\r\n if (formikValues.isDomestic) {\r\n const defaultAccountSelected = selectDefaultAccount(userAccountsData, domesticDriverCollectionAccounts);\r\n defaultAccountSelected && setFieldValue('accounts', [defaultAccountSelected]);\r\n } else {\r\n const defaultAccountSelected = selectDefaultAccount(userAccountsData, internationalRoadAccounts);\r\n defaultAccountSelected && setFieldValue('accounts', [defaultAccountSelected]);\r\n }\r\n }, [userAccountsData]);\r\n\r\n const selectDefaultAccount = (userAccountsData, selectedAccounts) => {\r\n let defaultAccountSelected = '';\r\n let isValueExist = false;\r\n for (let i = 0; i < selectedAccounts.length; i++) {\r\n for (let j = 0; j < userAccountsData.length; j++) {\r\n if (userAccountsData[j].accountId == selectedAccounts[i].accountId) {\r\n defaultAccountSelected = userAccountsData[j].accountId;\r\n isValueExist = true;\r\n }\r\n }\r\n if (isValueExist) break;\r\n }\r\n return defaultAccountSelected;\r\n };\r\n\r\n useEffect(() => {\r\n // dateRange(formikValues.deliveryStatusForAccounts.value);\r\n }, [formikValues.deliveryStatusForAccounts]);\r\n\r\n const dateRange = (selectedValue) => {\r\n if (props.dashboardDetails.loadedFrom === MISC_VALUES.DASHBOARD_DETAILS && props?.dashboardDetails?.loadedResponse) {\r\n setOpen(false)\r\n setFieldValue('deliveryStatusForAccounts', deliveryStatusForDashboard[0]);\r\n }\r\n else if (selectedValue === MISC_VALUES.DATE_RANGE) {\r\n setOpen(true);\r\n }\r\n };\r\n\r\n const dateRangeInSelect = () => {\r\n setOpen(true);\r\n };\r\n const handleDateClose = (value) => {\r\n setOpen(false);\r\n fromCollectionDate = formatDate(datepickerValue.start._i);\r\n collectedToDate = formatDate(datepickerValue.end._d);\r\n\r\n const dateValues = {\r\n fromCollectionDate,\r\n toCollectionDate: collectedToDate,\r\n };\r\n setRenderVal(`${moment(fromCollectionDate).format('DD/MM/YYYY')}-${moment(collectedToDate).format('DD/MM/YYYY')}`);\r\n setValues({ ...formikValues, ...dateValues });\r\n };\r\n\r\n const onSelect = (value) => {\r\n const count = getNumberOfDays(value.start, value.end);\r\n if (count > 30) {\r\n setDatepickerValue(moment.range(value.start._d, moment(value.end._d).subtract(count - 30, \"days\")));\r\n } else {\r\n setDatepickerValue(moment.range(value.start._d, value.end._d));\r\n }\r\n };\r\n\r\n function getNumberOfDays(start, end) {\r\n if (start < end) {\r\n return (end - start) / 1000 / 60 / 60 / 24;\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n if (props.dashboardDetails.loadedFrom === MISC_VALUES.DASHBOARD_DETAILS && props?.dashboardDetails?.loadedResponse) {\r\n const responseFormikValues = props.dashboardDetails.loadedResponse;\r\n const retainedValues = {\r\n accounts: responseFormikValues?.accounts ?? [],\r\n isDomestic: responseFormikValues?.isDomestic,\r\n deliveryStatusForAccounts: responseFormikValues?.deliveryStatusForAccounts,\r\n };\r\n setValues({ ...formikValues, ...retainedValues });\r\n if (!responseFormikValues?.isDomestic) {\r\n setcountryAccount('international');\r\n }\r\n if (props.dashboardDetails.tabIndex) {\r\n setTabIndex(props.dashboardDetails.tabIndex);\r\n }\r\n }\r\n }, [props.dashboardDetails, publicHolidays]);\r\n\r\n useEffect(() => {\r\n setFieldValue('internationalCountry', setDropdownValues(props.countries, 'code2Digit', ''));\r\n const responseFormikValues = props.dashboardDetails.loadedResponse;\r\n if (\r\n props.dashboardDetails.loadedFrom === MISC_VALUES.DASHBOARD_DETAILS && props?.dashboardDetails?.loadedResponse &&\r\n props.countries.length > 0 &&\r\n responseFormikValues.internationalCountry\r\n ) {\r\n setFieldValue(\r\n 'internationalCountry',\r\n setDropdownValues(props.countries, 'code2Digit', responseFormikValues.internationalCountry.code2Digit),\r\n );\r\n }\r\n }, [props.countries]);\r\n\r\n const componentRef = React.useRef();\r\n useEffect(() => {\r\n deliveryStatusForDashboard[4].clickEvent = dateRangeInSelect;\r\n if (formikValues.deliveryStatusForAccounts.value === MISC_VALUES.DATE_RANGE) {\r\n dateRange('daterange');\r\n } else {\r\n setOpen(false);\r\n deliveryStatusForDashboard[4].name = 'Date range';\r\n }\r\n }, [formikValues.deliveryStatusForAccounts]);\r\n const ref = React.createRef();\r\n\r\n\r\n const options = {\r\n orientation: 'potrait',\r\n };\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n Domestic \r\n \r\n \r\n International \r\n \r\n \r\n \r\n \r\n \r\n \r\n {formikValues.isDomestic ? null : (\r\n \r\n )}\r\n \r\n \r\n \r\n {({ toPdf }) => (\r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Selected accounts: \r\n {((formikValues || {}).accounts || []).join(', ')} \r\n \r\n \r\n {formikValues.deliveryStatusForAccounts?.value === 'today&yesterday' ? (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {(formikValues || {}).accounts.length > 0 ? (\r\n \r\n \r\n \r\n ) : null}\r\n \r\n \r\n }\r\n component={RouterLink}\r\n onClick={dispatchingAction}\r\n />\r\n \r\n \r\n \r\n\r\n \r\n {(formikValues || {}).accounts.length > 0 ? (\r\n \r\n \r\n \r\n ) : null}\r\n \r\n \r\n }\r\n component={RouterLink}\r\n onClick={dispatchingAction}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ) : (\r\n \r\n \r\n \r\n \r\n \r\n {(formikValues || {}).accounts.length > 0 ? (\r\n \r\n ) : null}\r\n \r\n \r\n \r\n \r\n }\r\n component={RouterLink}\r\n onClick={dispatchingAction}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\nAccountsForDashboard.propTypes = {\r\n formField: PropTypes.object,\r\n isDomestic: PropTypes.bool,\r\n};\r\nTabPanel.propTypes = {\r\n children: PropTypes.node,\r\n index: PropTypes.any.isRequired,\r\n value: PropTypes.any.isRequired,\r\n};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n dashboardDetails: ((state || {}).dashboardTracking || {}).dashboardTracking,\r\n userAccounts: (((state || {}).auth || {}).userDetails || {}).accounts,\r\n };\r\n};\r\nexport default connect(mapStateToProps, null)(AccountsForDashboard);\r\n","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from \"react\";\n\nvar _ref2 = /*#__PURE__*/React.createElement(\"path\", {\n id: \"Icon_feather-filter\",\n \"data-name\": \"Icon feather-filter\",\n d: \"M22.135,4.5H3l7.654,9.051v6.257l3.827,1.913V13.551Z\",\n transform: \"translate(-2 -3.5)\",\n fill: \"none\",\n stroke: \"#000\",\n strokeLinecap: \"round\",\n strokeLinejoin: \"round\",\n strokeWidth: 2\n});\n\nfunction SvgFilter(_ref, svgRef) {\n var title = _ref.title,\n titleId = _ref.titleId,\n props = _objectWithoutProperties(_ref, [\"title\", \"titleId\"]);\n\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 21.135,\n height: 19.221,\n viewBox: \"0 0 21.135 19.221\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, _ref2);\n}\n\nvar ForwardRef = /*#__PURE__*/React.forwardRef(SvgFilter);\nexport default __webpack_public_path__ + \"static/media/Filter.17d6d49a.svg\";\nexport { ForwardRef as ReactComponent };","import React, { forwardRef, useState, useEffect, useRef } from 'react';\r\nimport MaterialTable from 'material-table';\r\nimport { Grid, SvgIcon, IconButton, MenuItem, Select, ListItemIcon, ListItemText, Checkbox } from '@material-ui/core';\r\nimport VisibilityOutlinedIcon from '@material-ui/icons/VisibilityOutlined';\r\nimport Badge from '@material-ui/core/Badge';\r\nimport FilterListOutlinedIcon from '@material-ui/icons/FilterListOutlined';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport KeyboardArrowUpIcon from '@material-ui/icons/KeyboardArrowUp';\r\nimport { ReactComponent as FilterIcon } from '../../../assets/images/Filter.svg';\r\nimport { useHistory } from 'react-router';\r\nimport './DashnboardMonitorList.scss';\r\nimport { customTableSort, basicSort, customTableShipmentNoSort, formatDateToUKFormat } from '../../../utils/helperFunctions';\r\nimport { shipmentDetails } from '../../../utils/Models';\r\nconst ITEM_HEIGHT = 48;\r\nconst ITEM_PADDING_TOP = 8;\r\n\r\nconst MenuProps = {\r\n PaperProps: {\r\n style: {\r\n maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,\r\n width: 250,\r\n },\r\n },\r\n getContentAnchorEl: null,\r\n anchorOrigin: {\r\n vertical: 'bottom',\r\n horizontal: 'center',\r\n },\r\n transformOrigin: {\r\n vertical: 'top',\r\n horizontal: 'center',\r\n },\r\n};\r\nconst DashboardMonitorList = (props) => {\r\n const [selectedRows, setSelectedRows] = React.useState([]);\r\n const [showFilter, setShowFilter] = React.useState(false);\r\n const [selectedVal, setSelectedVal] = useState([]);\r\n const [monitorListData, setmonitorList] = useState(props.monitorList);\r\n const [tableData, setTableData] = useState(props.monitorList);\r\n let history = useHistory();\r\n const tableRef = useRef();\r\n const filterButtonStyle = {\r\n padding: '4px !important',\r\n };\r\n const CustomFilter = props => {\r\n const handleChange = async (e) => {\r\n const val = await e.target.value;\r\n setSelectedVal(val);\r\n // props.onFilterChanged(props.columnDef.tableData.columnOrder, val);\r\n if (val.length > 0) {\r\n const myArrayFiltered = monitorListData.filter(el => {\r\n return val.some(f => {\r\n return f === el.shipmentDetails.status;\r\n });\r\n });\r\n setTableData(myArrayFiltered)\r\n } else {\r\n setTableData(monitorListData)\r\n }\r\n }\r\n\r\n return (\r\n \r\n {(data.length > 1) ? data[0] + '...' : data[0]}
}\r\n // disableUnderline\r\n >\r\n {props.columnDef.filterValues.map((option) => (\r\n \r\n \r\n -1}\r\n />\r\n \r\n \r\n \r\n ))}\r\n \r\n \r\n );\r\n };\r\n const columns = [\r\n {\r\n title: 'Customer ref.', field: 'shipmentDetails.customerReference',\r\n customSort: (a, b) => customTableSort(a.shipmentDetails.customerReference, b.shipmentDetails.customerReference),\r\n filtering: false\r\n },\r\n {\r\n title: 'Shipment number', field: 'shipmentDetails.shipmentNumber',\r\n customSort: (a, b) => customTableShipmentNoSort(a.shipmentDetails.shipmentNumber, b.shipmentDetails.shipmentNumber),\r\n filtering: false\r\n },\r\n {\r\n title: 'Collection date', field: 'shipmentDetails.collectionDate',\r\n render: (row) => {`${formatDateToUKFormat(row.shipmentDetails.collectionDate)}`} ,\r\n customSort: (a, b) => basicSort(new Date(a.shipmentDetails.collectionDate).getTime() || 0, new Date(b.shipmentDetails.collectionDate).getTime() || 0),\r\n filtering: false\r\n },\r\n {\r\n title: 'Delivery date', field: 'shipmentDetails.deliveryDate',\r\n render: (row) => {`${formatDateToUKFormat(row.shipmentDetails.deliveryDate)}`} ,\r\n customSort: (a, b) => basicSort(new Date(a.shipmentDetails.deliveryDate).getTime() || 0, new Date(b.shipmentDetails.deliveryDate).getTime() || 0),\r\n filtering: false,\r\n },\r\n {\r\n title: (\r\n \r\n
\r\n Status \r\n
\r\n
\r\n setShowFilter(true)} style={filterButtonStyle}>\r\n \r\n \r\n
\r\n
\r\n ),\r\n field: 'shipmentDetails.status',\r\n sorting: false,\r\n render: (rowData) => {\r\n let statusStyleBar = { height: '15px', width: '5px', margin: '2px', background: '' };\r\n switch (rowData.shipmentDetails?.status?.trim()?.toLowerCase()) {\r\n case 'order received':\r\n statusStyleBar.background = '#ED7700';\r\n break;\r\n case 'in transit':\r\n statusStyleBar.background = '#F7BC00';\r\n break;\r\n case 'exception':\r\n statusStyleBar.background = '#9A77E8';\r\n break;\r\n case 'delivery attempted':\r\n statusStyleBar.background = '#2699FB';\r\n break;\r\n case 'out for delivery':\r\n statusStyleBar.background = '#025598';\r\n break;\r\n case 'delivered':\r\n statusStyleBar.background = '#76BD22';\r\n break;\r\n default:\r\n statusStyleBar.background = '#F7BC00';\r\n }\r\n return (\r\n \r\n
\r\n
{rowData.shipmentDetails.status}
\r\n
\r\n );\r\n },\r\n filtering: showFilter,\r\n lookup: {\r\n 'Order received': 'Order received',\r\n 'In transit': 'In transit',\r\n Exception: 'Exception',\r\n 'Delivery attempted': 'Delivery attempted',\r\n 'Out for delivery': 'Out for delivery',\r\n Delivered: 'Delivered'\r\n },\r\n filterValues:\r\n ['In transit', 'Out for delivery', 'Exception', 'Delivered', 'Delivery attempted'\r\n , 'Order received'\r\n ],\r\n filterComponent: (props) => ,\r\n },\r\n ];\r\n const tableIcons = {\r\n SortArrow: forwardRef((props, ref) => ),\r\n };\r\n const tableOptions = {\r\n selection: true,\r\n search: false,\r\n paging: false,\r\n showTitle: false,\r\n filtering: showFilter,\r\n sorting: true,\r\n maxBodyHeight: '387px',\r\n toolbar: false,\r\n overflowY: 'auto',\r\n overflowX: 'auto',\r\n headerStyle: { position: 'sticky', top: 0, fontWeight: 'bold' },\r\n rowStyle: (rowData, index) => {\r\n let backGroundColor = '';\r\n index % 2 === 0 ? (backGroundColor = '#F2F2F2') : (backGroundColor = '');\r\n if (rowData.isStatusChanged) {\r\n backGroundColor = '#FFEFAE';\r\n }\r\n return { backgroundColor: backGroundColor };\r\n },\r\n };\r\n\r\n useEffect(() => {\r\n return () => {\r\n props.clearRecentlyViewed();\r\n }\r\n }, [])\r\n useEffect(() => {\r\n setTableData(props.monitorList)\r\n setmonitorList(props.monitorList)\r\n }, [props.monitorList])\r\n\r\n const addSelectedRows = (selectedRowsFromTable) => {\r\n if (selectedVal.length > 0) {\r\n const myArrayFiltered = props.monitorList.filter(el => {\r\n return selectedVal.some(f => {\r\n return f === el.shipmentDetails.status;\r\n });\r\n });\r\n setTableData(myArrayFiltered)\r\n } else {\r\n setTableData(props.monitorList)\r\n }\r\n setSelectedRows(selectedRowsFromTable);\r\n };\r\n\r\n const trackShipmet = () => {\r\n history.push(`/dashboard/Tracking?id=${selectedRows[0].shipmentDetails.shipmentNumber}`);\r\n };\r\n\r\n const clearShipmet = () => {\r\n props.clearFromMonitorList(selectedRows);\r\n setSelectedVal([])\r\n setSelectedRows([]);\r\n };\r\n\r\n const clearRecent = () => {\r\n props.clearRecentlyViewed();\r\n if (tableRef.current) {\r\n tableRef.current.onAllSelected(false)\r\n }\r\n props.handleDrawer();\r\n };\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n Monitor list ({props.monitorListCount.total}) \r\n \r\n \r\n \r\n \r\n \r\n { addSelectedRows(rows) }}\r\n tableRef={tableRef}\r\n />\r\n \r\n \r\n {/* \r\n {Note: Use long press to set the priority of the rows
}\r\n */}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nexport default DashboardMonitorList;\r\n","import React, { useEffect } from 'react';\r\nimport { connect, useDispatch } from 'react-redux';\r\nimport { getYupSchemaFromMetaData } from '../../../utils/yupSchema/yupSchemaGenerator';\r\nimport { Grid, Snackbar } from '@material-ui/core';\r\nimport { Form, Formik } from 'formik';\r\nimport dashboardForm from '../../../utils/formConfig/dashboardForm/dashboardForm';\r\nimport AccountsForDashboard from '../dashboard/accountsForDashboard/accountsForDashboard';\r\nimport { GET, PUT, POST } from '../../../../src/api/axios';\r\nimport VisibilityOutlinedIcon from '@material-ui/icons/VisibilityOutlined';\r\nimport Badge from '@material-ui/core/Badge';\r\nimport FilterListOutlinedIcon from '@material-ui/icons/FilterListOutlined';\r\nimport Drawer from '@material-ui/core/Drawer';\r\n// import {PDFtoIMG} from 'react-pdf-to-image';\r\n// import file from './pdf-sample.pdf';\r\nimport Pdf from 'react-to-pdf';\r\nimport DashboardMonitorList from '../../../components/dashboard/MonitorList/DashnboardMonitorList';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { fullSearchDashboardByOptions } from '../../../utils/constants/constants';\r\nimport { dynamicSort } from '../../../utils/helperFunctions';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { useSelector } from 'react-redux';\r\nimport html2canvas from 'html2canvas';\r\nimport jsPDF from 'jspdf';\r\n\r\nconst { formId, formField } = dashboardForm;\r\n\r\nconst Dashboard = (props) => {\r\n const [open, setOpen] = React.useState(false);\r\n const [monitorList, setMonitorList] = React.useState([]);\r\n const [monitorListCount, setMonitorListCount] = React.useState({ total: 0, active: 0 });\r\n const [countries, setCountries] = React.useState([]);\r\n const dispatch = useDispatch();\r\n const newDomestiValidationSchema = getYupSchemaFromMetaData(formField, [], []);\r\n\r\n let alertInfo = useSelector((state) => state.alertInfo.showAlert);\r\n // console.log(alertInfo + ' Testing');\r\n\r\n const initialValues = {\r\n // dashboardSearchBy: fullSearchDashboardByOptions[0],\r\n };\r\n for (let property in formField) {\r\n if (Object.prototype.hasOwnProperty.call(formField, property)) {\r\n const field = formField[property];\r\n if (field.props.type === 'checkbox' || field.props.type === 'radio') {\r\n initialValues[field.props.name] = field.value;\r\n } else if (field.props.type === 'array') {\r\n initialValues[field.props.name] = field.values;\r\n } else {\r\n initialValues[field.props.name] = field.value || '';\r\n }\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n GET(ServiceEndPoints.getCountries)\r\n .then((res) => {\r\n const sortedCountries = res.data.countries.sort(dynamicSort('name'));\r\n sortedCountries.unshift({ value: '', name: 'All countries', code2Digit: '' });\r\n setCountries(sortedCountries);\r\n })\r\n .catch((err) => {\r\n setCountries([]);\r\n });\r\n }, []);\r\n useEffect(() => {\r\n props.userDetails?.userId && getAllMonitioredShipments();\r\n }, [props.userDetails]);\r\n\r\n const getAllMonitioredShipments = () => {\r\n const requestUrl = ServiceEndPoints.getAllMonitioredShipments + props.userDetails.userId;\r\n GET(requestUrl)\r\n .then((response) => {\r\n const changedItems = response.data.filter((x) => x.isStatusChanged === true);\r\n setMonitorListCount({ active: changedItems ? changedItems.length : 0, total: response.data.length });\r\n setMonitorList(response.data);\r\n })\r\n .catch((error) => {\r\n setMonitorList([]);\r\n setMonitorListCount({ active: 0, total: 0 });\r\n });\r\n };\r\n\r\n const handleDrawer = () => {\r\n open ? setOpen(false) : setOpen(true);\r\n };\r\n\r\n const clearRecentlyViewed = () => {\r\n const requestUrl = ServiceEndPoints.getAllMonitioredShipments + props.userDetails.userId;\r\n const payload = monitorList.filter((x) => x.isStatusChanged === true);\r\n if (payload.length > 0) {\r\n PUT(requestUrl, payload)\r\n .then((response) => {\r\n getAllMonitioredShipments();\r\n })\r\n .catch((error) => {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Failed to update',\r\n },\r\n ],\r\n }),\r\n );\r\n // dispatch(actions.setAppSnackBarData({ type: 'error', msg: 'Failed to update' }));\r\n });\r\n }\r\n };\r\n\r\n const clearFromMonitorList = (selectedRows) => {\r\n const requestUrl = ServiceEndPoints.clearMonitoredShipments + props.userDetails.userId;\r\n const payload = selectedRows.map((row) => {\r\n return row.shipmentDetails.shipmentNumber;\r\n });\r\n POST(requestUrl, payload)\r\n .then((resposne) => {\r\n getAllMonitioredShipments();\r\n })\r\n .catch((err) => {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Failed to clear the shipment',\r\n },\r\n ],\r\n }),\r\n );\r\n // dispatch(actions.setAppSnackBarData({ type: 'error', msg: 'Failed to clear the shipment' }));\r\n });\r\n };\r\n\r\n const printDocument = () => {\r\n const input = document.getElementById('dpie');\r\n var w = document.getElementById('dpie').offsetWidth;\r\n var h = document.getElementById('dpie').offsetHeight;\r\n html2canvas(input, {\r\n dpi: 300,\r\n scale: 3,\r\n }).then((canvas) => {\r\n var pdf = new jsPDF('L', 'px', [w, h]);\r\n var imgData = canvas.toDataURL('image/jpeg', 1);\r\n pdf.addImage(imgData, 'JPEG', 15, 5, 1080, 600);\r\n pdf.save('Dashboard_Graph.pdf');\r\n });\r\n };\r\n const ref = React.createRef();\r\n\r\n const options = {\r\n orientation: 'portrait',\r\n unit: 'in',\r\n format: [4, 2],\r\n };\r\n return (\r\n \r\n \r\n \r\n \r\n {({ values, setValues, setFieldValue, setFieldTouched, errors, resetForm }) => {\r\n const isDomestic = ((values || {}).destinationCountry || {}).code === 'GBR';\r\n return (\r\n \r\n );\r\n }}\r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nDashboard.propTypes = {};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n // selectedAccount: state.accounts.selectedAccount,\r\n // favouriteCustomers: state.customers.favouriteCustomers,\r\n userDetails: state.auth.userDetails,\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, null)(Dashboard);\r\n","import React from 'react'\r\nimport { Grid } from '@material-ui/core';\r\nimport CustomCaption from '../../../framework/summaryFormate/CustomCaption';\r\nimport { dateFormatForSummaryPage } from '../../../utils/helperFunctions'\r\n\r\nconst CollectionSetUpSummary = ({ data }) => {\r\n return (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n )\r\n}\r\n\r\n\r\nexport default CollectionSetUpSummary\r\n","import React, { useState, useEffect } from 'react';\r\nimport { Grid } from '@material-ui/core';\r\nimport CustomCaption from '../../../framework/summaryFormate/CustomCaption';\r\nimport ReadOnlyCheckbox from '../../../framework/readOnlyCheckbox/ReadOnlyCheckbox';\r\nimport { getParsedFloatValues } from '../../../utils/helperFunctions';\r\nimport PropTypes from 'prop-types';\r\nimport { useSelector } from 'react-redux';\r\n\r\nconst CollectionParcelSummary = ({ shipmentSummary, accountDetails, isCollections }) => {\r\n const [parcelDetails, setParcelDetails] = useState({});\r\n const [volumetricWeight, setVolumetricWeight] = useState(0.0);\r\n const [parcelDimensionsChecked, setParcelDimensionsChecked] = useState(false);\r\n const [volumetricWeightDivisor, setVolumetricWeightDivisor] = useState(4000);\r\n\r\n const userDetails = useSelector((state) => state.auth.userDetails);\r\n\r\n useEffect(() => {\r\n setParcelDetails(shipmentSummary?.parcelDetail);\r\n }, [shipmentSummary]);\r\n\r\n useEffect(() => {\r\n setParcelDimensionsChecked(parcelDetails?.parcelDimensionsAdded);\r\n let volumetricWeight = 0;\r\n parcelDetails?.pieces?.forEach((row) => {\r\n volumetricWeight += getCaluclatedVolumetricWeight(row);\r\n });\r\n setVolumetricWeight(volumetricWeight);\r\n }, [parcelDetails, accountDetails]);\r\n\r\n useEffect(() => {\r\n const shipmentAcc = userDetails?.accounts?.find((user) => user.accountId === shipmentSummary.accountNumber);\r\n setVolumetricWeightDivisor(shipmentAcc?.configuration?.volumetricWeightDivisor || 4000);\r\n }, [userDetails, shipmentSummary.accountNumber]);\r\n\r\n const getCaluclatedVolumetricWeight = (row) => {\r\n return getParsedFloatValues((row.length * row.height * row.width) / (volumetricWeightDivisor || 4000));\r\n };\r\n\r\n return (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {!isCollections && (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n )}\r\n \r\n \r\n >\r\n );\r\n};\r\n\r\nCollectionParcelSummary.propTypes = {\r\n isCollections: PropTypes.bool,\r\n};\r\n\r\nCollectionParcelSummary.defaultProps = {\r\n isCollections: false,\r\n};\r\n\r\nexport default CollectionParcelSummary;\r\n","import React, { useEffect, useState } from 'react';\r\nimport { useHistory, useParams } from 'react-router-dom';\r\nimport AddressFormate from '../../../framework/addressFormate/AddressFormate';\r\nimport { Grid, Box, makeStyles, Divider, SvgIcon } from '@material-ui/core';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { GET, POST } from '../../../api/axios';\r\nimport CollectionSetUpSummary from './CollectionSetUpSummary';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport CustomHeader from '../../../framework/summaryFormate/CustomHeader';\r\nimport CollectionParcelSummary from './CollectionParcelSummary';\r\nimport CustomCaption from '../../../framework/summaryFormate/CustomCaption';\r\nimport { connect, useDispatch } from 'react-redux';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { setDropdownValues, formatDateToUKFormat } from '../../../utils/helperFunctions';\r\nimport { getYupSchemaFromMetaData } from '../../../utils/yupSchema/yupSchemaGenerator';\r\nimport { Form, Formik } from 'formik';\r\nimport CustomDialog from '../../../framework/dialog/customDialog';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { EmailParam } from '../../../utils/constants/constants';\r\nimport ClearanceDeclarationSummary from '../../../components/shipmentManagement/shipmentSummary/clearanceDeclarationSummary/clearanceDeclarationSummary';\r\nimport { getClearanceDeclarationDetails } from '../../../utils/utilsFunctions';\r\nimport { CLERANCE_DECLARATION, DELIVER_TYPE } from '../../../utils/constants/constants';\r\nimport { ReactComponent as EyesIcon } from '../../../assets/images/eyes.svg';\r\n\r\nconst formikRef = React.createRef();\r\n\r\nconst useStyles = makeStyles({\r\n boxContainer: {\r\n '& :last-child': {\r\n borderBottom: 'unset',\r\n },\r\n },\r\n customTitle: {\r\n color: '#000000E6',\r\n paddingBottom: '10px',\r\n paddingTop: '10px',\r\n },\r\n contentHead: {\r\n paddingBottom: '5px',\r\n paddingTop: '5px',\r\n },\r\n verticalLine: {\r\n borderLeft: '1px solid #E3E3E3',\r\n height: '500px',\r\n margin: '3px',\r\n },\r\n});\r\nconst BookedCollectionSummary = ({ userDetails }) => {\r\n const formField = emailLabelForm;\r\n const newEmailValidationSchema = getYupSchemaFromMetaData(formField, [], []);\r\n const initialValues = {\r\n sendLabelEmailAddress: '',\r\n };\r\n\r\n const dispatch = useDispatch();\r\n let { id } = useParams();\r\n const classes = useStyles();\r\n const [list, setlist] = useState([]);\r\n const [doorStepInstructionsValue, setDoorStepInstructionsValue] = useState('');\r\n let history = useHistory();\r\n const [accountDetails, setAccountDetails] = useState({});\r\n const [showEmailConfirmation, setShowEmailConfirmation] = useState(false);\r\n const [labelResponse, setLabelResponse] = useState('');\r\n const [labelEmail, setLabelEmail] = useState('');\r\n const [showClearanceDeclarationDetails, setShowClearanceDeclarationDetails] = useState(false);\r\n const [clearanceDeclarationDetails, setClearanceDeclarationDetails] = useState({});\r\n const [isDomestic, setisDomestic] = useState(true);\r\n\r\n const getShipmentList = () => {\r\n GET(`${ServiceEndPoints.getShipment}/${id}`)\r\n .then((res) => {\r\n setlist(res.data);\r\n setSelectedAccountDetails(res.data?.accountNumber);\r\n dispatch(\r\n actions.setShipmentId({\r\n shipmentId: res.data?.shipmentNumber,\r\n }),\r\n );\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n getShipmentList();\r\n return () => {\r\n dispatch(\r\n actions.setShipmentId({\r\n shipmentId: '',\r\n }),\r\n );\r\n };\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (((list || {}).deliveryOptions || {}).addressType === DELIVER_TYPE.DOORSTEP) {\r\n if (((list || {}).deliveryOptions || {}).neighbourDelivery) {\r\n setDoorStepInstructionsValue('Deliver to neighbour if no answer at doorstep');\r\n } else if (((list || {}).deliveryOptions || {}).secureLocationDelivery) {\r\n setDoorStepInstructionsValue('Leave safe if no answer at doorstep');\r\n } else {\r\n setDoorStepInstructionsValue('Deliver to doorstep only');\r\n }\r\n }\r\n if (((list || {}).collectionDetails || {}).email) {\r\n formikRef.current.setValues({ sendLabelEmailAddress: ((list || {}).collectionDetails || {}).email });\r\n } else {\r\n formikRef.current.setErrors({ sendLabelEmailAddress: 'Email address is required' });\r\n }\r\n }, [list]);\r\n\r\n const setSelectedAccountDetails = (accountId) => {\r\n setAccountDetails(setDropdownValues(userDetails.accounts, 'accountId', accountId));\r\n };\r\n\r\n const backToBookedCollection = () => {\r\n dispatch(actions.setActiveTab('bookedCollection'));\r\n history.push('/shipment/shipmentmanagement');\r\n };\r\n\r\n const cancelCollection = () => {\r\n const itemsToBeSelected = [];\r\n const item = {\r\n pickupAccount: list?.accountNumber,\r\n shipmentId: list?.shipmentNumber,\r\n postalCode: list?.deliveryAddress?.postalCode,\r\n };\r\n itemsToBeSelected.push(item);\r\n const payload = itemsToBeSelected;\r\n POST(ServiceEndPoints.cancelShipment, payload)\r\n .then((response) => {\r\n dispatch(actions.setAppSnackBarData({ type: 'success', msg: 'Collection successfully cancelled' }));\r\n dispatch(actions.setActiveTab('bookedCollection'));\r\n history.push({\r\n pathname: '/shipment/shipmentmanagement',\r\n state: {\r\n itemsToBeSelected: itemsToBeSelected,\r\n shipmentSummary: false,\r\n },\r\n });\r\n })\r\n .catch((error) => {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in cancelling the collection:' + payload[0].shipmentId,\r\n },\r\n ],\r\n }),\r\n );\r\n });\r\n };\r\n\r\n const handleSubmit = (values, errors) => {\r\n if (!isFormValid(errors)) {\r\n return;\r\n }\r\n const payload = [id];\r\n POST(`${ServiceEndPoints.reprintShipments}?isLabel=true&isCustomsInvoice=false&format=PDF`, payload)\r\n .then((response) => {\r\n setLabelEmail(values.sendLabelEmailAddress);\r\n setLabelResponse(response?.data[0]?.labelResponse[0]?.labels[0]?.label);\r\n setShowEmailConfirmation(false);\r\n })\r\n .catch((error) => {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: `Error in sending email : ${JSON.parse(error?.response?.data?.errorMessage)?.[0]?.title}\\n ${\r\n JSON.parse(error?.response?.data?.errorMessage)?.[0]?.detail\r\n }`,\r\n },\r\n ],\r\n }),\r\n );\r\n setShowEmailConfirmation(false);\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n if (labelResponse !== '' && labelEmail !== '') {\r\n let reqEmailObjArray = {\r\n fromEmailAddress: EmailParam.fromEmailAddress,\r\n toEmailAddresses: [labelEmail],\r\n subject: EmailParam.subject,\r\n body:\r\n list && list?.collectionDate !== ''\r\n ? EmailParam.body.replace('(date)', formatDateToUKFormat(list.collectionDate))\r\n : EmailParam.body,\r\n attachments: [\r\n {\r\n content: labelResponse,\r\n type: EmailParam.type,\r\n fileName: EmailParam.fileName,\r\n },\r\n ],\r\n displayRecipients: EmailParam.displayRecipients,\r\n };\r\n POST(`${ServiceEndPoints.email}`, reqEmailObjArray)\r\n .then((response) => {\r\n dispatch(actions.setAppSnackBarData({ type: 'success', msg: 'Email with label sent successfully' }));\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n }\r\n }, [labelResponse, labelEmail]);\r\n\r\n const isFormValid = (errors) => {\r\n const { deliveryServicePoint, ...restControls } = errors;\r\n return Object.keys(restControls).length === 0;\r\n };\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Collection details \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Delivery details \r\n \r\n \r\n \r\n \r\n \r\n {(list || {}).thirdPartyCollection === false && (\r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n\r\n \r\n \r\n Service \r\n \r\n \r\n \r\n \r\n \r\n\r\n {/* To view Clearance Declaration details for Domestic*/}\r\n {isDomestic && list?.clearanceDeclaration && (\r\n <>\r\n \r\n \r\n }\r\n onClick={getClearanceDeclarationDetails(\r\n id,\r\n setClearanceDeclarationDetails,\r\n setShowClearanceDeclarationDetails,\r\n dispatch,\r\n )}\r\n isDisabled={showClearanceDeclarationDetails}\r\n />\r\n \r\n \r\n {showClearanceDeclarationDetails && (\r\n \r\n \r\n \r\n )}\r\n >\r\n )}\r\n \r\n\r\n \r\n \r\n backToBookedCollection()}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n setShowEmailConfirmation(true)}\r\n />\r\n \r\n \r\n \r\n {({ values, setFieldValue, errors, setFieldError, setErrors, setFieldTouched }) => (\r\n \r\n )}\r\n \r\n \r\n );\r\n};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n userDetails: state.auth.userDetails,\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, null)(BookedCollectionSummary);\r\n\r\nconst emailLabelForm = {\r\n sendLabelEmailAddress: {\r\n props: {\r\n name: 'sendLabelEmailAddress',\r\n label: 'Email address',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 70,\r\n },\r\n },\r\n validation: {\r\n name: 'sendLabelEmailAddress',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Email address is required'],\r\n },\r\n {\r\n type: 'max',\r\n params: [70, 'Maximum 70 characters are allowed'],\r\n },\r\n {\r\n type: 'email',\r\n params: ['Invalid email address'],\r\n },\r\n {\r\n type: 'matches',\r\n params: [\r\n /^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/,\r\n 'Invalid email address',\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n};\r\n","import React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport DynamicMaterialTable from '../../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\n// import TableGrid from '../../../framework/grid/grid';\r\nimport { useHistory } from 'react-router-dom';\r\nimport { Grid } from '@material-ui/core';\r\n\r\nconst ShipmentDetailView = (props) => {\r\n let history = useHistory();\r\n\r\n const onRowClicked = (res) => {\r\n history.push(`/dashboard/summary/${res.shipments[0].shipmentDetails.shipmentId}`);\r\n };\r\n\r\n return (\r\n \r\n \r\n \r\n );\r\n};\r\n\r\nShipmentDetailView.propTypes = {};\r\n\r\nexport default ShipmentDetailView;\r\n","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport ShipmentDetailView from '../shipmentDetailView/shipmentDetailView';\r\nimport { Grid, IconButton, SvgIcon, MenuItem, Select, ListItemIcon, ListItemText, Checkbox } from '@material-ui/core';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport { Form, Formik } from 'formik';\r\nimport { axiosConfig, GET, POST } from '../../../api/axios';\r\nimport { useHistory } from 'react-router';\r\nimport { connect, useDispatch, useSelector } from 'react-redux';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { ReactComponent as FilterIcon } from '../../../assets/images/Filter.svg';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport {\r\n customTableSort,\r\n getBackGroundColor,\r\n remove_duplicates_dashboardSummary,\r\n basicSort,\r\n customTableShipmentNoSort,\r\n formatDateToUKFormat,\r\n formatDate,\r\n} from '../../../utils/helperFunctions';\r\n// import TableExport from '../../../components/TableExport/TableExport';\r\nimport TableExportPopup from '../../../components/TableExport/TableExportPopup';\r\nimport './summary.scss';\r\nimport jsPDF from 'jspdf';\r\nimport 'jspdf-autotable';\r\nimport { arrayValuesToQueryStringParam } from '../../../utils/common';\r\nimport { getDayOfTheWeek, convertTZwithFormat, formatDateToSecondFormat, convertTZ } from '../../../utils/helperFunctions';\r\n\r\nconst filterButtonStyle = {\r\n padding: '4px !important',\r\n};\r\nconst ITEM_HEIGHT = 48;\r\nconst ITEM_PADDING_TOP = 8;\r\nconst MenuProps = {\r\n PaperProps: {\r\n style: {\r\n maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,\r\n width: 250,\r\n },\r\n },\r\n getContentAnchorEl: null,\r\n anchorOrigin: {\r\n vertical: 'bottom',\r\n horizontal: 'center',\r\n },\r\n transformOrigin: {\r\n vertical: 'top',\r\n horizontal: 'center',\r\n },\r\n};\r\nconst Summary = ({ dashboardDetails, userDetails }) => {\r\n const trackingType = useSelector((state) => state.dashboardTracking.dashboardTracking);\r\n const dashboardResponse = (dashboardDetails || {}).loadedResponse;\r\n const history = useHistory();\r\n const dispatch = useDispatch();\r\n // const [totalRecodsLength, setTotalRecodsLength] = useState();\r\n const getLookupData = (dataObj, isNested = false, nestedPropertyName = '') => {\r\n let lookupObj = {};\r\n (dataObj || []).forEach((ele) => {\r\n const propertyValue = isNested ? ele[nestedPropertyName] : ele;\r\n lookupObj[propertyValue] = propertyValue;\r\n });\r\n return lookupObj;\r\n };\r\n const getLookupFilterData = (dataObj, isNested = false, nestedPropertyName = '') => {\r\n let lookupArray = [];\r\n (dataObj || []).forEach((ele) => {\r\n const propertyValue = isNested ? ele[nestedPropertyName] : ele;\r\n lookupArray.push(propertyValue);\r\n });\r\n return lookupArray;\r\n };\r\n\r\n const headers = [\r\n { label: 'Accounts', key: 'pickupAccount' },\r\n { label: 'Customer reference', key: 'customerReferenceNumber' },\r\n { label: 'Shipment number', key: 'Shipmentnumber' },\r\n { label: 'Status', key: 'status' },\r\n { label: 'Delivery due date', key: 'deliveryDueDate' },\r\n { label: 'ETA', key: 'ETA' },\r\n { label: 'Number of parcels', key: 'numberOfParcels' },\r\n { label: 'Weight', key: 'weight' },\r\n { label: 'Product', key: 'product' },\r\n { label: 'Service', key: 'service' },\r\n { label: 'Country', key: 'destinationCountry' },\r\n { label: 'Dispatch date', key: 'collectionDate' },\r\n { label: 'Business/Recipient name', key: 'recipientName' },\r\n { label: 'Contact number', key: 'contactNumber' },\r\n { label: 'Postal Code', key: 'destinationPostalCode' },\r\n ];\r\n\r\n const CustomFilter = (props) => {\r\n const [selectedVal, setSelectedVal] = useState([]);\r\n function handleChange(e) {\r\n const val = e.target.value;\r\n setSelectedVal(val);\r\n props.onFilterChanged(props.columnDef.tableData?.id, val);\r\n }\r\n\r\n return (\r\n \r\n {data.length > 1 ? data[0] + ',...' : data[0]}
}\r\n >\r\n {props.columnDef.filterValues.map((option) => (\r\n \r\n \r\n -1} />\r\n \r\n \r\n \r\n ))}\r\n \r\n \r\n );\r\n };\r\n const columns = [\r\n { title: 'id', field: 'id', hidden: true },\r\n {\r\n title: (\r\n \r\n
\r\n Accounts \r\n
\r\n {(\r\n (dashboardDetails || {}).loadedFrom === 'findshipment'\r\n ? (dashboardDetails || {}).userAccounts.length > 1\r\n : (dashboardResponse?.accounts ?? []).length > 1\r\n ) ? (\r\n
\r\n\r\n setShowFilter(true)} style={filterButtonStyle}>\r\n \r\n \r\n
\r\n ) : null}\r\n
\r\n ),\r\n field: 'pickupAccount',\r\n fieldName: 'accounts',\r\n // lookup: getLookupData(dashboardResponse?.accounts ?? [], false, ''),\r\n lookup: getLookupData(\r\n (dashboardDetails || {}).loadedFrom === 'findshipment'\r\n ? (dashboardDetails || {}).userAccounts\r\n : dashboardResponse?.accounts ?? [],\r\n false,\r\n '',\r\n ),\r\n // filtering: (dashboardResponse?.accounts ?? []).length > 1,\r\n filtering:\r\n (dashboardDetails || {}).loadedFrom === 'findshipment'\r\n ? (dashboardDetails || {}).userAccounts.length > 1\r\n : (dashboardResponse?.accounts ?? []).length > 1,\r\n // customSort: (a, b) => customTableSort(a.pickupAccount, b.pickupAccount),\r\n sorting: true,\r\n filterValues: getLookupFilterData(\r\n (dashboardDetails || {}).loadedFrom === 'findshipment'\r\n ? (dashboardDetails || {}).userAccounts\r\n : dashboardResponse?.accounts ?? [],\r\n false,\r\n '',\r\n ),\r\n filterComponent: (props) => ,\r\n },\r\n {\r\n title: 'Customer ref.',\r\n field: 'customerReferenceNumber',\r\n filtering: false,\r\n //whiteSpace: \"nowrap\",\r\n // customSort: (a, b) => customTableSort(a.customerReferenceNumber, b.customerReferenceNumber),\r\n sorting: true,\r\n },\r\n {\r\n title: 'Shipment no.',\r\n field: 'shipments[0].shipmentDetails.shipmentId',\r\n filtering: false,\r\n customSort: (a, b) =>\r\n customTableShipmentNoSort(a.shipments[0].shipmentDetails.shipmentId, b.shipments[0].shipmentDetails.shipmentId),\r\n },\r\n {\r\n title: (\r\n \r\n
\r\n Status \r\n
\r\n {dashboardDetails.loadedFrom !== 'onChartClick' ? (\r\n
\r\n setShowFilter(true)} style={filterButtonStyle}>\r\n \r\n \r\n
\r\n ) : null}\r\n
\r\n ),\r\n field: 'status',\r\n fieldName: 'status',\r\n cellStyle: {\r\n whiteSpace: 'nowrap',\r\n },\r\n render: (row) => (\r\n \r\n \r\n \r\n {row.status}\r\n \r\n \r\n ),\r\n filtering: dashboardDetails.loadedFrom !== 'onChartClick',\r\n lookup: {\r\n 'In transit': 'In transit',\r\n 'Out for delivery': 'Out for delivery',\r\n Exception: 'Exception',\r\n Delivered: 'Delivered',\r\n 'Delivery attempted': 'Delivery attempted',\r\n 'Order received': 'Order received'\r\n },\r\n filterValues: [\r\n 'In transit',\r\n 'Out for delivery',\r\n 'Exception',\r\n 'Delivered',\r\n 'Delivery attempted',\r\n 'Order received'\r\n ],\r\n sorting: false,\r\n filterComponent: (props) => ,\r\n },\r\n {\r\n\r\n title: (trackingType?.loadedFrom === 'onChartClick' && trackingType?.status === 'Delivered') ? 'Delivery date' : 'Delivery due date',\r\n field: 'deliveryDueDate',\r\n filtering: false,\r\n // sorting: true,\r\n\r\n render: (row) => row?.status === 'Out for delivery' ? {convertTZwithFormat(row?.eventDateTime, 'DD/MM/YYYY')} : trackingType?.loadedFrom === 'onChartClick' && trackingType?.status === 'Delivered' ? {convertTZwithFormat(row?.eventDateTime, 'DD/MM/YYYY')} : {`${((trackingType?.loadedFrom === 'detailView' || trackingType?.loadedFrom === 'findshipment') && row?.status === 'Delivered') ? '' : formatDateToUKFormat(row?.deliveryDueDate)}`} ,\r\n customSort: (a, b) =>\r\n basicSort(new Date(a?.deliveryDueDate).getTime() || 0, new Date(b?.deliveryDueDate).getTime() || 0),\r\n },\r\n {\r\n title: (trackingType?.loadedFrom === 'onChartClick' && trackingType?.status === 'Delivered') ? 'Delivery time' : 'ETA',\r\n cellStyle: {\r\n whiteSpace: 'nowrap',\r\n },\r\n render: (row) => (trackingType?.loadedFrom === 'detailView' || trackingType?.loadedFrom === 'findshipment') && row?.status === 'Delivered' ? '' : row?.status === 'Out for delivery' ? {(row?.eventEstimatedDeliveryStartTime && row?.eventEstimatedDeliveryEndTime) ? `${row?.eventEstimatedDeliveryStartTime} - ${row?.eventEstimatedDeliveryEndTime}` : `${row?.estimatedDeliveryStartTime} - ${row?.estimatedDeliveryEndTime}`} : (trackingType?.loadedFrom === 'onChartClick' && trackingType?.status === 'Delivered') ? convertTZwithFormat(row?.eventDateTime, 'H:mm') : (row?.estimatedDeliveryStartTime && row?.estimatedDeliveryEndTime && {`${row?.estimatedDeliveryStartTime} - ${row?.estimatedDeliveryEndTime}`} ),\r\n filtering: false,\r\n // customSort: (a, b) => customTableSort(a?.estimatedDeliveryStartTime, b?.estimatedDeliveryStartTime),\r\n sorting: true,\r\n },\r\n {\r\n title: 'No. of parcels',\r\n field: 'numberOfParcels',\r\n filtering: false,\r\n // customSort: (a, b) => customTableSort(a.numberOfParcels, b.numberOfParcels),\r\n sorting: true,\r\n },\r\n // {\r\n // title: 'Weight',\r\n // field: 'weight',\r\n // filtering: false,\r\n // customSort: (a, b) => customTableSort(a.weight, b.weight),\r\n // },\r\n {\r\n title: (\r\n \r\n
\r\n Product \r\n
\r\n {!(\r\n dashboardDetails.loadedFrom === 'onChartClick' ||\r\n (history.location.pathname.indexOf('dashboardDetailsBreakdown') !== -1 &&\r\n ((dashboardDetails.loadedResponse || {}).product || {}).value)\r\n ) ? (\r\n
\r\n setShowFilter(true)} style={filterButtonStyle}>\r\n \r\n \r\n
\r\n ) : null}\r\n
\r\n ),\r\n field: 'product.productNameForUI',\r\n fieldName: 'product',\r\n filtering: !(\r\n dashboardDetails.loadedFrom === 'onChartClick' ||\r\n (history.location.pathname.indexOf('dashboardDetailsBreakdown') !== -1 &&\r\n ((dashboardDetails.loadedResponse || {}).product || {}).value)\r\n ),\r\n lookup: getLookupData(dashboardDetails.products, true, 'productName'),\r\n filterValues: getLookupFilterData(dashboardDetails.products, true, 'productName'),\r\n filterComponent: (props) => ,\r\n // customSort: (a, b) => customTableSort((a.product || {}).productName, (b.product || {}).productName),\r\n sorting: true,\r\n },\r\n {\r\n title: (\r\n \r\n
\r\n Service \r\n
\r\n {!(\r\n dashboardDetails.loadedFrom === 'onChartClick' ||\r\n (history.location.pathname.indexOf('dashboardDetailsBreakdown') !== -1 &&\r\n ((dashboardDetails.loadedResponse || {}).domesticService || {}).value)\r\n ) ? (\r\n
\r\n setShowFilter(true)} style={filterButtonStyle}>\r\n \r\n \r\n
\r\n ) : null}\r\n
\r\n ),\r\n field: 'service.description',\r\n fieldName: 'service',\r\n lookup: getLookupData(dashboardDetails.services, true, 'serviceName'),\r\n filterValues: getLookupFilterData(dashboardDetails.services, true, 'serviceName'),\r\n filterComponent: (props) => ,\r\n filtering: !(\r\n dashboardDetails.loadedFrom === 'onChartClick' ||\r\n (history.location.pathname.indexOf('dashboardDetailsBreakdown') !== -1 &&\r\n ((dashboardDetails.loadedResponse || {}).domesticService || {}).value)\r\n ),\r\n // customSort: (a, b) => customTableSort(a.service.description, b.service.description),\r\n sorting: true,\r\n },\r\n {\r\n title: (\r\n \r\n
\r\n Country \r\n
\r\n {dashboardDetails.loadedFrom === 'onChartClick' ||\r\n ((history.location.pathname.indexOf('dashboardDetailsSummary') !== -1 ||\r\n history.location.pathname.indexOf('dashboardDetailsBreakdown') !== -1) &&\r\n ((dashboardDetails.loadedResponse || {}).internationalCountry || {}).name !== 'All countries') ? null : (\r\n
\r\n setShowFilter(true)} style={filterButtonStyle}>\r\n \r\n \r\n
\r\n )}\r\n
\r\n ),\r\n field: 'destinationCountry',\r\n fieldName: 'destinationCountry',\r\n filtering: !(\r\n dashboardDetails.loadedFrom === 'onChartClick' ||\r\n ((history.location.pathname.indexOf('dashboardDetailsSummary') !== -1 ||\r\n history.location.pathname.indexOf('dashboardDetailsBreakdown') !== -1) &&\r\n ((dashboardDetails.loadedResponse || {}).internationalCountry || {}).name !== 'All countries')\r\n ),\r\n lookup: getLookupData(dashboardDetails.countries, true, 'name'),\r\n filterValues: getLookupFilterData(dashboardDetails.countries, true, 'name'),\r\n filterComponent: (props) => ,\r\n sorting: false,\r\n },\r\n {\r\n title: 'Dispatch date',\r\n field: 'collectionDate',\r\n filtering: false,\r\n // sorting: false,\r\n render: (row) => {`${formatDateToUKFormat(row.collectionDate)}`} ,\r\n customSort: (a, b) =>\r\n basicSort(new Date(a.collectionDate).getTime() || 0, new Date(b.collectionDate).getTime() || 0),\r\n },\r\n {\r\n title: 'Business/Recipient name',\r\n field: 'recipientName',\r\n render: (row) => (\r\n \r\n \r\n {row?.recipientName ? row.recipientName : row.businessName ? row.businessName : row.receiverName}\r\n \r\n \r\n ),\r\n filtering: false,\r\n // customSort: (a, b) =>\r\n // customTableSort(\r\n // a.businessName ? a.businessName : a.receiverName,\r\n // b.businessName ? b.businessName : b.receiverName,\r\n // ),\r\n sorting: true,\r\n },\r\n {\r\n title: 'Contact no.',\r\n field: 'contactNumber',\r\n filtering: false,\r\n // customSort: (a, b) => customTableSort(a.contactNumber, b.contactNumber),\r\n sorting: true,\r\n },\r\n {\r\n title: 'Postal code',\r\n field: 'destinationPostalCode',\r\n filtering: false,\r\n // customSort: (a, b) => customTableSort(a.destinationPostalCode, b.destinationPostalCode),\r\n sorting: true,\r\n },\r\n ];\r\n\r\n const [selectedRows, setSelectedRows] = useState([]);\r\n const [tableColumns, setTableColumns] = useState(columns);\r\n const [tableHeaderColumns, setTableHeaderColumns] = useState(headers);\r\n const [selectedAccounts, setSelectedAccounts] = useState([]);\r\n const [SelectedAccountsFromDashboard, setSelectedAccountsFromDashboard] = useState([]);\r\n const [shipmentCancelItems, setshipmentCancelItems] = useState([]);\r\n const [tableRawData, setTableRawData] = useState([]);\r\n const [ExporttableRawData, setExportTableRawData] = useState([]);\r\n const [TotalCount, setTotalCount] = useState(0);\r\n const [pageSize, setPageSize] = useState(10);\r\n const [tableData, setTableData] = useState([]);\r\n const [tableDataLength, setTableDataLength] = useState([]);\r\n const [pageNumber, setPageNumber] = useState(0);\r\n const [queryString, setqueryString] = useState('');\r\n const [sortByOrder, setSortByOrder] = useState('');\r\n\r\n const [isLoading, setIsLoading] = useState(false);\r\n const [showExportDialog, setshowExportDialog] = useState(false);\r\n\r\n // const [pageSize, setPageSize] = useState(10);\r\n\r\n const [pageDetails, setPageDetails] = useState({\r\n offset: 0,\r\n limit: 0,\r\n totalRecordsLength: 0,\r\n });\r\n const [showFilter, setShowFilter] = React.useState(false);\r\n\r\n const addSelectedRows = (selectedRowsFromTable) => {\r\n setSelectedRows(selectedRowsFromTable);\r\n };\r\n\r\n const addToMonitorList = () => {\r\n const reqBody = selectedRows.map((row) => {\r\n return {\r\n customerReference: row.customerReferenceNumber,\r\n shipmentNumber: row.shipments[0].shipmentDetails.shipmentId,\r\n collectionDate: row.collectionDate,\r\n deliveryDate: row.deliveryDueDate,\r\n status: row.status,\r\n };\r\n });\r\n POST(`${ServiceEndPoints.getAllMonitioredShipments}${userDetails.userId}`, reqBody)\r\n .then((res) => {\r\n setSelectedRows([]);\r\n dispatch(actions.setAppSnackBarData({ msg: 'Details added to monitor list' }));\r\n getTableData();\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n };\r\n\r\n const trackShipmet = () => {\r\n // history.push(`/dashboard/Tracking?id=${selectedRows[0].shipments[0].shipmentDetails.shipmentId}`);\r\n window.open(`#/dashboard/Tracking?id=${selectedRows[0].shipments[0].shipmentDetails.shipmentId}`,'_blank');\r\n };\r\n\r\n const getUrl = (offset, limit) => {\r\n let url = `${ServiceEndPoints.getShipmentManagement}${(dashboardDetails || {}).dashboardQueryParams}`;\r\n url += queryString?.indexOf('accounts=') > -1 ? '' : `&${dashboardDetails.accountsParams}`;\r\n if (queryString) {\r\n url += `${queryString}`;\r\n }\r\n if (sortByOrder) {\r\n url += sortByOrder;\r\n }\r\n url += `&offset=${offset}`;\r\n return (url += `&limit=${limit}`);\r\n };\r\n\r\n useEffect(() => {\r\n getTableData();\r\n }, [pageSize, pageNumber, queryString]);\r\n\r\n const getTableData = () => {\r\n setIsLoading(true);\r\n const offset = pageNumber * pageSize;\r\n axiosConfig\r\n .get(getUrl(offset, pageSize))\r\n .then((res) => {\r\n let tempTableData = [];\r\n tempTableData = res.data?.shipmentModels;\r\n if (history.location && history.location.state !== undefined && history.location.state !== null) {\r\n tempTableData = remove_duplicates_dashboardSummary(tempTableData, history.location.state.itemsToBeSelected);\r\n }\r\n setTableData(tempTableData);\r\n setTableRawData(tempTableData);\r\n setPageDetails({\r\n offset,\r\n pageSize,\r\n totalRecordsLength: res.data?.totalRecords,\r\n });\r\n // setTotalRecodsLength(res.data?.totalRecords);\r\n resolveTableData(res.data?.totalRecords);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n setTableData([]);\r\n setTableRawData([]);\r\n setPageDetails({\r\n offset,\r\n pageSize,\r\n totalRecordsLength: 0,\r\n });\r\n })\r\n .finally(() => {\r\n setIsLoading(false);\r\n });\r\n };\r\n const onPageNumChange = (pageNum = 0) => {\r\n setPageNumber(pageNum);\r\n };\r\n\r\n const onFilter_Change = (filterData) => {\r\n let _filterQueryString = '';\r\n filterData.map((element) => {\r\n if (element.value.length > 0) {\r\n element.value.map((data) => {\r\n if (!dashboardResponse?.isDomestic && element.column.fieldName === \"destinationCountry\") {\r\n dashboardDetails.countries.map((country) => {\r\n if (country.name === data) {\r\n _filterQueryString += `&${element.column.fieldName}=${country.code2Digit}`;\r\n }\r\n })\r\n } else {\r\n _filterQueryString += `&${element.column.fieldName}=${data}`;\r\n }\r\n });\r\n }\r\n });\r\n // console.log(_filterQueryString);\r\n setqueryString(_filterQueryString);\r\n setPageNumber(0);\r\n setPageSize(10);\r\n // getTableData();\r\n };\r\n\r\n const onPageSizeChange = (pageSize = 10) => {\r\n setPageSize(pageSize);\r\n };\r\n\r\n // const filterData = (filters) => {\r\n // // const filtersArray = [...query.filters];\r\n // const filteredAccounts = filters.find((filter) => filter.column.field === 'pickupAccount');\r\n // (filteredAccounts || {}).value === undefined || (filteredAccounts || {}).value.length == 0\r\n // ? setSelectedAccounts(SelectedAccountsFromDashboard)\r\n // : setSelectedAccounts((filteredAccounts || {}).value);\r\n\r\n // const filteredData = tableRawData.filter((row) => {\r\n // return !filters\r\n // .filter((individualFilter) => individualFilter.value.length > 0)\r\n // .map((mappedObjet) => {\r\n // if (\r\n // (mappedObjet.value || []).filter((filterValue) => {\r\n // const rowValue = mappedObjet.column.field.split('.').reduce((a, b) => (a || {})[b], row);\r\n // return (filterValue || '').toLowerCase() === (rowValue || '').toLowerCase();\r\n // }).length > 0\r\n // ) {\r\n // return true;\r\n // }\r\n // return false;\r\n // })\r\n // .some((checkValue) => checkValue === false);\r\n // });\r\n // setTableData(filteredData);\r\n // // resolveTableData(resolve, filteredData, query, totalRecordsLength);\r\n // };\r\n\r\n useEffect(() => {\r\n if (history.location && history.location.state !== undefined && history.location.state !== null) {\r\n setshipmentCancelItems(history.location.state.itemsToBeSelected);\r\n }\r\n return () => {\r\n if (history.location.pathname === '/dashboard') {\r\n dispatch(\r\n actions.setDashboardTracking({\r\n loadedFrom: 'dashboardDetails',\r\n loadedResponse: dashboardResponse,\r\n dashboardQueryParams: (dashboardDetails || {}).dashboardQueryParams,\r\n tabIndex: (dashboardDetails || {}).tabIndex,\r\n accountsParams: arrayValuesToQueryStringParam(dashboardDetails?.loadedResponse?.accounts),\r\n }),\r\n );\r\n }\r\n };\r\n }, []);\r\n\r\n const resolveTableData = (totalRecordsLength) => {\r\n setTotalCount(totalRecordsLength ?? 0);\r\n };\r\n\r\n useEffect(() => {\r\n let updatedColumns = [...columns];\r\n let updatedHeaderColumns = [...headers];\r\n updatedColumns.forEach((column) => {\r\n if (column.lookup && Object.keys(column.lookup).length === 0 && column.lookup.constructor === Object) {\r\n delete column.lookup;\r\n }\r\n });\r\n if (dashboardResponse?.isDomestic) {\r\n updatedColumns = updatedColumns.filter((val) => val.fieldName !== 'destinationCountry')\r\n updatedHeaderColumns = updatedHeaderColumns.filter((val) => val.key !== 'destinationCountry')\r\n // updatedColumns.splice(10, 1);\r\n // updatedHeaderColumns.splice(9, 1);\r\n } else {\r\n // updatedColumns.splice(9, 1);\r\n updatedColumns = updatedColumns.filter((val) => val.fieldName !== 'service')\r\n updatedHeaderColumns = updatedHeaderColumns.filter((val) => val.key !== 'service')\r\n // updatedHeaderColumns.splice(10, 1);\r\n }\r\n // updatedHeaderColumns = updatedHeaderColumns.map((val) => {\r\n // if (trackingType?.loadedFrom === 'onChartClick' && trackingType?.status === 'Delivered') {\r\n // if (val.key === 'ETA') val.label = \"Delivery time\";\r\n // else if (val.key === 'deliveryDueDate') val.label = \"Delivery date\"\r\n // };\r\n // return val\r\n // });\r\n setTableColumns(updatedColumns);\r\n setTableHeaderColumns(updatedHeaderColumns);\r\n setSelectedAccounts(\r\n (dashboardDetails || {}).loadedFrom === 'findshipment'\r\n ? (dashboardDetails || {}).userAccounts\r\n : ((dashboardDetails || {}).loadedResponse || {}).accounts,\r\n );\r\n setSelectedAccountsFromDashboard(\r\n (dashboardDetails || {}).loadedFrom === 'findshipment'\r\n ? (dashboardDetails || {}).userAccounts\r\n : ((dashboardDetails || {}).loadedResponse || {}).accounts,\r\n );\r\n }, [dashboardDetails]);\r\n\r\n const onDataUpdate = async () => {\r\n dispatch(actions.setLoaderLayOver(true));\r\n await GET(getUrl(0, pageDetails.totalRecordsLength))\r\n .then((res) => {\r\n let ExportData = [];\r\n res.data.shipmentModels.forEach((data) => {\r\n ExportData.push({\r\n pickupAccount: data?.pickupAccount,\r\n customerReferenceNumber: data?.customerReferenceNumber,\r\n Shipmentnumber: data.shipments[0]?.shipmentDetails?.shipmentId,\r\n status: data?.status,\r\n deliveryDueDate: (trackingType?.loadedFrom === 'onChartClick' && trackingType?.status === 'Delivered') ?\r\n convertTZwithFormat(data?.eventDateTime, 'DD/MM/YYYY') :\r\n data?.status === 'Delivered' ? '' : formatDate(data.deliveryDueDate, '/','dd/mm/yyyy', true),\r\n ETA: (trackingType?.loadedFrom === 'onChartClick' && trackingType?.status === 'Delivered') ?\r\n convertTZwithFormat(data?.eventDateTime, 'H:mm') :\r\n data?.status === 'Delivered' ? '' :\r\n data?.status === 'Out for delivery' && (data?.eventEstimatedDeliveryStartTime && data?.eventEstimatedDeliveryEndTime) ?\r\n `${data?.eventEstimatedDeliveryStartTime} - ${data?.eventEstimatedDeliveryEndTime}` :\r\n `${data?.estimatedDeliveryStartTime} - ${data?.estimatedDeliveryEndTime}`,\r\n numberOfParcels: data?.numberOfParcels,\r\n weight: data?.shipments[0]?.shipmentDetails?.totalWeight,\r\n product: data.product?.productNameForUI,\r\n service: data.service?.description,\r\n destinationCountry: data?.destinationCountry,\r\n collectionDate: formatDate(data?.collectionDate, '/', 'dd/mm/yyyy'),\r\n recipientName: data?.recipientName ? data.recipientName : data?.businessName != '' ? data?.businessName : data?.receiverName,\r\n contactNumber: data?.contactNumber,\r\n destinationPostalCode: data?.destinationPostalCode,\r\n });\r\n });\r\n setExportTableRawData(ExportData);\r\n dispatch(actions.setAppSnackBarData({ msg: `Data exported successfully` }));\r\n setshowExportDialog(false);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n setExportTableRawData([]);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in exporting data, please try again later',\r\n },\r\n ],\r\n }),\r\n );\r\n setshowExportDialog(false);\r\n })\r\n .finally(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n });\r\n };\r\n const printDocument = () => {\r\n try {\r\n axiosConfig.get(getUrl(0, pageDetails.totalRecordsLength)).then(async (res) => {\r\n let data = res.data?.shipmentModels ?? [];\r\n const unit = 'pt';\r\n const size = 'A4'; // Use A1, A2, A3 or A4\r\n const orientation = 'landscape'; // portrait or landscape\r\n const doc = new jsPDF(orientation, unit, size);\r\n const title = 'My Awesome Report';\r\n\r\n let updatedColumns = [...columns];\r\n let updatedHeaderColumns = [...headers];\r\n updatedColumns.forEach((column) => {\r\n if (column.lookup && Object.keys(column.lookup).length === 0 && column.lookup.constructor === Object) {\r\n delete column.lookup;\r\n }\r\n });\r\n if (dashboardResponse?.isDomestic) {\r\n // updatedColumns.splice(10, 1);\r\n updatedHeaderColumns = updatedHeaderColumns.filter((val) => val.key !== 'destinationCountry');\r\n data = data.map((elt) => [\r\n elt.pickupAccount,\r\n elt.customerReferenceNumber,\r\n elt.shipmentId,\r\n elt.status,\r\n (trackingType?.loadedFrom === 'onChartClick' && trackingType?.status === 'Delivered') ?\r\n convertTZwithFormat(elt?.eventDateTime, 'DD/MM/YYYY') :\r\n elt?.status === 'Delivered' ? '' : formatDate(elt.deliveryDueDate, '/', 'dd/mm/yyyy', true),\r\n (trackingType?.loadedFrom === 'onChartClick' && trackingType?.status === 'Delivered') ?\r\n convertTZwithFormat(elt?.eventDateTime, 'H:mm') :\r\n elt?.status === 'Delivered' ? '' :\r\n elt?.status === 'Out for delivery' && (elt?.eventEstimatedDeliveryStartTime && elt?.eventEstimatedDeliveryEndTime) ?\r\n `${elt?.eventEstimatedDeliveryStartTime} - ${elt?.eventEstimatedDeliveryEndTime}` :\r\n `${elt?.estimatedDeliveryStartTime} - ${elt?.estimatedDeliveryEndTime}`,\r\n elt.numberOfParcels,\r\n elt?.shipments[0]?.shipmentDetails?.totalWeight,\r\n elt.product?.productNameForUI,\r\n elt.service?.description,\r\n formatDate(elt.collectionDate, '/', 'dd/mm/yyyy'),\r\n elt?.recipientName ? elt.recipientName : elt.businessName != '' ? elt?.businessName : elt?.receiverName,\r\n elt.contactNumber,\r\n elt.destinationPostalCode,\r\n ]);\r\n } else {\r\n // updatedColumns.splice(9, 1);\r\n updatedHeaderColumns = updatedHeaderColumns.filter((val) => val.key !== 'service');\r\n data = data.map((elt) => [\r\n elt.pickupAccount,\r\n elt.customerReferenceNumber,\r\n elt.shipmentId,\r\n elt.status,\r\n (trackingType?.loadedFrom === 'onChartClick' && trackingType?.status === 'Delivered') ?\r\n convertTZwithFormat(elt?.eventDateTime, 'DD/MM/YYYY') :\r\n elt?.status === 'Delivered' ? '' : formatDate(elt.deliveryDueDate, '/', 'dd/mm/yyyy', true),\r\n (trackingType?.loadedFrom === 'onChartClick' && trackingType?.status === 'Delivered') ?\r\n convertTZwithFormat(elt?.eventDateTime, 'H:mm') :\r\n elt?.status === 'Delivered' ? '' :\r\n elt?.status === 'Out for delivery' && (elt?.eventEstimatedDeliveryStartTime && elt?.eventEstimatedDeliveryEndTime) ?\r\n `${elt?.eventEstimatedDeliveryStartTime} - ${elt?.eventEstimatedDeliveryEndTime}` :\r\n `${elt?.estimatedDeliveryStartTime} - ${elt?.estimatedDeliveryEndTime}`,\r\n elt.numberOfParcels,\r\n elt?.shipments[0]?.shipmentDetails?.totalWeight,\r\n elt.product?.productNameForUI,\r\n elt.destinationCountry,\r\n formatDate(elt.collectionDate, '/', 'dd/mm/yyyy'),\r\n elt.businessName != '' ? elt?.businessName : elt?.receiverName,\r\n elt.contactNumber,\r\n elt.destinationPostalCode,\r\n ]);\r\n }\r\n const _headers = [updatedHeaderColumns.map((headers) => headers.label)];\r\n if (!dashboardResponse?.isDomestic) {\r\n }\r\n\r\n let content = {\r\n head: _headers,\r\n body: data,\r\n columnStyles: {\r\n 1: {\r\n columnWidth: 80,\r\n },\r\n 6: {\r\n columnWidth: 35,\r\n },\r\n 11: {\r\n columnWidth: 100,\r\n },\r\n 12: {\r\n columnWidth: 60,\r\n }\r\n // 7: {\r\n // columnWidth: 50\r\n // },\r\n // 8: {\r\n // columnWidth: 50\r\n // }\r\n },\r\n styles: {\r\n cellWidth: 'wrap',\r\n fontSize: 6,\r\n cellPadding: 2,\r\n overflowColumns: 'linebreak',\r\n },\r\n };\r\n\r\n // doc.text(title, marginLeft, 40);\r\n doc.autoTable(content);\r\n doc.save('DashboardSummary.pdf');\r\n dispatch(actions.setAppSnackBarData({ msg: `Data exported successfully` }));\r\n setshowExportDialog(false);\r\n });\r\n } catch (err) {\r\n console.log(err);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in exporting data, please try again later',\r\n },\r\n ],\r\n }),\r\n );\r\n setshowExportDialog(false);\r\n }\r\n };\r\n\r\n const handleDialogClose = () => {\r\n setshowExportDialog(false);\r\n };\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Selected accounts
\r\n {(selectedAccounts || []).join(', ')}
\r\n
\r\n \r\n \r\n \r\n setshowExportDialog(true)}\r\n isDisabled={tableDataLength === 0 ? true : false}\r\n />\r\n \r\n {/* */}\r\n \r\n \r\n \r\n \r\n \r\n \r\n onPageSizeChange(e),\r\n onChangePage: (a) => onPageNumChange(a),\r\n onFilterChange: (e) => onFilter_Change(e),\r\n }}\r\n page={pageNumber}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nSummary.propTypes = {};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n dashboardDetails: ((state || {}).dashboardTracking || {}).dashboardTracking,\r\n userDetails: state.auth.userDetails,\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, null)(Summary);\r\n","import React, { useEffect, useState } from \"react\";\r\nimport { connect } from 'react-redux';\r\nimport { Grid } from \"@material-ui/core\";\r\nimport { useSelector } from 'react-redux';\r\nimport { axiosConfig } from '../../../api/axios';\r\nimport { ServiceEndPoints } from \"../../../utils/constants/ApiConstant\";\r\nimport moment from \"moment\";\r\nimport * as actions from '../../../store/actions/index'\r\n\r\nconst MarketplaceConfig = (props) => {\r\n\r\n const[hostedPageUrl, setHostedPageUrl]= useState(\"\");\r\n const[pageExpiredAt, setpageExpiredAt]= useState(\"\");\r\n const[storeCreationFlag, setStoreCreationFlag]= useState(false);\r\n\r\n const userDetails = useSelector((state) => state.auth.userDetails);\r\n\r\n useEffect(()=>{\r\n const interval = setInterval(() => {\r\n var currentDate = moment();\r\n var expiryDate = moment(pageExpiredAt);\r\n \r\n if(expiryDate.diff(currentDate, 'minutes') === 3){\r\n setStoreCreationFlag(!storeCreationFlag)\r\n }\r\n }, 60000);\r\n \r\n return () => clearInterval(interval);\r\n },[pageExpiredAt]);\r\n\r\n useEffect(()=>{\r\n props.setLoader(true);\r\n axiosConfig\r\n .post(`${ServiceEndPoints.getHostedPageUrl}?customerAccountNumber=${userDetails?.accounts[0]?.customerAccountNumber}`)\r\n .then((res) => {\r\n setHostedPageUrl(res.data?.url);\r\n setpageExpiredAt(res.data?.expiredAt);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n if (err.response?.status === 422) {\r\n axiosConfig\r\n .post(`${ServiceEndPoints.getCreateStoreUrl}?customerAccountNumber=${userDetails?.accounts[0]?.customerAccountNumber}`)\r\n .then((res) => {\r\n setStoreCreationFlag(!storeCreationFlag)\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n props.setBottomAlert({msgs : [\r\n {\r\n type: 'error',\r\n msg: 'Authentication error. Please try again later',\r\n },\r\n ]})\r\n })\r\n .finally(() => { });\r\n } else {\r\n props.setBottomAlert({msgs : [\r\n {\r\n type: 'error',\r\n msg: 'Authentication error. Please try again later',\r\n },\r\n ]})\r\n }\r\n })\r\n .finally(() => { props.setLoader(false); });\r\n },[storeCreationFlag]);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n setLoader: (isActive) => {\r\n dispatch(actions.setLoaderLayOver(isActive));\r\n },\r\n setBottomAlert: (errorMessage) => {\r\n dispatch(actions.setBottomAlert(errorMessage));\r\n }\r\n };\r\n}\r\n\r\nexport default connect(null, mapDispatchToProps)(MarketplaceConfig);","export default __webpack_public_path__ + \"static/media/GeneralConfigurations.876d54d5.svg\";","export default __webpack_public_path__ + \"static/media/PrinterConfigurations.5b91b808.svg\";","export default __webpack_public_path__ + \"static/media/OrderFileConfigurations.27e67973.svg\";","export default __webpack_public_path__ + \"static/media/Icon_awesome_barcode.f80ce32b.svg\";","export default __webpack_public_path__ + \"static/media/marketplaceIcon.c32fe588.svg\";","import React from 'react';\r\nimport Grid from '@material-ui/core/Grid';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\nimport Card from '@material-ui/core/Card';\r\nimport CardActionArea from '@material-ui/core/CardActionArea';\r\nimport CardContent from '@material-ui/core/CardContent';\r\nimport CardMedia from '@material-ui/core/CardMedia';\r\nimport Typography from '@material-ui/core/Typography';\r\nimport { Link as RouterLink } from 'react-router-dom';\r\nimport { useSelector } from 'react-redux';\r\nimport { UserRoles } from '../../utils/constants/constants';\r\nimport MarketplaceConfig from './MarketplaceConfiguration/MarketplaceConfig';\r\n\r\nimport genralConfiguration from '../../assets/images/GeneralConfigurations.svg';\r\nimport printerConfiguration from '../../assets/images/PrinterConfigurations.svg';\r\nimport fileConfiguration from '../../assets/images/OrderFileConfigurations.svg';\r\nimport barCodeConfiguration from '../../assets/images/Icon_awesome_barcode.svg';\r\nimport marketplaceConfiguration from '../../assets/images/marketplaceIcon.svg';\r\nimport './ConfigurationHome.scss';\r\n\r\nconst useCardStyles = makeStyles({\r\n root: {\r\n height: '114px',\r\n width: '212px',\r\n background: '#F8F7F7',\r\n '&:hover': {\r\n background: '#FFCC00',\r\n },\r\n },\r\n img: {\r\n 'object-fit': 'contain !important',\r\n },\r\n});\r\n\r\nconst useCardContentStyles = makeStyles({\r\n root: {\r\n height: '114px',\r\n display: 'flex !important',\r\n },\r\n roleAccess: {\r\n height: '114px',\r\n display: 'flex !important',\r\n cursor: 'not-allowed',\r\n pointerevents: 'all !important',\r\n opacity: '1',\r\n '&:hover': {\r\n background: '#FFFFFF',\r\n },\r\n }\r\n});\r\n\r\nconst ConfigurationHome = (props) => {\r\n const userDetails = useSelector((state) => state?.auth?.userDetails);\r\n const userRole = userDetails?.role;\r\n const classes = useCardStyles();\r\n const carContentclasses = useCardContentStyles();\r\n const isMarketplaceAccount = userDetails?.accounts?.some((val) => { \r\n return val?.configuration?.marketplaceUserOptional === true;\r\n })\r\n \r\n return (\r\n \r\n
Select the tile to go to configuration flow
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n Order configurations \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Printer configurations \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n General configurations \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Barcode configurations \r\n \r\n \r\n \r\n \r\n {(isMarketplaceAccount || userRole === UserRoles.Admin) && \r\n \r\n \r\n \r\n \r\n Connect to marketplaces \r\n \r\n \r\n \r\n }\r\n \r\n \r\n
\r\n );\r\n};\r\n\r\nexport default ConfigurationHome;\r\n","export const genralConfigurationForm = {\r\n formId: 'genralConfigurationform',\r\n formField: {\r\n customerReference: {\r\n props: {\r\n name: 'customerReferenceMandetory',\r\n label: 'Customer reference mandatory',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n alternativeReference: {\r\n props: {\r\n name: 'alternativeReferenceMandatory',\r\n label: 'Alternative reference mandatory',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n duplicateCustomerReference: {\r\n props: {\r\n name: 'disallowDuplicateCustomerReference',\r\n label: 'Disallow duplicate customer reference',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n duplicateAlternativeReference: {\r\n props: {\r\n name: 'disallowDuplicateAlternateReference',\r\n label: 'Disallow duplicate alternative reference',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n customerReferenceText: {\r\n props: {\r\n name: 'reference1',\r\n label: 'Reference 1 (Customer reference)',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n inputProps: {\r\n maxLength: 20,\r\n },\r\n },\r\n },\r\n alternativeReferenceText: {\r\n props: {\r\n name: 'reference2',\r\n label: 'Reference 2 (Alternative reference)',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n inputProps: {\r\n maxLength: 20,\r\n },\r\n },\r\n },\r\n addNewAccountToUsers: {\r\n props: {\r\n name: 'addToAllUsers',\r\n label: 'By default add new account to all users',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n printCustomInvoice: {\r\n props: {\r\n name: 'printCustomInvoice',\r\n label: 'Print customs invoice',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n defaultPrintInboxReturnLabel: {\r\n props: {\r\n name: 'defaultPrintInboxReturnLabel',\r\n label: 'By default print inbox return label',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n },\r\n};\r\n","import React, { useEffect } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid } from '@material-ui/core';\r\n// import InputTextfield from '../../../framework/Inputs/inputTextField/inputTextField'\r\nimport FormRenderer from '../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../../../store/actions';\r\n// import { useSelector } from 'react-redux';\r\n// import { genralConfigurationForm } from '../../../../utils/formConfig/genralconfiguration/genralConfiguratiomForm';\r\nconst GeneralCoonfig = (props) => {\r\n const {\r\n formField: { addNewAccountToUsers },\r\n } = props;\r\n\r\n const { formikValues } = props;\r\n const dispatch = useDispatch();\r\n\r\n useEffect(() => {\r\n dispatch(actions.setDefaultAddNewAccount(formikValues.addToAllUsers));\r\n }, [formikValues.addToAllUsers]);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\nGeneralCoonfig.propTypes = {\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n setFieldValue: PropTypes.func,\r\n};\r\n\r\nexport default GeneralCoonfig;\r\n","import React from 'react';\r\nimport { connect } from 'react-redux';\r\nimport { Link as RouterLink } from 'react-router-dom';\r\nimport { Form, Formik } from 'formik';\r\nimport Grid from '@material-ui/core/Grid';\r\nimport CustomAccordion from '../../../framework/accordion/customAccordion';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport { genralConfigurationForm } from '../../../utils/formConfig/genralconfiguration/genralConfiguratiomForm';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { POST, GET } from '../../../api/axios';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport GeneralCoonfig from './generalConfigurationDetails/generalConfigurationDetails';\r\nimport { getCustomerAccountID } from '../../../utils/helperFunctions';\r\nimport CustomModal from '../../../framework/modal/modal';\r\nimport ConfirmationDialog from '../../../components/addressBook/confirmation/confirmation';\r\nimport * as actions from '../../../store/actions/index';\r\nimport './GenralConfiguration.scss';\r\n\r\nclass GenralConfiguration extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n initialFormValues: null,\r\n showCancelConfirmationDialog:false,\r\n confirmationMsg:'',\r\n };\r\n }\r\n\r\n setShowCancelConfirmationDialog(showmodel) {\r\n this.setState({ showCancelConfirmationDialog: showmodel });\r\n}\r\nsetConfirmationMsg(Msg){\r\n this.setState({ confirmationMsg: Msg });\r\n\r\n}\r\nhandleDialogClose = () => {\r\n this.setShowCancelConfirmationDialog(false);\r\n};\r\n onDialogCancel = () => {\r\n this.setShowCancelConfirmationDialog(false);\r\n};\r\n\r\n onCancelDialogConfirm = () => {\r\n // history.goBack();\r\n this.props.history.push(`/configuration`);\r\n this.setShowCancelConfirmationDialog(false);\r\n};\r\n\r\n componentDidMount() {\r\n this.getInitialValues();\r\n this.props.setLoader(true);\r\n }\r\n\r\n getInitialValues = () => {\r\n GET(`${ServiceEndPoints.genralConfiguration}?organization=${getCustomerAccountID()}`)\r\n .then((response) => {\r\n this.setState({\r\n initialFormValues: response.data,\r\n });\r\n this.props.setLoader(false);\r\n })\r\n .catch((err) => {\r\n this.props.setLoader(false);\r\n this.setEmptyValues();\r\n });\r\n };\r\n\r\n setEmptyValues = () => {\r\n const initialValues = {};\r\n const { formField } = genralConfigurationForm;\r\n for (let property in formField) {\r\n if (Object.prototype.hasOwnProperty.call(formField, property)) {\r\n const field = formField[property];\r\n if (field.props.type === 'checkbox' || field.props.type === 'radio') {\r\n initialValues[field.props.name] = field.value;\r\n } else if (field.props.type === 'array') {\r\n initialValues[field.props.name] = field.values;\r\n } else {\r\n initialValues[field.props.name] = field.value || '';\r\n }\r\n }\r\n }\r\n this.setState({ initialFormValues: initialValues });\r\n };\r\n\r\n handleFormSubmit = (values, errors) => {\r\n //Todo set organization.\r\n let payload = {\r\n id: '',\r\n type: '',\r\n organization: getCustomerAccountID(),\r\n ...values,\r\n };\r\n POST(ServiceEndPoints.genralConfiguration, payload)\r\n .then((response) => {\r\n this.props.setSnackBar({msg:\"General configuration saved successfully\"});\r\n this.props.saveGenralConfiguration(payload);\r\n })\r\n .catch((err) => {\r\n alert('Failed to save..');\r\n });\r\n };\r\n\r\n cancelSchema = () => {\r\n this.setConfirmationMsg('Any unsaved changes will be lost?');\r\n this.setShowCancelConfirmationDialog(true);\r\n };\r\n\r\n render() {\r\n const { formId, formField, value } = genralConfigurationForm;\r\n const { initialFormValues } = this.state;\r\n return (\r\n \r\n {initialFormValues ? (\r\n \r\n {({ values, errors }) => {\r\n return (\r\n \r\n );\r\n }}\r\n \r\n ) : null}{' '}\r\n \r\n );\r\n }\r\n}\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n saveGenralConfiguration: (genralConfiguration) => {\r\n dispatch(actions.setGenralConfiguration(genralConfiguration));\r\n },\r\n setUserNotification: (alert) => {\r\n dispatch(actions.setUserNotification(alert));\r\n },\r\n setLoader: (isActive) => {\r\n dispatch(actions.setLoaderLayOver(isActive));\r\n },\r\n setSnackBar:(data)=>{\r\n dispatch(actions.setAppSnackBarData(data));\r\n }\r\n };\r\n};\r\nexport default connect(null, mapDispatchToProps)(GenralConfiguration);\r\n","import React from 'react';\r\nimport Grid from '@material-ui/core/Grid';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\nimport CircularProgress from '@material-ui/core/CircularProgress';\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n root: {\r\n display: 'flex',\r\n '& > * + *': {\r\n marginLeft: theme.spacing(2),\r\n },\r\n },\r\n colorPrimary: {\r\n color: '#FFCC00 !important',\r\n },\r\n}));\r\n\r\nexport default function Spinner() {\r\n const classes = useStyles();\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n );\r\n}\r\n","export const printerConfiguration = {\r\n formId: 'printerConfiguration',\r\n formField: {\r\n labelRadioTypes: {\r\n props: {\r\n name: 'labelRadioTypes',\r\n type: 'radio',\r\n },\r\n value: 'PrintLabel',\r\n },\r\n labelPrinter: {\r\n props: {\r\n name: 'labelPrinter',\r\n label: 'Print labels with printer',\r\n type: 'select',\r\n displayField: 'name',\r\n hasDefaultValue: false,\r\n isRequired: true,\r\n },\r\n validation: {\r\n name: 'labelPrinter',\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Label printer is required'],\r\n },\r\n {\r\n type: 'test',\r\n params: [\r\n '',\r\n 'Label printer is required',\r\n (value) => {\r\n return value?.value ? true : false;\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n labelType: {\r\n props: {\r\n name: 'labelType',\r\n label: 'Label type',\r\n type: 'select',\r\n displayField: 'name',\r\n isRequired: true,\r\n hasDefaultValue: false,\r\n },\r\n validation: {\r\n name: 'labelType',\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Label type is required'],\r\n },\r\n {\r\n type: 'test',\r\n params: [\r\n '',\r\n 'Label type is required',\r\n (value) => {\r\n return value?.value ? true : false;\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n pauseCount: {\r\n props: {\r\n name: 'pauseCount',\r\n label: 'Pause after how many labels',\r\n type: 'text',\r\n },\r\n validation: {\r\n name: 'pauseCount',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'typeError',\r\n params: ['Only numbers allowed'],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Pause count should be greater than 0'],\r\n },\r\n ],\r\n },\r\n },\r\n otherReportsPrinter: {\r\n props: {\r\n name: 'otherReportsPrinter',\r\n label: 'Print all other reports with',\r\n type: 'select',\r\n displayField: 'name',\r\n hasDefaultValue: false,\r\n },\r\n },\r\n labelSize: {\r\n props: {\r\n name: 'labelSize',\r\n label: 'Label size',\r\n type: 'select',\r\n displayField: 'name',\r\n isRequired: true,\r\n hasDefaultValue: false,\r\n },\r\n validation: {\r\n name: 'labelSize',\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'test',\r\n params: [\r\n '',\r\n 'Label size is required',\r\n (value) => {\r\n return value?.value === 1 || value?.value === 0 ? true : false;\r\n },\r\n ],\r\n },\r\n\r\n ],\r\n },\r\n },\r\n jspmVersion: {\r\n props: {\r\n name: 'jspmVersion',\r\n label: 'JSPM Version',\r\n type: 'select',\r\n displayField: 'name',\r\n hasDefaultValue: false,\r\n isRequired: true,\r\n },\r\n validation: {\r\n name: 'jspmVersion',\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'test',\r\n params: [\r\n '',\r\n 'JSPM version is required',\r\n (value) => {\r\n return value?.value === '3' || value?.value === '4' ? true : false;\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n },\r\n};\r\n","import React from 'react';\r\nimport { connect } from 'react-redux';\r\nimport { Link as RouterLink } from 'react-router-dom';\r\nimport { Form, Formik } from 'formik';\r\nimport Grid from '@material-ui/core/Grid';\r\n\r\nimport CustomAccordion from '../../../framework/accordion/customAccordion';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport Spinner from '../../../framework/spinner/spinner';\r\n\r\nimport { printerConfiguration } from '../../../utils/formConfig/printerConfiguration/printerConfiguration';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { POST, GET } from '../../../api/axios';\r\nimport { getAvaiablePrinters } from '../../../utils/PrintHelper';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { labelType, labelSize, labelSizeWhenZpl } from '../../../utils/constants/constants';\r\nimport { getYupSchemaFromMetaData } from '../../../utils/yupSchema/yupSchemaGenerator';\r\n\r\nimport * as actions from '../../../store/actions/index';\r\nimport './PrinterConfiguration.scss';\r\n\r\nconst initialVals = {\r\n labelPrinter: { name: 'Select', value: '' },\r\n labelType: { name: 'Select', value: '' },\r\n otherReportsPrinter: { name: 'Select', value: '' },\r\n pauseCount: '',\r\n labelSize: labelSize[0],\r\n // labelRadioTypes:false,\r\n};\r\n\r\nclass PrinterConfiguration extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.printerConfigResp = null;\r\n this.state = {\r\n downloadPDF: false,\r\n initialFormValues: {\r\n labelRadioTypes: labelTypeRadioOptions[0].value,\r\n pauseCount: '',\r\n jspmVersion: _jspmVersion[0],\r\n },\r\n availablePrinters: [],\r\n jspmVersionMismatch: true,\r\n };\r\n this.onJspmVersionSelectionChange = this.onJspmVersionSelectionChange.bind(this);\r\n }\r\n\r\n componentDidMount() {\r\n this.props.setLoader(true);\r\n GET(`${ServiceEndPoints.printConfiguration}?userId=${this.props.userDetails.emailId}`)\r\n .then((response) => {\r\n this.printerConfigResp = response?.data;\r\n this.setState({ downloadPDF: response?.data?.isDowloadLabelAsPDF })\r\n setTimeout(() => {\r\n this.setAvailablePrinters(response);\r\n }, 2500);\r\n })\r\n .catch((err) => {\r\n // this.setEmptyValues();\r\n // this.props.setLoader(false);\r\n setTimeout(() => {\r\n this.setAvailablePrinters();\r\n }, 2500);\r\n });\r\n // this.setAvailablePrinters();\r\n }\r\n\r\n getInitialValues = (response) => {\r\n const { availablePrinters } = this.state;\r\n // GET(`${ServiceEndPoints.printConfiguration}?userId=${this.props.userDetails.emailId}`)\r\n // .then((response) => {\r\n let labelPrinter = availablePrinters?.find((x) => x.value === response?.data?.labelPrinter);\r\n let otherPrinter = availablePrinters?.find((x) => x.value === response?.data?.otherReportsPrinter);\r\n let printFormat = (labelType || []).find((x) => x.value === response?.data?.labelType);\r\n let labelSizeFormat = !printFormat && !(response?.data?.isDowloadLabelAsPDF) ? labelSize[0] : labelSize[response?.data?.pageSize + 1 || 0]\r\n const storedValues = {\r\n labelPrinter: labelPrinter ?? availablePrinters[0],\r\n labelType: printFormat ?? labelType[0],\r\n otherReportsPrinter: otherPrinter ?? availablePrinters[0],\r\n pauseCount: response?.data?.pauseCount === 0 ? '' : response?.data.pauseCount,\r\n labelRadioTypes: response?.data?.isDowloadLabelAsPDF === true ? labelTypeRadioOptions[1].value : labelTypeRadioOptions[0].value,\r\n labelSize: labelSizeFormat,\r\n jspmVersion: (response?.data?.jspmVersion === '3') ? _jspmVersion[1] : response?.data?.jspmVersion === '4' ? _jspmVersion[2] : this.state.availablePrinters?.length ? _jspmVersion[2] : _jspmVersion[0] ,\r\n };\r\n this.setState({\r\n initialFormValues: storedValues,\r\n },()=> {this.props.setLoader(false)});\r\n \r\n // })\r\n // .catch((err) => {\r\n // this.setEmptyValues();\r\n // this.props.setLoader(false);\r\n // });\r\n };\r\n\r\n setEmptyValues = () => {\r\n const emptyVal = {\r\n jspmVersion: this.state.availablePrinters?.length ? _jspmVersion[2] : _jspmVersion[0],\r\n labelPrinter: this.state.availablePrinters[0],\r\n labelType: labelType[0],\r\n otherReportsPrinter: this.state.availablePrinters[0],\r\n pauseCount: '',\r\n labelSize: labelSize[0],\r\n labelRadioTypes: this.state.downloadPDF === true ? labelTypeRadioOptions[1].value : labelTypeRadioOptions[0].value\r\n };\r\n this.setState({ initialFormValues: emptyVal });\r\n };\r\n\r\n setAvailablePrinters = (response) => {\r\n getAvaiablePrinters()\r\n ?.then((availablePrinterList) => {\r\n let printers = this.createKeyValuePair(availablePrinterList);\r\n printers.unshift({ name: 'Select', value: '' });\r\n this.setState({ availablePrinters: printers ,jspmVersionMismatch: false}, () => {\r\n this.getInitialValues(response);\r\n });\r\n })\r\n .catch((err) => {\r\n console.log(err)\r\n this.setState({ availablePrinters: [], jspmVersionMismatch: true, ...this.getInitialValues(response) });\r\n });\r\n };\r\n\r\n handleFormSubmit = (formValues, isValid) => {\r\n if (formValues.labelRadioTypes === \"Downloadlabel\") {\r\n if(formValues.labelSize?.value || formValues.labelSize?.value === 0)\r\n {\r\n isValid = true;\r\n }\r\n else\r\n {\r\n isValid = false;\r\n } \r\n }\r\n if (isValid || (this.state.jspmVersionMismatch && formValues.labelRadioTypes !== \"Downloadlabel\" && formValues.jspmVersion.value !== '')) {\r\n let payload = {\r\n userId: this.props.userDetails.emailId,\r\n organization: 'dhl',\r\n labelPrinter: formValues.labelPrinter?.value ? formValues.labelPrinter?.value : undefined,\r\n labelType: formValues.labelType?.value ? formValues.labelType?.value : undefined,\r\n otherReportsPrinter: formValues.otherReportsPrinter?.value ? formValues.otherReportsPrinter?.value : undefined,\r\n pauseCount: formValues.pauseCount ? parseInt(formValues.pauseCount) : undefined,\r\n isDowloadLabelAsPDF: formValues.labelRadioTypes === \"PrintLabel\" ? false : true,\r\n pageSize: formValues.labelRadioTypes === \"Downloadlabel\" ? (formValues?.labelSize?.value === \"\" || formValues?.labelSize?.value === null || formValues?.labelSize?.value === undefined ? 1 : formValues.labelSize?.value) : formValues.labelSize?.value || undefined,\r\n jspmVersion: formValues.jspmVersion.value || undefined, \r\n };\r\n if(this.state.jspmVersionMismatch && this.printerConfigResp) {\r\n payload = { ...this.printerConfigResp, jspmVersion: formValues.jspmVersion.value || undefined, isDowloadLabelAsPDF: formValues.labelRadioTypes === \"PrintLabel\" ? false : true, pageSize: formValues.labelRadioTypes === \"Downloadlabel\" ? (formValues?.labelSize?.value === \"\" || formValues?.labelSize?.value === null || formValues?.labelSize?.value === undefined ? 1 : formValues.labelSize?.value) : formValues.labelSize?.value || undefined,}\r\n }\r\n POST(ServiceEndPoints.printConfiguration, payload)\r\n\r\n .then((response) => {\r\n this.props.savePrintConfiguration(payload);\r\n this.props.setSnackBar({ msg: 'Printer configuration saved successfully' });\r\n // if(this.printerConfigResp?.jspmVersion !== formValues.jspmVersion.value){\r\n // setTimeout(() => {\r\n // window.location.reload();\r\n // }, 100);\r\n // }\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n } else {\r\n this.props.setBottomAlert([\r\n {\r\n type: 'error',\r\n msg: 'The form has errors, please correct and try again',\r\n },\r\n ]);\r\n }\r\n };\r\n\r\n createKeyValuePair = (arrayList) => {\r\n return arrayList?.map((item) => {\r\n return {\r\n name: item,\r\n value: item,\r\n };\r\n });\r\n };\r\n\r\n onJspmVersionSelectionChange(jspmVersion) {\r\n if(this.printerConfigResp?.jspmVersion !== jspmVersion)\r\n {\r\n let payload = {\r\n jspmVersion: jspmVersion || undefined,\r\n userId: this.props.userDetails.emailId,\r\n organization: 'dhl', \r\n };\r\n if(this.printerConfigResp) {\r\n payload = { ...this.printerConfigResp, jspmVersion: jspmVersion || undefined, isDowloadLabelAsPDF: false,}\r\n }\r\n POST(ServiceEndPoints.printConfiguration, payload)\r\n .then((response) => {\r\n this.props.savePrintConfiguration(payload);\r\n setTimeout(() => {\r\n window.location.reload();\r\n }, 100);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n }\r\n }\r\n\r\n render() {\r\n const { formId, formField } = printerConfiguration;\r\n const { initialFormValues, availablePrinters } = this.state;\r\n const printerConfigValidationSchema = getYupSchemaFromMetaData(formField, [], []);\r\n return (\r\n \r\n {/* {initialFormValues ? ( */}\r\n \r\n
\r\n {({ values, isValid, setFieldValue }) => {\r\n if (values?.labelRadioTypes === \"PrintLabel\" && values?.labelType?.value === 1 && values?.labelSize?.value === 1) {\r\n setFieldValue('labelSize', labelSizeWhenZpl[1])\r\n }\r\n return (\r\n \r\n );\r\n }}\r\n \r\n
\r\n {/* ) :null} */}\r\n \r\n );\r\n }\r\n}\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n printerConfiguration: state.common.printerConfiguration,\r\n userDetails: state.auth.userDetails,\r\n };\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n savePrintConfiguration: (printerConfiguration) => {\r\n dispatch(actions.setPrinterConfiguration(printerConfiguration));\r\n },\r\n setUserNotification: (alert) => {\r\n dispatch(actions.setUserNotification(alert));\r\n },\r\n setLoader: (isActive) => {\r\n dispatch(actions.setLoaderLayOver(isActive));\r\n },\r\n setSnackBar: (data) => {\r\n dispatch(actions.setAppSnackBarData(data));\r\n },\r\n setBottomAlert: (alertMsgs) => {\r\n dispatch(actions.setBottomAlert({ msgs: alertMsgs }));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(PrinterConfiguration);\r\n\r\nconst labelTypeRadioOptions = [\r\n {\r\n value: 'PrintLabel',\r\n label: 'Print label',\r\n },\r\n {\r\n value: 'Downloadlabel',\r\n label: 'Download label as PDF',\r\n },\r\n];\r\n\r\nconst _jspmVersion = [\r\n {\r\n name: 'Select',\r\n value: ''\r\n },\r\n { \r\n name: '3',\r\n value: '3' \r\n },\r\n { \r\n name: '4',\r\n value: '4' \r\n }\r\n];","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from \"react\";\n\nvar _ref2 = /*#__PURE__*/React.createElement(\"g\", {\n id: \"noun_Upload_1157132\",\n transform: \"translate(19.407 19.175) rotate(180)\"\n}, /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_2760\",\n \"data-name\": \"Path 2760\",\n d: \"M18.424,10.677H.963A.943.943,0,0,1,0,9.754V.923A.943.943,0,0,1,.963,0a.93.93,0,0,1,.963.923V8.851H17.481V.923A.943.943,0,0,1,18.444,0a.93.93,0,0,1,.963.923V9.754A1,1,0,0,1,18.424,10.677Z\",\n transform: \"translate(19.407 10.677) rotate(180)\",\n fill: \"#3e2d2e\"\n}), /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_2761\",\n \"data-name\": \"Path 2761\",\n d: \"M9.091,3.984,5.379.271a.97.97,0,0,0-1.345,0L.281,3.984A.956.956,0,0,0,0,4.666a.91.91,0,0,0,.281.662.944.944,0,0,0,.662.281.956.956,0,0,0,.682-.281L3.673,3.3v9.533a1,1,0,0,0,2.007,0V3.261L7.747,5.328a.97.97,0,0,0,1.345,0,.944.944,0,0,0,.281-.662A.956.956,0,0,0,9.091,3.984Z\",\n transform: \"translate(14.388 19.175) rotate(180)\",\n fill: \"#3e2d2e\"\n}));\n\nfunction SvgUploadGray(_ref, svgRef) {\n var title = _ref.title,\n titleId = _ref.titleId,\n props = _objectWithoutProperties(_ref, [\"title\", \"titleId\"]);\n\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 19.407,\n height: 19.175,\n viewBox: \"0 0 19.407 19.175\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, _ref2);\n}\n\nvar ForwardRef = /*#__PURE__*/React.forwardRef(SvgUploadGray);\nexport default __webpack_public_path__ + \"static/media/upload-gray.331a6cfc.svg\";\nexport { ForwardRef as ReactComponent };","import React, { useState, useRef, useEffect } from 'react';\r\n\r\nimport { getYupSchemaFromMetaData } from '../../../../utils/yupSchema/yupSchemaGenerator';\r\nimport { Form, Formik } from 'formik';\r\nimport { useHistory, useParams } from 'react-router-dom';\r\n\r\nimport { schemaValues, importTypeValues, dateOptions, delimiterOptions } from '../../../../utils/constants/constants';\r\n\r\nimport InputButton from '../../../../framework/Inputs/inputButton/inputButton';\r\nimport { Grid, Snackbar } from '@material-ui/core';\r\nimport CustomModal from '../../../../framework/modal/modal';\r\nimport ConfirmationDialog from '../../../addressBook/confirmation/confirmation';\r\nimport { formatCreateSchemaObj, getCustomerAccountID } from '../../../../utils/helperFunctions';\r\nimport { axiosConfig } from '../../../../api/axios';\r\nimport './createNewSchema.scss';\r\nimport MainSchemaDetails from './MainSchemaDetails';\r\nimport { ServiceEndPoints } from '../../../../utils/constants/ApiConstant';\r\nimport * as actions from '../../../../store/actions/index';\r\nimport { useDispatch } from 'react-redux';\r\nimport { CREATE_NEW_SCHEMA, SCHEMA_MAPPING_GRID } from '../../../../utils/constants/constants';\r\nlet OrderSetupResponse;\r\n\r\nconst CreateNewSchema = (props) => {\r\n let history = useHistory();\r\n const dispatch = useDispatch();\r\n const { oldSchemaName } = useParams();\r\n\r\n const { formId, formField } = createNewSchemaForm;\r\n const [confirmationMsg, setConfirmationMsg] = useState('');\r\n const [showClearConfirmationDialog, setShowClearConfirmationDialog] = useState(false);\r\n const [showCancelConfirmationDialog, setShowCancelConfirmationDialog] = useState(false);\r\n const [requiredField, setRequiredField] = useState(false);\r\n const [userSchemaDetails, setUserSchemaDetails] = useState();\r\n const [userMappingDetails, setUserMappingDetails] = useState();\r\n const [uploadedFile, setUploadedFile] = useState(null);\r\n const [isClear, setIsClear] = useState(false);\r\n const [showWarningModal, setShowWarningModal] = useState(false);\r\n const formikRef = useRef(null);\r\n const [isValid, setIsValid] = useState(true);\r\n const [schemaNameExist, setSchemaNameExist] = useState(false);\r\n const [existingFolderPaths, setExistingFolderPaths] = useState([]);\r\n const [folderPathExist, setFolderPathExist] = useState(false);\r\n\r\n let newSearchValidationSchema = getYupSchemaFromMetaData(formField, [], []);\r\n const {\r\n SCHEMA_NAME,\r\n POLLING_PATH,\r\n FILE_EXTENSION,\r\n OTHER_FORMAT,\r\n OTHER,\r\n NEW_DELIMETER,\r\n OTHER_DELIMITER,\r\n ROW_INDICATOR_3,\r\n ROW_INDICATOR_2,\r\n ROW_INDICATOR_1,\r\n } = CREATE_NEW_SCHEMA;\r\n\r\n const {\r\n ORDERS_CUSTOMS_COLLECTIONS,\r\n ORDERS_CUSTOMS_PARCELS,\r\n ORDERS_CUSTOMS,\r\n ORDERS_COLLECTIONS,\r\n ORDERS_CLEARANCE,\r\n COLLECTIONS_CLEARANCE,\r\n DELIMITED,\r\n ORDER,\r\n COLLECTION,\r\n CUSTOM,\r\n ORDER_COLLECTION_CONSIGNOR,\r\n PARCEL,\r\n CLEARANCE,\r\n FIXED_LENGTH\r\n } = SCHEMA_MAPPING_GRID;\r\n\r\n const initialValues = {\r\n dateFormat: dateOptions[0],\r\n importType: importTypeValues[1].value,\r\n delimiter: delimiterOptions[0],\r\n schemaType: schemaValues[0],\r\n schemaName: '',\r\n pollingPath: '',\r\n newDelimeter: '',\r\n otherformat: '',\r\n rowIndicator3: '',\r\n rowIndicator1: '',\r\n rowIndicator2: '',\r\n fileExtension: '',\r\n };\r\n\r\n let reqFields = [\r\n 'schemaName',\r\n 'schemaType',\r\n 'dateFormat',\r\n 'delimiter',\r\n 'newDelimeter',\r\n 'otherformat',\r\n 'rowIndicator3',\r\n 'rowIndicator2',\r\n 'rowIndicator1',\r\n 'pollingPath',\r\n 'fileExtension',\r\n ];\r\n\r\n const isFormInValid = (errors, values, mappingField) => {\r\n if (Object.keys(errors).length > 0) {\r\n for (let err in errors) {\r\n if (\r\n reqFields.some((fieldName) => {\r\n if (fieldName === SCHEMA_NAME) {\r\n return fieldName === err;\r\n } else if (fieldName === POLLING_PATH) {\r\n return fieldName === err;\r\n } else if (fieldName === FILE_EXTENSION) {\r\n return fieldName === err;\r\n } else if (fieldName === OTHER_FORMAT) {\r\n if (values.dateFormat.value === OTHER) {\r\n return fieldName === err;\r\n }\r\n } else if (fieldName === NEW_DELIMETER) {\r\n if (values.importType === DELIMITED) {\r\n if (values.delimiter.value === OTHER_DELIMITER) {\r\n return fieldName === err;\r\n }\r\n }\r\n } else if (\r\n fieldName === ROW_INDICATOR_3 ||\r\n fieldName === ROW_INDICATOR_2 ||\r\n fieldName === ROW_INDICATOR_1\r\n ) {\r\n for (let i = 0; i < mappingField.length; i++) {\r\n if (\r\n values.schemaType.value === ORDERS_CUSTOMS_COLLECTIONS ||\r\n values.schemaType.value === ORDERS_CUSTOMS_PARCELS\r\n ) {\r\n if (values.rowIndicator1 === '' || values.rowIndicator2 === '' || values.rowIndicator3 === '') {\r\n return true;\r\n }\r\n } else if (\r\n values.schemaType.value === ORDERS_CUSTOMS ||\r\n values.schemaType.value === ORDERS_COLLECTIONS ||\r\n values.schemaType.value === ORDERS_CLEARANCE ||\r\n values.schemaType.value === COLLECTIONS_CLEARANCE\r\n ) {\r\n if (values.rowIndicator1 === '' || values.rowIndicator2 === '') {\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n })\r\n ) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n return true;\r\n };\r\n\r\n const isMapInValid = (schemaDetails, fieldName) => {\r\n if (schemaDetails.importType === FIXED_LENGTH) {\r\n for (let i = 0; i < fieldName.length; i++) {\r\n if (fieldName[i].isRequiredField) {\r\n if (\r\n fieldName[i].startsAt === '' ||\r\n fieldName[i].length === '' ||\r\n isNaN(fieldName[i].startsAt) ||\r\n isNaN(fieldName[i].length)\r\n ) {\r\n return true;\r\n }\r\n } else if (!fieldName[i].isRequiredField) {\r\n if (fieldName[i].startsAt != '' || fieldName[i].length != '') {\r\n if (isNaN(fieldName[i].startsAt) || isNaN(fieldName[i].length)) {\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n } else if (schemaDetails.importType === DELIMITED) {\r\n for (let i = 0; i < fieldName.length; i++) {\r\n if (fieldName[i].isRequiredField) {\r\n if (fieldName[i].columnFromFile === '') {\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return false;\r\n };\r\n\r\n const [isOderSetupValueMatching, setIsOderSetupValueMatching] = useState(true);\r\n\r\n useEffect(() => {\r\n axiosConfig\r\n .get(`${ServiceEndPoints.orderSetup}?organization=${getCustomerAccountID()}`)\r\n .then((res) => {\r\n OrderSetupResponse = res.data;\r\n if (!res.data.importsSetup?.overWriteSameCustomerRef || !res.data.importsSetup?.overWriteSameAltRef) {\r\n setIsOderSetupValueMatching(false);\r\n }\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n axiosConfig.get(`${ServiceEndPoints.getSchemas}?&organization=${getCustomerAccountID()}`).then((res) => {\r\n let existingPaths = [];\r\n if (oldSchemaName) {\r\n existingPaths = res.data.orderFileSchemas\r\n .filter((schema) => schema.schemaName?.trim()?.toLowerCase() !== oldSchemaName?.trim()?.toLowerCase())\r\n .filter((sc) => sc.filePollingFolder?.trim());\r\n } else existingPaths = res.data.orderFileSchemas.filter((schema) => schema.filePollingFolder?.trim());\r\n\r\n setExistingFolderPaths(existingPaths.map((available) => available.filePollingFolder.replaceAll('//', '/')));\r\n });\r\n }, []);\r\n\r\n const isMultipleSchema = () => {\r\n const formValues = formikRef.current.values;\r\n return formValues.schemaType.value !== ORDER &&\r\n formValues.schemaType.value !== COLLECTION &&\r\n formValues.schemaType.value !== CUSTOM &&\r\n formValues.schemaType.value !== ORDER_COLLECTION_CONSIGNOR &&\r\n formValues.schemaType.value !== PARCEL &&\r\n formValues.schemaType.value !== CLEARANCE\r\n ? true\r\n : false;\r\n };\r\n\r\n const handleSubmit = (values, errors, showConditionalPopup = true) => {\r\n setRequiredField(true);\r\n userMappingDetails.map((item) =>\r\n item.tableData?.checked === true ? Object.assign(item, (item.tableData.checked = false)) : item,\r\n );\r\n if (\r\n !isFormInValid(errors, values, userMappingDetails) &&\r\n !isMapInValid(userSchemaDetails, userMappingDetails) &&\r\n !schemaNameExist &&\r\n !folderPathExist\r\n ) {\r\n if (showConditionalPopup && isMultipleSchema() && !isOderSetupValueMatching) {\r\n setShowWarningModal(true);\r\n return;\r\n }\r\n const reqObj = formatCreateSchemaObj(userSchemaDetails, userMappingDetails, values);\r\n axiosConfig\r\n .post(ServiceEndPoints.schemaUrl, reqObj)\r\n .then((res) => {\r\n dispatch(actions.setAppSnackBarData({ msg: 'Schema saved successfully' }));\r\n if (!oldSchemaName) {\r\n setUploadedFile(null);\r\n formikRef.current.resetForm();\r\n setIsClear(true);\r\n } else {\r\n dispatch(actions.setActiveTab('mySchema'));\r\n history.push('/configuration/fileConfiguration');\r\n }\r\n })\r\n .catch((err) => {\r\n console.log(err, 'err');\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in saving schema: Error status',\r\n },\r\n ],\r\n }),\r\n );\r\n });\r\n }\r\n };\r\n\r\n const clearSchema = () => {\r\n setConfirmationMsg('Are you sure you want to clear the page?');\r\n setShowClearConfirmationDialog(true);\r\n setIsClear(false);\r\n };\r\n\r\n const cancelSchema = () => {\r\n setConfirmationMsg('Any unsaved changes will be lost?');\r\n setShowCancelConfirmationDialog(true);\r\n };\r\n const handleDialogClose = () => {\r\n setShowCancelConfirmationDialog(false);\r\n setShowClearConfirmationDialog(false);\r\n };\r\n const onClearDialogConfirm = () => {\r\n setIsClear(true);\r\n\r\n setShowClearConfirmationDialog(false);\r\n formikRef?.current?.resetForm();\r\n setUploadedFile(null);\r\n };\r\n\r\n const onCancelDialogConfirm = () => {\r\n if (oldSchemaName != undefined) {\r\n dispatch(actions.setActiveTab('mySchema'));\r\n }\r\n\r\n history.goBack();\r\n setShowCancelConfirmationDialog(false);\r\n };\r\n\r\n const onDialogCancel = () => {\r\n setShowCancelConfirmationDialog(false);\r\n setShowClearConfirmationDialog(false);\r\n };\r\n const setTotalSchemaDetails = (data) => {\r\n setRequiredField(false);\r\n\r\n setUserSchemaDetails(data);\r\n };\r\n const setTotalMappingDetails = (fields) => {\r\n setRequiredField(false);\r\n\r\n setUserMappingDetails(fields);\r\n };\r\n\r\n const setOrderSetupOwerWriteValues = () => {\r\n if (OrderSetupResponse) {\r\n const reqObj = {\r\n ...OrderSetupResponse,\r\n importsSetup: {\r\n ...OrderSetupResponse?.importsSetup,\r\n overWriteSameCustomerRef: true,\r\n },\r\n };\r\n axiosConfig\r\n .post(`${ServiceEndPoints.orderSetup}`, reqObj)\r\n .then((res) => {})\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n }\r\n };\r\n\r\n return (\r\n \r\n \r\n {({ values, setFieldValue, errors, setFieldTouched, resetForm, setValues }) => (\r\n \r\n )}\r\n \r\n {\r\n setShowWarningModal(false);\r\n }}\r\n maxWidth=\"sm\"\r\n >\r\n {\r\n setShowWarningModal(false);\r\n setOrderSetupOwerWriteValues();\r\n handleSubmit(formikRef?.current?.values, formikRef?.current?.errors, false);\r\n }}\r\n />\r\n \r\n
\r\n );\r\n};\r\n\r\nexport default CreateNewSchema;\r\n\r\nconst createNewSchemaForm = {\r\n formId: 'createNewSchema',\r\n\r\n formField: {\r\n schemaName: {\r\n props: {\r\n name: 'schemaName',\r\n label: 'Schema name',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n isRequired: true,\r\n },\r\n validation: {\r\n name: 'schemaName',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Schema name is required'],\r\n },\r\n ],\r\n },\r\n },\r\n schemaType: {\r\n props: {\r\n name: 'schemaType',\r\n label: 'Schema type',\r\n type: 'select',\r\n displayField: 'name',\r\n hasDefaultValue: true,\r\n isRequired: true,\r\n },\r\n validation: {\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Schema type is required'],\r\n },\r\n ],\r\n },\r\n },\r\n pollingPath: {\r\n props: {\r\n name: 'pollingPath',\r\n label: 'File polling path',\r\n type: 'text',\r\n isRequired: true,\r\n placeholder: 'C:\\\\Myfolder\\\\Myfilelocation',\r\n },\r\n validation: {\r\n name: 'pollingPath',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['File polling path is required'],\r\n },\r\n ],\r\n },\r\n },\r\n importType: {\r\n props: {\r\n name: 'importType',\r\n label: 'Import type:',\r\n type: 'radio',\r\n },\r\n },\r\n dateFormat: {\r\n props: {\r\n name: 'dateFormat',\r\n label: 'Date format',\r\n type: 'select',\r\n displayField: 'name',\r\n hasDefaultValue: true,\r\n isRequired: true,\r\n },\r\n validation: {\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Date format is required'],\r\n },\r\n ],\r\n },\r\n },\r\n isheaderIncluded: {\r\n props: {\r\n name: 'isheaderIncluded',\r\n label: 'Is first row a header?',\r\n type: 'checkbox',\r\n },\r\n },\r\n delimiter: {\r\n props: {\r\n name: 'delimiter',\r\n label: 'Delimiter',\r\n type: 'select',\r\n displayField: 'name',\r\n hasDefaultValue: true,\r\n },\r\n validation: {\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Doorstep instructions is required'],\r\n },\r\n ],\r\n },\r\n },\r\n otherformat: {\r\n props: {\r\n name: 'otherformat',\r\n label: 'Enter other date format',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n },\r\n validation: {\r\n name: 'otherformat',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Date format is required'],\r\n },\r\n ],\r\n },\r\n },\r\n newDelimeter: {\r\n props: {\r\n name: 'newDelimeter',\r\n label: 'Enter the delimeter',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n isRequired: true,\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Delimiter is required'],\r\n },\r\n ],\r\n },\r\n },\r\n rowIndicator1: {\r\n props: {\r\n name: 'rowIndicator1',\r\n label: 'Row indicator',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n isRequired: true,\r\n },\r\n validation: {\r\n name: 'rowIndicator1',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Row indicator is required'],\r\n },\r\n ],\r\n },\r\n },\r\n rowIndicator2: {\r\n props: {\r\n name: 'rowIndicator2',\r\n label: 'Row indicator',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n isRequired: true,\r\n },\r\n validation: {\r\n name: 'rowIndicator2',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Row indicator is required'],\r\n },\r\n ],\r\n },\r\n },\r\n rowIndicator3: {\r\n props: {\r\n name: 'rowIndicator3',\r\n label: 'Row indicator',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n isRequired: true,\r\n },\r\n validation: {\r\n name: 'rowIndicator3',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Row indicator is required'],\r\n },\r\n ],\r\n },\r\n },\r\n fileExtension: {\r\n props: {\r\n name: 'fileExtension',\r\n label: 'File Extension',\r\n type: 'text',\r\n isRequired: true,\r\n placeholder: '*.txt',\r\n },\r\n validation: {\r\n name: 'fileExtension',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['File extension is required'],\r\n },\r\n {\r\n type: 'matches',\r\n params: [\r\n /^[a-zA-z0-9*]*(\\d*\\.\\d*)[a-zA-z]{1,5}$/,\r\n 'File extension must be in correct format e.g. *.txt or *.csv',\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n },\r\n};\r\n","import { Box, Button, FormControl, Grid, Input, InputAdornment, InputLabel } from '@material-ui/core';\r\nimport React, { useState, useEffect } from 'react';\r\nimport { axiosConfig } from '../../../../api/axios';\r\nimport FormRenderer from '../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport languageEncoding from \"detect-file-encoding-and-language\"\r\nimport {\r\n schemaValues,\r\n importTypeValues,\r\n dateOptions,\r\n delimiterOptions,\r\n MAX_ROWS_FOR_SCHEMA,\r\n} from '../../../../utils/constants/constants';\r\nimport { getCustomerAccountID } from '../../../../utils/helperFunctions';\r\nimport CloudUploadSharpIcon from '@material-ui/icons/CloudUploadSharp';\r\nimport { ReactComponent as UploadIcon } from '../../../../../src/assets/images/upload-gray.svg';\r\nimport CloseSharpIcon from '@material-ui/icons/CloseSharp';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../../../store/actions/index';\r\nimport { ServiceEndPoints } from '../../../../utils/constants/ApiConstant';\r\nimport { useDebouncedCallback } from 'use-debounce/lib';\r\n\r\nconst SchemaDetailsField = (props) => {\r\n const {\r\n formField: {\r\n schemaName,\r\n schemaType,\r\n importType,\r\n dateFormat,\r\n isheaderIncluded,\r\n delimiter,\r\n otherformat,\r\n newDelimeter,\r\n pollingPath,\r\n fileExtension,\r\n },\r\n\r\n setFieldValue,\r\n setValues,\r\n oldSchemaName,\r\n errors,\r\n setFieldTouched,\r\n currentSelectedValue,\r\n currentValueStartLength,\r\n dropdownValues,\r\n setCurrentValue,\r\n setCurrentValueStartLength,\r\n formikValues,\r\n currentRowIndicatorValue,\r\n currentRowIndicatorPlacement,\r\n uploadedFile,\r\n setUploadedFile,\r\n isDefaultSchema,\r\n setIsDefaultSchema,\r\n setSchemaNameExist,\r\n setFolderPathExist,\r\n existingFolderPaths,\r\n folderPathExist\r\n } = props;\r\n const dispatch = useDispatch();\r\n const [isOtherFormat, setOtherFormat] = useState(false);\r\n const [isDelimeter, setDelimeter] = useState(false);\r\n const [allRowsWithColumns, setAllRowsWithColumns] = useState([]);\r\n const [existingSchema, setExistingSchema] = useState(false);\r\n const [fileError, setFileError] = useState(false);\r\n let allRows = [];\r\n let allDropDownValues = [];\r\n\r\n\r\n useEffect(() => {\r\n if (oldSchemaName != undefined) {\r\n dispatch(actions.setLoaderLayOver(true));\r\n getSchemaDetails(oldSchemaName)\r\n }\r\n }, [oldSchemaName]);\r\n\r\n useEffect(() => {\r\n if (formikValues.dateFormat.value != 'other') {\r\n setFieldValue('otherformat', '');\r\n setOtherFormat(true);\r\n } else {\r\n setOtherFormat(false);\r\n }\r\n if ((formikValues.delimiter || undefined) && formikValues.delimiter.value === 'otherDelimiter') {\r\n setDelimeter(true);\r\n } else {\r\n setFieldValue('newDelimeter', '');\r\n setDelimeter(false);\r\n }\r\n }, [formikValues.dateFormat, formikValues.delimiter]);\r\n\r\n useEffect(() => {\r\n if (oldSchemaName === undefined) {\r\n getSchemaDetails(formikValues.schemaName)\r\n }\r\n }, [formikValues.schemaName])\r\n // useEffect(() => {\r\n\r\n const ifNameExist = useDebouncedCallback((name) => {\r\n const encodeURIName = encodeURIComponent(name)\r\n axiosConfig\r\n .get(\r\n `${ServiceEndPoints.getSchemas}?schemaName=${encodeURIName\r\n }&organization=${getCustomerAccountID()}&isExactMatch=true`,\r\n )\r\n .then((res) => {\r\n if (res.data.orderFileSchemas?.[0]?.isDefault) {\r\n setIsDefaultSchema(true)\r\n }\r\n else {\r\n setIsDefaultSchema(false)\r\n }\r\n if (oldSchemaName != undefined) {\r\n dispatch(\r\n actions.setShipmentId({\r\n shipmentId: res.data.orderFileSchemas[0].schemaName,\r\n }),\r\n );\r\n getSchemaDetailsForFields(res.data.orderFileSchemas[0]);\r\n } else {\r\n setExistingSchema(true)\r\n setSchemaNameExist(true)\r\n }\r\n\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n setExistingSchema(false)\r\n setSchemaNameExist(false)\r\n // resetForm();\r\n // setFieldValue('pollingPath', '');\r\n });\r\n }, 500)\r\n\r\n const getSchemaDetails = (name) => {\r\n if (name !== '') {\r\n ifNameExist(name);\r\n }\r\n }\r\n\r\n // }, []);\r\n\r\n\r\n const getSchemaDetailsForFields = (orderFileSchemas) => {\r\n props.getResultedSchemaDetails(orderFileSchemas);\r\n const newObj = {}\r\n newObj[\"schemaName\"] = orderFileSchemas.schemaName;\r\n newObj['pollingPath'] = orderFileSchemas.filePollingFolder;\r\n\r\n newObj['isheaderIncluded'] = orderFileSchemas.isheaderIncluded;\r\n\r\n newObj['fileExtension'] = orderFileSchemas.fileExtension ? orderFileSchemas.fileExtension : '';\r\n if (orderFileSchemas.schemaFileType.fileType === 2) {\r\n newObj['importType'] = importTypeValues[1].value;\r\n } else {\r\n newObj['importType'] = importTypeValues[0].value;\r\n }\r\n\r\n //this is for schemaType\r\n newObj['schemaType'] = schemaValues.find(val => val.value === orderFileSchemas.schemaType);\r\n\r\n //this is for dateFormat\r\n if (orderFileSchemas.date === 'other') {\r\n newObj['dateFormat'] = dateOptions[2];\r\n } else if (orderFileSchemas.date === 'M/d/yyyy') {\r\n newObj['dateFormat'] = dateOptions[1];\r\n } else if (orderFileSchemas.date === 'd/M/yyyy') {\r\n newObj['dateFormat'] = dateOptions[0];\r\n } else {\r\n newObj['dateFormat'] = dateOptions[2];\r\n newObj['otherformat'] = orderFileSchemas.date;\r\n }\r\n\r\n //this is for delimiter\r\n\r\n if (orderFileSchemas.schemaFileType.delimiter === ',') {\r\n newObj['delimiter'] = delimiterOptions[0];\r\n } else if (orderFileSchemas.schemaFileType.delimiter === '~') {\r\n newObj['delimiter'] = delimiterOptions[1];\r\n } else if (orderFileSchemas.schemaFileType.delimiter === '|') {\r\n newObj['delimiter'] = delimiterOptions[2];\r\n } else if (orderFileSchemas.schemaFileType.delimiter === '\\\\t' || orderFileSchemas.schemaFileType.delimiter === \"\\t\") {\r\n newObj['delimiter'] = delimiterOptions[3];\r\n } else if (orderFileSchemas.schemaFileType.delimiter === ';') {\r\n newObj['delimiter'] = delimiterOptions[4];\r\n } else {\r\n newObj['delimiter'] = delimiterOptions[5];\r\n newObj['newDelimeter'] = orderFileSchemas.schemaFileType.delimiter;\r\n }\r\n setValues({ ...formikValues, ...newObj });\r\n dispatch(actions.setLoaderLayOver(false));\r\n };\r\n\r\n const isMultipleSchema = () => {\r\n return formikValues.schemaType?.value !== 'order' && formikValues.schemaType?.value !== 'collection' && formikValues.schemaType.value !== 'custom' && formikValues.schemaType?.value !== \"order+collectionsConsignor\" && formikValues.schemaType?.value !== 'parcel' && formikValues.schemaType?.value !== \"clearance\" ? true : false;\r\n };\r\n\r\n const setAllRowsInFile = (string) => {\r\n const lastIndex = string.indexOf('\\n');\r\n if (allRows.length <= MAX_ROWS_FOR_SCHEMA) {\r\n if (lastIndex !== -1) {\r\n allRows.push(string.slice(0, lastIndex));\r\n setAllRowsInFile(string.slice(lastIndex + 1, string.length));\r\n } else if (string.length > 0) {\r\n allRows.push(string);\r\n }\r\n }\r\n };\r\n\r\n const setPageDataFromFile = (file) => {\r\n setAllRowsWithColumns([]);\r\n props.setDropdownValues([]);\r\n //read file as text and form dropdownvalues and show content of file\r\n if (file) {\r\n let asText = new FileReader();\r\n languageEncoding(file).then((fileInfo) => {\r\n asText.readAsText(file, fileInfo.encoding || \"latin1\");\r\n })\r\n\r\n asText.onload = () => {\r\n setAllRowsInFile(asText.result);\r\n if (formikValues.importType === 'fixedlength') {\r\n if (currentRowIndicatorValue) {\r\n allRows = allRows.filter(row => {\r\n if (row.split(\" \").filter(f => f)\r\n .find(value => value.trim().toLowerCase() === currentRowIndicatorValue.trim().toLowerCase())) { return true }\r\n return false\r\n })\r\n }\r\n setAllRowsWithColumns(allRows);\r\n } else {\r\n const selectedDel =\r\n formikValues.delimiter.value === 'otherDelimiter'\r\n ? formikValues.newDelimeter\r\n : formikValues.delimiter.value.replace(\"\\\\t\", \"\\t\");\r\n allRows = allRows\r\n .filter((val, index) => {\r\n let values = val.split(selectedDel);\r\n if (isMultipleSchema()) {\r\n if (currentRowIndicatorValue) {\r\n if (values.find(val => val.toLowerCase() === currentRowIndicatorValue.toLowerCase())) {\r\n return true;\r\n } else return false\r\n } else return true;\r\n\r\n }\r\n else return true;\r\n })\r\n .map((row) => {\r\n let values = row.split(selectedDel);\r\n return values;\r\n });\r\n allRows = allRows.map((val) => {\r\n let newArr = [];\r\n let start;\r\n let flag = true;\r\n val.forEach((a, i) => {\r\n if (selectedDel === \",\" && a.includes(\"\\\"\") && a.split(\"\\\"\").length === 2) {\r\n flag = false;\r\n if (start && start != i) {\r\n newArr.push(val.slice(start, i + 1).join(`${selectedDel} `));\r\n flag = true;\r\n start = null;\r\n }\r\n else start = i;\r\n }\r\n else if (flag) {\r\n newArr.push(a);\r\n }\r\n });\r\n return newArr;\r\n });\r\n\r\n if (allRows.length > 0) {\r\n if (formikValues.isheaderIncluded) {\r\n allDropDownValues = allRows[0].map((v) => {\r\n return { name: v, value: v };\r\n });\r\n }\r\n else if (isMultipleSchema()) {\r\n if (currentRowIndicatorValue) {\r\n if (allRows[0].find(val => val.toLowerCase() === currentRowIndicatorValue.toLowerCase())) {\r\n allDropDownValues = allRows[0].map((v, index) => {\r\n return { name: `Col${index + 1}`, value: index + 1 };\r\n });\r\n }\r\n } else {\r\n allDropDownValues = allRows[0].map((v, index) => {\r\n return { name: `Col${index + 1}`, value: index + 1 };\r\n });\r\n }\r\n }\r\n else {\r\n allDropDownValues = allRows[0].map((v, index) => {\r\n return { name: `Col${index + 1}`, value: index + 1 };\r\n });\r\n }\r\n }\r\n\r\n setAllRowsWithColumns(allRows);\r\n if (allDropDownValues.length > 1) {\r\n allDropDownValues.unshift({\r\n value: '',\r\n name: 'Select',\r\n });\r\n props.setDropdownValues(allDropDownValues);\r\n } else {\r\n props.setDropdownValues([]);\r\n }\r\n }\r\n };\r\n }\r\n };\r\n\r\n const getFileDetails = (e) => {\r\n const files = e.target.files;\r\n const file = files[0];\r\n const fileName = file.name.split('.').pop().toLowerCase();\r\n const allowedExtensions = ['.csv', '.txt'];\r\n const allowedMIMETypes = ['text/csv', 'text/plain'];\r\n if (allowedExtensions.includes('.' + fileName) && allowedMIMETypes.includes(file.type)) {\r\n setUploadedFile(file);\r\n setPageDataFromFile(file);\r\n setFileError(false);\r\n }\r\n else{\r\n setFileError(true);\r\n }\r\n };\r\n\r\n const resetFileSelection = (e) => {\r\n e.target.value = '';\r\n };\r\n\r\n const handleClick = (e) => {\r\n setUploadedFile(null);\r\n setPageDataFromFile(null);\r\n resetFileSelection(e);\r\n };\r\n\r\n useEffect(() => {\r\n setCurrentValue('');\r\n setCurrentValueStartLength([0, 0]);\r\n if (uploadedFile && (formikValues.delimiter.value != 'otherDelimiter' || formikValues.newDelimeter.trim())) {\r\n setPageDataFromFile(uploadedFile);\r\n } else if (!uploadedFile) {\r\n setPageDataFromFile(null);\r\n }\r\n }, [\r\n uploadedFile,\r\n formikValues.isheaderIncluded,\r\n formikValues.delimiter,\r\n formikValues.newDelimeter,\r\n formikValues.schemaType,\r\n formikValues.importType,\r\n currentRowIndicatorValue\r\n ]);\r\n\r\n const sliceText = (text, start, end) => {\r\n return text.slice(start, end);\r\n };\r\n\r\n useEffect(() => {\r\n if (isMultipleSchema()) {\r\n setFieldValue('isheaderIncluded', false);\r\n }\r\n }, [formikValues.schemaType, formikValues.importType]);\r\n\r\n\r\n useEffect(() => {\r\n if (formikValues.pollingPath?.trim()) {\r\n if (existingFolderPaths.find(path => path === formikValues.pollingPath)) {\r\n setFolderPathExist(true)\r\n } else setFolderPathExist(false)\r\n }\r\n }, [formikValues.pollingPath]);\r\n\r\n return (\r\n \r\n
\r\n \r\n \r\n \r\n Schema name already exists\r\n \r\n \r\n \r\n ele.value !== 'order+collectionsConsignor') : schemaValues} fullWidth />\r\n \r\n \r\n
\r\n \r\n \r\n \r\n File polling path already exists\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {!isOtherFormat ? : null}\r\n\r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n Import file format \r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n {formikValues.importType !== 'fixedlength' ? (\r\n <>\r\n \r\n \r\n \r\n \r\n {isDelimeter ? : ''}\r\n {' '}\r\n >\r\n ) : null}\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {/* \r\n */}\r\n \r\n \r\n getFileDetails(event)}\r\n onClick={resetFileSelection}\r\n disabled={isDefaultSchema}\r\n />\r\n \r\n \r\n {/* */}\r\n \r\n \r\n \r\n \r\n \r\n \r\n Example upload file \r\n \r\n \r\n \r\n ) : (\r\n ''\r\n )\r\n }\r\n />\r\n \r\n \r\n \r\n Invalid format. Please upload a .txt or .csv file\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n {allRowsWithColumns.length > 0 ? (\r\n
\r\n {!Array.isArray(allRowsWithColumns[0])\r\n ? allRowsWithColumns.map((row, index) => {\r\n let splittedElements = [];\r\n const start = currentValueStartLength[0] - 1 <= 0 ? 0 : currentValueStartLength[0] - 1;\r\n\r\n if (start === 0) {\r\n splittedElements.push('');\r\n } else {\r\n splittedElements.push(sliceText(row, 0, currentValueStartLength[0] - 1));\r\n }\r\n if (currentValueStartLength[0] + currentValueStartLength[1] === row.length) {\r\n splittedElements.push('');\r\n } else {\r\n splittedElements.push(sliceText(row, start + currentValueStartLength[1], row.length));\r\n }\r\n const highlight = sliceText(row, start, start + currentValueStartLength[1]);\r\n\r\n return (\r\n \r\n \r\n {splittedElements[0]} \r\n {highlight} \r\n {splittedElements[1]} \r\n \r\n \r\n );\r\n })\r\n : allRowsWithColumns.map((row) => {\r\n return (\r\n \r\n {row.map((col, index) => {\r\n return (\r\n \r\n {col}\r\n \r\n );\r\n })}\r\n \r\n );\r\n })}\r\n
\r\n ) : null}\r\n
\r\n \r\n
\r\n );\r\n};\r\n\r\nexport default SchemaDetailsField;\r\n","import { Grid, IconButton } from '@material-ui/core';\r\nimport React, { useState, useEffect } from 'react';\r\nimport DynamicMaterialTable from '../../../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\nimport ArrowForwardIcon from '@material-ui/icons/ArrowForward';\r\nimport ArrowBackIcon from '@material-ui/icons/ArrowBack';\r\nimport MaterialTable from \"material-table\";\r\nimport './createNewSchema.scss'\r\n\r\nconst SchemaMaterialTable = (props) => {\r\n const { formikValues, dragFromValues, dragToValues, isSelectable, leftSideColumns, rightSideColumns, setDragToValues, setDragFromValues, setCurrentValueStartLength, setCurrentValue, isDefaultSchema ,isOutputFile} = props;\r\n\r\n const [selectedRows, setSelectedRows] = useState([]);\r\n const [importRows, setImportRows] = useState([]);\r\n const [isImportIconDisabled, setImportIconDisabled] = useState(true);\r\n const [isExportIconDisabled, setExportIconDisabled] = useState(true);\r\n\r\n\r\n const addSelectedRows = (selectedValues) => {\r\n\r\n // selectedRows.tableData.checked= true;\r\n setSelectedRows(selectedValues);\r\n\r\n };\r\n const addSelectedFiles = (files) => {\r\n\r\n setImportRows(files)\r\n }\r\n const handleImport = () => {\r\n selectedRows.map((row) => {\r\n row.startsAt = '';\r\n row.length = '';\r\n row.columnFromFile = '';\r\n row.tableData.checked = false\r\n })\r\n props.removeFromfields(selectedRows)\r\n setSelectedRows([]);\r\n if(!isOutputFile){\r\n setCurrentValueStartLength([0, 0]);\r\n setCurrentValue(\"\");\r\n }\r\n }\r\n const handleExport = () => {\r\n importRows.map((row) => {\r\n row.startsAt = '';\r\n row.length = '';\r\n row.columnFromFile = '';\r\n row.tableData.checked = false\r\n })\r\n props.removeFromImportFiles(importRows)\r\n setImportRows([]);\r\n if(!isOutputFile){\r\n setCurrentValueStartLength([0, 0]);\r\n setCurrentValue(\"\");\r\n }\r\n }\r\n\r\n\r\n useEffect(() => {\r\n if (selectedRows.length > 0) {\r\n setImportIconDisabled(false)\r\n } else {\r\n setImportIconDisabled(true)\r\n }\r\n\r\n if (importRows.length > 0) {\r\n setExportIconDisabled(false)\r\n } else {\r\n setExportIconDisabled(true)\r\n }\r\n\r\n\r\n }, [selectedRows, importRows, formikValues])\r\n\r\n\r\n // useEffect(() => {\r\n // dragFromValues.forEach((fromValue)=>{\r\n // const data= (fromValue.name.toLowerCase())[0].toUpperCase() + (fromValue.name.toLowerCase()).substr(1)\r\n // const objIndex =dragFromValues.findIndex((obj => obj.id == fromValue.id));\r\n // dragFromValues[objIndex].name=data\r\n // })\r\n // },[dragFromValues])\r\n // console.log(dragToValues)\r\n return (\r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n
\r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nexport default SchemaMaterialTable;\r\n","import React, { useState, useEffect } from 'react';\r\nimport { AppBar, FormControl, Grid, NativeSelect, Tab, Tabs } from '@material-ui/core';\r\nimport TabPanel from '../../../shared/tabPanel';\r\nimport FormRenderer from '../../../../framework/Inputs/formRenderer/formRenderer';\r\n\r\nimport SchemaMaterialTable from './SchemaMaterialTable';\r\nimport { removeDuplicates, sortBasedOnNestedOrNot } from '../../../../utils/helperFunctions';\r\nimport { SCHEMA_MAPPING_GRID, MISC_VALUES } from '../../../../utils/constants/constants';\r\n\r\n\r\nconst SchemaMappingGrid = (props) => {\r\n const {\r\n columns,\r\n multiTab,\r\n firstTab,\r\n secTab,\r\n thirdTab,\r\n customsValues,\r\n collectionValues,\r\n formikValues,\r\n mappingDetails,\r\n getFieldSchemaDetails,\r\n typeOfSchema,\r\n requiredField,\r\n setDropdownValues,\r\n dropdownValues,\r\n setCurrentValue,\r\n setCurrentValueStartLength,\r\n setCurrentRowIndicatorValue,\r\n setCurrentRowIndicatorPlacement,\r\n formField,\r\n isClear,\r\n setFieldValue,\r\n currentTab,\r\n setTabValue,\r\n isDefaultSchema,\r\n setIsClear,\r\n setFieldTouched\r\n } = props;\r\n\r\n let { orderValues } = props;\r\n\r\n const { \r\n ROW_INDICATOR,\r\n ORDER,\r\n COLLECTION,\r\n CUSTOM,\r\n ORDER_COLLECTION_CONSIGNOR,\r\n PARCEL,\r\n CLEARANCE,\r\n ORDERS_CUSTOMS,\r\n ORDERS_COLLECTIONS,\r\n ORDERS_CLEARANCE,\r\n COLLECTIONS_CLEARANCE,\r\n COLUMN_NAME,\r\n COLLECTIONS,\r\n ORDERS_CUSTOMS_COLLECTIONS,\r\n DELIMITED,\r\n ORDERS_CUSTOMS_PARCELS,\r\n FIXED_LENGTH,\r\n ROW_INDICATOR_VALUE,\r\n ROWINDICATOR\r\n } = SCHEMA_MAPPING_GRID\r\n\r\n if (!multiTab) {\r\n orderValues = orderValues.filter(order => order.name !== ROW_INDICATOR)\r\n }\r\n \r\n const [dragFromValues, setDragFromValues] = useState(sortBasedOnNestedOrNot(orderValues, \"name\"));\r\n const [dragToValues, setDragToValues] = useState([]);\r\n const [dragFromDropDownValues, setDragFromDropDownValues] = useState([]);\r\n\r\n\r\n const [firstDragFromValues, setFirstDragFromValues] = useState(sortBasedOnNestedOrNot(orderValues, \"name\"));\r\n const [firstDragToValues, setFirstDragToValues] = useState([]);\r\n const [dropDownFirstDragFromValues, setDropDownFirstDragFromValues] = useState([]);\r\n\r\n\r\n const [secDragFromValues, setSecDragFromValues] = useState(sortBasedOnNestedOrNot(customsValues, \"name\"));\r\n const [secDragToValues, setSecDragToValues] = useState([]);\r\n const [dropDownSecDragFromValues, setDropDownSecDragFromValues] = useState([]);\r\n\r\n\r\n const [thirdDragFromValues, setThirdDragFromValues] = useState(sortBasedOnNestedOrNot(collectionValues, \"name\"));\r\n const [thirdDragToValues, setThirdDragToValues] = useState([]);\r\n const [dropDownThirdDragFromValues, setDropDownThirdDragFromValues] = useState([]);\r\n\r\n\r\n const handleChange = (event, newValue) => {\r\n setTabValue(newValue);\r\n setCurrentValueStartLength([0, 0]);\r\n let currentTabIndicatorValue = formikValues[`rowIndicator${newValue + 1}`]?.trim()\r\n setCurrentRowIndicatorValue && setCurrentRowIndicatorValue(currentTabIndicatorValue);\r\n setCurrentValue(\"\");\r\n };\r\n\r\n useEffect(() => {\r\n setFieldTouched('rowIndicator1', false);\r\n setFieldTouched('rowIndicator2', false);\r\n setFieldTouched('rowIndicator3', false);\r\n }, [currentTab])\r\n\r\n useEffect(() => {\r\n\r\n if (isClear) {\r\n setDragToValues([])\r\n setDragFromValues(sortBasedOnNestedOrNot(orderValues, \"name\"))\r\n setFirstDragToValues([])\r\n setFirstDragFromValues(sortBasedOnNestedOrNot(orderValues, \"name\"))\r\n\r\n setSecDragToValues([])\r\n setSecDragFromValues(sortBasedOnNestedOrNot(customsValues, \"name\"))\r\n\r\n setThirdDragToValues([])\r\n setThirdDragFromValues(sortBasedOnNestedOrNot(collectionValues, \"name\"))\r\n setIsClear(false)\r\n }\r\n }, [isClear])\r\n\r\n\r\n useEffect(() => {\r\n\r\n const firstMappingArray = [];\r\n const secMappingArray = []\r\n const thirdMappingArray = []\r\n\r\n const dropDownValues = [{ name: \"Select\", value: '' }]\r\n const firstDropDownValues = [{ name: \"Select\", value: '' }]\r\n const secDropDownValues = [{ name: \"Select\", value: '' }]\r\n const thirdDropDownValues = [{ name: \"Select\", value: '' }]\r\n\r\n if ((mappingDetails || {}).schemaType === ORDER\r\n || (mappingDetails || {}).schemaType === COLLECTION \r\n || (mappingDetails || {}).schemaType === CUSTOM \r\n || (mappingDetails || {}).schemaType === ORDER_COLLECTION_CONSIGNOR \r\n || (mappingDetails || {}).schemaType === PARCEL \r\n || (mappingDetails || {}).schemaType === CLEARANCE) {\r\n const fromValues = [...dragFromValues];\r\n (mappingDetails.fieldsMappingSchema || []).sort(function (a, b) {\r\n return a.mapFrom - b.mapFrom;\r\n }).map((filedDetails, index) => {\r\n const dropDownObj = {}\r\n const colName = COLUMN_NAME\r\n if (fromValues.length > 0) {\r\n const fieldObject = fromValues.find(fromValues => fromValues.valueName === filedDetails.mapTo);\r\n if (fieldObject != undefined) {\r\n fieldObject['valueName'] = filedDetails.mapTo;\r\n fieldObject['columnFromFile'] = filedDetails.mapFrom;\r\n fieldObject['startsAt'] = filedDetails.range.startIndex;\r\n fieldObject['length'] = filedDetails.range.columnLength;\r\n fieldObject['type'] = filedDetails.type;\r\n if (filedDetails.mapFrom != '') {\r\n dropDownObj[\"id\"] = index;\r\n dropDownObj[\"name\"] = mappingDetails.isheaderIncluded ? filedDetails.mapFrom : colName.concat(filedDetails.mapFrom);\r\n dropDownObj[\"value\"] = filedDetails.mapFrom;\r\n }\r\n const filteredValue = fromValues.findIndex(fromValues => fromValues.valueName === filedDetails.mapTo);\r\n fromValues.splice(filteredValue, 1);\r\n\r\n firstMappingArray.push(fieldObject)\r\n dropDownValues.push(dropDownObj)\r\n }\r\n }\r\n })\r\n setDragFromDropDownValues(removeDuplicates(dropDownValues, item => item.name))\r\n setDragFromValues(sortBasedOnNestedOrNot(fromValues, \"name\"))\r\n\r\n\r\n setDragToValues(firstMappingArray)\r\n }\r\n if ((mappingDetails || {}).schemaType === ORDERS_CUSTOMS \r\n || (mappingDetails || {}).schemaType === ORDERS_COLLECTIONS\r\n || (mappingDetails || {}).schemaType === ORDERS_CLEARANCE) {\r\n\r\n const firstFromValues = [...firstDragFromValues];\r\n const secFromValues = [...secDragFromValues];\r\n\r\n\r\n (mappingDetails.fieldsMappingSchema || []).sort(function (a, b) {\r\n return a.mapFrom - b.mapFrom;\r\n }).map((filedDetails, index) => {\r\n const dropDownObj = {}\r\n const colName = COLUMN_NAME\r\n if (filedDetails.type === ORDER) {\r\n if (firstFromValues.length > 0) {\r\n const fieldObject = firstFromValues.find(firstFromValues => firstFromValues.valueName === filedDetails.mapTo);\r\n if (fieldObject != undefined) {\r\n fieldObject['valueName'] = filedDetails.mapTo;\r\n fieldObject['columnFromFile'] = filedDetails.mapFrom;\r\n fieldObject['startsAt'] = filedDetails.range.startIndex;\r\n fieldObject['length'] = filedDetails.range.columnLength;\r\n fieldObject['type'] = filedDetails.type;\r\n if (filedDetails.mapTo === ROWINDICATOR) {\r\n\r\n setFieldValue(\"rowIndicator1\", filedDetails.value || '')\r\n\r\n }\r\n if (filedDetails.mapFrom != '') {\r\n dropDownObj[\"id\"] = index;\r\n dropDownObj[\"name\"] = colName.concat(filedDetails.mapFrom);\r\n dropDownObj[\"value\"] = filedDetails.mapFrom;\r\n\r\n\r\n }\r\n firstMappingArray.push(fieldObject)\r\n const filteredValue = firstFromValues.findIndex(firstFromValues => firstFromValues.valueName === filedDetails.mapTo);\r\n firstDropDownValues.push(dropDownObj)\r\n firstFromValues.splice(filteredValue, 1);\r\n }\r\n }\r\n } else if (filedDetails.type === CUSTOM) {\r\n if (secFromValues.length > 0) {\r\n const fieldObject = secFromValues.find(secFromValues => secFromValues.valueName === filedDetails.mapTo);\r\n if (fieldObject != undefined) {\r\n fieldObject['valueName'] = filedDetails.mapTo;\r\n fieldObject['columnFromFile'] = filedDetails.mapFrom;\r\n fieldObject['startsAt'] = filedDetails.range.startIndex;\r\n fieldObject['length'] = filedDetails.range.columnLength;\r\n fieldObject['type'] = filedDetails.type;\r\n secMappingArray.push(fieldObject)\r\n if (filedDetails.mapFrom != '') {\r\n dropDownObj[\"id\"] = index;\r\n dropDownObj[\"name\"] = colName.concat(filedDetails.mapFrom);\r\n dropDownObj[\"value\"] = filedDetails.mapFrom;\r\n\r\n\r\n }\r\n if (filedDetails.mapTo === ROWINDICATOR) {\r\n\r\n setFieldValue(\"rowIndicator2\", filedDetails.value || '')\r\n }\r\n const secfilteredValue = secFromValues.findIndex(secFromValues => secFromValues.valueName === filedDetails.mapTo);\r\n secDropDownValues.push(dropDownObj)\r\n\r\n secFromValues.splice(secfilteredValue, 1);\r\n }\r\n\r\n }\r\n } else if (filedDetails.type === CLEARANCE) {\r\n if (secFromValues.length > 0) {\r\n const fieldObject = secFromValues.find(secFromValues => secFromValues.valueName === filedDetails.mapTo);\r\n if (fieldObject != undefined) {\r\n fieldObject['valueName'] = filedDetails.mapTo;\r\n fieldObject['columnFromFile'] = filedDetails.mapFrom;\r\n fieldObject['startsAt'] = filedDetails.range.startIndex;\r\n fieldObject['length'] = filedDetails.range.columnLength;\r\n fieldObject['type'] = filedDetails.type;\r\n secMappingArray.push(fieldObject)\r\n if (filedDetails.mapFrom != '') {\r\n dropDownObj[\"id\"] = index;\r\n dropDownObj[\"name\"] = colName.concat(filedDetails.mapFrom);\r\n dropDownObj[\"value\"] = filedDetails.mapFrom;\r\n }\r\n if (filedDetails.mapTo === ROWINDICATOR) {\r\n\r\n setFieldValue(\"rowIndicator2\", filedDetails.value || '')\r\n }\r\n const secfilteredValue = secFromValues.findIndex(secFromValues => secFromValues.valueName === filedDetails.mapTo);\r\n secDropDownValues.push(dropDownObj)\r\n\r\n secFromValues.splice(secfilteredValue, 1);\r\n }\r\n\r\n }\r\n\r\n } else if (filedDetails.type === COLLECTIONS) {\r\n if (secFromValues.length > 0) {\r\n const fieldObject = secFromValues.find(secFromValues => secFromValues.valueName === filedDetails.mapTo);\r\n if (fieldObject != undefined) {\r\n fieldObject['valueName'] = filedDetails.mapTo;\r\n fieldObject['columnFromFile'] = filedDetails.mapFrom;\r\n fieldObject['startsAt'] = filedDetails.range.startIndex;\r\n fieldObject['length'] = filedDetails.range.columnLength;\r\n fieldObject['type'] = filedDetails.type;\r\n secMappingArray.push(fieldObject)\r\n if (filedDetails.mapTo === ROWINDICATOR) {\r\n\r\n setFieldValue(\"rowIndicator2\", filedDetails.value || '')\r\n }\r\n if (filedDetails.mapFrom != '') {\r\n dropDownObj[\"id\"] = index;\r\n dropDownObj[\"name\"] = colName.concat(filedDetails.mapFrom);\r\n dropDownObj[\"value\"] = filedDetails.mapFrom;\r\n\r\n\r\n }\r\n const secfilteredValue = secFromValues.findIndex(secFromValues => secFromValues.valueName === filedDetails.mapTo);\r\n secDropDownValues.push(dropDownObj)\r\n\r\n secFromValues.splice(secfilteredValue, 1);\r\n }\r\n\r\n }\r\n \r\n } \r\n setFirstDragToValues(firstMappingArray)\r\n setSecDragToValues(secMappingArray)\r\n\r\n })\r\n\r\n setDropDownFirstDragFromValues(removeDuplicates(firstDropDownValues, item => item.name))\r\n setDropDownSecDragFromValues(removeDuplicates(secDropDownValues, item => item.name))\r\n\r\n\r\n\r\n setFirstDragFromValues(sortBasedOnNestedOrNot(firstFromValues, \"name\"))\r\n setSecDragFromValues(sortBasedOnNestedOrNot(secFromValues, \"name\"))\r\n }\r\n if (\r\n (mappingDetails || {}).schemaType === ORDERS_CUSTOMS_COLLECTIONS ||\r\n (mappingDetails || {}).schemaType === ORDERS_CUSTOMS_PARCELS \r\n ) {\r\n const firstFromValues = [...firstDragFromValues];\r\n const secFromValues = [...secDragFromValues];\r\n const thirdFromValues = [...thirdDragFromValues];\r\n\r\n (mappingDetails.fieldsMappingSchema || [])\r\n .sort(function (a, b) {\r\n return a.mapFrom - b.mapFrom;\r\n })\r\n .map((filedDetails, index) => {\r\n let fieldObject = {};\r\n const dropDownObj = {};\r\n const colName = COLUMN_NAME;\r\n\r\n if (filedDetails.type === ORDER) {\r\n if (firstFromValues.length > 0) {\r\n fieldObject = firstFromValues.find((firstFromValues) => firstFromValues.valueName === filedDetails.mapTo);\r\n if (fieldObject != undefined) {\r\n fieldObject['valueName'] = filedDetails.mapTo;\r\n fieldObject['columnFromFile'] = filedDetails.mapFrom;\r\n fieldObject['startsAt'] = filedDetails.range.startIndex;\r\n fieldObject['length'] = filedDetails.range.columnLength;\r\n fieldObject['type'] = filedDetails.type;\r\n if (filedDetails.mapTo === ROWINDICATOR) {\r\n setFieldValue('rowIndicator1', filedDetails.value || '');\r\n }\r\n\r\n if (filedDetails.mapFrom != '') {\r\n dropDownObj['id'] = index;\r\n dropDownObj['name'] = colName.concat(filedDetails.mapFrom);\r\n dropDownObj['value'] = filedDetails.mapFrom;\r\n }\r\n firstMappingArray.push(fieldObject);\r\n const filteredValue = firstFromValues.findIndex(\r\n (firstFromValues) => firstFromValues.valueName === filedDetails.mapTo,\r\n );\r\n firstDropDownValues.push(dropDownObj);\r\n\r\n firstFromValues.splice(filteredValue, 1);\r\n }\r\n }\r\n } else if (filedDetails.type === CUSTOM) {\r\n if (secFromValues.length > 0) {\r\n fieldObject = secFromValues.find((secFromValues) => secFromValues.valueName === filedDetails.mapTo);\r\n\r\n if (fieldObject != undefined) {\r\n fieldObject['valueName'] = filedDetails.mapTo;\r\n fieldObject['columnFromFile'] = filedDetails.mapFrom;\r\n fieldObject['startsAt'] = filedDetails.range.startIndex;\r\n fieldObject['length'] = filedDetails.range.columnLength;\r\n fieldObject['type'] = filedDetails.type;\r\n if (filedDetails.mapTo === ROWINDICATOR) {\r\n setFieldValue('rowIndicator2', filedDetails.value || '');\r\n }\r\n if (filedDetails.mapFrom != '') {\r\n dropDownObj['id'] = index;\r\n dropDownObj['name'] = colName.concat(filedDetails.mapFrom);\r\n dropDownObj['value'] = filedDetails.mapFrom;\r\n }\r\n\r\n secMappingArray.push(fieldObject);\r\n const filteredValue = secFromValues.findIndex(\r\n (secFromValues) => secFromValues.valueName === filedDetails.mapTo,\r\n );\r\n secDropDownValues.push(dropDownObj);\r\n\r\n secFromValues.splice(filteredValue, 1);\r\n }\r\n }\r\n } else if (\r\n filedDetails.type === COLLECTIONS ||\r\n filedDetails.type === PARCEL ||\r\n filedDetails.type === CLEARANCE\r\n ) {\r\n if (thirdFromValues.length > 0) {\r\n fieldObject = thirdFromValues.find((thirdFromValues) => thirdFromValues.valueName === filedDetails.mapTo);\r\n if (fieldObject != undefined) {\r\n fieldObject['valueName'] = filedDetails.mapTo;\r\n fieldObject['columnFromFile'] = filedDetails.mapFrom;\r\n fieldObject['startsAt'] = filedDetails.range.startIndex;\r\n fieldObject['length'] = filedDetails.range.columnLength;\r\n fieldObject['type'] = filedDetails.type;\r\n if (filedDetails.mapTo === ROWINDICATOR) {\r\n setFieldValue('rowIndicator3', filedDetails.value || '');\r\n }\r\n if (filedDetails.mapFrom != '') {\r\n dropDownObj['id'] = index;\r\n dropDownObj['name'] = colName.concat(filedDetails.mapFrom);\r\n dropDownObj['value'] = filedDetails.mapFrom;\r\n }\r\n thirdMappingArray.push(fieldObject);\r\n const filteredValue = thirdFromValues.findIndex(\r\n (thirdFromValues) => thirdFromValues.valueName === filedDetails.mapTo,\r\n );\r\n thirdDropDownValues.push(dropDownObj);\r\n\r\n thirdFromValues.splice(filteredValue, 1);\r\n }\r\n }\r\n }\r\n\r\n setFirstDragToValues(firstMappingArray);\r\n setSecDragToValues(secMappingArray);\r\n setThirdDragToValues(thirdMappingArray);\r\n });\r\n\r\n setDropDownFirstDragFromValues(removeDuplicates(firstDropDownValues, (item) => item.name));\r\n setDropDownSecDragFromValues(removeDuplicates(secDropDownValues, (item) => item.name));\r\n setDropDownThirdDragFromValues(removeDuplicates(thirdDropDownValues, (item) => item.name));\r\n\r\n setFirstDragFromValues(sortBasedOnNestedOrNot(firstFromValues, 'name'));\r\n setSecDragFromValues(sortBasedOnNestedOrNot(secFromValues, 'name'));\r\n setThirdDragFromValues(sortBasedOnNestedOrNot(thirdFromValues, 'name'));\r\n }\r\n\r\n if ((mappingDetails || {}).schemaType === COLLECTIONS_CLEARANCE) {\r\n\r\n const firstFromValues = [...firstDragFromValues];\r\n const secFromValues = [...secDragFromValues];\r\n\r\n\r\n (mappingDetails.fieldsMappingSchema || []).sort(function (a, b) {\r\n return a.mapFrom - b.mapFrom;\r\n }).map((filedDetails, index) => {\r\n const dropDownObj = {}\r\n const colName = COLUMN_NAME\r\n if (filedDetails.type === COLLECTIONS) {\r\n if (firstFromValues.length > 0) {\r\n const fieldObject = firstFromValues.find(firstFromValues => firstFromValues.valueName === filedDetails.mapTo);\r\n if (fieldObject != undefined) {\r\n fieldObject['valueName'] = filedDetails.mapTo;\r\n fieldObject['columnFromFile'] = filedDetails.mapFrom;\r\n fieldObject['startsAt'] = filedDetails.range.startIndex;\r\n fieldObject['length'] = filedDetails.range.columnLength;\r\n fieldObject['type'] = filedDetails.type;\r\n if (filedDetails.mapTo === ROWINDICATOR) {\r\n\r\n setFieldValue(\"rowIndicator1\", filedDetails.value || '')\r\n\r\n }\r\n if (filedDetails.mapFrom != '') {\r\n dropDownObj[\"id\"] = index;\r\n dropDownObj[\"name\"] = colName.concat(filedDetails.mapFrom);\r\n dropDownObj[\"value\"] = filedDetails.mapFrom;\r\n\r\n\r\n }\r\n firstMappingArray.push(fieldObject)\r\n const filteredValue = firstFromValues.findIndex(firstFromValues => firstFromValues.valueName === filedDetails.mapTo);\r\n firstDropDownValues.push(dropDownObj)\r\n firstFromValues.splice(filteredValue, 1);\r\n }\r\n }\r\n } else if (filedDetails.type === CLEARANCE) {\r\n if (secFromValues.length > 0) {\r\n const fieldObject = secFromValues.find(secFromValues => secFromValues.valueName === filedDetails.mapTo);\r\n if (fieldObject != undefined) {\r\n fieldObject['valueName'] = filedDetails.mapTo;\r\n fieldObject['columnFromFile'] = filedDetails.mapFrom;\r\n fieldObject['startsAt'] = filedDetails.range.startIndex;\r\n fieldObject['length'] = filedDetails.range.columnLength;\r\n fieldObject['type'] = filedDetails.type;\r\n secMappingArray.push(fieldObject)\r\n if (filedDetails.mapFrom != '') {\r\n dropDownObj[\"id\"] = index;\r\n dropDownObj[\"name\"] = colName.concat(filedDetails.mapFrom);\r\n dropDownObj[\"value\"] = filedDetails.mapFrom;\r\n }\r\n if (filedDetails.mapTo === ROWINDICATOR) {\r\n\r\n setFieldValue(\"rowIndicator2\", filedDetails.value || '')\r\n }\r\n const secfilteredValue = secFromValues.findIndex(secFromValues => secFromValues.valueName === filedDetails.mapTo);\r\n secDropDownValues.push(dropDownObj)\r\n\r\n secFromValues.splice(secfilteredValue, 1);\r\n }\r\n\r\n }\r\n\r\n }\r\n setFirstDragToValues(firstMappingArray)\r\n setSecDragToValues(secMappingArray)\r\n\r\n })\r\n\r\n setDropDownFirstDragFromValues(removeDuplicates(firstDropDownValues, item => item.name))\r\n setDropDownSecDragFromValues(removeDuplicates(secDropDownValues, item => item.name))\r\n\r\n\r\n\r\n setFirstDragFromValues(sortBasedOnNestedOrNot(firstFromValues, \"name\"))\r\n setSecDragFromValues(sortBasedOnNestedOrNot(secFromValues, \"name\"))\r\n }\r\n }, [mappingDetails])\r\n\r\n useEffect(() => {\r\n\r\n let feildArray = [...dragToValues, ...firstDragToValues, ...secDragToValues, ...thirdDragToValues];\r\n props.getFieldSchemaDetails(feildArray);\r\n }, [dragToValues, firstDragToValues, secDragToValues, thirdDragToValues])\r\n\r\n useEffect(() => {\r\n const { rowIndicator3 } = formikValues;\r\n setCurrentRowIndicatorValue && setCurrentRowIndicatorValue(rowIndicator3?.trim() || \"\")\r\n }, [formikValues.rowIndicator3])\r\n\r\n useEffect(() => {\r\n const { rowIndicator2 } = formikValues;\r\n setCurrentRowIndicatorValue && setCurrentRowIndicatorValue(rowIndicator2?.trim() || \"\")\r\n }, [formikValues.rowIndicator2])\r\n\r\n useEffect(() => {\r\n const { rowIndicator1 } = formikValues;\r\n setCurrentRowIndicatorValue && setCurrentRowIndicatorValue(rowIndicator1?.trim() || \"\")\r\n }, [formikValues.rowIndicator1])\r\n\r\n const removeFromfields = (selecteddata) => {\r\n\r\n const toValues = [...dragToValues];\r\n const fromValues = [...dragFromValues];\r\n\r\n const itemsToBeDeleted = selecteddata.map((address) => {\r\n if (formikValues.importType === DELIMITED) {\r\n address['columnFromFile'] = '';\r\n if (address.name === ROW_INDICATOR) {\r\n address['rowIndicator'] = '';\r\n }\r\n }\r\n\r\n address['startsAt'] = '';\r\n address['length'] = '';\r\n address['type'] = typeOfSchema;\r\n\r\n\r\n toValues.push(address);\r\n setDragToValues(toValues);\r\n const filteredValue = fromValues.indexOf(address);\r\n fromValues.splice(filteredValue, 1);\r\n\r\n\r\n\r\n });\r\n setDragFromValues(sortBasedOnNestedOrNot(fromValues, \"name\"));\r\n };\r\n\r\n\r\n const removeFromImportFiles = (selecteddata) => {\r\n const fromValues = [...dragFromValues];\r\n\r\n const toValues = [...dragToValues];\r\n const itemsToBeDeleted = selecteddata.map((address) => {\r\n fromValues.push(address);\r\n setDragFromValues(sortBasedOnNestedOrNot(fromValues, \"name\"));\r\n\r\n const filteredValue = toValues.indexOf(address);\r\n\r\n toValues.splice(filteredValue, 1);\r\n });\r\n setDragToValues(toValues);\r\n };\r\n\r\n const removeFirstFromfields = (selecteddata) => {\r\n const toValues = [...firstDragToValues];\r\n const fromValues = [...firstDragFromValues];\r\n\r\n const itemsToBeDeleted = selecteddata.map((address) => {\r\n if (formikValues.importType === DELIMITED) {\r\n address['columnFromFile'] = '';\r\n if (address.name === ROW_INDICATOR) {\r\n address['rowIndicator'] = '';\r\n }\r\n } else {\r\n address['startsAt'] = '';\r\n address['length'] = '';\r\n }\r\n\r\n if ((formikValues.schemaType || {}).value === COLLECTIONS_CLEARANCE) {\r\n address['type'] = COLLECTIONS;\r\n } else{\r\n address['type'] = ORDER;\r\n }\r\n toValues.push(address);\r\n setFirstDragToValues(toValues);\r\n const filteredValue = fromValues.indexOf(address);\r\n fromValues.splice(filteredValue, 1);\r\n\r\n });\r\n setFirstDragFromValues(sortBasedOnNestedOrNot(fromValues, \"name\"));\r\n };\r\n\r\n const removeFirstFromImportFiles = (selecteddata) => {\r\n const fromValues = [...firstDragFromValues];\r\n\r\n const toValues = [...firstDragToValues];\r\n const itemsToBeDeleted = selecteddata.map((address) => {\r\n fromValues.push(address);\r\n setFirstDragFromValues(sortBasedOnNestedOrNot(fromValues, \"name\"));\r\n\r\n const filteredValue = toValues.indexOf(address);\r\n\r\n toValues.splice(filteredValue, 1);\r\n });\r\n setFirstDragToValues(toValues);\r\n };\r\n\r\n const removeSecFromfields = (selecteddata) => {\r\n const toValues = [...secDragToValues];\r\n const fromValues = [...secDragFromValues];\r\n\r\n const itemsToBeDeleted = selecteddata.map((address) => {\r\n if (formikValues.importType === DELIMITED) {\r\n address['columnFromFile'] = '';\r\n if (address.name === ROW_INDICATOR) {\r\n address['rowIndicator'] = '';\r\n }\r\n } else {\r\n address['startsAt'] = '';\r\n address['length'] = '';\r\n }\r\n\r\n if ((formikValues.schemaType || {}).value === ORDERS_COLLECTIONS) {\r\n address['type'] = COLLECTIONS;\r\n } else if (\r\n (formikValues.schemaType || {}).value === ORDERS_CLEARANCE ||\r\n (formikValues.schemaType || {}).value === COLLECTIONS_CLEARANCE\r\n ) {\r\n address['type'] = CLEARANCE;\r\n } else {\r\n address['type'] = CUSTOM;\r\n }\r\n\r\n toValues.push(address);\r\n setSecDragToValues(toValues);\r\n const filteredValue = fromValues.indexOf(address);\r\n fromValues.splice(filteredValue, 1);\r\n\r\n });\r\n setSecDragFromValues(sortBasedOnNestedOrNot(fromValues, \"name\"));\r\n };\r\n\r\n const removeSecFromImportFiles = (selecteddata) => {\r\n const fromValues = [...secDragFromValues];\r\n\r\n const toValues = [...secDragToValues];\r\n const itemsToBeDeleted = selecteddata.map((address) => {\r\n fromValues.push(address);\r\n setSecDragFromValues(sortBasedOnNestedOrNot(fromValues, \"name\"));\r\n\r\n const filteredValue = toValues.indexOf(address);\r\n\r\n toValues.splice(filteredValue, 1);\r\n });\r\n setSecDragToValues(toValues);\r\n };\r\n\r\n const removeThirdFromfields = (selecteddata) => {\r\n const toValues = [...thirdDragToValues];\r\n const fromValues = [...thirdDragFromValues];\r\n\r\n const itemsToBeDeleted = selecteddata.map((address) => {\r\n if (formikValues.importType === DELIMITED) {\r\n address['columnFromFile'] = '';\r\n if (address.name === ROW_INDICATOR) {\r\n address['rowIndicator'] = '';\r\n }\r\n } else {\r\n address['startsAt'] = '';\r\n address['length'] = '';\r\n }\r\n\r\n address['type'] = typeOfSchema === ORDERS_CUSTOMS_PARCELS ? PARCEL : COLLECTIONS;\r\n\r\n\r\n toValues.push(address);\r\n setThirdDragToValues(toValues);\r\n const filteredValue = fromValues.indexOf(address);\r\n fromValues.splice(filteredValue, 1);\r\n\r\n });\r\n setThirdDragFromValues(sortBasedOnNestedOrNot(fromValues, \"name\"));\r\n };\r\n\r\n const removeThirdFromImportFiles = (selecteddata) => {\r\n const fromValues = [...thirdDragFromValues];\r\n\r\n const toValues = [...thirdDragToValues];\r\n const itemsToBeDeleted = selecteddata.map((address) => {\r\n fromValues.push(address);\r\n setThirdDragFromValues(sortBasedOnNestedOrNot(fromValues, \"name\"));\r\n\r\n const filteredValue = toValues.indexOf(address);\r\n\r\n toValues.splice(filteredValue, 1);\r\n });\r\n setThirdDragToValues(toValues);\r\n };\r\n\r\n const leftSideColumns = [\r\n {\r\n title: 'Available fields', field: 'name', render: (row) => \r\n {row.name} {row.isRequiredField ? ** : ''}\r\n
\r\n }\r\n ];\r\n const rightSideColumns = [\r\n {\r\n title: 'Selected fields in import file', field: 'name', render: (row) => {\r\n return {row.name}
\r\n }\r\n },\r\n {\r\n title: 'Columns from the file',\r\n field: 'columnFromFile',\r\n render: (row) => {\r\n let dropDownArray = []\r\n\r\n if (dropdownValues.length === 0) {\r\n if (!formikValues.isheaderIncluded && formikValues.isheaderIncluded != undefined) {\r\n dropDownArray = dragFromDropDownValues.sort(function (a, b) {\r\n return a.value - b.value;\r\n })\r\n } else {\r\n dropDownArray = dragFromDropDownValues\r\n }\r\n\r\n } else {\r\n if (formikValues.isheaderIncluded) {\r\n (dropdownValues || []).map((item, index) => dropdownValues.length === index + 1 ?\r\n ((typeof item.value === MISC_VALUES.STRING || item.value instanceof String) ? item.value = item.value.replace(/\\r/g, \"\") : item)\r\n : item)\r\n }\r\n\r\n dropDownArray = dropdownValues\r\n\r\n }\r\n\r\n\r\n const handleChange = (event) => {\r\n\r\n const tableData = [...dragToValues];\r\n tableData[row.tableData.id].columnFromFile = event.target.value;\r\n setCurrentValue(event.target.value);\r\n setDragToValues(tableData);\r\n };\r\n\r\n return (\r\n <>\r\n \r\n {\r\n dropDownArray?.map((item, i) => {item.name} )\r\n }\r\n \r\n {dropDownArray.length === 0 ? Please check the example file : requiredField && row.isRequiredField && row.columnFromFile === '' ? \tColumn selection is required : ''}\r\n\r\n\r\n\r\n\r\n >\r\n );\r\n },\r\n },\r\n ];\r\n\r\n const rightSideColumnsFixedLength = [\r\n { title: 'Selected fields in import file', field: 'name', render: (row) => {row.name}
},\r\n {\r\n title: 'Starts at',\r\n field: 'startsAt',\r\n render: (row) => {\r\n const handleChange = (event) => {\r\n const tableData = [...dragToValues];\r\n tableData[row.tableData.id].startsAt = event.target.value;\r\n setCurrentValueStartLength([tableData[row.tableData.id].startsAt, tableData[row.tableData.id].length])\r\n setDragToValues(tableData);\r\n };\r\n\r\n\r\n return (\r\n <>\r\n \r\n >\r\n );\r\n },\r\n },\r\n {\r\n title: 'Length',\r\n field: 'length',\r\n render: (row) => {\r\n const handleChange = (event) => {\r\n const tableData = [...dragToValues];\r\n tableData[row.tableData.id].length = event.target.value;\r\n setCurrentValueStartLength([tableData[row.tableData.id].startsAt, tableData[row.tableData.id].length])\r\n setDragToValues(tableData);\r\n };\r\n\r\n return (\r\n <>\r\n \r\n >\r\n );\r\n },\r\n },\r\n ];\r\n\r\n const firstRightSideColumns = [\r\n { title: 'Selected fields in import file', field: 'name', render: (row) => {row.name}
},\r\n {\r\n title: 'Columns from the file',\r\n field: 'columnFromFile',\r\n render: (row) => {\r\n let dropDownArray = []\r\n\r\n if (dropdownValues.length === 0) {\r\n dropDownArray = dropDownFirstDragFromValues.sort(function (a, b) {\r\n return a.value - b.value;\r\n })\r\n } else {\r\n dropDownArray = dropdownValues\r\n\r\n }\r\n\r\n const handleChange = (event) => {\r\n\r\n const tableData = [...firstDragToValues];\r\n tableData[row.tableData.id].columnFromFile = event.target.value;\r\n setCurrentValue(event.target.value);\r\n setFirstDragToValues(tableData);\r\n row.name.toLowerCase() === ROW_INDICATOR_VALUE && setCurrentRowIndicatorPlacement(row)\r\n };\r\n\r\n\r\n\r\n\r\n return (\r\n <>\r\n\r\n \r\n {\r\n dropDownArray.map((item, i) => {item.name} )\r\n\r\n }\r\n\r\n \r\n {dropDownArray.length === 0 ? Please check the example file : requiredField && row.isRequiredField && row.columnFromFile === '' ? \tColumn selection is required : ''}\r\n\r\n >\r\n );\r\n },\r\n },\r\n ];\r\n const firstRightSideColumnsFixedLength = [\r\n { title: 'Selected fields in import file', field: 'name', render: (row) => {row.name}
},\r\n {\r\n title: 'Starts at',\r\n field: 'startsAt',\r\n render: (row) => {\r\n\r\n const handleChange = (event) => {\r\n\r\n const tableData = [...firstDragToValues];\r\n tableData[row.tableData.id].startsAt = event.target.value;\r\n setCurrentValueStartLength([tableData[row.tableData.id].startsAt, tableData[row.tableData.id].length])\r\n setFirstDragToValues(tableData);\r\n row.name.toLowerCase() === ROW_INDICATOR_VALUE && setCurrentRowIndicatorPlacement(row)\r\n };\r\n\r\n return (\r\n <>\r\n \r\n >\r\n );\r\n },\r\n },\r\n {\r\n title: 'Length',\r\n field: 'length',\r\n render: (row) => {\r\n const handleChange = (event) => {\r\n const tableData = [...firstDragToValues];\r\n tableData[row.tableData.id].length = event.target.value;\r\n setCurrentValueStartLength([tableData[row.tableData.id].startsAt, tableData[row.tableData.id].length])\r\n setFirstDragToValues(tableData);\r\n };\r\n\r\n return (\r\n <>\r\n \r\n >\r\n );\r\n },\r\n },\r\n ];\r\n const secRightSideColumns = [\r\n { title: 'Selected fields in import file', field: 'name', render: (row) => {row.name}
},\r\n {\r\n title: 'Columns from the file',\r\n field: 'columnFromFile',\r\n render: (row) => {\r\n let dropDownArray = []\r\n\r\n if (dropdownValues.length === 0) {\r\n dropDownArray = dropDownSecDragFromValues.sort(function (a, b) {\r\n return a.value - b.value;\r\n })\r\n } else {\r\n dropDownArray = dropdownValues\r\n\r\n }\r\n const handleChange = (event) => {\r\n\r\n const tableData = [...secDragToValues];\r\n tableData[row.tableData.id].columnFromFile = event.target.value;\r\n setCurrentValue(event.target.value);\r\n setSecDragToValues(tableData);\r\n row.name.toLowerCase() === ROW_INDICATOR_VALUE && setCurrentRowIndicatorPlacement(row)\r\n\r\n };\r\n\r\n\r\n\r\n return (\r\n <>\r\n\r\n \r\n {\r\n dropDownArray.map((item, i) => {item.name} )\r\n\r\n }\r\n \r\n {dropDownArray.length === 0 ? Please check the example file : requiredField && row.isRequiredField && row.columnFromFile === '' ? \tColumn selection is required : ''}\r\n\r\n >\r\n );\r\n },\r\n },\r\n ];\r\n const secRightSideColumnsFixedLength = [\r\n { title: 'Selected fields in import file', field: 'name', render: (row) => {row.name}
},\r\n {\r\n title: 'Starts at',\r\n field: 'startsAt',\r\n render: (row) => {\r\n const handleChange = (event) => {\r\n\r\n const tableData = [...secDragToValues];\r\n tableData[row.tableData.id].startsAt = event.target.value;\r\n setCurrentValueStartLength([tableData[row.tableData.id].startsAt, tableData[row.tableData.id].length])\r\n setSecDragToValues(tableData);\r\n row.name.toLowerCase() === ROW_INDICATOR_VALUE && setCurrentRowIndicatorPlacement(row)\r\n\r\n };\r\n\r\n return (\r\n <>\r\n \r\n >\r\n );\r\n },\r\n },\r\n {\r\n title: 'Length',\r\n field: 'length',\r\n render: (row) => {\r\n const handleChange = (event) => {\r\n const tableData = [...secDragToValues];\r\n tableData[row.tableData.id].length = event.target.value;\r\n setCurrentValueStartLength([tableData[row.tableData.id].startsAt, tableData[row.tableData.id].length])\r\n setSecDragToValues(tableData);\r\n };\r\n\r\n return (\r\n <>\r\n \r\n >\r\n );\r\n },\r\n },\r\n ];\r\n const thirdRightSideColumns = [\r\n { title: 'Selected fields in import file', field: 'name', render: (row) => {row.name}
},\r\n {\r\n title: 'Columns from the file',\r\n field: 'columnFromFile',\r\n render: (row) => {\r\n let dropDownArray = []\r\n\r\n if (dropdownValues.length === 0) {\r\n dropDownArray = dropDownThirdDragFromValues.sort(function (a, b) {\r\n return a.value - b.value;\r\n })\r\n } else {\r\n dropDownArray = dropdownValues\r\n\r\n }\r\n const handleChange = (event) => {\r\n\r\n const tableData = [...thirdDragToValues];\r\n tableData[row.tableData.id].columnFromFile = event.target.value;\r\n setCurrentValue(event.target.value);\r\n setThirdDragToValues(tableData);\r\n row.name.toLowerCase() === ROW_INDICATOR_VALUE && setCurrentRowIndicatorPlacement(row)\r\n\r\n };\r\n\r\n\r\n\r\n return (\r\n <>\r\n\r\n \r\n {\r\n dropDownArray.map((item, i) => {item.name} )\r\n\r\n }\r\n \r\n {dropDownArray.length === 0 ? Please check the example file : requiredField && row.isRequiredField && row.columnFromFile === '' ? \tColumn selection is required : ''}\r\n\r\n >\r\n );\r\n },\r\n },\r\n ];\r\n const thirdRightSideColumnsFixedLength = [\r\n { title: 'Selected fields in import file', field: 'name', render: (row) => {row.name}
},\r\n {\r\n title: 'Starts at',\r\n field: 'startsAt',\r\n render: (row) => {\r\n const handleChange = (event) => {\r\n\r\n const tableData = [...thirdDragToValues];\r\n tableData[row.tableData.id].startsAt = event.target.value;\r\n setCurrentValueStartLength([tableData[row.tableData.id].startsAt, tableData[row.tableData.id].length])\r\n setThirdDragToValues(tableData);\r\n row.name.toLowerCase() === ROW_INDICATOR_VALUE && setCurrentRowIndicatorPlacement(row)\r\n };\r\n\r\n return (\r\n <>\r\n \r\n >\r\n );\r\n },\r\n },\r\n {\r\n title: 'Length',\r\n field: 'length',\r\n render: (row) => {\r\n const handleChange = (event) => {\r\n const tableData = [...thirdDragToValues];\r\n tableData[row.tableData.id].length = event.target.value;\r\n setCurrentValueStartLength([tableData[row.tableData.id].startsAt, tableData[row.tableData.id].length])\r\n setThirdDragToValues(tableData);\r\n };\r\n\r\n return (\r\n <>\r\n \r\n >\r\n );\r\n },\r\n },\r\n ];\r\n return (\r\n \r\n {multiTab\r\n ? (\r\n <>\r\n {' '}\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Note: Please enter the row indicator to create the mapping(Case sensitive) \r\n
\r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Note: Please enter the row indicator to create the mapping(Case sensitive) \r\n
\r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Note: Please enter the row indicator to create the mapping(Case sensitive) \r\n
\r\n \r\n \r\n \r\n \r\n >\r\n )\r\n : (\r\n <>\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n >\r\n )}\r\n
\r\n );\r\n};\r\n\r\nexport default SchemaMappingGrid;\r\n","import React, { useState } from 'react';\r\nimport SchemaMappingGrid from './SchemaMappingGrid';\r\nimport SchemaMaterialTable from './SchemaMaterialTable';\r\nimport { SCHEMATAB_CREATION } from '../../../../utils/constants/constants';\r\n\r\nconst SchemaTabCreations = (props) => {\r\n const {\r\n formField,\r\n formikValues,\r\n mappingDetails,\r\n getFieldSchemaDetails,\r\n requiredField,\r\n setIsValid,\r\n dropdownValues,\r\n setCurrentValue,\r\n setCurrentValueStartLength,\r\n setCurrentRowIndicatorValue,\r\n setCurrentRowIndicatorPlacement,\r\n isClear,\r\n setFieldValue,\r\n currentTab,\r\n setTabValue,\r\n setIsClear,\r\n setFieldTouched\r\n } = props;\r\n\r\n return (\r\n \r\n {(formikValues.schemaType || {}).value === SCHEMATAB_CREATION.ORDER\r\n ? (\r\n value.valueName !== SCHEMATAB_CREATION.ROWINDICATOR)}\r\n formikValues={formikValues}\r\n setFieldTouched={setFieldTouched}\r\n mappingDetails={mappingDetails}\r\n getFieldSchemaDetails={getFieldSchemaDetails}\r\n requiredField={requiredField}\r\n setIsValid={setIsValid}\r\n dropdownValues={dropdownValues}\r\n setCurrentValue={setCurrentValue}\r\n setCurrentValueStartLength={setCurrentValueStartLength}\r\n isClear={isClear}\r\n setFieldValue={setFieldValue}\r\n setIsClear={setIsClear}\r\n />\r\n )\r\n : (\r\n ''\r\n )}\r\n {(formikValues.schemaType || {}).value === SCHEMATAB_CREATION.PARCEL\r\n ? (\r\n value.valueName !== SCHEMATAB_CREATION.ROWINDICATOR)}\r\n formikValues={formikValues}\r\n setFieldTouched={setFieldTouched}\r\n mappingDetails={mappingDetails}\r\n getFieldSchemaDetails={getFieldSchemaDetails}\r\n requiredField={requiredField}\r\n setIsValid={setIsValid}\r\n dropdownValues={dropdownValues}\r\n setCurrentValue={setCurrentValue}\r\n setCurrentValueStartLength={setCurrentValueStartLength}\r\n isClear={isClear}\r\n setFieldValue={setFieldValue}\r\n setIsClear={setIsClear}\r\n />\r\n )\r\n : (\r\n ''\r\n )}\r\n {(formikValues.schemaType || {}).value === SCHEMATAB_CREATION.CLEARANCE\r\n ? (\r\n value.valueName !== SCHEMATAB_CREATION.ROWINDICATOR)]}\r\n formikValues={formikValues}\r\n setFieldTouched={setFieldTouched}\r\n mappingDetails={mappingDetails}\r\n getFieldSchemaDetails={getFieldSchemaDetails}\r\n requiredField={requiredField}\r\n setIsValid={setIsValid}\r\n dropdownValues={dropdownValues}\r\n setCurrentValue={setCurrentValue}\r\n setCurrentValueStartLength={setCurrentValueStartLength}\r\n isClear={isClear}\r\n setFieldValue={setFieldValue}\r\n setIsClear={setIsClear}\r\n />\r\n )\r\n : (\r\n ''\r\n )}\r\n {(formikValues.schemaType || {}).value === SCHEMATAB_CREATION.ORDERS_CUSTOM\r\n ? (\r\n \r\n )\r\n : (\r\n ''\r\n )}\r\n {(formikValues.schemaType || {}).value === SCHEMATAB_CREATION.ORDERS_COLLECTIONS\r\n ? (\r\n \r\n )\r\n : (\r\n ''\r\n )}\r\n\r\n {(formikValues.schemaType || {}).value === SCHEMATAB_CREATION.ORDERS_CLEARANCE\r\n ? (\r\n \r\n )\r\n : (\r\n ''\r\n )}\r\n {(formikValues.schemaType || {}).value === SCHEMATAB_CREATION.COLLECTIONS_CLEARANCE\r\n ? (\r\n \r\n )\r\n : (\r\n ''\r\n )}\r\n {(formikValues.schemaType || {}).value === SCHEMATAB_CREATION.ORDERS_CUSTOMS_COLLECTIONS\r\n ? (\r\n \r\n )\r\n : (\r\n ''\r\n )}\r\n\r\n {(formikValues.schemaType || {}).value === SCHEMATAB_CREATION.ORDERS_CUSTOMS_PARCELS\r\n ? (\r\n value.valueName !== SCHEMATAB_CREATION.LENGTH && value.valueName !== SCHEMATAB_CREATION.WIDTH && value.valueName !== SCHEMATAB_CREATION.HEIGHT)}\r\n formikValues={formikValues}\r\n setFieldTouched={setFieldTouched}\r\n firstTab=\"Orders mapping\"\r\n secTab=\"Customs mapping\"\r\n thirdTab=\"Parcels mapping\"\r\n multiTab={true}\r\n mappingDetails={mappingDetails}\r\n getFieldSchemaDetails={getFieldSchemaDetails}\r\n requiredField={requiredField}\r\n setIsValid={setIsValid}\r\n dropdownValues={dropdownValues}\r\n setCurrentValue={setCurrentValue}\r\n setCurrentValueStartLength={setCurrentValueStartLength}\r\n setCurrentRowIndicatorValue={setCurrentRowIndicatorValue}\r\n setCurrentRowIndicatorPlacement={setCurrentRowIndicatorPlacement}\r\n isClear={isClear}\r\n setFieldValue={setFieldValue}\r\n setTabValue={setTabValue}\r\n currentTab={currentTab}\r\n setIsClear={setIsClear}\r\n />\r\n )\r\n : (\r\n ''\r\n )}\r\n {(formikValues.schemaType || {}).value === SCHEMATAB_CREATION.ORDER_COLLECTIONSCONSIGNOR\r\n ? (\r\n \r\n )\r\n : (\r\n ''\r\n )}\r\n {(formikValues.schemaType || {}).value === SCHEMATAB_CREATION.COLLECTION\r\n ? (\r\n value.valueName !== SCHEMATAB_CREATION.ROWINDICATOR)}\r\n formikValues={formikValues}\r\n setFieldTouched={setFieldTouched}\r\n mappingDetails={mappingDetails}\r\n getFieldSchemaDetails={getFieldSchemaDetails}\r\n requiredField={requiredField}\r\n setIsValid={setIsValid}\r\n dropdownValues={dropdownValues}\r\n setCurrentValue={setCurrentValue}\r\n setCurrentValueStartLength={setCurrentValueStartLength}\r\n isClear={isClear}\r\n setFieldValue={setFieldValue}\r\n setIsClear={setIsClear}\r\n\r\n />\r\n )\r\n : (\r\n ''\r\n )}\r\n {(formikValues.schemaType || {}).value === SCHEMATAB_CREATION.CUSTOM\r\n ? (\r\n value.valueName !== SCHEMATAB_CREATION.ROWINDICATOR)}\r\n formikValues={formikValues}\r\n setFieldTouched={setFieldTouched}\r\n mappingDetails={mappingDetails}\r\n getFieldSchemaDetails={getFieldSchemaDetails}\r\n requiredField={requiredField}\r\n setIsValid={setIsValid}\r\n dropdownValues={dropdownValues}\r\n setCurrentValue={setCurrentValue}\r\n setCurrentValueStartLength={setCurrentValueStartLength}\r\n isClear={isClear}\r\n setFieldValue={setFieldValue}\r\n setIsClear={setIsClear}\r\n\r\n />\r\n )\r\n : (\r\n ''\r\n )}\r\n
\r\n );\r\n};\r\n\r\nexport default SchemaTabCreations;\r\n\r\nconst orderValues = [\r\n {\r\n id: 1,\r\n valueName: 'AccountNumber',\r\n name: 'Account number',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 2,\r\n valueName: 'DispatchDate',\r\n name: 'Dispatch date',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 3,\r\n valueName: 'CustomerName',\r\n name: 'Delivery business name',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 4,\r\n valueName: 'Address1',\r\n name: 'Delivery address 1',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 5,\r\n valueName: 'Address2',\r\n name: 'Delivery address 2',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 6,\r\n valueName: 'Address3',\r\n name: 'Delivery address 3',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 7,\r\n valueName: 'Town',\r\n name: 'Delivery town',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 8,\r\n valueName: 'County',\r\n name: 'Delivery county',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 9,\r\n valueName: 'TelephoneNumber',\r\n name: 'Delivery telephone',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 10,\r\n valueName: 'PostalCode',\r\n name: 'Delivery postal code',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 11,\r\n valueName: 'Contact',\r\n name: 'Delivery contact name',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 12,\r\n valueName: 'NoOfItems',\r\n name: 'No.of items',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 13,\r\n valueName: 'Weight',\r\n name: 'Weight',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 14,\r\n valueName: 'ServiceCode',\r\n name: 'Service code',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 15,\r\n valueName: 'ExtendedCover',\r\n name: 'Extended liability domestic',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 16,\r\n valueName: 'SpecialInstructions1',\r\n name: 'Special instructions 1st line',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 17,\r\n valueName: 'SpecialInstructions2',\r\n name: 'Special instructions 2nd line',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 18,\r\n valueName: 'ExchangeOnDelivery',\r\n name: 'Exchange on delivery',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 19,\r\n valueName: 'CustomersReference',\r\n name: 'Customer reference',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 20,\r\n valueName: 'AlternateReference',\r\n name: 'Alternative reference',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 21,\r\n valueName: 'Email',\r\n name: 'Delivery email',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 22,\r\n valueName: 'Length',\r\n name: 'Length',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 23,\r\n valueName: 'Width',\r\n name: 'Width',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 24,\r\n valueName: 'Height',\r\n name: 'Height',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 25,\r\n valueName: 'ExtraInsurance',\r\n name: 'Extended liability international',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 26,\r\n valueName: 'Country',\r\n name: 'Country',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 27,\r\n valueName: 'IncludeInboxReturnLabel',\r\n name: 'Include inbox return label',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 28,\r\n valueName: 'ReturnCustomerReference',\r\n name: 'Return customer reference',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 29,\r\n\r\n valueName: 'AddressType',\r\n name: 'Address type',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 30,\r\n valueName: 'RecipientAddress1',\r\n name: 'Recipient address 1',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 31,\r\n valueName: 'RecipientAddress2',\r\n name: 'Recipient address 2',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 32,\r\n valueName: 'RecipientAddress3',\r\n\r\n name: 'Recipient address 3',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 33,\r\n valueName: 'RecipientTown',\r\n\r\n name: 'Recipient town',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 34,\r\n valueName: 'RecipientCounty',\r\n\r\n name: 'Recipient county',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 35,\r\n valueName: 'RecipientPostalCode',\r\n\r\n name: 'Recipient postal code',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 36,\r\n valueName: 'RecipientTelephone',\r\n\r\n name: 'Recipient telephone',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 37,\r\n valueName: 'RecipientContact',\r\n\r\n name: 'Recipient name',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 38,\r\n valueName: 'RecipientEmail',\r\n\r\n name: 'Recipient email',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 39,\r\n valueName: 'ServicePointId',\r\n\r\n name: 'Service point id',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 40,\r\n valueName: 'DescriptionOfGoods1',\r\n\r\n name: 'Description of goods 1',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 41,\r\n valueName: 'DescriptionOfGoods2',\r\n\r\n name: 'Description of goods 2',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 42,\r\n valueName: 'DescriptionOfGoods3',\r\n\r\n name: 'Description of goods 3',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 43,\r\n valueName: 'Value',\r\n\r\n name: 'Value',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 44,\r\n valueName: 'Currency',\r\n\r\n name: 'Currency',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 45,\r\n valueName: 'InvoiceType',\r\n\r\n name: 'Invoice type',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 46,\r\n valueName: 'InvoiceDate',\r\n\r\n name: 'Invoice date',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 47,\r\n valueName: 'InvoiceNumber',\r\n\r\n name: 'Invoice number',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 48,\r\n valueName: 'ReceiverCustomsIdentifier',\r\n\r\n name: 'Receiver customs identifier',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 49,\r\n valueName: 'ShippingCharges',\r\n\r\n name: 'Shipping charges',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 50,\r\n valueName: 'ReasonForExportCode',\r\n\r\n name: 'Reason for export code',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 51,\r\n valueName: 'rowindicator',\r\n name: 'Row indicator',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 52,\r\n valueName: 'RecipientCountry',\r\n name: 'Recipient country',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 53,\r\n valueName: 'PrinterQueueName',\r\n name: 'Printer queue name',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 54,\r\n valueName: 'USStateCode',\r\n name: 'US state code',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 55,\r\n valueName: 'RecipientBusinessName',\r\n name: 'Recipient business name',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 56,\r\n valueName: 'IossShipment',\r\n name: 'IOSS Shipment',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 57,\r\n valueName: 'IossNumber',\r\n name: 'Marketplace IOSS number',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 58,\r\n valueName: 'Pallets',\r\n name: 'Pallets',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 59,\r\n valueName: 'What3Words',\r\n name: 'What3Words',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 60,\r\n valueName: 'W3WLat',\r\n name: 'What3Words latitude',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 61,\r\n valueName: 'W3WLong',\r\n name: 'What3Words longitude',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 62,\r\n valueName: 'ShipmentMovementType',\r\n name: 'Shipment Movement Type',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 63,\r\n valueName: 'SendersEORINumber',\r\n name: `Shipper's EORI Number`,\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 64,\r\n valueName: 'SendersUKIMSNumber',\r\n name: `Shipper's UKIMS Number`,\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 65,\r\n valueName: 'RecipientEORINumber',\r\n name: 'Recipient EORI Number',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 66,\r\n valueName: 'RecipientUKIMSNumber',\r\n name: 'Recipient UKIMS Number',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 67,\r\n valueName: 'TotalValue',\r\n name: 'Total Value',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 68,\r\n valueName: 'DescriptionofgoodC2CMovementType',\r\n name: 'Description Of Goods(Shipment Level)',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 69,\r\n valueName: 'SendersDefermentAccount',\r\n name: `Shipper's Deferment Account Number`,\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 70,\r\n valueName: 'DeliveryChoice',\r\n name: 'Delivery Choice',\r\n isRequiredField: false,\r\n }\r\n];\r\n\r\nconst customsValues = [\r\n {\r\n id: 1,\r\n valueName: 'CustomerReference',\r\n\r\n name: 'Customer reference',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 2,\r\n valueName: 'CommodityCode',\r\n\r\n name: 'Commodity code',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 3,\r\n valueName: 'DescriptionOfGoods',\r\n\r\n name: 'Description of goods',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 4,\r\n valueName: 'Quantity',\r\n\r\n name: 'Quantity',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 5,\r\n valueName: 'NetWeight',\r\n\r\n name: 'Net weight',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 6,\r\n valueName: 'UnitValue',\r\n\r\n name: 'Unit value',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 7,\r\n valueName: 'CountryOfOrigin',\r\n\r\n name: 'Country of origin',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 8,\r\n valueName: 'rowindicator',\r\n name: 'Row indicator',\r\n isRequiredField: true,\r\n },\r\n];\r\n\r\nconst collectionValues = [\r\n {\r\n id: 1,\r\n valueName: 'CollectionDate',\r\n name: 'Collection date',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 2,\r\n valueName: 'AccountNumber',\r\n name: 'Account number',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 3,\r\n valueName: 'CollectionBusinessName',\r\n name: 'Collection business name',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 4,\r\n valueName: 'CollectionAddress1',\r\n name: 'Collection address 1',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 5,\r\n valueName: 'CollectionAddress2',\r\n name: 'Collection address 2',\r\n },\r\n {\r\n id: 6,\r\n valueName: 'CollectionAddress3',\r\n name: 'Collection address 3',\r\n },\r\n {\r\n id: 7,\r\n valueName: 'CollectionTown',\r\n name: 'Collection town',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 8,\r\n valueName: 'CollectionCounty',\r\n name: 'Collection county',\r\n },\r\n {\r\n id: 9,\r\n valueName: 'CollectionPostalCode',\r\n name: 'Collection postal code',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 10,\r\n valueName: 'CollectionTelephoneNumber',\r\n name: 'Collection telephone number',\r\n },\r\n {\r\n id: 11,\r\n valueName: 'CollectionContact',\r\n name: 'Collection contact name',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 12,\r\n valueName: 'CustomersReference',\r\n name: 'Customer reference',\r\n },\r\n {\r\n id: 13,\r\n valueName: 'CollectionSpecialInstructions1',\r\n name: 'Collection special instructions 1',\r\n },\r\n {\r\n id: 14,\r\n valueName: 'CollectionSpecialInstructions2',\r\n name: 'Collection special instructions 2',\r\n },\r\n {\r\n id: 15,\r\n valueName: 'DeliveryCustomerName',\r\n name: 'Delivery busines name',\r\n },\r\n {\r\n id: 16,\r\n valueName: 'DeliveryAddress1',\r\n name: 'Delivery address 1',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 17,\r\n valueName: 'DeliveryAddress2',\r\n name: 'Delivery address 2',\r\n },\r\n {\r\n id: 18,\r\n valueName: 'DeliveryAddress3',\r\n name: 'Delivery address 3',\r\n },\r\n {\r\n id: 19,\r\n valueName: 'DeliveryTown',\r\n name: 'Delivery town',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 20,\r\n valueName: 'DeliveryCounty',\r\n name: 'Delivery county',\r\n },\r\n {\r\n id: 21,\r\n valueName: 'DeliveryPostalCode',\r\n name: 'Delivery postal code',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 22,\r\n valueName: 'DeliveryTelephone',\r\n name: 'Delivery telephone',\r\n },\r\n {\r\n id: 23,\r\n valueName: 'DeliveryContact',\r\n name: 'Delivery contact name',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 24,\r\n valueName: 'ServiceCode',\r\n name: 'Service code',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 25,\r\n valueName: 'DeliverySpecialInstruction1',\r\n name: 'Delivery special instuctions 1',\r\n },\r\n {\r\n id: 26,\r\n valueName: 'DeliverySpecialInstruction2',\r\n name: 'Delivery special instuctions 2',\r\n },\r\n {\r\n id: 27,\r\n valueName: 'ColDescrOfGoods1',\r\n name: 'Collection description of goods 1',\r\n },\r\n {\r\n id: 28,\r\n valueName: 'ColDescrOfGoods2',\r\n name: 'Collection description of goods 2',\r\n },\r\n {\r\n id: 29,\r\n valueName: 'AddressType',\r\n name: 'Address type ',\r\n },\r\n {\r\n id: 30,\r\n valueName: 'ServicePointId',\r\n name: 'Service point id',\r\n },\r\n {\r\n id: 31,\r\n valueName: 'RecipientAddress1',\r\n name: 'Recipient address 1',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 32,\r\n valueName: 'RecipientAddress2',\r\n name: 'Recipient address 2',\r\n },\r\n {\r\n id: 33,\r\n valueName: 'RecipientAddress3',\r\n name: 'Recipient address 3',\r\n },\r\n {\r\n id: 34,\r\n valueName: 'RecipientTown',\r\n name: 'Recipient town',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 35,\r\n valueName: 'RecipientCounty',\r\n name: 'Recipient county',\r\n },\r\n {\r\n id: 36,\r\n valueName: 'RecipientPostalCode',\r\n name: 'Recipient postal code',\r\n },\r\n {\r\n id: 37,\r\n valueName: 'RecipientTelephone',\r\n name: 'Recipient telephone',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 38,\r\n valueName: 'RecipientContact',\r\n name: 'Recipient name',\r\n },\r\n {\r\n id: 39,\r\n valueName: 'RecipientEmail',\r\n name: 'Recipient email',\r\n },\r\n {\r\n id: 40,\r\n valueName: 'rowindicator',\r\n name: 'Row indicator',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 41,\r\n valueName: 'NoOfParcels',\r\n name: 'No.of parcels',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 42,\r\n valueName: 'Weight',\r\n name: 'Weight',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 43,\r\n valueName: 'CollectionEmail',\r\n name: 'Collection email',\r\n isRequiredField: true,\r\n\r\n },\r\n {\r\n id: 44,\r\n valueName: 'IsReturnToSender',\r\n name: 'Is return to sender',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 45,\r\n valueName: 'IsSendToThirdParty',\r\n name: 'Is send to third party',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 46,\r\n valueName: 'RecipientBusinessName',\r\n name: 'Recipient business name',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 47,\r\n valueName: 'DeliveryEmail',\r\n name: 'Delivery email',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 48,\r\n valueName: 'What3Words',\r\n name: 'What3Words',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 49,\r\n valueName: 'W3WLat',\r\n name: 'What3Words latitude',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 50,\r\n valueName: 'W3WLong',\r\n name: 'What3Words longitude',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 51,\r\n valueName: 'DescriptionofgoodC2CMovementType',\r\n name: 'Description Of Goods(Shipment Level)',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 52,\r\n valueName: 'shipmentMovementType',\r\n name: 'Shipment movement type',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 53,\r\n valueName: 'SendersEORINumber',\r\n name: `Shipper's EORI Number`,\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 54,\r\n valueName: 'SendersUKIMSNumber',\r\n name: `Shipper's UKIMS Number`,\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 55,\r\n valueName: 'SendersDefermentAccount',\r\n name: `Shipper's deferment account Number`,\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 56,\r\n valueName: 'recipientEoriNumber',\r\n name: 'Recipient EORI number',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 57,\r\n valueName: 'recipientUkimsNumber',\r\n name: 'Recipient UKIMS number',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 58,\r\n valueName: 'shippingCharges',\r\n name: 'Shipping Charges',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 59,\r\n valueName: 'totalValue',\r\n name: 'Total Value',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 60,\r\n valueName: 'reasonForExport',\r\n name: 'Reason for Export',\r\n isRequiredField: false,\r\n },\r\n];\r\n\r\nconst orderCollectionConsignor = [\r\n {\r\n id: 1,\r\n valueName: 'AccountNumber',\r\n name: 'Account number',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 2,\r\n valueName: 'DispatchDate',\r\n name: 'Despatch date',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 3,\r\n valueName: 'CustomerName',\r\n name: 'Delivery business name',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 4,\r\n valueName: 'Address1',\r\n name: 'Delivery address 1',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 5,\r\n valueName: 'Address2',\r\n name: 'Delivery address 2',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 6,\r\n valueName: 'Address3',\r\n name: 'Delivery address 3',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 7,\r\n valueName: 'Town',\r\n name: 'Delivery town',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 8,\r\n valueName: 'County',\r\n name: 'Delivery county',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 9,\r\n valueName: 'TelephoneNumber',\r\n name: 'Delivery telephone ',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 10,\r\n valueName: 'PostalCode',\r\n name: 'Delivery postal code',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 11,\r\n valueName: 'Contact',\r\n name: 'Delivery contact name',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 12,\r\n valueName: 'NoOfItems',\r\n name: 'No.of items',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 13,\r\n valueName: 'Weight',\r\n name: 'Weight',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 14,\r\n valueName: 'ServiceCode',\r\n name: 'Service code',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 15,\r\n valueName: 'ExtendedCover',\r\n name: 'Extended liability domestic',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 16,\r\n valueName: 'SpecialInstructions1',\r\n name: 'Delivery special instructions 1',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 17,\r\n valueName: 'SpecialInstructions2',\r\n name: 'Delivery special instructions 2',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 18,\r\n valueName: 'ExchangeOnDelivery',\r\n name: 'Exchange on delivery',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 19,\r\n valueName: 'CustomersReference',\r\n name: 'Customer reference',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 20,\r\n valueName: 'AlternateReference',\r\n name: 'Alternative reference',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 21,\r\n valueName: 'Email',\r\n name: 'Delivery email',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 22,\r\n valueName: 'Length',\r\n name: 'Length',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 23,\r\n valueName: 'Width',\r\n name: 'Width',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 24,\r\n valueName: 'Height',\r\n name: 'Height',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 25,\r\n valueName: 'ExtraInsurance',\r\n name: 'Extended liability international',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 26,\r\n valueName: 'Country',\r\n name: 'Country',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 27,\r\n valueName: 'IncludeInboxReturnLabel',\r\n name: 'Include inbox return label',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 28,\r\n valueName: 'ReturnCustomerReference',\r\n name: 'Return customer reference',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 29,\r\n\r\n valueName: 'AddressType',\r\n name: 'Address type',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 30,\r\n valueName: 'RecipientAddress1',\r\n name: 'Recipient address 1',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 31,\r\n valueName: 'RecipientAddress2',\r\n name: 'Recipient address 2',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 32,\r\n valueName: 'RecipientAddress3',\r\n\r\n name: 'Recipient address 3',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 33,\r\n valueName: 'RecipientTown',\r\n\r\n name: 'Recipient town',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 34,\r\n valueName: 'RecipientCounty',\r\n\r\n name: 'Recipient county',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 35,\r\n valueName: 'RecipientPostalCode',\r\n\r\n name: 'Recipient postal code',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 36,\r\n valueName: 'RecipientTelephone',\r\n\r\n name: 'Recipient telephone',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 37,\r\n valueName: 'RecipientContact',\r\n\r\n name: 'Recipient name',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 38,\r\n valueName: 'RecipientEmail',\r\n\r\n name: 'Recipient email',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 39,\r\n valueName: 'ServicePointId',\r\n\r\n name: 'Service point id',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 40,\r\n valueName: 'RecipientCountry',\r\n name: 'Recipient country',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 41,\r\n valueName: 'PrinterQueueName',\r\n name: 'Printer queue name',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 42,\r\n valueName: 'USStateCode',\r\n name: 'US state code',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 43,\r\n valueName: 'DescriptionOfGoods1',\r\n\r\n name: 'Description of goods 1',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 44,\r\n valueName: 'DescriptionOfGoods2',\r\n\r\n name: 'Description of goods 2',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 45,\r\n valueName: 'DescriptionOfGoods3',\r\n\r\n name: 'Description of goods 3',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 46,\r\n valueName: 'Value',\r\n\r\n name: 'Value',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 47,\r\n valueName: 'Currency',\r\n\r\n name: 'Currency',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 48,\r\n valueName: 'InvoiceType',\r\n\r\n name: 'Invoice type',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 49,\r\n valueName: 'InvoiceDate',\r\n\r\n name: 'Invoice date',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 50,\r\n valueName: 'InvoiceNumber',\r\n\r\n name: 'Invoice number',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 51,\r\n valueName: 'ReceiverCustomsIdentifier',\r\n\r\n name: 'Receiver customs identifier',\r\n isRequiredField: false,\r\n\r\n },\r\n {\r\n id: 52,\r\n valueName: 'ShippingCharges',\r\n\r\n name: 'Shipping charges',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 53,\r\n valueName: 'ReasonForExportCode',\r\n\r\n name: 'Reason for export code',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 54,\r\n valueName: 'CollectionDate',\r\n name: 'Collection date',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 55,\r\n valueName: 'CollectionAddress1',\r\n name: 'Collection address 1',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 56,\r\n valueName: 'CollectionAddress2',\r\n name: 'Collection address 2',\r\n },\r\n {\r\n id: 57,\r\n valueName: 'CollectionAddress3',\r\n name: 'Collection address 3',\r\n },\r\n {\r\n id: 58,\r\n valueName: 'CollectionTown',\r\n name: 'Collection town',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 59,\r\n valueName: 'CollectionCounty',\r\n name: 'Collection county',\r\n },\r\n {\r\n id: 60,\r\n valueName: 'CollectionPostalCode',\r\n name: 'Collection postal code',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 61,\r\n valueName: 'CollectionTelephoneNumber',\r\n name: 'Collection telephone number',\r\n },\r\n {\r\n id: 62,\r\n valueName: 'CollectionContact',\r\n name: 'Collection contact name',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 63,\r\n valueName: 'CollectionSpecialInstructions1',\r\n name: 'Collection special instructions 1',\r\n },\r\n {\r\n id: 64,\r\n valueName: 'CollectionSpecialInstructions2',\r\n name: 'Collection special instructions 2',\r\n },\r\n {\r\n id: 64,\r\n valueName: 'ColDescrOfGoods1',\r\n name: 'Collection description of goods 1',\r\n },\r\n {\r\n id: 66,\r\n valueName: 'ColDescrOfGoods2',\r\n name: 'Collection description of goods 2',\r\n },\r\n {\r\n id: 67,\r\n valueName: 'CollectionEmail',\r\n name: 'Collection email',\r\n },\r\n {\r\n id: 68,\r\n valueName: 'RecipientBusinessName',\r\n name: 'Recipient business name',\r\n },\r\n {\r\n id: 69,\r\n valueName: 'CollectionBusinessName',\r\n name: 'Collection business name',\r\n },\r\n {\r\n id: 70,\r\n valueName: 'Pallets',\r\n name: 'Pallets',\r\n isRequiredField: false,\r\n },\r\n]\r\n\r\nconst parcelValues = [\r\n {\r\n id: 1,\r\n valueName: 'CustomerReference',\r\n\r\n name: 'Customer reference',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 2,\r\n valueName: 'ParcelNumber',\r\n\r\n name: 'Parcel number',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 3,\r\n valueName: 'ParcelReference',\r\n\r\n name: 'Parcel reference',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 4,\r\n valueName: 'Weight',\r\n name: 'Weight',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 5,\r\n valueName: 'Length',\r\n name: 'Length',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 6,\r\n valueName: 'Width',\r\n name: 'Width',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 7,\r\n valueName: 'Height',\r\n name: 'Height',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 8,\r\n valueName: 'rowindicator',\r\n name: 'Row indicator',\r\n isRequiredField: true,\r\n },\r\n];\r\n\r\nconst clearanceValues = [\r\n {\r\n id: 1,\r\n valueName: 'CustomerReference',\r\n\r\n name: 'Customer reference',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 2,\r\n valueName: 'CommodityCode',\r\n\r\n name: 'Commodity code',\r\n isRequiredField: false,\r\n },\r\n {\r\n id: 3,\r\n valueName: 'DescriptionOfGoods',\r\n\r\n name: 'Description of goods',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 4,\r\n valueName: 'UnitQuantity',\r\n name: 'Unit quantity',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 5,\r\n valueName: 'UnitValue',\r\n name: 'Unit value',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 6,\r\n valueName: 'UnitWeight',\r\n name: 'Unit weight',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 7,\r\n valueName: 'CountryOfManufacture',\r\n name: 'Country of manufacture',\r\n isRequiredField: true,\r\n },\r\n {\r\n id: 8,\r\n valueName: 'rowindicator',\r\n name: 'Row indicator',\r\n isRequiredField: true,\r\n },\r\n];\r\n\r\n","import React, { useState, useEffect } from 'react';\r\nimport CustomAccordion from '../../../../framework/accordion/customAccordion';\r\nimport SchemaDetailsField from './SchemaDetailsField';\r\nimport SchemaTabCreations from './SchemaTabCreations';\r\n\r\nconst MainSchemaDetails = (props) => {\r\n const {\r\n formField,\r\n setFieldValue,\r\n errors,\r\n setFieldTouched,\r\n formikValues,\r\n setIsValid,\r\n requiredField,\r\n setTotalMappingDetails,\r\n oldSchemaName,\r\n uploadedFile,\r\n setUploadedFile,\r\n resetForm,\r\n isClear,\r\n setSchemaNameExist,\r\n setValues,\r\n setIsClear,\r\n setFolderPathExist,\r\n existingFolderPaths,\r\n folderPathExist\r\n } = props;\r\n\r\n const [resultedSchema, setResultedSchema] = useState();\r\n const [value, setTabValue] = useState(0);\r\n const [dropdownValues, setDropdownValues] = useState([]);\r\n const [currentSelectedValue, setCurrentValue] = useState(\"\");\r\n const [currentValueStartLength, setCurrentValueStartLength] = useState([0, 0]);\r\n const [currentRowIndicatorValue, setCurrentRowIndicatorValue] = useState(\"\");\r\n const [currentRowIndicatorPlacement, setCurrentRowIndicatorPlacement] = useState();\r\n const [isDefaultSchema, setIsDefaultSchema] = useState(false);\r\n\r\n\r\n useEffect(() => {\r\n setSchemaDetails(formikValues);\r\n }, [formikValues]);\r\n\r\n const setSchemaDetails = (data) => {\r\n props.setTotalSchemaDetails(data);\r\n };\r\n\r\n const getResultedSchemaDetails = (data) => {\r\n setResultedSchema(data);\r\n };\r\n const getFieldSchemaDetails = (fields) => {\r\n setTotalMappingDetails(fields);\r\n };\r\n\r\n const setStartAndLengthValues = (arr) => {\r\n let [start, length] = arr;\r\n start = parseInt(start);\r\n length = parseInt(length);\r\n start = isNaN(start) ? 0 : start;\r\n length = isNaN(length) ? 0 : length;\r\n setCurrentValueStartLength([start, length])\r\n }\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n {/* {uploadedFile ? */}\r\n \r\n {/* : null} */}\r\n\r\n
\r\n );\r\n};\r\n\r\nexport default MainSchemaDetails;\r\n","import React, { useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid } from '@material-ui/core';\r\nimport DynamicMaterialTable from '../../../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\nimport InputButton from '../../../../framework/Inputs/inputButton/inputButton';\r\nimport ConfirmationDialog from '../../../../components/addressBook/confirmation/confirmation';\r\nimport CustomModal from '../../../../framework/dialog/customDialog';\r\nexport default function MySchemaData(props) {\r\n const {\r\n rows,\r\n columns,\r\n isSearchable,\r\n isSelectable,\r\n sorting,\r\n paging,\r\n pageSize,\r\n pageSizeOptions,\r\n Dialogtitle,\r\n confirmationMessage,\r\n tableLayout\r\n } = props;\r\n const [selectedRows, setSelectedRows] = useState([]);\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n const [confirmationMsg, setConfirmationMsg] = useState(confirmationMessage);\r\n\r\n const addSelectedRows = (selectedRows) => {\r\n setSelectedRows(selectedRows);\r\n };\r\n const handleDialogClose = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n const onDialogConfirm = () => {\r\n props.deleteSelectedSchema(selectedRows);\r\n setShowConfirmationDialog(false);\r\n setSelectedRows([]);\r\n };\r\n const onDialogCancel = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n setShowConfirmationDialog(true)}\r\n />\r\n \r\n \r\n \r\n );\r\n}\r\n\r\nMySchemaData.propTypes = {\r\n rows: PropTypes.array,\r\n columns: PropTypes.array,\r\n isSearchable: PropTypes.bool,\r\n isSelectable: PropTypes.bool,\r\n sorting: PropTypes.bool,\r\n paging: PropTypes.bool,\r\n pageSize: PropTypes.object,\r\n pageSizeOptions: PropTypes.object,\r\n title: PropTypes.string,\r\n confirmationMessage: PropTypes.string,\r\n};\r\n","export default __webpack_public_path__ + \"static/media/order.e048a4e0.txt\";","export default __webpack_public_path__ + \"static/media/order_collection.3634d172.txt\";","export default __webpack_public_path__ + \"static/media/order_custom_collection.2dd95468.txt\";","export default __webpack_public_path__ + \"static/media/order_customs.e2426e91.txt\";","import React from 'react';\r\nimport { connect } from 'react-redux';\r\nimport { ServiceEndPoints } from '../../../../utils/constants/ApiConstant';\r\nimport { withRouter } from 'react-router-dom';\r\nimport MySchemaData from './mySchemaData';\r\nimport { IconButton, SvgIcon } from '@material-ui/core';\r\nimport { ReactComponent as DownloadIcon } from '../../../../assets/images/Download.svg';\r\nimport * as actions from '../../../../store/actions/index';\r\nimport { axiosConfig } from '../../../../api/axios';\r\nimport order from '../../../../assets/files/schema_sample_download_files/order.txt';\r\nimport ordersollection from '../../../../assets/files/schema_sample_download_files/order_collection.txt';\r\nimport orderscustomscollections from '../../../../assets/files/schema_sample_download_files/order_custom_collection.txt';\r\nimport orderscustoms from '../../../../assets/files/schema_sample_download_files/order_customs.txt';\r\nimport { customTableSort, getCustomerAccountID } from '../../../../utils/helperFunctions';\r\nclass MySchemas extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n columns: [\r\n { title: 'id', field: 'id', hidden: true, width: 0 },\r\n {\r\n title: 'Schema name',\r\n field: 'schemaName',\r\n width: 150,\r\n customSort: (a, b) => customTableSort(a.schemaName, b.schemaName),\r\n },\r\n {\r\n title: 'Schema type',\r\n field: 'schemaType',\r\n customSort: (a, b) => customTableSort(a.schemaType, b.schemaType),\r\n width: 150,\r\n },\r\n {\r\n title: 'File polling folder',\r\n field: 'filePollingFolder',\r\n sorting: false,\r\n width: 200,\r\n cellStyle: {\r\n whiteSpace: 'normal',\r\n WordBreak: 'break-all !important',\r\n },\r\n },\r\n {\r\n title: 'Download sample file',\r\n headerStyle: {\r\n textAlign: 'center',\r\n },\r\n cellStyle: {\r\n textAlign: 'center',\r\n },\r\n render: (row) => this._My_Schemas(row),\r\n sorting: false,\r\n disableClick: true,\r\n width: 150,\r\n },\r\n ],\r\n rows: [],\r\n schema_pageDetails: {\r\n offset: 0,\r\n limit: 0,\r\n totalRecordsLength: 0,\r\n },\r\n schema_final_data: [],\r\n schema_totalCount: 0,\r\n pageSize: 10,\r\n pageNumber: 0,\r\n isLoading: false,\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n this.getSchemaResults();\r\n }\r\n\r\n componentDidUpdate(prevProps) {\r\n if (this.props.isSearched !== prevProps.isSearched) {\r\n this.setState({ pageSize: 10, pageNumber: 0 }, () => {\r\n this.getSchemaResults();\r\n });\r\n }\r\n }\r\n\r\n _My_Schemas = (row) => {\r\n if (row.schemaType === 'orders+collections') {\r\n return row.isDefaultSchema ? (\r\n \r\n \r\n \r\n \r\n \r\n ) : null;\r\n } else if (row.schemaType === 'order') {\r\n return row.isDefaultSchema ? (\r\n \r\n \r\n \r\n \r\n \r\n ) : null;\r\n } else if (row.schemaType === 'orders+customs+collections') {\r\n return row.isDefaultSchema ? (\r\n \r\n \r\n \r\n \r\n \r\n ) : null;\r\n } else if (row.schemaType === 'orders+customs') {\r\n return row.isDefaultSchema ? (\r\n \r\n \r\n \r\n \r\n \r\n ) : null;\r\n } else {\r\n return null;\r\n }\r\n };\r\n // _MySchemas = (query) => {\r\n // return this.getSchemaResults(query);\r\n // };\r\n\r\n getSchemaResults = () => {\r\n this.setState({ isLoading: true });\r\n // return new Promise((resolve, reject) => {\r\n // if (\r\n // this.state.schema_pageDetails.offset !== query.page * query.pageSize ||\r\n // this.state.schema_pageDetails.limit !== query.pageSize\r\n // ) {\r\n let url;\r\n setTimeout(() => {\r\n url = this.getUrl();\r\n axiosConfig\r\n .get(url)\r\n .then((result) => {\r\n this.setState({ totalRecords: result.data?.totalRecords ?? 0 });\r\n this.formatSchemaData(result.data);\r\n })\r\n .catch((error) => {\r\n alert('Schema not found');\r\n this.formatSchemaData({\r\n orderFileSchemas: [],\r\n totalRecords: 0,\r\n });\r\n })\r\n .finally(() => this.setState({ isLoading: false }));\r\n }, 0);\r\n // }\r\n // });\r\n };\r\n\r\n getUrl = (query) => {\r\n let url = `${ServiceEndPoints.getSchemas}?organization=${getCustomerAccountID()}`;\r\n url += '&offset=' + this.state.pageNumber * this.state.pageSize;\r\n url += '&limit=' + this.state.pageSize;\r\n // setTimeout(() => {\r\n url += this.props.addressBookSearchParams;\r\n // }, 0);\r\n return url;\r\n };\r\n\r\n formatSchemaData = (result) => {\r\n let final_data = [];\r\n ((result || {}).orderFileSchemas || []).map((element, index) => {\r\n final_data.push({\r\n id: element.id,\r\n schemaName: element.schemaName,\r\n schemaType: element.schemaType,\r\n filePollingFolder: element.filePollingFolder,\r\n isDefaultSchema: element.isDefault,\r\n });\r\n });\r\n // resolve({\r\n // data: final_data,\r\n // page: query.page,\r\n // totalCount: result === null ? 0 : result.totalRecords,\r\n // });\r\n this.setState({\r\n schema_final_data: final_data,\r\n schema_totalCount: result === null ? 0 : result.totalRecords,\r\n });\r\n };\r\n\r\n deleteSelectedSchema = (schemaIds) => {\r\n const itemsToBeDeleted = schemaIds.map((schema) => {\r\n return schema.id;\r\n });\r\n const payload = itemsToBeDeleted;\r\n axiosConfig\r\n .post(`${ServiceEndPoints.postSchemas}/delete`, payload)\r\n .then((response) => {\r\n this.props.setSnackBar({ msg: 'Schema(s) deleted successfully' });\r\n this.getSchemaResults();\r\n // this.props.tableRef.current && this.props.tableRef.current.onQueryChange();\r\n })\r\n .catch((error) => {\r\n alert('Items were not deleted, please try again.');\r\n });\r\n };\r\n\r\n onRowClicked = (res) => {\r\n this.props.dispatch('');\r\n this.props.history.push(`/configuration/fileConfiguration/SchemaPreview/${res.schemaName}`);\r\n // this.props.history.push(`/configuration/fileConfiguration/editSchema`,+res.schemaName);\r\n };\r\n\r\n onPageNumChange(pageNum) {\r\n if (this.state.pageNumber !== pageNum) {\r\n this.setState({ pageNumber: pageNum }, () => {\r\n this.getSchemaResults();\r\n });\r\n }\r\n }\r\n\r\n onPageSizeChange(pageSize) {\r\n this.setState({ pageSize: pageSize }, () => {\r\n this.getSchemaResults();\r\n });\r\n }\r\n\r\n render() {\r\n return (\r\n this.onPageSizeChange(e),\r\n onChangePage: (a) => this.onPageNumChange(a),\r\n }}\r\n page={this.state.pageNumber}\r\n />\r\n );\r\n }\r\n}\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n addressBookSearchParams: state.searchParams,\r\n };\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n dispatch: (value) => {\r\n dispatch(actions.setActiveTab(value));\r\n },\r\n setSnackBar: (data) => {\r\n dispatch(actions.setAppSnackBarData(data));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(withRouter(MySchemas));\r\n","import { UK_POSTAL_CODE_REGEX } from '../../../constants/constants';\r\n\r\nconst collectionsDefaultsForm = {\r\n formId: 'collectionsDefaultsForm',\r\n formField: {\r\n destinationCountry: {\r\n props: {\r\n name: 'destinationCountry',\r\n label: 'Destination country',\r\n type: 'select',\r\n displayField: 'name',\r\n },\r\n },\r\n totalVolumetricWeight: {\r\n props: {\r\n name: 'totalVolumetricWeight',\r\n },\r\n value: 0.0,\r\n },\r\n weight: {\r\n props: {\r\n name: 'weight',\r\n label: 'Weight (kg)',\r\n type: 'number',\r\n placeholder: 'Select',\r\n inputProps: {\r\n min: 0,\r\n max: 999,\r\n },\r\n },\r\n validation: {\r\n name: 'weight',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'min',\r\n params: [0.1, 'Weight is outside permitted range'],\r\n },\r\n {\r\n type: 'max',\r\n params: [999, 'Weight is outside permitted range'],\r\n },\r\n ],\r\n },\r\n },\r\n\r\n deliveryType: {\r\n props: {\r\n name: 'deliveryType',\r\n label: 'Delivery type:',\r\n type: 'radio',\r\n },\r\n },\r\n doorStepInstructions: {\r\n props: {\r\n name: 'doorStepInstructions',\r\n label: 'Doorstep instructions',\r\n type: 'select',\r\n displayField: 'name',\r\n },\r\n },\r\n deliveryServicePoint: {\r\n props: {\r\n name: 'deliveryServicePoint',\r\n label: 'Find service point',\r\n type: 'text',\r\n placeholder: 'Find ServicePoint ',\r\n },\r\n validation: {\r\n name: 'postalCode',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'deliveryType',\r\n (deliveryType, schema) => {\r\n return deliveryType === 'deliverToServicePoint'\r\n ? schema.required('ServicePoint is required')\r\n // .matches(UK_POSTAL_CODE_REGEX, 'Invalid postal code')\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n leaveSafeLocation: {\r\n props: {\r\n name: 'leaveSafeLocation',\r\n label: 'Leave safe location',\r\n type: 'text',\r\n placeholder: 'Leave Safe location',\r\n },\r\n },\r\n exchange: {\r\n props: {\r\n name: 'exchange',\r\n label: 'Exchange on delivery:',\r\n type: 'radio',\r\n },\r\n },\r\n specialInstructions: {\r\n props: {\r\n name: 'specialInstructions',\r\n label: 'Special instructions',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 30,\r\n },\r\n },\r\n validation: {\r\n name: 'specialInstructions',\r\n validationType: 'string',\r\n validations: [{\r\n type: 'max',\r\n params: [30, 'Max 30 characters are allowed'],\r\n }],\r\n },\r\n },\r\n additionalInstruction: {\r\n props: {\r\n name: 'additionalInstruction',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 30,\r\n },\r\n },\r\n },\r\n\r\n service: {\r\n props: {\r\n name: 'service',\r\n label: 'Service',\r\n type: 'select',\r\n displayField: 'name',\r\n },\r\n },\r\n\r\n noOfItems: {\r\n props: {\r\n name: 'noOfItems',\r\n label: 'Number of parcels',\r\n type: 'number',\r\n inputProps: {\r\n min: 1,\r\n max: 20,\r\n },\r\n restrictDecimal: true\r\n },\r\n validation: {\r\n name: 'noOfItems',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n params: [1, 'Number of parcels must be between 1 and 200.'],\r\n type: 'min',\r\n },\r\n {\r\n type: 'max',\r\n params: [200, 'Number of parcels must be between 1 and 200.'],\r\n },\r\n ],\r\n },\r\n },\r\n\r\n collectionInstructions: {\r\n props: {\r\n name: 'collectionInstructions',\r\n label: 'Collection instructions',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 60,\r\n },\r\n },\r\n },\r\n descriptionOfGoods: {\r\n props: {\r\n name: 'descriptionOfGoods',\r\n label: 'Description of goods to be collected',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 50,\r\n },\r\n },\r\n },\r\n defaultCollectionAccounts: {\r\n props: {\r\n name: 'defaultCollectionAccounts',\r\n label: 'Default collection account',\r\n type: 'select',\r\n displayId: \"accountId\",\r\n displayField: 'accountName',\r\n hasDefaultValue: false,\r\n },\r\n\r\n },\r\n shipmentMovement: {\r\n props: {\r\n name: 'shipmentMovement',\r\n label: 'Shipment Movement Type',\r\n type: 'select',\r\n displayField: 'name',\r\n hasDefaultValue: true,\r\n },\r\n validation: {\r\n validationType: 'object',\r\n validations: [\r\n ],\r\n },\r\n },\r\n clearanceTotalValue: {\r\n props: {\r\n name: 'clearanceTotalValue',\r\n label: 'Total Value',\r\n type: 'number',\r\n inputProps: {\r\n min: 0,\r\n max: 99999999,\r\n }\r\n },\r\n validation: {\r\n name: 'clearanceTotalValue',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'min',\r\n params: [0.01, 'Total value cannot be less than 0.01'],\r\n },\r\n {\r\n type: 'max',\r\n params: [99999999.99, 'Total value should be 99999999.99 or less'],\r\n },\r\n ],\r\n },\r\n },\r\n clearanceDescriptionOfGoods: {\r\n props: {\r\n name: 'clearanceDescriptionOfGoods',\r\n label: 'Description of goods (shipment level)',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 90,\r\n },\r\n },\r\n validation: {\r\n name: 'clearanceDescriptionOfGoods',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [90, 'Max 90 characters are allowed'],\r\n },\r\n {\r\n type: 'min',\r\n params: [3, 'Minimum of 3 characters are required'],\r\n },\r\n {\r\n type: 'matches',\r\n params: [/(.*[a-zA-Z0-9$&+,:;=?@#|'<>.^*()%!-]){3}/i, 'Minimum 3 non blank characters are required'],\r\n },\r\n ],\r\n },\r\n },\r\n shippingCharges: {\r\n props: {\r\n name: 'shippingCharges',\r\n label: 'Shipping Charges',\r\n type: 'number',\r\n inputProps: {\r\n maxLength: 8,\r\n },\r\n },\r\n validation: {\r\n name: 'shippingCharges',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [99999999.99, 'Total Value be 99999999 or less'],\r\n },\r\n ],\r\n },\r\n },\r\n reasonExport: {\r\n props: {\r\n name: 'reasonExport',\r\n label: 'Reason For Export',\r\n type: 'select',\r\n displayField: 'name',\r\n hasDefaultValue: true,\r\n },\r\n validation: {\r\n validationType: 'object',\r\n },\r\n },\r\n\r\n commodityCode: {\r\n props: {\r\n name: 'commodityCode',\r\n label: 'Commodity code',\r\n type: 'text',\r\n inputProps: {\r\n maxLength: 10,\r\n },\r\n class_Name: 'commodity_Code',\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'matches',\r\n params: [/^[0-9]{10}$/, 'Commodity code should be a 10 digit number'],\r\n },\r\n {\r\n type: 'max',\r\n params: [10, 'Commodity code should be a 10 digit number'],\r\n },\r\n ],\r\n },\r\n },\r\n quantity: {\r\n props: {\r\n name: 'quantity',\r\n label: 'UnitQuantity',\r\n type: 'number',\r\n inputProps: {\r\n max: 999,\r\n min: 1,\r\n },\r\n },\r\n validation: {\r\n validationType: 'number',\r\n name: 'quantity',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [999, 'Quantity must be 999 or less'],\r\n },\r\n {\r\n type: 'integer',\r\n params: ['Quantity should be a whole number'],\r\n },\r\n ],\r\n },\r\n },\r\n unitWeight: {\r\n props: {\r\n name: 'unitWeight',\r\n label: 'UnitWeight',\r\n type: 'number',\r\n inputProps: {\r\n max: 999,\r\n min: 1,\r\n },\r\n },\r\n validation: {\r\n validationType: 'number',\r\n name: 'unitWeight',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [999, 'unitWeight must be 999 or less'],\r\n },\r\n {\r\n type: 'integer',\r\n params: ['unitWeight should be a whole number'],\r\n },\r\n ],\r\n },\r\n },\r\n unitValue: {\r\n props: {\r\n name: 'unitValue',\r\n label: 'UnitValue',\r\n type: 'number',\r\n inputProps: {\r\n max: 999,\r\n min: 1,\r\n },\r\n },\r\n validation: {\r\n validationType: 'number',\r\n name: 'unitValue',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [999, 'unitValue must be 999 or less'],\r\n },\r\n {\r\n type: 'integer',\r\n params: ['unitValue should be a whole number'],\r\n },\r\n ],\r\n },\r\n },\r\n countryOfOrigin: {\r\n props: {\r\n name: 'countryOfOrigin',\r\n label: 'Country of origin',\r\n type: 'select',\r\n displayField: 'name',\r\n },\r\n validation: {\r\n validationType: 'object',\r\n name: 'countryOfOrigin',\r\n },\r\n },\r\n clearanceItemData: {\r\n props: {\r\n name: 'clearanceItemData',\r\n type: 'array',\r\n fields: {\r\n commodityCode: 'text',\r\n fullDescriptionOfGoods: 'text',\r\n weight: 'number',\r\n quantity: 'number',\r\n unitValue: 'number',\r\n countryOfOrigin: 'text',\r\n },\r\n },\r\n values: [],\r\n validation: {\r\n name: 'clearanceItemData',\r\n validationType: 'array',\r\n validations: [],\r\n },\r\n },\r\n },\r\n};\r\n\r\nexport default collectionsDefaultsForm;\r\n","import React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid } from '@material-ui/core';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\n\r\nconst CollectionDetails = (props) => {\r\n const {\r\n formField: { collectionInstructions, descriptionOfGoods },\r\n } = props;\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nCollectionDetails.propTypes = {};\r\n\r\nexport default CollectionDetails;\r\n","import React, { useEffect, useState } from 'react';\r\nimport { Grid } from '@material-ui/core';\r\nimport InputSelect from '../../../../framework/Inputs/inputSelect/inputSelect'\r\nimport { useSelector } from 'react-redux';\r\nimport { getYupSchemaFromMetaData } from '../../../../utils/yupSchema/yupSchemaGenerator';\r\nimport FormRenderer from '../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport {\r\n formatParcelDetails,\r\n formatDeliveryOptions,\r\n setValuesToParcelDetails,\r\n setValuesToDeliveryOptions,\r\n setValuesToDeliveryOptions_domaesticDefaults,\r\n removeUndefinedProperties,\r\n getCustomerAccountID,\r\n getDomesticAccounts,\r\n getDriverCollectionAccounts,\r\n setDropdownValues,\r\n} from '../../../../utils/helperFunctions';\r\nimport domesticDefaultsForm from '../../../../utils/formConfig/configuration/orderFileDefaultsForm/domesticDefaultsForm';\r\nconst CollectionDefaultAccounts = (props) => {\r\n const { formField: { defaultCollectionAccounts },\r\n setFieldValue, formikValues } = props\r\n const userAccounts = useSelector(state => state?.accounts?.nonReturnuserAccounts ?? []);\r\n let domesticAccounts = getDomesticAccounts(userAccounts);\r\n\r\n let accountFromApi;\r\n useEffect(() => {\r\n accountFromApi = domesticAccounts.find(temp => temp?.accountId === props.collectionDefaultValues?.account);\r\n\r\n setTimeout(() => {\r\n if (!props.collectionDefaultValues?.account && domesticAccounts?.length > 0) {\r\n setFieldValue('defaultCollectionAccounts', domesticAccounts[0])\r\n }\r\n else {\r\n setFieldValue('defaultCollectionAccounts', accountFromApi)\r\n }\r\n }, 0);\r\n }, [props.tabIndex, props.collectionDefaultValues])\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n )\r\n\r\n}\r\n\r\n\r\nexport default CollectionDefaultAccounts\r\n","/* eslint-disable react-hooks/exhaustive-deps */\r\nimport React, { useEffect, useState } from 'react';\r\nimport { Button, Grid } from '@material-ui/core';\r\nimport PropTypes from 'prop-types';\r\nimport { Add } from '@material-ui/icons';\r\nimport FormRenderer from '../../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { connect } from 'react-redux';\r\nimport { ServiceEndPoints } from '../../../../../utils/constants/ApiConstant';\r\nimport { GET } from '../../../../../api/axios';\r\nimport { setDropdownValues } from '../../../../../utils/helperFunctions';\r\nconst CollectionsServices = (props) => {\r\n const {\r\n formField: {\r\n service,\r\n },\r\n formikValues,\r\n setFieldValue,\r\n collectionDefaultValues,\r\n } = props;\r\n\r\n const [services, setServices] = useState([]);\r\n\r\n useEffect(() => {\r\n if (formikValues.deliveryType) {\r\n let addressType = 'servicePoint'\r\n if (formikValues.deliveryType === 'deliverToDoorStep')\r\n addressType = 'doorstep'\r\n GET(\r\n `${ServiceEndPoints.products\r\n }?destinationPostalCode=CV37 6UH&destinationCountryCode=GB&destinationRecipientType=business&weight=${formikValues.weight || 15\r\n }&originPostalCode=TR20 8ZS&originCountryCode=GB&parcels=1&destinationAddressType=${addressType}`,\r\n )\r\n .then((res) => {\r\n if (res.data.length > 0) {\r\n let min = Math.min.apply(\r\n null,\r\n res.data.map((item) => item.sortOrder),\r\n );\r\n let minSortOrderData = res.data.find((services) => services.sortOrder === min);\r\n setServices(minSortOrderData?.deliveryCapabilities?.services || []);\r\n }\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n setServices([]);\r\n });\r\n }\r\n }, [formikValues.weight, formikValues.deliveryType]);\r\n\r\n useEffect(() => {\r\n if (props.collectionDefaultValues?.orderedProduct && services.length > 0) {\r\n const serviceObj = setDropdownValues(services, 'orderedProduct', collectionDefaultValues?.orderedProduct);\r\n setFieldValue('service', serviceObj);\r\n } else {\r\n setFieldValue('service', services[0]);\r\n }\r\n }, [services, props.collectionDefaultValues]);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nCollectionsServices.propTypes = {\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n setFieldValue: PropTypes.func,\r\n collectionDefaultValues: PropTypes.object\r\n};\r\n\r\n\r\nexport default connect(null, null)(CollectionsServices);\r\n","import React, { useEffect, useRef, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid } from '@material-ui/core';\r\nimport collectionsDefaultsForm from '../../../../../utils/formConfig/configuration/orderFileDefaultsForm/collectionsDefaultsForm';\r\nimport { Form, Formik } from 'formik';\r\nimport { connect } from 'react-redux';\r\nimport { getYupSchemaFromMetaData } from '../../../../../utils/yupSchema/yupSchemaGenerator';\r\nimport CustomAccordion from '../../../../../framework/accordion/customAccordion';\r\nimport DeliveryOptions from '../../../../../container/shipment/addShipment/deliveryOptions/deliveryOptions';\r\nimport CollectionDetails from '../../../../helperComponents/collectionDetails/collectionDetails';\r\nimport FormRenderer from '../../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { useDebouncedCallback } from 'use-debounce';\r\nimport { axiosConfig } from '../../../../../api/axios';\r\nimport { reasonOptions,shipmentMovementOptions } from '../../../../../utils/constants/constants';\r\n\r\nimport {\r\n formatDeliveryOptions,\r\n getCustomerAccountID,\r\n removeUndefinedProperties,\r\n setDropdownValues,\r\n getDomesticAccounts,\r\n setValuesToDeliveryOptions,\r\n setValuesToDeliveryOptions_domaesticDefaults,\r\n} from '../../../../../utils/helperFunctions';\r\nimport { useDispatch, useSelector } from 'react-redux';\r\nimport InputButton from '../../../../../framework/Inputs/inputButton/inputButton';\r\nimport { GET, PATCH } from '../../../../../api/axios';\r\nimport { ServiceEndPoints } from '../../../../../utils/constants/ApiConstant';\r\nimport CustomModal from '../../../../../framework/modal/modal';\r\nimport ConfirmationDialog from '../../../../addressBook/confirmation/confirmation';\r\nimport CollectionDefaultAccounts from '../defaultCollectionAccounts'\r\nimport CollectionsServices from './collectionsServices';\r\nimport * as actions from '../../../../../store/actions/index';\r\nimport DomesticDecleration from '../../../../../container/shipment/addShipment/customsDeclaration/domesticDecleration';\r\nimport { dynamicSort } from '../../../../../utils/helperFunctions';\r\nimport { getCommodityTotalWeightDefaults } from '../../../../../../src/utils/utilsFunctions';\r\n\r\nconst { formId, formField } = collectionsDefaultsForm;\r\nlet dimsValidation = {};\r\n\r\nconst CollectionsDefaults = (props) => {\r\n const { collectionDefaultValues, getOrderDefaults, isFromMarketplace } = props; \r\n const [orderFileDetailsValidationSchema, setOrderFileDetailsValidationSchema] = useState(\r\n getYupSchemaFromMetaData(formField, [], []),\r\n );\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n const [countries, setCountries] = useState([]);\r\n const userAccounts = useSelector(state => state?.accounts?.userAccounts ?? []);\r\n const formikRef = useRef(null);\r\n const dispatch = useDispatch();\r\n\r\n const initialValues = {\r\n };\r\n\r\n for (let property in formField) {\r\n if (Object.prototype.hasOwnProperty.call(formField, property)) {\r\n const field = formField[property];\r\n if (field.props.type === 'checkbox' || field.props.type === 'radio') {\r\n initialValues[field.props.name] = field.value;\r\n } else if (field.props.type === 'array') {\r\n initialValues[field.props.name] = field.values;\r\n } else {\r\n initialValues[field.props.name] = field.value || '';\r\n }\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n if (collectionDefaultValues) {\r\n const formikValues = formikRef.current.values;\r\n collectionDefaultValues['destinationCountry'] = 'GBR';\r\n const defaultValues = {\r\n noOfItems: collectionDefaultValues?.parcelDetails?.numberOfItems ?? '',\r\n weight: collectionDefaultValues?.parcelDetails?.weight ?? '',\r\n // ...setValuesToDeliveryOptions(collectionDefaultValues),\r\n ...setValuesToDeliveryOptions_domaesticDefaults(collectionDefaultValues),\r\n collectionInstructions: collectionDefaultValues?.collectionDetails?.collectionInstructions ?? '',\r\n descriptionOfGoods: collectionDefaultValues?.collectionDetails?.descriptionOfGoods ?? '',\r\n shippingCharges: collectionDefaultValues?.clearance?.shippingCharges,\r\n clearanceTotalValue: collectionDefaultValues?.clearance?.totalValue,\r\n clearanceDescriptionOfGoods: collectionDefaultValues?.clearance?.descriptionOfGoodsShipment || '',\r\n };\r\n removeUndefinedProperties(defaultValues);\r\n formikRef.current.setValues({ ...formikValues, ...defaultValues });\r\n const deliveryOptions = collectionDefaultValues.deliveryOptions;\r\n\r\n setTimeout(() => {\r\n formikRef?.current?.setFieldValue('specialInstructions', deliveryOptions?.specialInstructions ?? '');\r\n formikRef?.current?.setFieldValue('additionalInstruction', deliveryOptions?.additionalInstruction ?? '');\r\n const itemData = collectionDefaultValues?.clearance?.items?.map((obj)=>{\r\n const selectedCountry = countries.filter((country) => {\r\n return (obj?.countryOfManufacture == country?.code2Digit) \r\n });\r\n return{\r\n commodityCode:obj?.commodityCode||'',\r\n countryOfOrigin:selectedCountry[0],\r\n fullDescriptionOfGoods:obj?.descriptionOfGoods||'',\r\n quantity:obj?.unitQuantity||'',\r\n unitValue:obj?.unitValue||'',\r\n unitWeight:obj?.unitWeight||'',\r\n }\r\n \r\n })\r\n formikRef?.current?.setFieldValue('clearanceItemData', itemData);\r\n\r\n reasonOptions.map((reasonOption, index) => {\r\n if (collectionDefaultValues?.clearance?.reasonForExport == reasonOption.value) {\r\n formikRef?.current?.setFieldValue('reasonExport', reasonOptions[index]);\r\n }\r\n });\r\n \r\n shipmentMovementOptions.map((shipmentMovementOption, index) => {\r\n if (collectionDefaultValues?.clearance?.shipmentMovementType == shipmentMovementOption.value) {\r\n formikRef?.current?.setFieldValue('shipmentMovement', shipmentMovementOptions[index]);\r\n }\r\n });\r\n }, 10);\r\n }\r\n }, [collectionDefaultValues, countries]);\r\n const reqFields = ['weight', 'specialInstructions', 'additionalInstruction', 'noOfItems', 'collectionInstructions', 'descriptionOfGoods']\r\n const isFormInValid = (errors, values) => {\r\n let clonedReqFields = [...reqFields];\r\n\r\n for (let err in errors) {\r\n if (clonedReqFields.some((fieldName) => fieldName === err)) {\r\n return true;\r\n }\r\n }\r\n\r\n if (values?.shippingCharges > 99999999.99) {\r\n return true;\r\n }\r\n if (values?.clearanceTotalValue > 99999999.99) {\r\n return true;\r\n }\r\n if(values?.descriptionOfGoods && (values?.descriptionOfGoods?.length < 3 || values?.descriptionOfGoods?.length > 90)){\r\n return true;\r\n }\r\n\r\n // To display the form error if (unit quantity*unit weight) total is greater than total weight when shipment movement type b2b for defaults\r\n const commodityTotalWeight = getCommodityTotalWeightDefaults(values);\r\n if(values && (values?.weight < commodityTotalWeight)){\r\n return true;\r\n }\r\n \r\n\r\n return false;\r\n };\r\n\r\n const handleSubmit = (formikValues, errors) => {\r\n let noOfClearanceItem=0;\r\n if (!isFormInValid(errors, formikValues)) {\r\n const item = formikValues?.clearanceItemData?.map(obj => {\r\n noOfClearanceItem += Number(obj?.quantity);\r\n return {\r\n commodityCode: obj?.commodityCode,\r\n descriptionOfGoods: obj?.fullDescriptionOfGoods,\r\n unitQuantity:obj?.quantity ? obj?.unitValue : 0,\r\n unitValue: obj?.unitValue ? Math.round(obj?.unitValue*100)/100:0,\r\n unitWeight: obj?.unitWeight ? Math.round(obj?.unitWeight*100)/100:0,\r\n countryOfManufacture:obj?.countryOfOrigin?.code2Digit,\r\n };\r\n });\r\n const reqObj = {\r\n account: formikValues.defaultCollectionAccounts?.accountId,\r\n parcelDetails: {\r\n numberOfItems: formikValues.noOfItems || null,\r\n weight: formikValues.weight || null,\r\n },\r\n clearance:{\r\n shipmentMovementType:formikValues?.shipmentMovement?.value,\r\n shippingCharges :formikValues?.shippingCharges? Math.round(formikValues?.shippingCharges*100)/100:null,\r\n reasonForExport:formikValues?.reasonExport?.value,\r\n items:item,\r\n totalValue :formikValues?.clearanceTotalValue ? Math.round(formikValues?.clearanceTotalValue*100)/100:null,\r\n descriptionOfGoodsShipment:formikValues?.clearanceDescriptionOfGoods,\r\n numberOfItems: noOfClearanceItem,\r\n },\r\n orderedProduct: formikValues.service?.orderedProduct,\r\n deliveryOptions: formatDeliveryOptions(formikValues),\r\n collectionDetails: {\r\n collectionInstructions: formikValues.collectionInstructions,\r\n descriptionOfGoods: formikValues.descriptionOfGoods,\r\n },\r\n };\r\n removeUndefinedProperties(reqObj);\r\n if(isFromMarketplace){\r\n PATCH(`${ServiceEndPoints.getMarketplaceDefaults}/collectiondefaults?organization=${getCustomerAccountID()}`, reqObj) \r\n .then((res) => {\r\n dispatch(actions.setAppSnackBarData({ msg: \"Collections marketplace defaults saved successfully\" }))\r\n getOrderDefaults();\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n }else{\r\n PATCH(`${ServiceEndPoints.getOrderDefaults}/collection?organization=${getCustomerAccountID()}`, reqObj) \r\n .then((res) => {\r\n dispatch(actions.setAppSnackBarData({ msg: \"Collections order file defaults saved successfully\" }))\r\n getOrderDefaults(); \r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n }\r\n }\r\n else {\r\n dispatch(actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'The form has errors, please correct and try again',\r\n },\r\n ]\r\n }));\r\n }\r\n\r\n };\r\n\r\n const handleDialogClose = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n\r\n const resetForm = () => {\r\n formikRef?.current?.resetForm();\r\n handleDialogClose();\r\n // formikRef.current.setFieldValue('service', services[0]);\r\n formikRef.current.setFieldValue('deliveryType', deliveryTypeOptions[0].value)\r\n };\r\n\r\n const updateValidationSchema = () => {\r\n setOrderFileDetailsValidationSchema(getYupSchemaFromMetaData(formField, [], []));\r\n };\r\n\r\n const debounceCountryFeature = useDebouncedCallback(() => {\r\n axiosConfig\r\n .get(`${ServiceEndPoints.productCountryFeature}?countrycode=GB`)\r\n .then((response) => {\r\n const nonPalletProducts = response.data.filter((val) => val.productCode !== 97 && val.productCode !== 98);\r\n\r\n let allMaxParcelsList = nonPalletProducts.map((x) => x.maximumParcels);\r\n let allMaxWeightList = nonPalletProducts.map((x) => x.maximumWeight);\r\n dimsValidation = {\r\n ...dimsValidation,\r\n maxParcels: Math.max(...allMaxParcelsList),\r\n maxWeight: Math.max(...allMaxWeightList),\r\n };\r\n formField.weight.validation.validations = formField.weight.validation.validations.filter(\r\n (x) => x.type !== 'max',\r\n );\r\n formField.weight.validation.validations.push({\r\n type: 'max',\r\n params: [\r\n dimsValidation.maxWeight,\r\n `Declared weight must be less than or equal to ${dimsValidation.maxWeight}.`,\r\n ],\r\n });\r\n formField.weight.props.inputProps.max = dimsValidation.maxWeight;\r\n\r\n\r\n formField.noOfItems.validation.validations = formField.noOfItems.validation.validations.filter(\r\n (x) => x.type !== 'max',\r\n );\r\n formField.noOfItems.validation.validations.push({\r\n type: 'max',\r\n params: [dimsValidation.maxParcels, `Must be a value between 1 to ${dimsValidation.maxParcels}`],\r\n });\r\n formField.noOfItems.props.inputProps.max = dimsValidation.maxParcels;\r\n\r\n updateValidationSchema();\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n // console.log('Failed to load');\r\n });\r\n }, 500);\r\n\r\n useEffect(() => {\r\n debounceCountryFeature();\r\n }, []);\r\n\r\n useEffect(() => {\r\n // eslint-disable-next-line new-cap\r\n GET(ServiceEndPoints.getCountries)\r\n .then((res) => {\r\n setCountries(res.data.countries.sort(dynamicSort('name')));\r\n })\r\n .catch((err) => {\r\n setCountries([]);\r\n });\r\n }, []);\r\n\r\n\r\n return (\r\n \r\n \r\n {({ values, setValues, setFieldValue, setFieldTouched, errors, resetForm }) => {\r\n return (\r\n \r\n );\r\n }}\r\n \r\n\r\n \r\n\r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nCollectionsDefaults.propTypes = {};\r\n\r\n\r\nexport default CollectionsDefaults;\r\nconst deliveryTypeOptions = [\r\n {\r\n value: 'deliverToDoorStep',\r\n label: 'Deliver to doorstep',\r\n },\r\n {\r\n value: 'deliverToServicePoint',\r\n label: 'Deliver to ServicePoint',\r\n },\r\n];","const internationDefaultsForm = {\r\n formId: 'internationDefaultsForm',\r\n formField: {\r\n destinationCountry: {\r\n props: {\r\n name: 'destinationCountry',\r\n label: 'Destination country',\r\n type: 'select',\r\n displayField: 'name',\r\n isRequired: true,\r\n },\r\n value: {\r\n code: '',\r\n },\r\n },\r\n totalVolumetricWeight: {\r\n props: {\r\n name: 'totalVolumetricWeight',\r\n },\r\n value: 0.0,\r\n },\r\n weight: {\r\n props: {\r\n name: 'weight',\r\n label: 'Weight (kg)',\r\n type: 'number',\r\n placeholder: 'Select',\r\n // isRequired: true,\r\n\r\n inputProps: {\r\n min: 0,\r\n max: 1000,\r\n step: 'any',\r\n },\r\n },\r\n validation: {\r\n name: 'weight',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'min',\r\n params: [0.1, 'Weight is outside permitted range'],\r\n },\r\n {\r\n type: 'max',\r\n params: [1000, 'Weight is outside permitted range'],\r\n },\r\n ],\r\n },\r\n },\r\n length: {\r\n props: {\r\n name: 'length',\r\n label: 'Length (cm)',\r\n type: 'number',\r\n // isRequired: true,\r\n\r\n inputProps: {\r\n min: 1,\r\n max: 200,\r\n },\r\n },\r\n validation: {\r\n name: 'length',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'typeError',\r\n params: ['Length must be number type'],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Declared length must be greater than 0'],\r\n },\r\n {\r\n type: 'max',\r\n params: [200, 'Declared length must be less than or equal to 200'],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n ['width', 'height'],\r\n (width, height, schema) => {\r\n if (width || height) {\r\n return schema.test('', 'Length must be longest side', (value) => {\r\n return value >= width && value >= height;\r\n });\r\n }\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n width: {\r\n props: {\r\n name: 'width',\r\n label: 'Width (cm)',\r\n type: 'number',\r\n // isRequired: true,\r\n\r\n inputProps: {\r\n min: 1,\r\n max: 120,\r\n },\r\n },\r\n validation: {\r\n name: 'width',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'typeError',\r\n params: ['Width must be number type'],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Declared width must be greater than 0'],\r\n },\r\n {\r\n type: 'max',\r\n params: [120, 'Declared width must be less than or equal to 120'],\r\n },\r\n ],\r\n },\r\n },\r\n height: {\r\n props: {\r\n name: 'height',\r\n label: 'Height (cm)',\r\n type: 'number',\r\n // isRequired: true,\r\n\r\n inputProps: {\r\n min: 1,\r\n max: 120,\r\n },\r\n },\r\n validation: {\r\n name: 'height',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'typeError',\r\n params: ['Height must be number type'],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Declared height must be greater than 0'],\r\n },\r\n {\r\n type: 'max',\r\n params: [120, 'Declared height must be less than or equal to 120'],\r\n },\r\n ],\r\n },\r\n },\r\n\r\n inboxReturnLabel: {\r\n props: {\r\n name: 'inboxReturnLabel',\r\n label: 'Include inbox return label:',\r\n type: 'radio',\r\n },\r\n },\r\n\r\n returnReference: {\r\n props: {\r\n name: 'returnReference',\r\n label: 'Return reference',\r\n type: 'text',\r\n },\r\n value: '',\r\n },\r\n\r\n noOfItems: {\r\n props: {\r\n name: 'noOfItems',\r\n label: 'No. of items',\r\n type: 'number',\r\n inputProps: {\r\n min: 0,\r\n max: 20,\r\n },\r\n restrictDecimal: true\r\n },\r\n validation: {\r\n name: 'noOfItems',\r\n validationType: 'number',\r\n validations: [\r\n // {\r\n // type: 'required',\r\n // params: ['Number of Items is required.'],\r\n // },\r\n {\r\n params: [0, 'The value of items can not be less than 1'],\r\n type: 'min',\r\n },\r\n {\r\n type: 'max',\r\n params: [20, 'The value of items can not be greater than 20'],\r\n },\r\n ],\r\n },\r\n },\r\n\r\n commodityDetails: {\r\n props: {\r\n name: 'commodityDetails',\r\n type: 'array',\r\n fields: {\r\n commodityCode: 'text',\r\n fullDescriptionOfGoods: 'text',\r\n weight: 'number',\r\n quantity: 'number',\r\n unitValue: 'number',\r\n countryOfOrigin: 'text',\r\n },\r\n },\r\n values: [],\r\n validation: {\r\n name: 'commodityDetails',\r\n validationType: 'array',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [20, 'max 20 '],\r\n },\r\n ],\r\n },\r\n },\r\n subTotal: {\r\n props: {\r\n name: 'subTotal',\r\n },\r\n value: 0,\r\n },\r\n totalValue: {\r\n props: {\r\n name: 'totalValue',\r\n },\r\n value: 0,\r\n },\r\n totalWeightExceed: {\r\n props: {\r\n name: 'totalWeightExceed',\r\n type: 'number',\r\n },\r\n value: 0,\r\n validation: {\r\n name: 'totalWeightExceed',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n ['weight','noOfItems','destinationCountry'],\r\n (weight, noOfItems, destinationCountry, schema) => {\r\n if (destinationCountry?.code !== 'GBR') {\r\n return schema\r\n .test('', 'Total Weight of Pieces exceeds the Declared Weight', (value) => {\r\n return ((value || 0) <= (weight || 0) * (noOfItems || 1));\r\n });\r\n } else {\r\n return schema;\r\n }\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n\r\n invoiceTypeLabel: {\r\n props: {\r\n name: 'invoiceTypeLabel',\r\n label: 'Invoice type',\r\n type: 'radio',\r\n isRequired: 'true',\r\n },\r\n value: 'commercial',\r\n },\r\n \r\n invoiceNumber: {\r\n props: {\r\n name: 'InvoiceNumber',\r\n label: 'Invoice number',\r\n type: 'text',\r\n isRequired: false,\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n validation: {\r\n name: 'invoiceNumber',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [35, 'Maximum 35 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n\r\n customDeclarationShippingCharges: {\r\n props: {\r\n name: 'customDeclarationShippingCharges',\r\n label: 'Shipping charges',\r\n type: 'text',\r\n isRequired: false,\r\n inputProps: {\r\n maxLength: 10,\r\n },\r\n },\r\n validation: {\r\n name: 'customDeclarationShippingCharges',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'max',\r\n params: [10, 'Maximum 10 digits are allowed for shipping charges'],\r\n },\r\n {\r\n type: 'matches',\r\n params: [/^[+]?([0-9]+(?:[\\.][0-9]*)?|\\.[0-9]+)$/, 'Shipping charges must be a positive number'],\r\n },\r\n ],\r\n },\r\n },\r\n\r\n customDeclarationCurrency: {\r\n props: {\r\n name: 'customDeclarationCurrency',\r\n label: 'Currency',\r\n type: 'select',\r\n displayField: 'name',\r\n isRequired: false,\r\n hasDefaultValue: false,\r\n },\r\n },\r\n\r\n reasonForExport: {\r\n props: {\r\n name: 'reasonForExport',\r\n label: 'Reason for export',\r\n type: 'select',\r\n displayField: 'description',\r\n isRequired: false,\r\n // value: '0',\r\n hasDefaultValue: false,\r\n },\r\n },\r\n\r\n marketplaceIossNo: {\r\n props: {\r\n name: 'marketplaceIossNo',\r\n label: \"Marketplace IOSS number\",\r\n type: 'text',\r\n isRequired: false,\r\n inputProps: {\r\n maxLength: 12,\r\n },\r\n },\r\n validation: {\r\n name: 'marketplaceIossNo',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'matches',\r\n params: [/IM\\d{10}/, \"IOSS no. must be in the correct format (e.g. IM0123456789)\"],\r\n },\r\n ],\r\n },\r\n },\r\n\r\n termsOfDelivery: {\r\n props: {\r\n name: 'termsOfDelivery',\r\n label: 'Terms of delivery',\r\n type: 'select',\r\n displayField: 'label',\r\n isRequired: false,\r\n hasDefaultValue: false,\r\n // isDisabled: true,\r\n },\r\n },\r\n },\r\n};\r\n\r\nexport default internationDefaultsForm;\r\n","import React, { useEffect, useRef, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid } from '@material-ui/core';\r\nimport { Formik } from 'formik';\r\nimport { useSelector, useDispatch } from 'react-redux';\r\nimport * as actions from '../../../../../store/actions/index';\r\nimport { getYupSchemaFromMetaData } from '../../../../../utils/yupSchema/yupSchemaGenerator';\r\nimport CustomAccordion from '../../../../../framework/accordion/customAccordion';\r\nimport ParcelDetails from '../../../../../container/shipment/addShipment/parcelDetails/parcelDetails';\r\nimport ReturnOptions from '../../../../../container/shipment/addShipment/returnOptions/returnOptions';\r\nimport CommodityDetails from '../../../../../container/shipment/addShipment/customsDeclaration/commodityDetails/commodityDetails';\r\nimport internationDefaultsForm from '../../../../../utils/formConfig/configuration/orderFileDefaultsForm/internationalDefaultsForm';\r\nimport {\r\n formatParcelDetails,\r\n getParsedFloatValues,\r\n getCommodityDetails,\r\n setValuesToParcelDetails,\r\n setCommodityDetails,\r\n removeUndefinedProperties,\r\n setDropdownValues,\r\n getCustomerAccountID,\r\n getDomesticAccounts,\r\n getInternationalAccounts,\r\n getDriverCollectionAccounts,\r\n} from '../../../../../utils/helperFunctions';\r\nimport InputButton from '../../../../../framework/Inputs/inputButton/inputButton';\r\nimport { PATCH } from '../../../../../api/axios';\r\nimport { ServiceEndPoints } from '../../../../../utils/constants/ApiConstant';\r\nimport CustomModal from '../../../../../framework/modal/modal';\r\nimport ConfirmationDialog from '../../../../addressBook/confirmation/confirmation';\r\n\r\nconst { formField } = internationDefaultsForm;\r\n\r\nconst InternationalDefaults = (props) => {\r\n const { internationalDefaultValues, countries, getOrderDefaults, selectedAccount } = props;\r\n const [showReturnLabel, setReturnLabel] = useState(false);\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n const [orderFileDetailsValidationSchema, setorderFileDetailsValidationSchema] = useState(\r\n getYupSchemaFromMetaData(formField, [], []),\r\n );\r\n const formikRef = useRef(null);\r\n const initialValues = {};\r\n const userAccounts = useSelector((state) => state?.accounts?.userAccounts ?? []);\r\n const inboxReturnLabelValue = useSelector(\r\n (state) => state?.common?.commonConfiguration?.defaultPrintInboxReturnLabel,\r\n );\r\n const dispatch = useDispatch();\r\n const reqFields = ['destinationCountry', 'weight', 'length', 'width', 'height', 'inboxReturnLabel', 'returnReference', 'noOfItems', 'commodityDetails', 'subTotal', 'totalValue']\r\n for (let property in formField) {\r\n if (Object.prototype.hasOwnProperty.call(formField, property)) {\r\n const field = formField[property];\r\n if (field.props.type === 'checkbox' || field.props.type === 'radio') {\r\n initialValues[field.props.name] = field.value;\r\n } else if (field.props.type === 'array') {\r\n initialValues[field.props.name] = field.values;\r\n } else {\r\n initialValues[field.props.name] = field.value || '';\r\n }\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n if (getDriverCollectionAccounts(getInternationalAccounts(userAccounts)).length > 0) {\r\n setReturnLabel(true);\r\n } else {\r\n setReturnLabel(false);\r\n }\r\n }, [userAccounts]);\r\n\r\n useEffect(() => {\r\n if (internationalDefaultValues) {\r\n const parcelDimensions = (internationalDefaultValues?.parcelDetails?.parcelDimensions || [])[0];\r\n internationalDefaultValues['destinationCountry'] = 'DER';\r\n const defaultValues = {\r\n ...setValuesToParcelDetails(internationalDefaultValues , null , true),\r\n commodityDetails: setCommodityDetails(\r\n internationalDefaultValues?.customDeclaration?.customItemDetails,\r\n countries,\r\n ),\r\n inboxReturnLabel: internationalDefaultValues?.includeReturnLabel?.toString() ?? null,\r\n returnReference: internationalDefaultValues.returnreference,\r\n length: parcelDimensions?.length || '',\r\n width: parcelDimensions?.width || '',\r\n height: parcelDimensions?.height || '',\r\n };\r\n removeUndefinedProperties(defaultValues);\r\n formikRef.current.setValues({ ...formikRef.current.values, ...defaultValues });\r\n }\r\n }, [internationalDefaultValues]);\r\n\r\n // const isFormInValid = (errors) => {\r\n // let clonedReqFields = [...reqFields];\r\n // // clonedReqFields.forEach(field => {\r\n // // formikRef.current.setFieldTouched(field)\r\n // // });\r\n // for (let err in errors) {\r\n // if (clonedReqFields.some((fieldName) => fieldName === err)) {\r\n // return true;\r\n // }\r\n // }\r\n // return false;\r\n // };\r\n\r\n const handleSubmit = async (formikValues, errors) => {\r\n if (Object.keys(await formikRef.current.validateForm(formikValues)).length === 0) {\r\n const reqObj = {\r\n parcelDetails: formatParcelDetails(formikValues, false, true),\r\n customDeclaration: {\r\n // shippingCharges: 0,\r\n customItemDetails: getCommodityDetails(formikValues.commodityDetails),\r\n subTotal: Number(formikValues.subTotal),\r\n shippingCost: getParsedFloatValues(formikValues.customDeclarationShippingCharges),\r\n totalValue: Number(formikValues.totalValue),\r\n },\r\n returnreference: formikValues.returnReference,\r\n includeReturnLabel: formikValues.inboxReturnLabel === undefined ? inboxReturnLabelValue : formikValues.inboxReturnLabel === 'true',\r\n };\r\n removeUndefinedProperties(reqObj);\r\n PATCH(`${ServiceEndPoints.getOrderDefaults}/international?organization=${getCustomerAccountID()}`, reqObj)\r\n .then((res) => {\r\n dispatch(actions.setAppSnackBarData({ msg: \"International order file defaults saved successfully\" }))\r\n getOrderDefaults();\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n }\r\n else {\r\n dispatch(actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'The form has errors, please correct and try again',\r\n },\r\n ]\r\n }));\r\n }\r\n\r\n };\r\n\r\n const handleDialogClose = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n\r\n const resetForm = () => {\r\n formikRef?.current?.resetForm();\r\n handleDialogClose();\r\n };\r\n\r\n const updateValidationSchema = () => {\r\n setorderFileDetailsValidationSchema(getYupSchemaFromMetaData(formField, [], []));\r\n };\r\n\r\n return (\r\n \r\n \r\n {({ values, setFieldValue, setFieldTouched, errors }) => {\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n {showReturnLabel ? (\r\n \r\n \r\n \r\n ) : null}\r\n \r\n \r\n setShowConfirmationDialog(true)}\r\n label=\"Reset\"\r\n />\r\n \r\n \r\n handleSubmit(values, errors)}\r\n label=\"Save changes\"\r\n buttonType=\"submit\"\r\n />\r\n \r\n \r\n \r\n );\r\n }}\r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nInternationalDefaults.propTypes = {};\r\n\r\nexport default InternationalDefaults;\r\n","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid } from '@material-ui/core';\r\nimport ToggleButtonGroup from '@material-ui/lab/ToggleButtonGroup';\r\nimport ToggleButton from '@material-ui/lab/ToggleButton';\r\nimport { connect } from 'react-redux';\r\n\r\nimport DomesticDefaults from './domesticDefaults/domesticDefaults';\r\nimport CollectionsDefaults from './collectionsDefaults/collectionsDefaults';\r\nimport InternationalDefaults from './internationalDefaults/internationalDefaults';\r\nimport { GET } from '../../../../api/axios';\r\nimport { ServiceEndPoints } from '../../../../utils/constants/ApiConstant';\r\nimport { dynamicSort, getCustomerAccountID } from '../../../../utils/helperFunctions';\r\nimport DomesticDefaultAccounts from '../orderFileDefaults/domesticDefaultAccounts';\r\nimport './orderFileDefaults.scss';\r\n\r\nconst OrderFileDefaults = (props) => {\r\n const [formType, setFormType] = useState('domestic');\r\n const [defaultValues, setDefaultValues] = useState({});\r\n const [countries, setCountries] = React.useState([]);\r\n\r\n const toggleButtons = (event, value) => {\r\n if (value) {\r\n setFormType(value);\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n getOrderDefaults();\r\n }, []);\r\n\r\n const getOrderDefaults = () => {\r\n GET(`${ServiceEndPoints.getOrderDefaults}?organization=${getCustomerAccountID()}`)\r\n .then((res) => {\r\n setDefaultValues(res.data);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n GET(ServiceEndPoints.getCountries)\r\n .then((res) => {\r\n setCountries(res.data.countries.sort(dynamicSort('name')));\r\n })\r\n .catch((err) => {\r\n setCountries([]);\r\n });\r\n };\r\n\r\n return (\r\n \r\n \r\n \r\n Domestic \r\n International \r\n Collections \r\n \r\n \r\n \r\n {formType === 'domestic'\r\n ? (\r\n \r\n )\r\n : null}\r\n {formType === 'international'\r\n ? (\r\n \r\n )\r\n : null}\r\n {formType === 'collections'\r\n ? (\r\n \r\n )\r\n : null}\r\n \r\n \r\n );\r\n};\r\n\r\nOrderFileDefaults.propTypes = {};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n userDetails: state.auth.userDetails,\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, null)(OrderFileDefaults);\r\n","import React from 'react';\r\nimport { Grid } from '@material-ui/core';\r\nimport { PropTypes } from 'prop-types';\r\nimport DynamicMaterialTable from '../../../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\n\r\nexport default function OrderFile(props) {\r\n const {\r\n rows,\r\n columns,\r\n isSelectable,\r\n emptyDataSourceMessage\r\n } = props;\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n )\r\n}\r\n\r\nOrderFile.propTypes = {\r\n rows: PropTypes.any,\r\n columns: PropTypes.any,\r\n isSelectable: PropTypes.bool,\r\n emptyDataSourceMessage: PropTypes.string\r\n};\r\n","const orderFileMappingForm = {\r\n formId: 'orderFileMapping',\r\n formField: {\r\n mapCategory: {\r\n props: { \r\n name: 'mapCategory',\r\n label: 'Category',\r\n type: 'select',\r\n displayField: 'name',\r\n isRequired: true,\r\n value: '0',\r\n hasDefaultValue: true,\r\n },\r\n validation: {\r\n name: 'mapCategory',\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Please select a category to create a mapping'],\r\n },\r\n ],\r\n },\r\n },\r\n mapTo: {\r\n props: {\r\n name: 'mapTo',\r\n label: 'Map to',\r\n type: 'select',\r\n displayField: 'name',\r\n isRequired: true,\r\n value: '0',\r\n },\r\n validation: {\r\n name: 'mapTo',\r\n validationType: 'object',\r\n isRequired: true,\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Map to field is required'],\r\n },\r\n ],\r\n },\r\n },\r\n mapToForAccount: {\r\n props: {\r\n name: 'mapToForAccount',\r\n label: 'Map to',\r\n type: 'select',\r\n displayField: 'displayName',\r\n isRequired: true,\r\n value: '0',\r\n },\r\n validation: {\r\n name: 'mapToForAccount',\r\n validationType: 'object',\r\n isRequired: true,\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Map to field is required'],\r\n },\r\n ],\r\n },\r\n },\r\n mapFrom: {\r\n props: {\r\n name: 'mapFrom',\r\n label: 'Map from',\r\n type: 'text',\r\n isRequired: true,\r\n placeholder: 'Map from',\r\n },\r\n validation: {\r\n name: 'mapFrom',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Map from field is required'],\r\n },\r\n ],\r\n },\r\n },\r\n mappingDetails: {\r\n props: {\r\n name: 'mappingDetails',\r\n type: 'array',\r\n fields: {\r\n mapFrom: 'text',\r\n mapTo: 'text',\r\n },\r\n },\r\n values: [],\r\n },\r\n marketPlacesAvailable: {\r\n props: { \r\n name: 'marketPlacesAvailable',\r\n label: 'Marketplaces',\r\n type: 'select',\r\n displayField: 'marketplaceName',\r\n isRequired: true,\r\n hasDefaultValue: true,\r\n },\r\n },\r\n newMarketplaceName: {\r\n props: {\r\n name: 'newMarketplaceName',\r\n label: 'Marketplace name',\r\n type: 'text',\r\n isRequired: true,\r\n },\r\n },\r\n newMarketplaceCode: {\r\n props: {\r\n name: 'newMarketplaceCode',\r\n label: 'Marketplace code',\r\n type: 'text',\r\n isRequired: true,\r\n },\r\n },\r\n },\r\n };\r\n \r\n export default orderFileMappingForm;\r\n ","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid } from '@material-ui/core';\r\nimport { FieldArray } from 'formik';\r\nimport { ReactComponent as DeleteIcon } from '../../../../assets/images/DeleteIcon.svg';\r\nimport FormRenderer from '../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { mappingCategoryByOptions, mappingCategoryForMarketplaces } from '../../../../utils/constants/constants';\r\nimport {\r\n TableContainer,\r\n Paper,\r\n Table,\r\n TableHead,\r\n TableRow,\r\n TableCell,\r\n TableBody,\r\n IconButton,\r\n SvgIcon,\r\n} from '@material-ui/core';\r\nimport InputButton from '../../../../framework/Inputs/inputButton/inputButton';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\nimport CustomModal from '../../../../framework/modal/modal';\r\nimport ConfirmationDialog from '../../../../components/addressBook/confirmation/confirmation';\r\n\r\nconst useStyles = makeStyles({\r\n table: {\r\n minWidth: 850,\r\n border: '1px solid #B5B5B5',\r\n },\r\n container: {\r\n maxHeight: \"240px\",\r\n\r\n },\r\n tableHeading: {\r\n backgroundColor: \"#fafafa\",\r\n }\r\n});\r\n\r\nconst AddMapping = (props) => {\r\n const {\r\n formField: { mapFrom, mapTo, mapCategory, mapToForAccount, marketPlacesAvailable},\r\n saveNewMappings,\r\n formikValues,\r\n setFieldValue,\r\n setFieldTouched,\r\n mappedServices,\r\n mappedAccounts,\r\n defaultAccounts,\r\n defaultServices,\r\n _isUpdatingFlag,\r\n setErrors,\r\n isMarketplaceMapping,\r\n marketPlacesList,\r\n } = props;\r\n\r\n\r\n const [mappingDetails, setMappingDetails] = useState([]);\r\n const [mappingTo, setMappingTo] = useState([]);\r\n const [isAddButtonDisabled, setIsAddButtonDisabled] = useState(true);\r\n const [showDeleteConfirmationDialog, setshowDeleteConfirmationDialog] = useState(false);\r\n const [selectedCategory, setSelectedCategory] = useState('');\r\n const [oldAccountDetails, setOldAccountDetails] = useState(mappedAccounts)\r\n const [oldServiceDetails, setOldServiceDetails] = useState(mappedServices)\r\n const [Delete_array_Helpers, setDelete_array_Helpers] = useState({})\r\n const [Deleteindex, setDeleteindex] = useState('')\r\n const classes = useStyles();\r\n\r\n useEffect(() => {\r\n if (formikValues.mapFrom !== undefined &&\r\n (formikValues.mapCategory && formikValues.mapCategory.name !== 'Select')\r\n ) {\r\n if (formikValues.mapCategory.value === \"accounts\" && formikValues.mapToForAccount.displayName != 'Select') {\r\n setIsAddButtonDisabled(false)\r\n }\r\n else if (formikValues.mapCategory.value === \"services\" && formikValues.mapTo && formikValues.mapTo.name !== 'Select') {\r\n setIsAddButtonDisabled(false)\r\n } else {\r\n setIsAddButtonDisabled(true)\r\n }\r\n }\r\n }, [formikValues.mapFrom, formikValues.mapTo, formikValues.mapCategory, formikValues.mapToForAccount]);\r\n\r\n const deleteMappedDetails = (arrayHelpers, index) => {\r\n _isUpdatingFlag(true)\r\n setDelete_array_Helpers(arrayHelpers);\r\n setDeleteindex(index)\r\n setshowDeleteConfirmationDialog(true)\r\n }\r\n\r\n const onDialogConfirm = () => {\r\n let arrayHelpers = Delete_array_Helpers\r\n let index = Deleteindex\r\n\r\n arrayHelpers.remove(index)\r\n if (selectedCategory === 'accounts') {\r\n setOldAccountDetails((oldAccountDetails) => {\r\n const newMappingDetails = [...oldAccountDetails];\r\n newMappingDetails.splice(index, 1);\r\n\r\n return newMappingDetails;\r\n });\r\n }\r\n if (selectedCategory === 'services') {\r\n setOldServiceDetails((oldServiceDetails) => {\r\n const newMappingDetails = [...oldServiceDetails];\r\n newMappingDetails.splice(index, 1);\r\n\r\n return newMappingDetails;\r\n });\r\n }\r\n setshowDeleteConfirmationDialog(false);\r\n }\r\n const pushToParcelDetails = (arrayHelpers) => {\r\n if (formikValues.mapFrom === \"\" || formikValues.mapFrom === undefined) {\r\n let errors_object = {};\r\n errors_object.mapFrom = \"Map from field is required\";\r\n setFieldTouched('mapFrom', true);\r\n setErrors(errors_object);\r\n return;\r\n }\r\n _isUpdatingFlag(true)\r\n const rowDetails = {\r\n mapFrom: formikValues.mapFrom,\r\n mappedTo: selectedCategory === 'accounts' ? formikValues.mapToForAccount.accountId : formikValues.mapTo.name,\r\n };\r\n\r\n setMappingDetails((mappingDetails) => {\r\n const newMappingDetails = [...mappingDetails];\r\n newMappingDetails.push(rowDetails);\r\n\r\n return newMappingDetails;\r\n });\r\n arrayHelpers.push(rowDetails);\r\n\r\n if (selectedCategory === 'accounts') {\r\n setOldAccountDetails((oldAccountDetails) => {\r\n const newMappingDetails = [...oldAccountDetails];\r\n newMappingDetails.push(rowDetails);\r\n\r\n return newMappingDetails;\r\n });\r\n }\r\n if (selectedCategory === 'services') {\r\n setOldServiceDetails((oldServiceDetails) => {\r\n const newMappingDetails = [...oldServiceDetails];\r\n newMappingDetails?.push(rowDetails);\r\n\r\n return newMappingDetails;\r\n });\r\n }\r\n resetMapFromTo();\r\n setIsAddButtonDisabled(true);\r\n };\r\n\r\n const resetMapFromTo = () => {\r\n if (selectedCategory === 'accounts') {\r\n setFieldValue('mapFrom', '');\r\n setFieldValue('mapToForAccount', defaultAccounts[0]);\r\n setFieldTouched('mapFrom', false);\r\n }\r\n if (selectedCategory === 'services') {\r\n setFieldValue('mapFrom', '');\r\n setFieldValue('mapTo', defaultServices[0]);\r\n setFieldTouched('mapFrom', false);\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n _isUpdatingFlag(true)\r\n isMarketplaceMapping ? setFieldValue('mapCategory', mappingCategoryForMarketplaces[0]) : setFieldValue('mapCategory', mappingCategoryByOptions[0]);\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (formikValues.mapCategory && formikValues.mapCategory.value === '') {\r\n setFieldValue('mappingDetails', []);\r\n setMappingTo([])\r\n setFieldValue('mapFrom', '');\r\n setFieldValue('mapTo', { name: 'Select', value: '0' });\r\n setFieldValue('mapToForAccount', { name: 'Select', value: '0' });\r\n setSelectedCategory('select')\r\n setFieldTouched('mapFrom', false);\r\n }\r\n if (formikValues.mapCategory && formikValues.mapCategory.value === 'accounts') {\r\n setFieldValue('mappingDetails', oldAccountDetails);\r\n setMappingTo(defaultAccounts)\r\n setSelectedCategory('accounts')\r\n }\r\n if (formikValues.mapCategory && formikValues.mapCategory.value === 'services') {\r\n setFieldValue('mappingDetails', oldServiceDetails);\r\n setMappingTo(defaultServices)\r\n setSelectedCategory('services')\r\n }\r\n }, [formikValues.mapCategory]);\r\n\r\n useEffect(()=>{\r\n if (isMarketplaceMapping && formikValues?.marketPlacesAvailable?.marketplaceName && formikValues.mapCategory && formikValues.mapCategory.value === 'services') {\r\n setFieldValue('mappingDetails', mappedServices);\r\n setMappingTo(defaultServices)\r\n setSelectedCategory('services')\r\n }\r\n },[mappedServices, formikValues?.marketPlacesAvailable?.marketplaceName]);\r\n\r\n useEffect(() => {\r\n if (formikValues.mapCategory && formikValues.mapCategory.value === '') {\r\n setFieldValue('mapTo', { name: 'Select', value: '0' });\r\n }\r\n if (formikValues.mapCategory && formikValues.mapCategory.value === 'accounts') {\r\n setFieldValue('mapToForAccount', defaultAccounts[0]);\r\n }\r\n if (formikValues.mapCategory && formikValues.mapCategory.value === 'services') {\r\n setFieldValue('mapTo', defaultServices[0]);\r\n }\r\n }, [mappingTo]);\r\n\r\n const handleDialogClose = () => {\r\n setshowDeleteConfirmationDialog(false)\r\n }\r\n\r\n return (\r\n \r\n {\r\n const mappingDetails = formikValues.mappingDetails;\r\n return (\r\n \r\n \r\n \r\n Add/edit mapping \r\n
\r\n \r\n {isMarketplaceMapping ? \r\n \r\n \r\n \r\n : ''}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {selectedCategory === 'accounts'\r\n? \r\n : }\r\n \r\n \r\n \r\n pushToParcelDetails(arrayHelpers)}\r\n buttonType=\"submit\"\r\n label=\"Add\"\r\n isDisabled={isAddButtonDisabled}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Map from \r\n \r\n \r\n Map to \r\n \r\n \r\n \r\n \r\n \r\n {(mappingDetails || [])?.map((row, index) => (\r\n \r\n {row.mapFrom} \r\n {row.mappedTo} \r\n \r\n deleteMappedDetails(arrayHelpers, index)}>\r\n \r\n \r\n \r\n \r\n ))}\r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n saveNewMappings(oldAccountDetails, oldServiceDetails, formikValues)}\r\n buttonType=\"submit\"\r\n label=\"OK\"\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n }}\r\n />\r\n \r\n );\r\n};\r\n\r\nAddMapping.propTypes = {\r\n saveNewMappings: PropTypes.func.isRequired,\r\n formikValues: PropTypes.object,\r\n setFieldValue: PropTypes.func,\r\n};\r\n\r\nexport default AddMapping;\r\n","import React, { useEffect, useState } from 'react';\r\nimport { Form, Formik } from 'formik';\r\nimport { Grid, IconButton, SvgIcon, Snackbar } from '@material-ui/core';\r\nimport OrderFile from './orderFile';\r\nimport CustomModal from '../../../../framework/modal/modal';\r\nimport { ReactComponent as EditIcon } from '../../../../assets/images/EditIcon.svg';\r\nimport { getYupSchemaFromMetaData } from '../../../../utils/yupSchema/yupSchemaGenerator';\r\nimport orderFileMappingForm from '../../../../utils/formConfig/configuration/orderFileMappingForm/orderFileMappingForm';\r\nimport { useDispatch, useSelector } from 'react-redux';\r\nimport { ServiceEndPoints } from '../../../../utils/constants/ApiConstant';\r\nimport AddMapping from './addMapping';\r\nimport ConfirmationDialog from '../../../addressBook/confirmation/confirmation';\r\nimport InputButton from '../../../../framework/Inputs/inputButton/inputButton';\r\nimport { getCustomerAccountID, customTableSort } from '../../../../utils/helperFunctions';\r\nimport { axiosConfig } from '../../../../api/axios';\r\nimport * as actions from '../../../../store/actions/index';\r\n\r\nconst OrderFileMapping = (props) => {\r\n const tableColumns = [\r\n { title: 'Map from', field: 'mapFrom', width: '30%', customSort: (a, b) => customTableSort(a.mapFrom, b.mapFrom) },\r\n { title: 'Mapped to', field: 'mappedTo', sorting: false, width: '57%' },\r\n ];\r\n let userAccounts = useSelector((state) => state?.accounts?.nonReturnuserAccounts ?? []);\r\n\r\n const { formId, formField } = orderFileMappingForm;\r\n const orderFileMappingSchema = getYupSchemaFromMetaData(formField, [], []);\r\n const initialValues = {};\r\n\r\n const [columns, setColumns] = useState(tableColumns);\r\n\r\n const [accounts, setAccounts] = useState([]);\r\n const [services, setServices] = useState([]);\r\n const [mappingAccounts, setMappingAccounts] = useState([]);\r\n const [mappingServices, setMappingServices] = useState([]);\r\n\r\n const [isDialogOpen, setIsDialogOpen] = useState(false);\r\n const [mappedOrderDefault, setMappedOrderDefault] = React.useState({});\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n const [isUpdating_Flag, setisUpdating_Flag] = useState(false);\r\n\r\n const dispatch = useDispatch();\r\n\r\n useEffect(() => {\r\n getInitialValues();\r\n }, []);\r\n\r\n const handleDialogClose = (setFieldTouched, setFieldValue) => {\r\n setFieldValue('mapFrom','');\r\n setFieldTouched('mapFrom',false);\r\n if (isUpdating_Flag) {\r\n setisUpdating_Flag(false);\r\n setShowConfirmationDialog(true);\r\n } else {\r\n setIsDialogOpen(false);\r\n }\r\n };\r\n\r\n const setDialogOpen = () => {\r\n setIsDialogOpen(true);\r\n };\r\n\r\n const handleConfirmClose = () => {\r\n setIsDialogOpen(true)\r\n setShowConfirmationDialog(false);\r\n setisUpdating_Flag(true);\r\n };\r\n const onDialogConfirm = () => {\r\n setIsDialogOpen(false);\r\n setShowConfirmationDialog(false);\r\n };\r\n\r\n const getInitialValues = () => {\r\n axiosConfig\r\n .get(`${ServiceEndPoints.getMappedServices}`)\r\n .then((response) => {\r\n const output = response.data.map(({ code, longDescription }) => ({ name: longDescription, value: code }));\r\n setServices(output);\r\n })\r\n .catch((err) => {\r\n setServices([]);\r\n });\r\n\r\n axiosConfig\r\n .get(`${ServiceEndPoints.getOrderDefaults}?organization=${getCustomerAccountID()}`)\r\n .then((response) => {\r\n setMappedOrderDefault(response.data);\r\n })\r\n .catch((err) => {\r\n setMappedOrderDefault([]);\r\n });\r\n const output = userAccounts\r\n setAccounts(output);\r\n };\r\n useEffect(() => {\r\n if (services && services.length > 0 && mappedOrderDefault && mappedOrderDefault.orderFileMapping) {\r\n if (\r\n mappedOrderDefault.orderFileMapping.servicesMapping &&\r\n mappedOrderDefault.orderFileMapping.servicesMapping.length > 0\r\n ) {\r\n let serviceMap = [];\r\n mappedOrderDefault.orderFileMapping.servicesMapping.map((ser) => {\r\n var mapToName = services.find((serval) => serval.value === ser.mappedTo);\r\n if (mapToName !== undefined) {\r\n const item = {\r\n mapFrom: ser.mapFrom,\r\n mappedTo: mapToName.name,\r\n };\r\n serviceMap.push(item);\r\n }\r\n });\r\n setMappingServices(serviceMap);\r\n }\r\n if (\r\n mappedOrderDefault.orderFileMapping.accountsMapping &&\r\n mappedOrderDefault.orderFileMapping.accountsMapping.length > 0\r\n ) {\r\n setMappingAccounts(mappedOrderDefault.orderFileMapping.accountsMapping);\r\n }\r\n }\r\n }, [services, mappedOrderDefault.orderFileMapping]);\r\n\r\n const saveMappingDetails = (updatedAccounts, updatedServices) => {\r\n setIsDialogOpen(false);\r\n setMappingAccounts(updatedAccounts);\r\n setMappingServices(updatedServices);\r\n };\r\n\r\n const saveServiceAccountMapping = () => {\r\n let accountsMapping = [];\r\n let servicesMapping = [];\r\n mappingAccounts.map((updateMap) => {\r\n const item = {\r\n mapFrom: updateMap.mapFrom,\r\n mappedTo: updateMap.mappedTo,\r\n };\r\n accountsMapping.push(item);\r\n });\r\n mappingServices.map((updateMap) => {\r\n const item = {\r\n mapFrom: updateMap.mapFrom,\r\n mappedTo: services.find((serval) => serval.name === updateMap.mappedTo).value,\r\n };\r\n servicesMapping.push(item);\r\n });\r\n\r\n const objectModel = {\r\n servicesMapping,\r\n accountsMapping,\r\n };\r\n\r\n axiosConfig\r\n .patch(`${ServiceEndPoints.postOrderMapping}?organization=${getCustomerAccountID()}`, objectModel)\r\n .then((response) => {\r\n dispatch(actions.setAppSnackBarData({ msg: 'Order file mapping saved successfully' }));\r\n })\r\n .catch((error) => {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Mappings not saved in database, please try again.',\r\n },\r\n ],\r\n }),\r\n );\r\n // dispatch(actions.setAppSnackBarData({type:\"error\", msg:'Mappings not saved in database, please try again.'}))\r\n });\r\n };\r\n const _isUpdatingFlag = (flag) => {\r\n setisUpdating_Flag(flag);\r\n };\r\n return (\r\n \r\n \r\n {({ values, setFieldValue, setFieldError, setFieldTouched, setErrors, errors, resetForm }) => (\r\n \r\n )}\r\n \r\n \r\n );\r\n};\r\n\r\nexport default OrderFileMapping;\r\n","const OrderSetupForm = {\r\n formId: 'orderSetupForm',\r\n formField: {\r\n overWriteSameCustomerRef: {\r\n props: {\r\n name: 'overWriteSameCustomerRef',\r\n label: '',\r\n type: 'checkbox',\r\n labelPlacement: 'start',\r\n },\r\n value: false,\r\n },\r\n overWriteSameAltRef: {\r\n props: {\r\n name: 'overWriteSameAltRef',\r\n label: '',\r\n type: 'checkbox',\r\n labelPlacement: 'start',\r\n },\r\n value: false,\r\n },\r\n autoPostCollection: {\r\n props: {\r\n name: 'autoPostCollection',\r\n label: '',\r\n type: 'checkbox',\r\n labelPlacement: 'start',\r\n },\r\n value: false,\r\n },\r\n includeOrderDefaults: {\r\n props: {\r\n name: 'includeOrderDefaults',\r\n label: '',\r\n type: 'checkbox',\r\n labelPlacement: 'start',\r\n },\r\n value: false,\r\n },\r\n includeOrderMapping: {\r\n props: {\r\n name: 'includeOrderMapping',\r\n label: '',\r\n type: 'checkbox',\r\n labelPlacement: 'start',\r\n },\r\n value: false,\r\n },\r\n\r\n autoUpdateDomesticService: {\r\n props: {\r\n name: 'autoUpdateDomesticService',\r\n label: '',\r\n type: 'checkbox',\r\n labelPlacement: 'start',\r\n },\r\n value: false,\r\n },\r\n refreshOrderGridOnScanAndPrint: {\r\n props: {\r\n name: 'refreshOrderGridOnScanAndPrint',\r\n label: '',\r\n type: 'checkbox',\r\n labelPlacement: 'start',\r\n },\r\n value: false,\r\n },\r\n includeMarketplaceDefaults: {\r\n props: {\r\n name: 'includeMarketplaceDefaults',\r\n label: '',\r\n type: 'checkbox',\r\n labelPlacement: 'start',\r\n },\r\n value: false,\r\n },\r\n includeMarketplaceMapping: {\r\n props: {\r\n name: 'includeMarketplaceMapping',\r\n label: '',\r\n type: 'checkbox',\r\n labelPlacement: 'start',\r\n },\r\n value: false,\r\n },\r\n\r\n transferAction: {\r\n props: {\r\n name: 'transferAction',\r\n label: '',\r\n type: 'radio',\r\n },\r\n value: 'transferToHoldingArea',\r\n },\r\n\r\n pollingInterval: {\r\n props: {\r\n name: 'pollingInterval',\r\n label: 'Duration (in seconds)',\r\n type: 'text',\r\n inputProps: {\r\n min: 1,\r\n\r\n },\r\n },\r\n value: '10',\r\n validation: {\r\n name: 'pollingInterval',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'min',\r\n params: [1, 'Polling interval cannot be less than 1 second'],\r\n },\r\n {\r\n type: 'required',\r\n params: ['Polling interval is required'],\r\n },\r\n {\r\n type: 'integer',\r\n params: ['Polling interval must be a natural number'],\r\n },\r\n ],\r\n },\r\n },\r\n\r\n shipmentConfirmation: {\r\n props: {\r\n name: 'shipmentConfirmation',\r\n label: '',\r\n type: 'checkbox',\r\n labelPlacement: 'start',\r\n },\r\n value: false,\r\n },\r\n\r\n outputExportDirectory: {\r\n props: {\r\n name: 'outputExportDirectory',\r\n label: 'Export shipment confirmation file to',\r\n type: 'text',\r\n placeholder: 'Enter folder path',\r\n },\r\n value: \"\",\r\n validation: {\r\n name: 'outputExportDirectory',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n ['shipmentConfirmation'],\r\n (shipmentConfirmation, schema) => {\r\n if (shipmentConfirmation) {\r\n return schema.required('File output path is required');\r\n }\r\n }\r\n ]\r\n },\r\n ],\r\n },\r\n },\r\n manualShipmentConfirmation: {\r\n props: {\r\n name: 'manualShipmentConfirmation',\r\n label: '',\r\n type: 'checkbox',\r\n labelPlacement: 'start',\r\n },\r\n value: false,\r\n },\r\n delimiter: {\r\n props: {\r\n name: 'delimiter',\r\n label: 'Delimiter',\r\n type: 'select',\r\n displayField: 'name',\r\n hasDefaultValue: true,\r\n },\r\n validation: {\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Delimiter is required'],\r\n }\r\n ],\r\n },\r\n },\r\n newDelimeter: {\r\n props: {\r\n name: 'newDelimeter',\r\n label: 'Enter the delimeter',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n isRequired: true,\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Delimiter is required'],\r\n },\r\n ],\r\n },\r\n },\r\n fileExtension: {\r\n props: {\r\n name: 'fileExtension',\r\n label: 'File Extension',\r\n type: 'text',\r\n isRequired: true,\r\n placeholder: \"*.txt\",\r\n },\r\n validation: {\r\n name: 'fileExtension',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['File extension is required'],\r\n },\r\n {\r\n type: 'matches',\r\n params: [/^[a-zA-z0-9*]*(\\d*\\.\\d*)[a-zA-z]{1,5}$/, 'File extension must be in correct format e.g. *.txt or *.csv'],\r\n },\r\n ],\r\n },\r\n },\r\n },\r\n};\r\n\r\nexport default OrderSetupForm;\r\n","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from \"react\";\n\nvar _ref2 = /*#__PURE__*/React.createElement(\"g\", {\n id: \"Group_23651\",\n \"data-name\": \"Group 23651\",\n transform: \"translate(-448.096 -330.895)\"\n}, /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_43077\",\n \"data-name\": \"Path 43077\",\n d: \"M464.7,331.678a1.156,1.156,0,0,0-1.145-.6q-7.159.024-14.318,0a1.167,1.167,0,0,0-1.142.6c0-.769,0-.769.772-.769,5.084,0,10.169.009,15.253-.014.5,0,.687.1.581.591A.933.933,0,0,0,464.7,331.678Z\",\n fill: \"#fdfdfd\"\n}), /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_43078\",\n \"data-name\": \"Path 43078\",\n d: \"M618.706,379.664c-.153-.1-.094-.26-.094-.395q0-4.527,0-9.053c0-.153-.053-.324.094-.449Z\",\n transform: \"translate(-154.006 -35.111)\",\n fill: \"#2b2b2b\"\n}), /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_43079\",\n \"data-name\": \"Path 43079\",\n d: \"M448.1,370.76c.148.125.094.3.094.449q0,4.452,0,8.9c0,.152.058.324-.094.447Z\",\n transform: \"translate(0 -36.008)\",\n fill: \"#0e0e0e\"\n}), /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_43080\",\n \"data-name\": \"Path 43080\",\n d: \"M618.593,346.961a4.39,4.39,0,0,1,0-2.018Z\",\n transform: \"translate(-153.893 -12.689)\",\n fill: \"#2a2a2a\"\n}), /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_43081\",\n \"data-name\": \"Path 43081\",\n d: \"M464.7,332.708c-.24-.61-.327-.672-1-.672q-7.305,0-14.611,0c-.67,0-.756.061-1,.672v3.075a.6.6,0,0,1,.048.373q0,4.528,0,9.056a.6.6,0,0,1-.048.373v.1c.194.573.669.689,1.188.7.8.018,1.607.03,2.409,0,.611-.025,1.154.023,1.484.627a.758.758,0,0,0,.213.193,4.243,4.243,0,0,0,4.98.51.514.514,0,0,1,.716.1c.363.384.744.752,1.121,1.122a.841.841,0,0,0,.685.151.568.568,0,0,0,.458-.849,1.5,1.5,0,0,0-.3-.371c-.338-.342-.685-.676-1.019-1.021-.087-.09-.221-.184-.175-.319.058-.171.24-.129.376-.131.787-.008,1.575,0,2.362-.005a7.655,7.655,0,0,0,1.2-.039.979.979,0,0,0,.905-.669v-.1a.6.6,0,0,1-.048-.373q0-4.576,0-9.152a.6.6,0,0,1,.048-.373V335.3a8.251,8.251,0,0,1,0-2.018Zm-8.5,14.316a2.99,2.99,0,1,1,.072-5.979,2.99,2.99,0,0,1-.072,5.979Zm6.978-1.925c-.962-.027-1.925-.009-2.894-.009a4.161,4.161,0,1,0-8.145-.445c.06.352-.005.472-.393.453-.706-.035-1.415-.022-2.122,0-.279.007-.395-.044-.393-.36q.021-4.177.005-8.354c0-.291.105-.331.36-.331q6.8.01,13.6,0c.312,0,.364.1.363.379q-.015,4.129,0,8.258C463.563,344.972,463.525,345.11,463.177,345.1Zm.307-10.252c-.234.231-.732.066-1.114.068-1.979.007-3.958,0-5.937,0-2.252,0-4.5-.009-6.757.01-.364,0-.486-.086-.439-.445.052-.406-.18-.951.1-1.189.236-.2.764-.073,1.163-.073,4.183,0,8.366.007,12.549-.014.446,0,.561.128.512.535C463.515,334.118,463.717,334.617,463.484,334.848Z\",\n transform: \"translate(0 -1.031)\"\n}));\n\nfunction SvgChooseIcon(_ref, svgRef) {\n var title = _ref.title,\n titleId = _ref.titleId,\n props = _objectWithoutProperties(_ref, [\"title\", \"titleId\"]);\n\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 16.635,\n height: 17.171,\n viewBox: \"0 0 16.635 17.171\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, _ref2);\n}\n\nvar ForwardRef = /*#__PURE__*/React.forwardRef(SvgChooseIcon);\nexport default __webpack_public_path__ + \"static/media/ChooseIcon.e53c89c3.svg\";\nexport { ForwardRef as ReactComponent };","import { useEffect, React } from 'react';\r\nimport { Grid, Tab, Tabs, Box } from '@material-ui/core';\r\nimport SchemaMaterialTable from '../createNewSchema/SchemaMaterialTable';\r\nimport { sortBasedOnNestedOrNot, setDropdownValues } from '../../../../utils/helperFunctions';\r\nimport FormRenderer from '../../../../framework/Inputs/formRenderer/formRenderer';\r\n\r\nconst OutputFile = (props) => {\r\n const { dragFromValues, dragToValues, setDragToValues, setDragFromValues, formField, formikValues, setFieldValue } = props;\r\n\r\n const leftSideColumns = [\r\n {\r\n title: 'Available fields', field: 'name', render: (row) => \r\n {row.name} {row.isRequiredField ? ** : ''}\r\n
\r\n }\r\n ];\r\n\r\n const rightSideColumns = [\r\n {\r\n title: 'Selected fields', field: 'name', render: (row) => \r\n {row.name} {row.isRequiredField ? ** : ''}\r\n
\r\n }\r\n ];\r\n\r\n const removeFromFields = (selecteddata) => {\r\n const toValues = [...dragToValues];\r\n const fromValues = [...dragFromValues];\r\n\r\n const itemsToBeDeleted = selecteddata.map((address) => {\r\n toValues.push(address);\r\n setDragToValues(toValues);\r\n const filteredValue = fromValues.indexOf(address);\r\n fromValues.splice(filteredValue, 1);\r\n\r\n });\r\n setDragFromValues(sortBasedOnNestedOrNot(fromValues, \"name\"));\r\n };\r\n\r\n const removeFromImportFiles = (selecteddata) => {\r\n const fromValues = [...dragFromValues];\r\n\r\n const toValues = [...dragToValues];\r\n const itemsToBeDeleted = selecteddata.map((address) => {\r\n fromValues.push(address);\r\n setDragFromValues(sortBasedOnNestedOrNot(fromValues, \"name\"));\r\n const filteredValue = toValues.indexOf(address);\r\n toValues.splice(filteredValue, 1);\r\n });\r\n setDragToValues(toValues);\r\n };\r\n\r\n useEffect(() => {\r\n setDragFromValues(sortBasedOnNestedOrNot(props.outputFileValues, \"name\"));\r\n setDragToValues(props.selectedOutputFileValues);\r\n dragFromValues.map((row) => {\r\n row.tableData.checked = false\r\n });\r\n dragToValues.map((row) => {\r\n row.tableData.checked = false\r\n });\r\n setFieldValue('manualShipmentConfirmation', false);\r\n }, [])\r\n\r\n useEffect(() => {\r\n if (formikValues.manualShipmentConfirmation === false) {\r\n setFieldValue('fileExtension', '');\r\n setFieldValue('delimiter', setDropdownValues(delimiterOptions, 'value', delimiterOptions[0].value));\r\n setFieldValue('newDelimeter', '');\r\n }\r\n if (formikValues.delimiter?.value === 'otherDelimiter') {\r\n setFieldValue('newDelimeter', '');\r\n }\r\n }, [formikValues.manualShipmentConfirmation, formikValues.delimiter])\r\n\r\n return (\r\n \r\n\r\n \r\n \r\n Produce shipment confirmation for manually created shipments \r\n \r\n \r\n \r\n \r\n \r\n {formikValues.manualShipmentConfirmation ? <>\r\n \r\n \r\n {formikValues.delimiter?.value === 'otherDelimiter' ? : ''} \r\n > : ''}\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nexport default OutputFile;\r\n\r\nexport const delimiterOptions = [\r\n {\r\n value: ',',\r\n name: 'Comma',\r\n },\r\n {\r\n value: '~',\r\n name: 'Tilde',\r\n },\r\n {\r\n value: '|',\r\n name: 'Pipe',\r\n },\r\n {\r\n value: '\\\\t',\r\n name: 'Tab',\r\n },\r\n {\r\n value: ';',\r\n name: 'Semicolon',\r\n },\r\n {\r\n value: 'otherDelimiter',\r\n name: 'Other',\r\n },\r\n];\r\n\r\n","import React, { useState, useEffect, useRef } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, Divider, Checkbox, Box} from '@material-ui/core';\r\nimport CustomAccordion from '../../../../framework/accordion/customAccordion';\r\nimport OrderSetupForm from '../../../../utils/formConfig/configuration/orderSetupForm/orderSetupForm';\r\nimport { Form, Formik } from 'formik';\r\nimport { GET, POST } from '../../../../api/axios';\r\nimport FormRenderer from '../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport DynamicMaterialTable from '../../../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\nimport InputButton from '../../../../framework/Inputs/inputButton/inputButton';\r\nimport { ReactComponent as ChooseIcon } from '../../../../../src/assets/images/ChooseIcon.svg';\r\nimport { SearchIcon } from '@material-ui/data-grid';\r\nimport { reverseTransferActionTypes, constantTransferActionTypes, MISC_VALUES } from '../../../../utils/constants/constants';\r\nimport { getCustomerAccountID, sortBasedOnNestedOrNot, customTableSort, setDropdownValues } from '../../../../utils/helperFunctions';\r\nimport './orderSetup.scss';\r\nimport '../../../../styles/styles.scss';\r\nimport { getYupSchemaFromMetaData } from '../../../../utils/yupSchema/yupSchemaGenerator';\r\nimport { ServiceEndPoints } from '../../../../utils/constants/ApiConstant';\r\nimport * as actions from \"../../../../store/actions/index\"\r\nimport { useDispatch, connect} from 'react-redux';\r\nimport ConfirmationDialog from '../../../addressBook/confirmation/confirmation';\r\nimport CustomModal from '../../../../framework/dialog/customDialog';\r\nimport OutputFile from './outputFile';\r\n\r\nconst { formField } = OrderSetupForm;\r\nlet reqFields = [];\r\nconst OrderSetup = (props) => {\r\n const initialValues = {};\r\n const formikRef = useRef(null);\r\n const [orderSetupResponse, setOrderSetupResponse] = useState({});\r\n const [activeSchemas, setActiveSchemas] = useState([]);\r\n const orderSetupValidationSchema = getYupSchemaFromMetaData(formField, [], []);\r\n const [dragToValues, setDragToValues] = useState(selectedOutputFileValues);\r\n const [dragFromValues, setDragFromValues] = useState(sortBasedOnNestedOrNot(outputFileValues, \"name\"));\r\n\r\n for (let property in formField) {\r\n if (Object.prototype.hasOwnProperty.call(formField, property)) {\r\n const field = formField[property];\r\n if (field.props.type === MISC_VALUES.CHECKBOX || field.props.type === MISC_VALUES.RADIO) {\r\n initialValues[field.props.name] = field.value;\r\n } else if (field.props.type === MISC_VALUES.ARRAY) {\r\n initialValues[field.props.name] = field.values;\r\n } else {\r\n initialValues[field.props.name] = field.value || '';\r\n }\r\n }\r\n }\r\n\r\n const dispatch = useDispatch();\r\n\r\n const columns = [\r\n {\r\n title: 'Schema name',\r\n field: 'schemaName',\r\n customSort: (a, b) => customTableSort(a.schemaName, b.schemaName),\r\n width: 150,\r\n },\r\n {\r\n title: 'Schema type',\r\n field: 'schemaType',\r\n customSort: (a, b) => customTableSort(a.schemaType, b.schemaType),\r\n width: 100,\r\n },\r\n {\r\n title: 'File polling folder',\r\n field: 'filePollingFolder',\r\n customSort: (a, b) => customTableSort(a.filePollingFolder, b.filePollingFolder),\r\n width: 350,\r\n },\r\n {\r\n title: 'Is enabled?',\r\n field: 'isEnabled',\r\n sorting: false,\r\n width: 100,\r\n cellStyle: {\r\n textAlign: 'center'\r\n },\r\n render: (row) => (\r\n \r\n handleChange(event, row)} />\r\n
\r\n ),\r\n },\r\n ];\r\n\r\n\r\n const handleChange = (event, row) => {\r\n const tableData = [...activeSchemas];\r\n (tableData[row?.tableData?.id] || {}).isEnabled = event.target.checked;\r\n setActiveSchemas(tableData);\r\n };\r\n\r\n useEffect(() => {\r\n getOrderSetupResponse();\r\n }, []);\r\n\r\n const getOrderSetupResponse = () => {\r\n GET(`${ServiceEndPoints.orderSetup}?organization=${getCustomerAccountID()}`)\r\n .then((res) => {\r\n setOrderSetupResponse(res.data);\r\n sortBasedOnNestedOrNot(res.data?.schemas || [], 'schemaName', false);\r\n setActiveSchemas(res.data.schemas || []);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n setOrderSetupResponse({});\r\n setActiveSchemas([]);\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n var outputFileSetUpValues = {\r\n outputExportDirectory: orderSetupResponse.outputFileSetUp?.outputExportDirectory,\r\n shipmentConfirmation: orderSetupResponse.outputFileSetUp?.shipmentConfirmation,\r\n }\r\n formikRef.current.setValues({\r\n ...formikRef.current.values,\r\n ...orderSetupResponse.importsSetup,\r\n // ...orderSetupResponse.outputFileSetUp,\r\n ...outputFileSetUpValues,\r\n transferAction:\r\n constantTransferActionTypes[orderSetupResponse?.importsSetup?.transferAction] || 'transferToHoldingArea',\r\n });\r\n props.setAutoReloadProcessOrders(orderSetupResponse.importsSetup?.refreshOrderGridOnScanAndPrint);\r\n if (orderSetupResponse.outputFileSetUp?.selectedOutputFileValues?.length > 0) {\r\n let selectedOutputValues = orderSetupResponse.outputFileSetUp.selectedOutputFileValues;\r\n let availableOutputValues = [];\r\n let dragFromValuesResp = [];\r\n // selectedOutputValues = dragToValues.filter((ele) => (selectedOutputValues.map((val) => val.valueName).includes(ele.valueName))).concat(dragFromValues.filter((ele) => (selectedOutputValues.map((val) => val.valueName).includes(ele.valueName))));\r\n availableOutputValues = dragToValues.filter((ele) => !(selectedOutputValues.map((val) => val.valueName).includes(ele.valueName)));\r\n dragFromValuesResp = dragFromValues.filter((ele) => !(selectedOutputValues.map((val) => val.valueName).includes(ele.valueName)));\r\n setTimeout(() => {\r\n setDragToValues(selectedOutputValues);\r\n setDragFromValues(sortBasedOnNestedOrNot(availableOutputValues.concat(dragFromValuesResp), \"name\"));\r\n }, 0);\r\n }\r\n else {\r\n setDragToValues(selectedOutputFileValues);\r\n setDragFromValues(sortBasedOnNestedOrNot(outputFileValues, \"name\"));\r\n }\r\n if (orderSetupResponse.outputFileSetUp?.manualShipment) {\r\n setTimeout(() => {\r\n formikRef.current?.setFieldValue('manualShipmentConfirmation', orderSetupResponse.outputFileSetUp?.manualShipment);\r\n formikRef.current?.setFieldValue('fileExtension', orderSetupResponse.outputFileSetUp?.fileExtension);\r\n if ((delimiterOptions.map((ele) => ele.value).includes(orderSetupResponse.outputFileSetUp?.delimiter))) {\r\n formikRef.current?.setFieldValue('delimiter', setDropdownValues(delimiterOptions, 'value', delimiterOptions.filter((val) => val.value === orderSetupResponse.outputFileSetUp?.delimiter)[0].value));\r\n }\r\n else {\r\n formikRef.current?.setFieldValue('delimiter', setDropdownValues(delimiterOptions, 'value', 'otherDelimiter'));\r\n formikRef.current?.setFieldValue('newDelimeter', orderSetupResponse.outputFileSetUp?.delimiter);\r\n }\r\n }, 0);\r\n }\r\n }, [orderSetupResponse]);\r\n\r\n const isFormInValid = (errors, values, setFieldTouched) => {\r\n let clonedReqFields = [...reqFields];\r\n if (values.shipmentConfirmation) {\r\n clonedReqFields.push('outputExportDirectory')\r\n setFieldTouched('outputExportDirectory',true);\r\n if (values.manualShipmentConfirmation) {\r\n clonedReqFields.push('fileExtension');\r\n setFieldTouched('fileExtension',true);\r\n if (values.delimiter.value === 'otherDelimiter') {\r\n clonedReqFields.push('newDelimeter');\r\n setFieldTouched('newDelimeter',true);\r\n }\r\n }\r\n }\r\n for (let err in errors) {\r\n if (clonedReqFields.some((fieldName) => fieldName === err)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n const handleSubmit = (values, errors ,setFieldTouched) => {\r\n if (!isFormInValid(errors, values, setFieldTouched)) {\r\n const formikValues = formikRef.current.values;\r\n const reqObj = {\r\n organization: getCustomerAccountID(),\r\n importsSetup: {\r\n overWriteSameCustomerRef: formikValues.overWriteSameCustomerRef,\r\n overWriteSameAltRef: formikValues.overWriteSameAltRef,\r\n autoPostCollection: formikValues.autoPostCollection,\r\n includeOrderDefaults: formikValues.includeOrderDefaults,\r\n includeOrderMapping: formikValues.includeOrderMapping,\r\n autoUpdateDomesticService: formikValues.autoUpdateDomesticService,\r\n refreshOrderGridOnScanAndPrint: formikValues.refreshOrderGridOnScanAndPrint,\r\n includeMarketplaceDefaults: formikValues.includeMarketplaceDefaults,\r\n includeMarketplaceMapping: formikValues.includeMarketplaceMapping,\r\n transferAction: reverseTransferActionTypes[formikValues.transferAction],\r\n pollingInterval: parseInt(formikValues.pollingInterval),\r\n },\r\n outputFileSetUp: {\r\n shipmentConfirmation: formikValues.shipmentConfirmation,\r\n manualShipment: formikValues.shipmentConfirmation ? formikValues.manualShipmentConfirmation : false,\r\n fileExtension: formikValues.shipmentConfirmation ? formikValues.manualShipmentConfirmation ? formikValues.fileExtension : null : null,\r\n delimiter: formikValues.shipmentConfirmation ? formikValues.manualShipmentConfirmation ? formikValues.delimiter.value === 'otherDelimiter' ? formikValues?.newDelimeter.toString() : formikValues.delimiter.value : null : null,\r\n outputExportDirectory: formikValues.outputExportDirectory,\r\n selectedOutputFileValues: formikValues.shipmentConfirmation === true ? dragToValues : [],\r\n },\r\n schemas: [...activeSchemas],\r\n };\r\n POST(`${ServiceEndPoints.orderSetup}`, reqObj)\r\n .then((res) => {\r\n dispatch(actions.setAppSnackBarData({ msg: \"Order setup saved successfully\" }))\r\n getOrderSetupResponse();\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n } else {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [{ type: 'error', msg: 'The form has errors, please correct and try again' }],\r\n }),\r\n );\r\n }\r\n };\r\n const [overWriteCustomerRef, setOverWriteCustomerRef] = useState();\r\n const [overWriteAltRef, setOverWriteAltRef] = useState();\r\n const [currentSelected, setCurrentSelected] = useState(\"\");\r\n const [canShowPopupCustomerRef, setCanShowPopupCustomerRef] = useState(false);\r\n const [canShowPopupAltRef, setCanShowPopupAltRef] = useState(false);\r\n\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n useEffect(() => {\r\n if (!orderSetupResponse?.importsSetup?.overWriteSameCustomerRef && overWriteCustomerRef) {\r\n setCanShowPopupCustomerRef(true)\r\n }\r\n else {\r\n if (!overWriteCustomerRef && (canShowPopupCustomerRef || orderSetupResponse?.importsSetup?.overWriteSameCustomerRef)) {\r\n setCurrentSelected(\"overWriteSameCustomerRef\");\r\n setShowConfirmationDialog(true)\r\n }\r\n setCanShowPopupCustomerRef(false);\r\n }\r\n\r\n\r\n }, [overWriteCustomerRef])\r\n\r\n useEffect(() => {\r\n if (!orderSetupResponse?.importsSetup?.overWriteSameAltRef && overWriteAltRef) {\r\n setCanShowPopupAltRef(true)\r\n }\r\n else {\r\n if (!overWriteAltRef && (canShowPopupAltRef || orderSetupResponse?.importsSetup?.overWriteSameAltRef)) {\r\n setCurrentSelected(\"overWriteSameAltRef\");\r\n setShowConfirmationDialog(true)\r\n }\r\n setCanShowPopupAltRef(false)\r\n }\r\n\r\n }, [overWriteAltRef])\r\n\r\n const handleDialogClose = () => {\r\n setShowConfirmationDialog(false);\r\n formikRef.current.setFieldValue(currentSelected, true)\r\n\r\n }\r\n\r\n const onDialogConfirm = () => {\r\n setShowConfirmationDialog(false);\r\n }\r\n\r\n return (\r\n \r\n \r\n {({ values, errors, setFieldValue, setFieldTouched }) => {\r\n setOverWriteCustomerRef(values.overWriteSameCustomerRef);\r\n setOverWriteAltRef(values.overWriteSameAltRef);\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Overwrite in queue with same customer. ref \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Overwrite in queue with same alt ref \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Automatically post collections \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Include order defaults \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Include order mapping \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Auto update to the best service if chosen service is not available \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Auto refresh orders grid for scan and print \r\n \r\n \r\n \r\n \r\n \r\n {props.isMarketplaceAccount && <> \r\n \r\n Include marketplace defaults \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Include marketplace mapping \r\n \r\n \r\n \r\n \r\n >}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Action to carry out on transfer:\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Polling Interval:\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Produce shipment confirmation \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {values.shipmentConfirmation ? \r\n \r\n : ''}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {\r\n handleSubmit(values, errors, setFieldTouched);\r\n }}\r\n />\r\n \r\n \r\n \r\n )\r\n }}\r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nOrderSetup.propTypes = {};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n setAutoReloadProcessOrders: (autoReloadOrdersFlag) => {\r\n dispatch(actions.setAutoReloadProcessOrders(autoReloadOrdersFlag));\r\n },\r\n };\r\n};\r\nexport default connect(null, mapDispatchToProps)(OrderSetup);\r\n\r\nconst transferActionTypes = [\r\n {\r\n label: 'Transfer to process orders',\r\n value: 'transferToHoldingArea',\r\n },\r\n {\r\n label: 'Post with labels',\r\n value: 'postWithLabels',\r\n },\r\n];\r\n\r\nconst outputFileValues = [\r\n {\r\n valueName: 'accountNumber',\r\n name: 'Account number',\r\n },\r\n {\r\n valueName: 'deliveryType',\r\n name: 'Delivery type',\r\n },\r\n {\r\n valueName: 'specialInstructions',\r\n name: 'Special instructions',\r\n },\r\n {\r\n valueName: 'inBoxReturn',\r\n name: 'Include inbox return label',\r\n },\r\n {\r\n valueName: 'returnCustomerReference',\r\n name: 'Return reference',\r\n },\r\n {\r\n valueName: 'extendedLiability',\r\n name: 'Extended liability',\r\n },\r\n {\r\n valueName: 'product',\r\n name: 'Product',\r\n },\r\n {\r\n valueName: 'service',\r\n name: 'Service',\r\n },\r\n {\r\n valueName: 'what3Words',\r\n name: 'What3Words',\r\n },\r\n {\r\n valueName: 'w3WLat',\r\n name: 'What3Words latitude',\r\n },\r\n {\r\n valueName: 'w3WLong',\r\n name: 'What3Words longitude',\r\n },\r\n {\r\n valueName: 'shipmentMovementType',\r\n name: 'Shipment movement type ',\r\n },\r\n {\r\n valueName: 'sendersUKIMSNumber',\r\n name: `Shipper's UKIMS Number`,\r\n },\r\n {\r\n valueName: 'sendersEORINumber',\r\n name: `Shipper's EORI Number `,\r\n },\r\n {\r\n valueName: 'sendersDefermentAccount',\r\n name: `Shipper's deferment account`,\r\n },\r\n {\r\n valueName: 'recipientEORINumber',\r\n name: 'Recipient EORI Number',\r\n },\r\n {\r\n valueName: 'recipientUKIMSNumber',\r\n name: 'Recipient UKIMS Number',\r\n },\r\n \r\n];\r\n\r\nconst selectedOutputFileValues = [\r\n {\r\n valueName: 'customerReferenceNumber',\r\n name: 'Customer reference',\r\n },\r\n {\r\n valueName: 'shipmentNumber',\r\n name: 'Shipment number',\r\n },\r\n {\r\n valueName: 'alternateReference',\r\n name: 'Alternative reference',\r\n },\r\n {\r\n valueName: 'postCode',\r\n name: 'Postcode',\r\n },\r\n {\r\n valueName: 'businessName',\r\n name: 'Business name',\r\n },\r\n {\r\n valueName: 'contactName',\r\n name: 'Recipient name',\r\n },\r\n {\r\n valueName: 'address1',\r\n name: 'Address line 1',\r\n },\r\n {\r\n valueName: 'items',\r\n name: 'No. of items',\r\n },\r\n {\r\n valueName: 'weight',\r\n name: 'Weight',\r\n },\r\n {\r\n valueName: 'orderedProduct',\r\n name: 'Service code',\r\n },\r\n]\r\n\r\nexport const delimiterOptions = [\r\n {\r\n value: ',',\r\n name: 'Comma',\r\n },\r\n {\r\n value: '~',\r\n name: 'Tilde',\r\n },\r\n {\r\n value: '|',\r\n name: 'Pipe',\r\n },\r\n {\r\n value: '\\\\t',\r\n name: 'Tab',\r\n },\r\n {\r\n value: ';',\r\n name: 'Semicolon',\r\n },\r\n {\r\n value: 'otherDelimiter',\r\n name: 'Other',\r\n },\r\n];","import React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { FieldArray } from 'formik';\r\nimport {\r\n Grid,\r\n TableContainer,\r\n Paper,\r\n Table,\r\n TableHead,\r\n TableRow,\r\n TableCell,\r\n TableBody,\r\n IconButton,\r\n SvgIcon,\r\n} from '@material-ui/core';\r\n\r\nimport { ReactComponent as DeleteIcon } from '../../../../../../assets/images/DeleteIcon.svg'\r\nimport { ReactComponent as EditIcon } from '../../../../../../assets/images/EditIcon.svg';\r\nimport { ReactComponent as AddIcon } from '../../../../../../assets/images/AddIcon.svg';\r\nimport CustomDialog from '../../../../../../framework/dialog/customDialog';\r\nimport AddCommodityDetails from '../../../../../../container/shipment/addShipment/customsDeclaration/addCommodityDetails/addCommodityDetails';\r\nimport './marketplaceCommodityDetails.scss';\r\n\r\nconst MarketplaceCommodityDetails = (props) => {\r\n const {\r\n formField: { commodityDetails },\r\n formikValues,\r\n //errors,\r\n setFieldValue,\r\n // isOrderDefaults,\r\n marketPlacesList\r\n } = props;\r\n\r\n const [open, setOpen] = React.useState(false);\r\n const [modalData, setModalData] = React.useState({});\r\n const [footerValues, setFooterValues] = React.useState({\r\n subTotal: 0,\r\n totalValue: 0,\r\n });\r\n // const [spanIsActive, setspanIsActive] = React.useState(false);\r\n // const [commodityWeight, setcommodityWeight] = React.useState(0);\r\n //var commodityDetails_weight = 0;\r\n const openAddCommodityDetails = () => {\r\n setModalData({\r\n operationType: 'addCommodityDetails',\r\n totalWeight: formikValues.weight,\r\n });\r\n setOpen(true);\r\n };\r\n\r\n const handleClose = () => {\r\n setOpen(false);\r\n };\r\n\r\n const addNewCommodityDetails = (arrayHelpers, values) => {\r\n arrayHelpers.push(values);\r\n setOpen(false);\r\n };\r\n\r\n const updateCommodityDetails = (arrayHelpers, index, values) => {\r\n arrayHelpers.replace(index, values);\r\n setOpen(false);\r\n };\r\n\r\n const openUpdateCommodityDetails = (index, rowDetails) => {\r\n setModalData({\r\n index,\r\n rowDetails,\r\n operationType: 'updateCommodityDetails',\r\n totalWeight: formikValues.weight,\r\n });\r\n setOpen(true);\r\n };\r\n\r\n React.useEffect(() => {\r\n let product = 0;\r\n formikValues.commodityDetails.forEach((commodity) => {\r\n product = commodity.quantity * commodity.unitValue + product;\r\n });\r\n const shippingCharges =\r\n isNaN(parseFloat(formikValues.customDeclarationShippingCharges)) ||\r\n parseFloat(formikValues.customDeclarationShippingCharges) < 0\r\n ? 0\r\n : parseFloat(formikValues.customDeclarationShippingCharges);\r\n const totalValue = parseFloat(product + shippingCharges).toFixed(2); //+ parseFloat(shippingCharges).toFixed(2);\r\n setFooterValues({ subTotal: parseFloat(product).toFixed(2), totalValue: parseFloat(totalValue).toFixed(2) });\r\n setFieldValue('subTotal', parseFloat(product).toFixed(2));\r\n setFieldValue('totalValue', parseFloat(totalValue).toFixed(2));\r\n\r\n // formikValues.commodityDetails.forEach((commodity) => {\r\n // commodityDetails_weight += commodity.quantity * commodity.weight;\r\n // });\r\n // setcommodityWeight(commodityDetails_weight);\r\n // if (parseFloat(commodityDetails_weight) > parseFloat(formikValues.weight || 0) && !isOrderDefaults) {\r\n // setspanIsActive(true);\r\n // }\r\n // else if(isOrderDefaults && parseFloat(commodityDetails_weight) > (parseFloat(formikValues.weight || 0)*(formikValues.noOfItems || 1))){\r\n // setspanIsActive(true);\r\n // } else {\r\n // setspanIsActive(false);\r\n // }\r\n // let totalPiecesWeight = 0;\r\n // formikValues?.intlParcelDetails?.map((piece)=>{\r\n // totalPiecesWeight += parseFloat(piece.weight);\r\n // })\r\n // if(commodityDetails_weight > (formikValues.weight || 0) && !isOrderDefaults){\r\n // setFieldValue(\"totalWeightExceed\",commodityDetails_weight);\r\n // }\r\n // else if(isOrderDefaults && (commodityDetails_weight > ((formikValues.weight || 0)*formikValues.noOfItems))){\r\n // setFieldValue(\"totalWeightExceed\",commodityDetails_weight);\r\n // }\r\n // // else if(totalPiecesWeight > formikValues.weight){\r\n // // setFieldValue(\"totalWeightExceed\",totalPiecesWeight);\r\n // // }\r\n // else{\r\n // setFieldValue(\"totalWeightExceed\",formikValues.weight || 0);\r\n // }\r\n // if(formikValues.reasonForExport?.type === 'documents' && formikValues?.subTotal > 5 ) \r\n // {\r\n // setspanIsActive(true);\r\n // setFieldValue(\"totalWeightExceed\",formikValues.weight+1);\r\n // }\r\n }, [formikValues.commodityDetails, formikValues.customDeclarationShippingCharges, formikValues.weight ,formikValues.noOfItems, formikValues?.subTotal]);\r\n return (\r\n \r\n
{\r\n const commodityItems = formikValues.commodityDetails;\r\n return (\r\n \r\n \r\n \r\n Item details \r\n \r\n \r\n \r\n 19} onClick={openAddCommodityDetails}>\r\n \r\n \r\n Add new\r\n \r\n \r\n {\r\n addNewCommodityDetails(arrayHelpers, values);\r\n }}\r\n updateCommodityDetails={(index, values) => updateCommodityDetails(arrayHelpers, index, values)}\r\n marketPlacesList = {marketPlacesList}\r\n isMarketplacesCommodity = {true}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n SKU number \r\n Marketplace channel \r\n \r\n Commodity code \r\n \r\n \r\n Full description of goods \r\n \r\n \r\n Weight \r\n \r\n \r\n Quantity \r\n \r\n \r\n Unit value \r\n \r\n \r\n Country of origin \r\n \r\n \r\n \r\n \r\n \r\n \r\n {commodityItems.length>0 ? commodityItems.map((row, index) => (\r\n \r\n {row.skuNumber} \r\n {row?.marketplaceChannel?.marketplaceName} \r\n \r\n {row.commodityCode}\r\n \r\n {row.fullDescriptionOfGoods} \r\n {row.weight} kg \r\n {row.quantity} \r\n {row.unitValue} \r\n {row.countryOfOrigin?.name} \r\n \r\n openUpdateCommodityDetails(index, row)}>\r\n \r\n \r\n \r\n \r\n arrayHelpers.remove(index)}>\r\n \r\n \r\n \r\n \r\n )) : \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n }\r\n \r\n
\r\n \r\n {/* { formikValues.reasonForExport?.type === 'documents' && formikValues?.subTotal > 5 ?\r\n \r\n Max sub total allowed for this reason for export is 5.\r\n \r\n : \r\n Total weight: {parseFloat(commodityWeight).toFixed(2)} can not be greater than the declared\r\n weight {!isOrderDefaults ? parseFloat(formikValues.weight || 0).toFixed(2) : (parseFloat(formikValues.weight || 0)*(formikValues.noOfItems || 1)).toFixed(2) } \r\n \r\n }\r\n {errors?.commodityDetails ? {errors.commodityDetails} : null} */}\r\n \r\n );\r\n }}\r\n />\r\n \r\n );\r\n};\r\n\r\nMarketplaceCommodityDetails.propTypes = {\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n errors: PropTypes.object,\r\n};\r\n\r\nexport default MarketplaceCommodityDetails;\r\n","import React from 'react';\r\nimport FormRenderer from '../../../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { Grid } from '@material-ui/core';\r\n\r\nconst MarketplaceInvoiceDecAndShippingDtls = ({ formField, setFieldValue, currencies, reasonsForExportList, ...rest }) => {\r\n\r\n const { customDeclarationShippingCharges, customDeclarationCurrency, invoiceTypeLabel, invoiceNumber, reasonForExport } = formField;\r\n\r\n return (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n\r\n \r\n \r\n {\r\n if (/^\\d+(\\.\\d{0,2})?$/.test(value)) {\r\n setFieldValue('customDeclarationShippingCharges', value);\r\n } else if (value === '') {\r\n setFieldValue('customDeclarationShippingCharges', '');\r\n }\r\n }}\r\n fullWidth\r\n />\r\n \r\n \r\n \r\n \r\n \r\n >\r\n );\r\n\r\n}\r\n\r\nexport default MarketplaceInvoiceDecAndShippingDtls;\r\n\r\nconst invoiceTypeLabelOptions = [\r\n {\r\n value: 'commercial',\r\n label: 'Commercial',\r\n },\r\n {\r\n value: 'proforma',\r\n label: 'Proforma',\r\n },\r\n];\r\n\r\n","import React, { useEffect, useRef, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid } from '@material-ui/core';\r\nimport { Formik } from 'formik';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../../../../store/actions/index';\r\nimport { getYupSchemaFromMetaData } from '../../../../../utils/yupSchema/yupSchemaGenerator';\r\nimport CustomAccordion from '../../../../../framework/accordion/customAccordion';\r\nimport ParcelDetails from '../../../../../container/shipment/addShipment/parcelDetails/parcelDetails';\r\nimport MarketplaceCommodityDetails from './marketplaceCommodityDetails/marketplaceCommodityDetails';\r\nimport internationDefaultsForm from '../../../../../utils/formConfig/configuration/orderFileDefaultsForm/internationalDefaultsForm';\r\nimport {\r\n formatParcelDetails,\r\n getParsedFloatValues,\r\n getMarketplaceCommodityDetails,\r\n setValuesToParcelDetails,\r\n setMarketplaceCommodityDetails,\r\n removeUndefinedProperties,\r\n getCustomerAccountID,\r\n setDropdownValues,\r\n} from '../../../../../utils/helperFunctions';\r\nimport InputButton from '../../../../../framework/Inputs/inputButton/inputButton';\r\nimport { PATCH } from '../../../../../api/axios';\r\nimport { ServiceEndPoints } from '../../../../../utils/constants/ApiConstant';\r\nimport CustomModal from '../../../../../framework/modal/modal';\r\nimport ConfirmationDialog from '../../../../addressBook/confirmation/confirmation';\r\nimport FormRenderer from '../../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport MarketplaceInvoiceDecAndShippingDtls from './marketplaceInvoiceDeclarationAndShippingDetails/marketplaceInvoiceDecAndShippingDtls';\r\nimport * as CONSTANTS from '../../../../../utils/constants/constants';\r\nimport { axiosConfig } from '../../../../../api/axios';\r\n\r\n\r\nconst { formField } = internationDefaultsForm;\r\n\r\nconst MarketplaceIntlDefaults = (props) => {\r\n const { internationalDefaultValues, countries, getOrderDefaults, } = props;\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n const [marketPlacesList, setMarketPlacesList] = useState([]);\r\n const [orderFileDetailsValidationSchema, setorderFileDetailsValidationSchema] = useState(\r\n getYupSchemaFromMetaData(formField, [], []),\r\n );\r\n const formikRef = useRef(null);\r\n const initialValues = {};\r\n const dispatch = useDispatch();\r\n\r\n for (let property in formField) {\r\n if (Object.prototype.hasOwnProperty.call(formField, property)) {\r\n const field = formField[property];\r\n if (field.props.type === 'checkbox' || field.props.type === 'radio') {\r\n initialValues[field.props.name] = field.value;\r\n } else if (field.props.type === 'array') {\r\n initialValues[field.props.name] = field.values;\r\n } else {\r\n initialValues[field.props.name] = field.value || '';\r\n }\r\n }\r\n }\r\n\r\n useEffect(() =>{\r\n axiosConfig\r\n .get(`${ServiceEndPoints.getMarketplacesList}`)\r\n .then((response) => {\r\n setMarketPlacesList(response.data);\r\n })\r\n .catch((err) => {\r\n setMarketPlacesList([]);\r\n })\r\n },[]);\r\n\r\n useEffect(() => {\r\n if (internationalDefaultValues) {\r\n const customDeclaration = internationalDefaultValues?.customDeclaration;\r\n const parcelDimensions = (internationalDefaultValues?.parcelDetails?.parcelDimensions || [])[0];\r\n internationalDefaultValues['destinationCountry'] = 'DER';\r\n const defaultValues = {\r\n ...setValuesToParcelDetails(internationalDefaultValues),\r\n invoiceTypeLabel: customDeclaration?.invoiceType === 1 ? CONSTANTS.reverseInvoiceType[1] : CONSTANTS.reverseInvoiceType[2],\r\n InvoiceNumber: customDeclaration?.invoiceNumber,\r\n customDeclarationShippingCharges: customDeclaration?.shippingCharges,\r\n customDeclarationCurrency: setDropdownValues(CONSTANTS.currenciesMarketplaces, 'code', customDeclaration?.currency),\r\n termsOfDelivery: setDropdownValues(CONSTANTS.TermsOfDelivery, 'label', customDeclaration?.termsOfDelivery),\r\n reasonForExport: setDropdownValues(CONSTANTS.reasonsForExportList, 'type', customDeclaration?.reasonForExport),\r\n marketplaceIossNo: internationalDefaultValues?.senderCustomsRegistrations?.[0]?.id,\r\n commodityDetails: setMarketplaceCommodityDetails(\r\n customDeclaration?.customItemDetails,\r\n countries,\r\n marketPlacesList\r\n ),\r\n length: parcelDimensions?.length || '',\r\n width: parcelDimensions?.width || '',\r\n height: parcelDimensions?.height || '',\r\n };\r\n removeUndefinedProperties(defaultValues);\r\n formikRef.current.setValues({ ...formikRef.current.values, ...defaultValues });\r\n }\r\n }, [internationalDefaultValues, marketPlacesList]);\r\n\r\n const handleSubmit = async (formikValues, errors) => {\r\n if (Object.keys(await formikRef.current.validateForm(formikValues)).length === 0) {\r\n const reqObj = {\r\n parcelDetails: formatParcelDetails(formikValues, false, true),\r\n customDeclaration: {\r\n currency: formikValues?.customDeclarationCurrency.code,\r\n invoiceNumber: formikValues?.InvoiceNumber,\r\n invoiceType: formikValues?.invoiceTypeLabel === 'proforma' ? 2 : 1,\r\n termsOfDelivery: formikValues?.termsOfDelivery.label?.toString(),\r\n reasonForExport: formikValues?.reasonForExport.type,\r\n customItemDetails: getMarketplaceCommodityDetails(formikValues.commodityDetails),\r\n subTotal: Number(formikValues.subTotal),\r\n shippingCharges: getParsedFloatValues(formikValues.customDeclarationShippingCharges),\r\n totalValue: Number(formikValues.totalValue),\r\n },\r\n senderCustomsRegistrations: [{\r\n type: 'IOSS', id: formikValues.marketplaceIossNo\r\n }],\r\n };\r\n removeUndefinedProperties(reqObj);\r\n PATCH(`${ServiceEndPoints.getMarketplaceDefaults}/internationaldefaults?organization=${getCustomerAccountID()}`, reqObj)\r\n .then((res) => {\r\n dispatch(actions.setAppSnackBarData({ msg: \"International marketplace defaults saved successfully\" }))\r\n getOrderDefaults();\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n }\r\n else {\r\n dispatch(actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'The form has errors, please correct and try again',\r\n },\r\n ]\r\n }));\r\n }\r\n\r\n };\r\n\r\n const handleDialogClose = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n\r\n const resetForm = () => {\r\n formikRef?.current?.resetForm();\r\n handleDialogClose();\r\n };\r\n\r\n const updateValidationSchema = () => {\r\n setorderFileDetailsValidationSchema(getYupSchemaFromMetaData(formField, [], []));\r\n };\r\n\r\n return (\r\n \r\n \r\n {({ values, setFieldValue, setFieldTouched, errors }) => {\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n setShowConfirmationDialog(true)}\r\n label=\"Reset\"\r\n />\r\n \r\n \r\n handleSubmit(values, errors)}\r\n label=\"Save changes\"\r\n buttonType=\"submit\"\r\n />\r\n \r\n \r\n \r\n );\r\n }}\r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nMarketplaceIntlDefaults.propTypes = {};\r\n\r\nexport default MarketplaceIntlDefaults;\r\n\r\n","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid } from '@material-ui/core';\r\nimport ToggleButtonGroup from '@material-ui/lab/ToggleButtonGroup';\r\nimport ToggleButton from '@material-ui/lab/ToggleButton';\r\nimport { connect } from 'react-redux';\r\n\r\nimport DomesticDefaults from '../orderFileDefaults/domesticDefaults/domesticDefaults';\r\n// import CollectionsDefaults from '../orderFileDefaults/collectionsDefaults/collectionsDefaults';\r\nimport MarketplaceIntlDefaults from '../marketplacesDefaults/marketplaceIntlDefaults/marketplaceIntlDefaults'\r\nimport { GET } from '../../../../api/axios';\r\nimport { ServiceEndPoints } from '../../../../utils/constants/ApiConstant';\r\nimport { dynamicSort, getCustomerAccountID } from '../../../../utils/helperFunctions';\r\nimport '../orderFileDefaults/orderFileDefaults.scss';\r\n\r\nconst MarketplacesDefaults = (props) => {\r\n const [formType, setFormType] = useState('domestic');\r\n const [defaultValues, setDefaultValues] = useState({});\r\n const [countries, setCountries] = React.useState([]);\r\n\r\n const toggleButtons = (event, value) => {\r\n if (value) {\r\n setFormType(value);\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n getMarketplaceDefaults();\r\n }, []);\r\n\r\n const getMarketplaceDefaults = () => {\r\n GET(`${ServiceEndPoints.getMarketplaceDefaults}?organization=${getCustomerAccountID()}`)\r\n .then((res) => {\r\n setDefaultValues(res.data);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n GET(ServiceEndPoints.getCountries)\r\n .then((res) => {\r\n setCountries(res.data.countries.sort(dynamicSort('name')));\r\n })\r\n .catch((err) => {\r\n setCountries([]);\r\n });\r\n };\r\n\r\n return (\r\n \r\n \r\n \r\n Domestic \r\n International \r\n {/* Collections */}\r\n \r\n \r\n \r\n {formType === 'domestic'\r\n ? (\r\n \r\n )\r\n : null}\r\n {formType === 'international'\r\n ? (\r\n \r\n )\r\n : null}\r\n {/* {formType === 'collections'\r\n ? (\r\n \r\n )\r\n : null} */}\r\n \r\n \r\n );\r\n};\r\n\r\nMarketplacesDefaults.propTypes = {};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n userDetails: state.auth.userDetails,\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, null)(MarketplacesDefaults);\r\n","import React, { useState, useEffect } from 'react';\r\nimport { PropTypes } from 'prop-types';\r\nimport FormRenderer from '../../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport Grid from '@material-ui/core/Grid';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../../../../store/actions/index';\r\nimport { SearchIcon } from '@material-ui/data-grid';\r\nimport { IconButton } from '@material-ui/core';\r\nimport ClearIcon from '@material-ui/icons/Clear';\r\n\r\nconst useStyles = makeStyles(() => ({\r\n SearchMySchema: {\r\n marginTop: '4px',\r\n },\r\n}));\r\n\r\nconst SearchSchemas = (props) => {\r\n const classes = useStyles();\r\n const dispatch = useDispatch();\r\n let [isClearBtn, setIsClearBtn] = useState(false);\r\n\r\n const { \r\n formField: { schemaSearchFor },\r\n setFieldValue,\r\n onAddressChange,\r\n formikValues,\r\n setFieldTouched,\r\n } = props;\r\n\r\n const getClear = (event = null) => {\r\n if (event) {\r\n event.preventDefault();\r\n }\r\n setIsClearBtn(false);\r\n setFieldValue('schemaSearchFor', '');\r\n setFieldTouched('schemaSearchFor', false)\r\n dispatch(actions.setAddressBookSearchParams('&schemaName='));\r\n onAddressChange(true);\r\n };\r\n\r\n const getAddresses = (event = null) => {\r\n if (event) {\r\n event.preventDefault();\r\n }\r\n setIsClearBtn(true);\r\n onAddressChange(true);\r\n };\r\n\r\n useEffect(() => {\r\n setIsClearBtn(false);\r\n }, [props.formikValues.schemaSearchFor]);\r\n\r\n useEffect(() => {\r\n dispatch(actions.setAddressBookSearchParams(`&schemaName=${encodeURIComponent(formikValues.schemaSearchFor)}`));\r\n }, [dispatch, formikValues]);\r\n\r\n useEffect(() => {\r\n setFieldValue('schemaSearchFor', '');\r\n }, [setFieldValue]);\r\n return (\r\n \r\n \r\n \r\n getClear(event)}>\r\n \r\n \r\n )\r\n : (\r\n getAddresses(event, '')}>\r\n \r\n \r\n ),\r\n }}\r\n fullWidth\r\n />\r\n\r\n {/* \r\n getAddresses(event, '')}>\r\n \r\n \r\n ),\r\n }}\r\n fullWidth\r\n /> */}\r\n \r\n \r\n
\r\n );\r\n};\r\n\r\nSearchSchemas.propTypes = {\r\n formField: PropTypes.object,\r\n schemaSearchFor: PropTypes.string,\r\n setFieldValue: PropTypes.func,\r\n onAddressChange: PropTypes.func,\r\n formikValues: PropTypes.object,\r\n};\r\n\r\nexport default SearchSchemas;\r\n","import React from 'react';\r\nimport { Form, Formik } from 'formik';\r\nimport PropTypes from 'prop-types';\r\nimport SearchSchemas from './SearchSchemas';\r\nimport { getYupSchemaFromMetaData } from '../../../../../utils/yupSchema/yupSchemaGenerator';\r\n\r\nconst SearchMySchemas = (props) => {\r\n const formField = searchForm;\r\n const newSearchValidationSchema = getYupSchemaFromMetaData(formField, [], []);\r\n\r\n const initialValues = {\r\n schemaSearchFor: '',\r\n };\r\n\r\n return (\r\n \r\n \r\n {({ values, setFieldValue, errors, setFieldTouched }) => (\r\n \r\n )}\r\n \r\n
\r\n );\r\n};\r\n\r\nexport default SearchMySchemas;\r\n\r\nconst searchForm = {\r\n schemaSearchFor: {\r\n props: {\r\n name: 'schemaSearchFor',\r\n label: 'Search by',\r\n type: 'text',\r\n placeholder: 'Schema name',\r\n },\r\n },\r\n};\r\n\r\nSearchMySchemas.propTypes = {\r\n onAddressChange: PropTypes.func,\r\n};\r\n","const PrinterQueueForm = {\r\n formId: 'PrinterQueueForm',\r\n formField: {\r\n defaultPrinter: {\r\n props: {\r\n name: 'defaultPrinter',\r\n label: 'Print unknown printer queues to printer (Default)',\r\n type: 'select',\r\n displayField: 'name',\r\n },\r\n value: '',\r\n },\r\n printerQueueName: {\r\n props: {\r\n name: 'printerQueueName',\r\n label: 'Printer queue name',\r\n type: 'text',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 35,\r\n },\r\n },\r\n value: '',\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Printer queue name is required'],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n 'printerQueueList',\r\n (printerQueueList, schema) => {\r\n return schema.test('duplicateFinder', 'Duplicate printer queue name', (value) => {\r\n return !printerQueueList?.some(\r\n (printerQueue) =>\r\n printerQueue?.printerQueueName?.toLowerCase()?.trim() === value?.toLowerCase()?.trim(),\r\n );\r\n });\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n printerToPrint: {\r\n props: {\r\n name: 'printerToPrint',\r\n label: 'Printer to print on',\r\n type: 'select',\r\n displayField: 'name',\r\n isRequired: true,\r\n },\r\n value: '',\r\n validation: {\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Printer to print on is required'],\r\n },\r\n {\r\n type: 'test',\r\n params: [\r\n '',\r\n 'Printer to print on is required',\r\n (value) => {\r\n if (!value?.value) {\r\n return false;\r\n }\r\n return true;\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n printerQueueList: {\r\n props: {\r\n name: 'printerQueueList',\r\n type: 'array',\r\n fields: {\r\n printerQueueName: '',\r\n printerToPrint: '',\r\n },\r\n },\r\n values: [],\r\n },\r\n },\r\n};\r\nexport default PrinterQueueForm;\r\n","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, IconButton, SvgIcon } from '@material-ui/core';\r\nimport FormRenderer from '../../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport InputButton from '../../../../../framework/Inputs/inputButton/inputButton';\r\nimport DynamicMaterialTable from '../../../../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\nimport { ReactComponent as DeleteIcon } from '../../../../../assets/images/DeleteIcon.svg';\r\n\r\nconst AddPrinterQueue = (props) => {\r\n const {\r\n availablePrinters,\r\n setFieldTouched,\r\n setFieldValue,\r\n formikValues,\r\n formField,\r\n arrayHelpers,\r\n setOldprinterQueueList,\r\n savePrinterQueues,\r\n errors,\r\n setIsFormDirty,\r\n } = props;\r\n\r\n const getColumns = () => {\r\n return [\r\n { title: 'id', field: 'id', hidden: true, width: 0 },\r\n {\r\n title: 'Printer queue name',\r\n field: 'printerQueueName',\r\n sorting: false,\r\n },\r\n {\r\n title: 'Printer to print on',\r\n field: 'printerToPrint.name',\r\n sorting: false,\r\n },\r\n {\r\n title: '',\r\n render: (row) => (\r\n {\r\n setIsFormDirty(true);\r\n arrayHelpers.remove(row.tableData?.id);\r\n }}\r\n >\r\n \r\n \r\n ),\r\n sorting: false,\r\n },\r\n ];\r\n };\r\n const [columns] = useState(getColumns());\r\n\r\n const addDataToTable = (arrayHelpers) => {\r\n setIsFormDirty(true);\r\n const rowDetails = {\r\n printerQueueName: formikValues.printerQueueName,\r\n printerToPrint: formikValues.printerToPrint,\r\n };\r\n arrayHelpers.push(rowDetails);\r\n setFieldValue('printerQueueName', '');\r\n setFieldValue('printerToPrint', availablePrinters[0]);\r\n setFieldTouched('printerQueueName', false);\r\n setFieldTouched('printerToPrint', false);\r\n };\r\n\r\n useEffect(() => {\r\n setOldprinterQueueList([...formikValues.printerQueueList]);\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (!formikValues?.printerToPrint?.value) {\r\n setFieldValue('printerToPrint', availablePrinters[0]);\r\n }\r\n }, [availablePrinters, formikValues?.printerToPrint, setFieldValue]);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n addDataToTable(arrayHelpers)}\r\n />\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nAddPrinterQueue.propTypes = {};\r\n\r\nexport default AddPrinterQueue;\r\n","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, IconButton, makeStyles, Paper, SvgIcon } from '@material-ui/core';\r\nimport DynamicMaterialTable from '../../../../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\nimport { ReactComponent as EditIcon } from '../../../../../assets/images/EditIcon.svg';\r\nimport CustomDialog from '../../../../../framework/dialog/customDialog';\r\nimport AddPrinterQueue from '../addPrinterQueue/addPrinterQueue';\r\nimport { FieldArray } from 'formik';\r\nimport ConfirmationDialog from '../../../../addressBook/confirmation/confirmation';\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n customHeader: {\r\n font: '14px Delivery_W_Bd',\r\n padding: '0px 16px',\r\n },\r\n customTable: {\r\n padding: '5px 30px 20px 30px !important',\r\n },\r\n}));\r\n\r\nconst PrinterQueueList = (props) => {\r\n const classes = useStyles();\r\n const { availablePrinters, setFieldValue, formikValues, formField } = props;\r\n const getColumns = () => {\r\n return [\r\n { title: 'id', field: 'id', hidden: true, width: 0 },\r\n {\r\n title: 'Printer queue name',\r\n field: 'printerQueueName',\r\n sorting: false,\r\n },\r\n {\r\n title: 'Printer to print on',\r\n field: 'printerToPrint.name',\r\n sorting: false,\r\n },\r\n ];\r\n };\r\n const [open, setOpen] = useState(false);\r\n const [isFormDirty, setIsFormDirty] = useState(false);\r\n const [showConfirmationPopup, setConfirmationPopup] = useState(false);\r\n\r\n const [columns] = useState(getColumns());\r\n const [oldprinterQueueList, setOldprinterQueueList] = React.useState([]);\r\n\r\n const handleModal = () => {\r\n open ? setOpen(false) : setOpen(true);\r\n };\r\n\r\n const handleDialogClose = () => {\r\n if (!isFormDirty) {\r\n setOpen(false);\r\n setFieldValue('printerQueueList', oldprinterQueueList);\r\n setFieldValue('printerQueueName', '');\r\n setFieldValue('printerToPrint', availablePrinters[0]);\r\n } else {\r\n setConfirmationPopup(true);\r\n }\r\n };\r\n\r\n const handleCloseConfirmationPopup = () => {\r\n setConfirmationPopup(false);\r\n };\r\n\r\n const addToPrinterList = (arrayHelpers, printersList) => {\r\n arrayHelpers.form.setValues(printersList);\r\n };\r\n\r\n const handleConfirmation = () => {\r\n setOpen(false);\r\n setFieldValue('printerQueueList', oldprinterQueueList);\r\n setFieldValue('printerQueueName', '');\r\n setFieldValue('printerToPrint', availablePrinters[0]);\r\n setConfirmationPopup(false);\r\n };\r\n\r\n useEffect(() => {\r\n if (!formikValues?.defaultPrinter?.value) {\r\n setFieldValue('defaultPrinter', availablePrinters[0]);\r\n }\r\n }, [availablePrinters, formikValues?.defaultPrinter, setFieldValue]);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n Add/remove\r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Printer queue list \r\n \r\n \r\n \r\n \r\n {\r\n const printerList = formikValues.printerQueueList;\r\n return (\r\n <>\r\n \r\n \r\n addToPrinterList(arrayHelpers, printerList)}\r\n setOldprinterQueueList={setOldprinterQueueList}\r\n savePrinterQueues={handleModal}\r\n setIsFormDirty={setIsFormDirty}\r\n />\r\n \r\n \r\n \r\n \r\n >\r\n );\r\n }}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nPrinterQueueList.propTypes = {};\r\n\r\nexport default PrinterQueueList;\r\n","import React, { useEffect, useRef, useState } from 'react';\r\nimport { Grid, Paper } from '@material-ui/core';\r\nimport CustomAccordion from '../../../../framework/accordion/customAccordion';\r\nimport { Formik } from 'formik';\r\nimport PrinterQueueForm from '../../../../utils/formConfig/configuration/printerQueue/printerQueueForm';\r\nimport FormRenderer from '../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport PrinterQueueList from './printerQueueList/printerQueueList';\r\nimport { axiosConfig } from '../../../../api/axios';\r\nimport { ServiceEndPoints } from '../../../../utils/constants/ApiConstant';\r\nimport { getCustomerAccountID, setDropdownValues } from '../../../../utils/helperFunctions';\r\nimport InputButton from '../../../../framework/Inputs/inputButton/inputButton';\r\nimport { getAvaiablePrinters } from '../../../../utils/PrintHelper';\r\nimport { getYupSchemaFromMetaData } from '../../../../utils/yupSchema/yupSchemaGenerator';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../../../store/actions/index';\r\nimport './printerQueue.scss';\r\n\r\nconst { formField } = PrinterQueueForm;\r\n\r\nconst PrinterQueue = (props) => {\r\n const [printers, setPrinters] = useState([]);\r\n const [printerQueueDefaults, setPrinterQueueDefaults] = useState({});\r\n const dispatch = useDispatch();\r\n\r\n const formikRef = useRef(null);\r\n const initialValues = {\r\n defaultPrinter: '',\r\n printerQueueName: '',\r\n printerToPrint: '',\r\n printerQueueList: [],\r\n };\r\n\r\n const createKeyValuePair = (arrayList) => {\r\n return arrayList?.map((item) => {\r\n return {\r\n name: item,\r\n value: item,\r\n };\r\n });\r\n };\r\n\r\n const validationSchema = getYupSchemaFromMetaData(formField, [], []);\r\n\r\n const handleSubmit = () => {\r\n const formikValues = formikRef.current.values;\r\n const printerQueues = formikValues.printerQueueList?.map((res) => {\r\n return {\r\n queueName: res?.printerQueueName,\r\n printerName: res?.printerToPrint?.value,\r\n };\r\n });\r\n const reqObj = {\r\n printerQueueDefault: formikValues.defaultPrinter.value,\r\n printerQueue: printerQueues,\r\n };\r\n axiosConfig\r\n .patch(`${ServiceEndPoints.printerQueue}?organization=${getCustomerAccountID()}`, reqObj)\r\n .then((res) => {\r\n dispatch(actions.setAppSnackBarData({ msg: \"Data saved successfully\" }))\r\n // console.log(res);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n dispatch(actions.setAppSnackBarData({ type: \"error\", msg: \"Something went wrong, please try again\" }))\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n getAvaiablePrinters()\r\n .then((res) => {\r\n setPrinters(createKeyValuePair(res));\r\n })\r\n .catch((err) => console.log(err));\r\n axiosConfig\r\n .get(`${ServiceEndPoints.getOrderDefaults}?organization=${getCustomerAccountID()}`)\r\n .then((res) => {\r\n // console.log(res);\r\n setPrinterQueueDefaults(res.data.printerQueueDefaults);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (Object.keys(printerQueueDefaults).length > 1 && printers.length > 1) {\r\n formikRef.current.setFieldValue(\r\n 'defaultPrinter',\r\n setDropdownValues(printers, 'value', printerQueueDefaults?.printerQueueDefault ?? ''),\r\n );\r\n const printerQueueList = printerQueueDefaults?.printerQueue?.map((res) => {\r\n return {\r\n printerQueueName: res?.queueName ?? '',\r\n printerToPrint: setDropdownValues(printers, 'value', res?.printerName ?? ''),\r\n };\r\n });\r\n formikRef.current.setFieldValue('printerQueueList', printerQueueList);\r\n }\r\n }, [printerQueueDefaults, printers]);\r\n\r\n return (\r\n \r\n \r\n \r\n {({ values, setFieldValue, setFieldTouched, errors, resetForm }) => (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n );\r\n};\r\n\r\nPrinterQueue.propTypes = {};\r\n\r\nexport default PrinterQueue;\r\n","import React, { useEffect, useState } from 'react';\r\nimport { Grid, IconButton, SvgIcon} from '@material-ui/core';\r\nimport OrderFile from '../orderFileMapping/orderFile';\r\nimport CustomModal from '../../../../framework/modal/modal';\r\nimport { ReactComponent as EditIcon } from '../../../../assets/images/EditIcon.svg';\r\nimport { useDispatch, useSelector } from 'react-redux';\r\nimport { ServiceEndPoints } from '../../../../utils/constants/ApiConstant';\r\nimport AddMapping from '../orderFileMapping/addMapping';\r\nimport ConfirmationDialog from '../../../addressBook/confirmation/confirmation';\r\nimport InputButton from '../../../../framework/Inputs/inputButton/inputButton';\r\nimport { getCustomerAccountID, customTableSort } from '../../../../utils/helperFunctions';\r\nimport { axiosConfig } from '../../../../api/axios';\r\nimport * as actions from '../../../../store/actions/index';\r\nimport FormRenderer from '../../../../framework/Inputs/formRenderer/formRenderer';\r\n\r\nconst MarketplaceMapping = (props) => {\r\n const {\r\n formField : {marketPlacesAvailable, newMarketplaceName, newMarketplaceCode},\r\n values,\r\n setFieldValue, \r\n setFieldTouched, \r\n errors, \r\n setErrors,\r\n setMarketPlacesList,\r\n marketPlacesList\r\n } = props;\r\n\r\n const tableColumns = [\r\n { title: 'Map from', field: 'mapFrom', width: '30%', customSort: (a, b) => customTableSort(a.mapFrom, b.mapFrom) },\r\n { title: 'Mapped to', field: 'mappedTo', sorting: false, width: '57%' },\r\n ];\r\n\r\n let mappingsUrl;\r\n\r\n const [services, setServices] = useState([]);\r\n const [mappingServices, setMappingServices] = useState([]);\r\n const [isDialogOpen, setIsDialogOpen] = useState(false);\r\n const [mappedMarketplaceDefault, setMappedMarketplaceDefault] = React.useState({});\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n const [isUpdating_Flag, setisUpdating_Flag] = useState(false);\r\n\r\n const dispatch = useDispatch();\r\n\r\n useEffect(() => {\r\n getMarketplacesList();\r\n getInitialValues();\r\n }, []);\r\n\r\n const handleDialogClose = (setFieldTouched, setFieldValue) => {\r\n setFieldValue('mapFrom', '');\r\n setFieldTouched('mapFrom', false);\r\n if (isUpdating_Flag) {\r\n setisUpdating_Flag(false);\r\n setShowConfirmationDialog(true);\r\n } else {\r\n setIsDialogOpen(false);\r\n }\r\n };\r\n\r\n const setDialogOpen = () => {\r\n setIsDialogOpen(true);\r\n };\r\n\r\n const handleConfirmClose = () => {\r\n setIsDialogOpen(true)\r\n setShowConfirmationDialog(false);\r\n setisUpdating_Flag(true);\r\n };\r\n const onDialogConfirm = () => {\r\n setIsDialogOpen(false);\r\n setShowConfirmationDialog(false);\r\n };\r\n\r\n const getMarketplacesList = () =>{\r\n axiosConfig\r\n .get(`${ServiceEndPoints.getMarketplacesList}`)\r\n .then((response) => {\r\n setMarketPlacesList(response.data);\r\n })\r\n .catch((err) => {\r\n setMarketPlacesList([]);\r\n })\r\n .finally((e) =>{\r\n if(props.adminLevelMapping){\r\n setMarketPlacesList((marketPlacesList) => {\r\n const pushAddMarketplace = [...marketPlacesList];\r\n pushAddMarketplace.push({marketplaceName : '+ Add Marketplace', marketplaceCode: 'addMarketplace'});\r\n return pushAddMarketplace;\r\n });\r\n }\r\n });\r\n };\r\n \r\n const addMarketplacesToList = (values, setFieldValue) => {\r\n const newMarketplaceData = {\r\n marketplaceCode: values?.newMarketplaceCode,\r\n marketplaceName: values?.newMarketplaceName\r\n\r\n }\r\n axiosConfig\r\n .post(`${ServiceEndPoints.getMarketplacesList}`,newMarketplaceData)\r\n .then((response) => {\r\n dispatch(actions.setAppSnackBarData({ msg: 'Marketplace added successfully' }));\r\n setFieldValue('newMarketplaceName','');\r\n setFieldValue('newMarketplaceCode','');\r\n getMarketplacesList();\r\n })\r\n .catch((error) => {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in adding marketplace, please try again.',\r\n },\r\n ],\r\n }),\r\n );\r\n });\r\n }\r\n\r\n const getInitialValues = () => {\r\n axiosConfig\r\n .get(`${ServiceEndPoints.getMappedServices}`)\r\n .then((response) => {\r\n const output = response.data.map(({ code, longDescription }) => ({ name: longDescription, value: code }));\r\n setServices(output);\r\n })\r\n .catch((err) => {\r\n setServices([]);\r\n });\r\n\r\n props.adminLevelMapping ? mappingsUrl = ServiceEndPoints.getAdminMarketplaceMappings : mappingsUrl = ServiceEndPoints.getMarketplaceDefaults;\r\n axiosConfig\r\n .get(`${mappingsUrl}?organization=${getCustomerAccountID()}`)\r\n .then((response) => {\r\n props.adminLevelMapping ? setMappedMarketplaceDefault(response.data) : setMappedMarketplaceDefault(response.data.marketPlaceMappings);\r\n })\r\n .catch((err) => {\r\n setMappedMarketplaceDefault([]);\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n if (props.adminLevelMapping && values?.marketPlacesAvailable?.marketplaceCode !== 'addMarketplace') {\r\n setFieldValue('newMarketplaceName', '');\r\n setFieldValue('newMarketplaceCode', '');\r\n }\r\n if (services && services.length > 0 && mappedMarketplaceDefault && mappedMarketplaceDefault.length > 0) {\r\n let serviceMap = [];\r\n let marketplacesServicesData = mappedMarketplaceDefault.filter((ele) => ele?.marketplaceName === values?.marketPlacesAvailable?.marketplaceName);\r\n marketplacesServicesData.map((ele) => {\r\n ele.servicesMapping.map((ser) => {\r\n var mapToName = services.find((serval) => serval.value === ser.mappedTo);\r\n if (mapToName !== undefined) {\r\n const item = {\r\n mapFrom: ser.mapFrom,\r\n mappedTo: mapToName.name,\r\n };\r\n serviceMap.push(item);\r\n }\r\n });\r\n });\r\n setMappingServices(serviceMap);\r\n }\r\n }, [services, mappedMarketplaceDefault, values?.marketPlacesAvailable?.marketplaceName]);\r\n\r\n const saveMappingDetails = (updatedAccounts, updatedServices, formikValues) => {\r\n let newServicesMapping = [];\r\n setIsDialogOpen(false);\r\n setMappingServices(updatedServices);\r\n updatedServices.map((updateMap) => {\r\n const item = {\r\n mapFrom: updateMap.mapFrom,\r\n mappedTo: services.find((serval) => serval.name === updateMap.mappedTo).value,\r\n };\r\n newServicesMapping.push(item);\r\n });\r\n const updatedMarketplaceServices = {\r\n marketplaceName : formikValues?.marketPlacesAvailable?.marketplaceName,\r\n servicesMapping : newServicesMapping,\r\n }\r\n setMappedMarketplaceDefault((mappedMarketplaceDefault) => {\r\n let newMappedMarketplaceDefault = [];\r\n if(mappedMarketplaceDefault){\r\n newMappedMarketplaceDefault = [...mappedMarketplaceDefault?.filter((ele) => ele.marketplaceName !== formikValues?.marketPlacesAvailable.marketplaceName)];\r\n }\r\n newMappedMarketplaceDefault?.push(updatedMarketplaceServices);\r\n return newMappedMarketplaceDefault;\r\n });\r\n };\r\n\r\n const saveServiceMapping = () => {\r\n if(props.adminLevelMapping){\r\n axiosConfig\r\n .post(`${ServiceEndPoints.getAdminMarketplaceMappings}?organization=${getCustomerAccountID()}`, mappedMarketplaceDefault)\r\n .then((response) => {\r\n dispatch(actions.setAppSnackBarData({ msg: 'Marketplace order mappings saved successfully' }));\r\n })\r\n .catch((error) => {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Mappings not saved in database, please try again.',\r\n },\r\n ],\r\n }),\r\n );\r\n })\r\n }\r\n else{\r\n axiosConfig\r\n .patch(`${ServiceEndPoints.getMarketplaceDefaults}/marketplacemappings?organization=${getCustomerAccountID()}`, mappedMarketplaceDefault)\r\n .then((response) => {\r\n dispatch(actions.setAppSnackBarData({ msg: 'Marketplace order mappings saved successfully' }));\r\n })\r\n .catch((error) => {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Mappings not saved in database, please try again.',\r\n },\r\n ],\r\n }),\r\n );\r\n })\r\n };\r\n };\r\n\r\n const _isUpdatingFlag = (flag) => {\r\n setisUpdating_Flag(flag);\r\n };\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n {props.adminLevelMapping && values?.marketPlacesAvailable?.marketplaceCode === 'addMarketplace' ? <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n addMarketplacesToList(values, setFieldValue)}\r\n isDisabled={values?.newMarketplaceCode === '' || values?.newMarketplaceName === ''}\r\n label=\"Add\"\r\n buttonType=\"submit\"\r\n fullWidth\r\n />\r\n > : ''}\r\n \r\n \r\n \r\n Services \r\n \r\n \r\n setDialogOpen()} disabled={values?.marketPlacesAvailable?.marketplaceCode === 'addMarketplace'}>\r\n \r\n Add/edit \r\n \r\n\r\n \r\n \r\n\r\n \r\n handleDialogClose(setFieldTouched, setFieldValue)} >\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n saveServiceMapping()}\r\n buttonType=\"submit\"\r\n label=\"Save changes\"\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nexport default MarketplaceMapping;","import React, {useState} from \"react\";\r\nimport { Form, Formik} from 'formik';\r\nimport MarketplaceMapping from \"../marketplaceMapping\";\r\nimport orderFileMappingForm from \"../../../../../utils/formConfig/configuration/orderFileMappingForm/orderFileMappingForm\";\r\nimport { getYupSchemaFromMetaData } from \"../../../../../utils/yupSchema/yupSchemaGenerator\";\r\n\r\nconst formikRef = React.createRef();\r\nconst { formId, formField } = orderFileMappingForm;\r\n\r\nconst CustomerLevelMarketplaceMapping = ((props) => {\r\n\r\n const [marketPlacesList, setMarketPlacesList] = useState([]);\r\n const orderFileMappingSchema = getYupSchemaFromMetaData(formField, [], []);\r\n const initialValues = {\r\n marketPlacesAvailable : marketPlacesList[0],\r\n };\r\n \r\n return(\r\n \r\n \r\n {({ values, setFieldValue, setFieldTouched, setErrors, errors }) => (\r\n \r\n )}\r\n \r\n \r\n );\r\n})\r\n\r\nexport default CustomerLevelMarketplaceMapping;","import React, { useState } from \"react\";\r\nimport { Form, Formik } from 'formik';\r\nimport MarketplaceMapping from \"../marketplaceMapping\";\r\nimport orderFileMappingForm from \"../../../../../utils/formConfig/configuration/orderFileMappingForm/orderFileMappingForm\";\r\nimport { getYupSchemaFromMetaData } from \"../../../../../utils/yupSchema/yupSchemaGenerator\";\r\n\r\nconst formikRef = React.createRef();\r\nconst { formId, formField } = orderFileMappingForm;\r\n\r\nconst AdminLevelMarketplaceMapping = ((props) => {\r\n\r\n const [marketPlacesList, setMarketPlacesList] = useState([]);\r\n const orderFileMappingSchema = getYupSchemaFromMetaData(formField, [], []);\r\n const initialValues = {\r\n marketPlacesAvailable: marketPlacesList[0],\r\n };\r\n\r\n return (\r\n \r\n \r\n {({ values, setFieldValue, setFieldTouched, setErrors, errors }) => (\r\n \r\n )}\r\n \r\n \r\n );\r\n})\r\n\r\nexport default AdminLevelMarketplaceMapping;","import { Grid, Paper, Tabs, Tab } from '@material-ui/core';\r\nimport React, { useEffect, useState } from 'react';\r\nimport TabPanel from '../../../components/shared/tabPanel';\r\nimport CreateNewSchema from '../../../components/configuration/orderFileConfigurations/createNewSchema/createNewSchema';\r\n\r\nimport MySchemas from '../../../components/configuration/orderFileConfigurations/mySchemas/mySchemas';\r\nimport OrderFileDefaults from '../../../components/configuration/orderFileConfigurations/orderFileDefaults/orderFileDefaults';\r\nimport OrderFileMapping from '../../../components/configuration/orderFileConfigurations/orderFileMapping/orderFileMapping';\r\nimport OrderSetup from '../../../components/configuration/orderFileConfigurations/orderSetup/orderSetup';\r\nimport './OrderFileConfiguration.scss';\r\nimport MarketplacesDefaults from '../../../components/configuration/orderFileConfigurations/marketplacesDefaults/marketplacesDefaults';\r\nimport SearchMySchemas from '../../../components/configuration/orderFileConfigurations/mySchemas/searchSchema/SearchMySchemas';\r\nimport PrinterQueue from '../../../components/configuration/orderFileConfigurations/printerQueue/printerQueue';\r\nimport { useDispatch, useSelector } from 'react-redux';\r\nimport * as actions from '../../../store/actions/index';\r\nimport CustomerLevelMarketplaceMapping from '../../../components/configuration/orderFileConfigurations/MarketplaceMapping/customerLevelMarketplaceMapping/customerLevelMarketplaceMapping';\r\nimport AdminLevelMarketplaceMapping from '../../../components/configuration/orderFileConfigurations/MarketplaceMapping/adminLevelMarketplaceMapping/adminLevelMarketplaceMapping';\r\n\r\n// const tableRef = React.createRef();\r\nconst OrderFileConfiguration = () => {\r\n const [tabIndex, setTabIndex] = useState(0);\r\n const [isSearched, setIsSearched] = useState(0);\r\n\r\n const dispatch = useDispatch();\r\n\r\n let activeTab = useSelector((state) => state.common.activeTab);\r\n const userDetails = useSelector((state) => state?.auth?.userDetails);\r\n const userRole = userDetails?.role;\r\n const isMarketplaceAccount = userDetails?.accounts?.some((val) => {\r\n return val?.configuration?.marketplaceUserOptional === true;\r\n })\r\n\r\n const onTabChange = (event, index) => {\r\n setTabIndex(index);\r\n };\r\n\r\n const onAddressChange = () => {\r\n setIsSearched(!isSearched);\r\n // tableRef.current && tableRef.current.onQueryChange();\r\n };\r\n\r\n useEffect(() => {\r\n if (activeTab === 'mySchema') {\r\n setTabIndex(1);\r\n }\r\n dispatch(actions.setActiveTab(''));\r\n }, []);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {(userRole !== 'Supervisor' && isMarketplaceAccount) || userRole === 'Admin' ?\r\n : ''}\r\n {(userRole !== 'Supervisor' && isMarketplaceAccount) || userRole === 'Admin' ?\r\n : ''}\r\n {userRole === 'Admin' ?\r\n : ''}\r\n \r\n \r\n \r\n {tabIndex === 1\r\n ? (\r\n \r\n \r\n \r\n )\r\n : null}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {(userRole !== 'Supervisor' && isMarketplaceAccount) || userRole === 'Admin' ? \r\n \r\n \r\n \r\n : ''}\r\n {(userRole !== 'Supervisor' && isMarketplaceAccount) || userRole === 'Admin' ? \r\n \r\n \r\n \r\n : ''}\r\n {userRole === 'Admin' ? \r\n \r\n \r\n \r\n : ''}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nexport default OrderFileConfiguration;\r\n","const userManagementForm = {\r\n formId: 'userManagement',\r\n formField: {\r\n userName: {\r\n props: {\r\n name: 'userName',\r\n type: 'text',\r\n label: 'User name',\r\n isRequired: true,\r\n inputProps: {\r\n maxLength: 35\r\n }\r\n },\r\n validation: {\r\n name: 'userName',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['User name is required'],\r\n },\r\n {\r\n type: 'matches',\r\n params: [/^(?!\\s+$).*/,'User name is required'],\r\n },\r\n ],\r\n },\r\n },\r\n userId: {\r\n props: {\r\n name: 'userId',\r\n type: 'text',\r\n label: 'Id',\r\n\r\n\r\n },\r\n\r\n },\r\n emailId: {\r\n props: {\r\n name: 'emailId',\r\n type: 'text',\r\n label: 'Email Id',\r\n isRequired: true,\r\n\r\n },\r\n validation: {\r\n name: 'emailId',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Email is required'],\r\n },\r\n\r\n {\r\n type: 'matches',\r\n params: [/^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/, 'Invalid email'],\r\n },\r\n ],\r\n },\r\n },\r\n\r\n role: {\r\n props: {\r\n name: 'role',\r\n type: 'select',\r\n label: 'Role',\r\n displayField: 'label',\r\n isRequired: true,\r\n hasDefaultValue: true\r\n },\r\n value: [],\r\n validation: {\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Role is required'],\r\n },\r\n ],\r\n },\r\n },\r\n\r\n\r\n accounts: {\r\n props: {\r\n name: 'accounts',\r\n type: 'multiSelect',\r\n label: 'Accounts',\r\n displayField: 'accountId',\r\n isRequired: true,\r\n hasDefaultValue: false,\r\n },\r\n value: [],\r\n validation: {\r\n name: 'accounts',\r\n validationType: 'array',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Accounts selection is required'],\r\n },\r\n ],\r\n },\r\n },\r\n isActive: {\r\n props: {\r\n name: 'isActive',\r\n label: 'Is active',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n selectAccount: {\r\n props: {\r\n name: 'selectAccount',\r\n label: 'Select account',\r\n type: 'select',\r\n displayField: 'name',\r\n isRequired: true,\r\n value: '0',\r\n },\r\n validation: {\r\n name: 'selectAccount',\r\n validationType: 'object',\r\n validations: [\r\n // {\r\n // type: 'required',\r\n // params: ['Select account is required'],\r\n // },\r\n ],\r\n },\r\n },\r\n setupSearchBy: {\r\n props: {\r\n name: 'setupSearchFor',\r\n type: 'searchControl',\r\n },\r\n selectProps: {\r\n props: {\r\n name: 'setupSearchBy',\r\n label: 'Search For',\r\n placeholder: \"Enter User's Name\",\r\n },\r\n },\r\n textProps: {\r\n props: {\r\n name: 'setupSearchFor',\r\n label: 'Search For',\r\n placeholder: \"Enter User's Name\",\r\n },\r\n },\r\n validation: {\r\n name: 'setupSearchFor',\r\n validationType: 'string',\r\n validations: [\r\n // {\r\n // type: 'required',\r\n // params: ['SearchFor is required'],\r\n // },\r\n {\r\n type: 'min',\r\n params: [1, 'SearchFor length must be greater than 0'],\r\n },\r\n ],\r\n },\r\n },\r\n },\r\n};\r\n\r\nexport default userManagementForm;\r\n","import React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, IconButton, SvgIcon, Divider, Snackbar } from '@material-ui/core';\r\n// import InputTextfield from '../../../framework/Inputs/inputTextField/inputTextField'\r\nimport userManagementForm from '../../../utils/formConfig/userManagement/userManagementForm';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport ConfirmationDialog from '../../addressBook/confirmation/confirmation';\r\nimport { useSelector, useDispatch, connect } from 'react-redux';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport { ReactComponent as InfoIcon } from '../../../assets/images/InfoIcon.svg';\r\nimport { axiosConfig, GET, PATCH, POST } from '../../../api/axios';\r\nimport DialogBox from '../../../components/addShipment/templates/dialogForTemplate/dialogForTemplate';\r\nimport Menu from '@material-ui/core/Menu';\r\nimport MenuItem from '@material-ui/core/MenuItem';\r\nimport { userDetailsObj, setDropdownValues, updateUserObj } from '../../../utils/helperFunctions';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { roleOptions } from '../../../utils/constants/constants';\r\nimport * as actions from '../../../store/actions/index';\r\nimport CustomModal from '../../../framework/dialog/customDialog';\r\n\r\nconst UserDetails = (props) => {\r\n const {\r\n formField: { userName, userId, emailId, role, accounts, isActive },\r\n getuserListData,\r\n } = props;\r\n const isFormValid = (errors) => {\r\n const { deliveryServicePoint, ...restControls } = errors;\r\n return Object.keys(restControls).length === 0;\r\n };\r\n const { setFieldValue, formikValues, errors, setErrors, setFieldTouched } = props;\r\n const userAccounts = useSelector((state) => state.accounts.userAccounts);\r\n const [roles, setroles] = React.useState([]);\r\n const [open, setOpen] = React.useState(false);\r\n const [roleAccess, setRollAccess] = React.useState([]);\r\n const [anchorEl, setAnchorEl] = React.useState(null);\r\n const [showConfirmationDialog, setShowConfirmationDialog] = React.useState(false);\r\n let roleArray = [];\r\n const showRoleDetails = () => { };\r\n const dispatch = useDispatch();\r\n const getRoles = () => {\r\n GET(ServiceEndPoints.getRolesAccess).then((res) => {\r\n roleArray.push(res.data.find(r => r.roleName?.toLowerCase() === formikValues?.role?.value?.toLowerCase())?.accessSet || []);\r\n\r\n // if (formikValues.role && formikValues.role.value === 'Admin') {\r\n // roleArray.push(res.data[0].accessSet);\r\n // }\r\n // if (formikValues.role && formikValues.role.value === 'SuperUser') {\r\n // roleArray.push(res.data[1].accessSet);\r\n // }\r\n // if (formikValues.role && formikValues.role.value === 'Supervisor') {\r\n // roleArray.push(res.data[3].accessSet);\r\n // }\r\n // if (formikValues.role && formikValues.role.value === 'Shipment Entry') {\r\n // roleArray.push(res.data[4].accessSet);\r\n // }\r\n // if (formikValues.role && formikValues.role.value === 'Shipment Entry & Reporting') {\r\n // roleArray.push(res.data[5].accessSet);\r\n // }\r\n // if (formikValues.role && formikValues.role.value === 'Reporting & Shipment Entry') {\r\n // roleArray.push(res.data[6].accessSet);\r\n // }\r\n // if (formikValues.role && formikValues.role.value === 'Reporting') {\r\n // roleArray.push(res.data[2].accessSet);\r\n // }\r\n\r\n setRollAccess(roleArray);\r\n });\r\n };\r\n\r\n React.useEffect(() => {\r\n getRoles();\r\n }, [formikValues.role]);\r\n\r\n React.useEffect(() => {\r\n if (!props.updateUser)\r\n setFieldValue('userName', '');\r\n }, []);\r\n const handleClick = (event) => {\r\n setAnchorEl(event.currentTarget);\r\n };\r\n const handleClose = (value) => {\r\n setAnchorEl(null);\r\n };\r\n\r\n const handleDialogClose = () => {\r\n setShowConfirmationDialog(false);\r\n setFieldValue('role', roleOptions?.[0]);\r\n };\r\n\r\n const onDialogConfirm = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n\r\n const onDialogCancel = () => {\r\n setShowConfirmationDialog(false);\r\n setFieldValue('role', setDropdownValues(roleOptions, 'value', props.updateRowData.role));\r\n };\r\n\r\n function validateEmail(input) {\r\n var validRegex = /^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\r\n if (input.match(validRegex)) {\r\n return false;\r\n }\r\n else {\r\n return true;\r\n }\r\n }\r\n\r\n const postData = () => {\r\n let errors_object = {};\r\n\r\n if (formikValues.userName?.trim() === '') {\r\n errors_object.userName = 'User name is required';\r\n }\r\n if (formikValues.emailId === '' || formikValues.emailId === ' ') {\r\n errors_object.emailId = 'Email is required';\r\n }\r\n if (validateEmail(formikValues.emailId)) {\r\n errors_object.emailId = 'Invalid email';\r\n }\r\n if (formikValues.role.value === '') {\r\n errors_object.role = 'Role is required';\r\n }\r\n if (formikValues.accounts.length === 0) {\r\n errors_object.accounts = 'Accounts selection is required';\r\n }\r\n setErrors(errors_object);\r\n\r\n if (isFormValid(errors_object)) {\r\n dispatch(actions.setLoaderLayOver(true));\r\n const reqObj = userDetailsObj(formikValues);\r\n POST(`${ServiceEndPoints.postUser}`, reqObj)\r\n .then((res) => {\r\n dispatch(actions.setAppSnackBarData({ msg: 'User Created Successfully' }));\r\n setTimeout(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n }, 2000);\r\n props.handleButtonClick();\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: err?.response?.data?.[0]?.detail ?? 'Error occurred, please try again',\r\n },\r\n ],\r\n }),\r\n );\r\n // dispatch(actions.setAppSnackBarData({type:\"error\", msg:'Error!'}))\r\n setTimeout(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n }, 2000);\r\n });\r\n } else {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [{ type: 'error', msg: 'The form has errors, please correct and try again' }],\r\n }),\r\n );\r\n setFieldTouched('userName', true);\r\n setFieldTouched('emailId', true);\r\n setFieldTouched('role', true);\r\n setFieldTouched('accounts', true);\r\n }\r\n };\r\n\r\n const updateData = () => {\r\n let errors_object = {};\r\n\r\n if (formikValues.userName?.trim() === '') {\r\n errors_object.userName = 'User name is required';\r\n }\r\n if (formikValues.emailId === '' || formikValues.emailId === ' ') {\r\n errors_object.emailId = 'Email is required';\r\n }\r\n if (validateEmail(formikValues.emailId)) {\r\n errors_object.emailId = 'Invalid email';\r\n }\r\n if (formikValues.role.value === '') {\r\n errors_object.role = 'Role is required';\r\n }\r\n if (formikValues.accounts.length === 0) {\r\n errors_object.accounts = 'Accounts selection is required';\r\n }\r\n setErrors(errors_object);\r\n if (isFormValid(errors_object)) {\r\n dispatch(actions.setLoaderLayOver(true));\r\n const reqObj = updateUserObj(formikValues);\r\n PATCH(ServiceEndPoints.postUser, reqObj)\r\n .then((res) => {\r\n dispatch(actions.setAppSnackBarData({ msg: 'User updated successfully' }));\r\n\r\n setTimeout(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n }, 2000);\r\n\r\n props.handleButtonClick();\r\n props.getuserListData();\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: err?.response?.data?.[0]?.detail ?? 'Error occurred, please try again',\r\n },\r\n ],\r\n }),\r\n );\r\n setTimeout(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n }, 2000);\r\n });\r\n } else {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [{ type: 'error', msg: 'The form has errors, please correct and try again' }],\r\n }),\r\n );\r\n setFieldTouched('userName', true);\r\n setFieldTouched('emailId', true);\r\n setFieldTouched('role', true);\r\n setFieldTouched('accounts', true);\r\n // return;\r\n }\r\n };\r\n React.useEffect(() => {\r\n if (props.updateUser) {\r\n setFieldValue('userName', props.updateRowData.userName);\r\n setFieldValue('userId', props.updateRowData.id);\r\n setFieldValue('emailId', props.updateRowData.emailId);\r\n setFieldValue('role', setDropdownValues(roleOptions, 'value', props.updateRowData.role));\r\n setTimeout(() => {\r\n setFieldValue('accounts', props.updateRowData.accounts);\r\n }, 0);\r\n setFieldValue('isActive', props.updateRowData.status);\r\n } else if (props.row) {\r\n setFieldValue('userName', '');\r\n setFieldValue('emailId', '');\r\n setFieldValue('role', setDropdownValues(roleOptions, 'value', props.row[0].role));\r\n setFieldValue('accounts', props.row[0].accounts);\r\n } else {\r\n setFieldValue('userName', '');\r\n setFieldValue('userId', ' ');\r\n setFieldValue('emailId', '');\r\n setFieldValue('role', setDropdownValues(roleOptions, 'value', roleOptions[0].value));\r\n setFieldValue('accounts', '');\r\n setFieldValue('isActive', props.updateRowData.status);\r\n }\r\n }, [props.updateUser, props.row]);\r\n\r\n React.useEffect(() => {\r\n if ((formikValues.role?.value?.toLowerCase() === 'retail superuser' || formikValues.role?.value?.toLowerCase() === 'national superuser') && props.updateSuperUserFlag) {\r\n setShowConfirmationDialog(true);\r\n }\r\n }, [formikValues?.role]);\r\n\r\n React.useEffect(() => {\r\n let selectedAccount = [];\r\n if (formikValues.role.value === 'SuperUser') {\r\n userAccounts.map((ele) => {\r\n selectedAccount.push(ele.accountId);\r\n });\r\n setFieldValue('accounts', selectedAccount);\r\n }\r\n else {\r\n if (props.createUser && props.createUser === true)\r\n setFieldValue('accounts', selectedAccount);\r\n }\r\n }, [formikValues.role]);\r\n return (\r\n \r\n \r\n \r\n \r\n {props.updateUser === true ? (\r\n \r\n \r\n \r\n ) : (\r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n With this role user get access to \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {formikValues.accounts !== undefined ? (\r\n formikValues.accounts.length > 1 ? (\r\n Selected accounts \r\n ) : formikValues.accounts.length === 1 ? (\r\n Selected account \r\n ) : null\r\n ) : null}\r\n \r\n \r\n \r\n {((formikValues || {}).accounts || []).join(',')} \r\n \r\n {props.updateUser === true ? (\r\n \r\n \r\n \r\n ) : null}\r\n \r\n {props.updateUser === true ? \r\n \r\n \r\n \r\n : ''}\r\n \r\n \r\n \r\n \r\n 0 && formikValues.isActive}\r\n variant=\"contained\"\r\n buttonType=\"submit\"\r\n onClick={() => {\r\n props.updateUser !== true ? postData() : updateData();\r\n }}\r\n className={`${props.updateUser ? 'contained-btn update-btn' : 'contained-btn create-btn'}`}\r\n />\r\n \r\n \r\n \r\n \r\n );\r\n};\r\nUserDetails.propTypes = {\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n setFieldValue: PropTypes.func,\r\n};\r\n\r\n// const roleOptions = [\r\n// {\r\n// value: '',\r\n// label: 'Select',\r\n// },\r\n// {\r\n// value: 'Admin',\r\n// label: 'Admin',\r\n// },\r\n\r\n// {\r\n// value: 'SuperUser',\r\n// label: 'SuperUser',\r\n// },\r\n// {\r\n// value: 'Supervisor',\r\n// label: 'Supervisor',\r\n// },\r\n// {\r\n// value: 'Shipment Entry',\r\n// label: 'Shipment Entry',\r\n// },\r\n// {\r\n// value: 'Shipment Entry & Reporting',\r\n// label: 'Shipment Entry & Reporting',\r\n// },\r\n// {\r\n// value: 'Reporting',\r\n// label: 'Reporting',\r\n// },\r\n// ];\r\nexport default UserDetails;","import React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, IconButton, SvgIcon } from '@material-ui/core';\r\nimport { ReactComponent as AddIcon } from '../../../../src/assets/images/AddIcon.svg';\r\nimport CustomDialog from './../../../framework/dialog/customDialog';\r\nimport './createNewUser.scss';\r\nimport UserDetails from '../userDetails/userDetails';\r\nimport userManagementForm from '../../../utils/formConfig/userManagement/userManagementForm';\r\nconst CreateNewUser = (props) => {\r\n const { formField, formId } = userManagementForm;\r\n const { setFieldValue, formikValues, updateUser, updateRowData, row, setFieldTouched } = props;\r\n const [open, setOpen] = React.useState(false);\r\n\r\n const openCreateUserModal = () => {\r\n setOpen(true);\r\n };\r\n\r\n// React.useEffect(() => {\r\n// setFieldValue('user')\r\n// },[])\r\n\r\n const handleClose = (props) => {\r\n setOpen(false);\r\n };\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nexport default CreateNewUser;\r\n","import React, { useEffect } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, IconButton, SvgIcon, Divider } from '@material-ui/core';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { useSelector, useDispatch } from 'react-redux';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport { ReactComponent as InfoIcon } from '../../../assets/images/InfoIcon.svg';\r\nimport { axiosConfig, GET, PATCH, POST } from '../../../api/axios';\r\nimport CustomModal from '../../../framework/dialog/customDialog';\r\nimport ConfirmationDialog from '../../addressBook/confirmation/confirmation';\r\nimport Menu from '@material-ui/core/Menu';\r\nimport MenuItem from '@material-ui/core/MenuItem';\r\nimport { userDetailsObj, setDropdownValues, updateUserObj, getCustomerAccountID } from '../../../utils/helperFunctions';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport * as actions from '../../../store/actions/index';\r\n\r\nconst CreateNewRetailUser = (props) => {\r\n const {\r\n formField: { userName, userId, emailId, role, accounts, isActive },\r\n getuserListData,\r\n } = props;\r\n const isFormValid = (errors) => {\r\n const { deliveryServicePoint, ...restControls } = errors;\r\n return Object.keys(restControls).length === 0;\r\n };\r\n const { setFieldValue, formikValues, errors, setErrors, setFieldTouched } = props;\r\n const [roleAccess, setRollAccess] = React.useState([]);\r\n const [anchorEl, setAnchorEl] = React.useState(null);\r\n const [accountsData, setAccountsData] = React.useState([]);\r\n const [roleOptions, setRoleOptions] = React.useState([]);\r\n const [offset, setOffset] = React.useState(0);\r\n // const [showConfirmationDialog, setShowConfirmationDialog] = React.useState(false);\r\n let roleArray = [];\r\n\r\n const showRoleDetails = () => { };\r\n const dispatch = useDispatch();\r\n const getRoles = () => {\r\n GET(ServiceEndPoints.getRolesAccess).then((res) => {\r\n roleArray.push(res.data.find(r => r.roleName?.toLowerCase() === formikValues?.role?.value?.toLowerCase())?.accessSet || []);\r\n setRollAccess(roleArray);\r\n });\r\n };\r\n\r\n React.useEffect(() => {\r\n getRoles();\r\n }, [formikValues.role]);\r\n\r\n\r\n\r\n const getAccounts = (data, textQueryParam = \"\", offsetValue = 0) => {\r\n data.length === 0 && setOffset(0);\r\n let url = `${ServiceEndPoints.getAccounts}?customerAccountId=${getCustomerAccountID()}&offset=${offsetValue}&limit=50`;\r\n if (textQueryParam) {\r\n url += `&text=${textQueryParam}`;\r\n }\r\n GET(url).then((res) => {\r\n let tempArray = data.concat(res.data)\r\n setAccountsData(tempArray);\r\n });\r\n\r\n };\r\n\r\n useEffect(() => {\r\n getAccounts([]);\r\n if (!props.updateUser)\r\n setFieldValue('userName', '');\r\n if (props.userDetailsRole?.toLowerCase() === 'retail superuser') {\r\n setRoleOptions(roleOptionsRetailer);\r\n }\r\n if (props.userDetailsRole?.toLowerCase() === 'national superuser') {\r\n setRoleOptions(roleOptionsReseller);\r\n }\r\n\r\n }, []);\r\n\r\n const handleClick = (event) => {\r\n setAnchorEl(event.currentTarget);\r\n };\r\n const handleClose = (value) => {\r\n setAnchorEl(null);\r\n };\r\n\r\n // const handleDialogClose = () => {\r\n // setShowConfirmationDialog(false);\r\n // };\r\n\r\n // const onDialogConfirm = () => {\r\n // setShowConfirmationDialog(false);\r\n // };\r\n\r\n // const onDialogCancel = () => {\r\n // setShowConfirmationDialog(false);\r\n // setFieldValue('role',roleOptions[0]);\r\n // };\r\n\r\n function validateEmail(input){\r\n var validRegex = /^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\r\n if(input.match(validRegex))\r\n {\r\n return false;\r\n }\r\n else\r\n {\r\n return true;\r\n }\r\n }\r\n\r\n const postData = () => {\r\n let errors_object = {};\r\n\r\n if (formikValues.userName?.trim() === '') {\r\n errors_object.userName = 'User name is required';\r\n }\r\n if (formikValues.emailId === '' || formikValues.emailId === ' ') {\r\n errors_object.emailId = 'Email is required';\r\n }\r\n if(validateEmail(formikValues.emailId))\r\n {\r\n errors_object.emailId = 'Invalid email'\r\n }\r\n if (formikValues.role.value === '') {\r\n errors_object.role = 'Role is required';\r\n }\r\n if (formikValues.accounts.length === 0) {\r\n errors_object.accounts = 'Accounts selection is required';\r\n }\r\n setErrors(errors_object);\r\n\r\n if (isFormValid(errors_object)) {\r\n dispatch(actions.setLoaderLayOver(true));\r\n const reqObj = userDetailsObj(formikValues);\r\n POST(`${ServiceEndPoints.postUser}`, reqObj)\r\n .then((res) => {\r\n dispatch(actions.setAppSnackBarData({ msg: 'User Created Successfully' }));\r\n setTimeout(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n }, 2000);\r\n props.handleButtonClick();\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: err?.response?.data?.[0]?.detail ?? 'Error occurred, please try again',\r\n },\r\n ],\r\n }),\r\n );\r\n // dispatch(actions.setAppSnackBarData({type:\"error\", msg:'Error!'}))\r\n setTimeout(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n }, 2000);\r\n });\r\n } else {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [{ type: 'error', msg: 'The form has errors, please correct and try again' }],\r\n }),\r\n );\r\n setFieldTouched('userName', true);\r\n setFieldTouched('emailId', true);\r\n setFieldTouched('role', true);\r\n setFieldTouched('accounts', true);\r\n }\r\n };\r\n\r\n const updateData = () => {\r\n let errors_object = {};\r\n\r\n if (formikValues.userName?.trim() === '') {\r\n errors_object.userName = 'User name is required';\r\n }\r\n if (formikValues.emailId === '' || formikValues.emailId === ' ') {\r\n errors_object.emailId = 'Email is required';\r\n }\r\n if(validateEmail(formikValues.emailId))\r\n {\r\n errors_object.emailId = 'Invalid email'\r\n }\r\n if (formikValues.role.value === '') {\r\n errors_object.role = 'Role is required';\r\n }\r\n if (formikValues.accounts.length === 0) {\r\n errors_object.accounts = 'Accounts selection is required';\r\n }\r\n setErrors(errors_object);\r\n if (isFormValid(errors_object)) {\r\n dispatch(actions.setLoaderLayOver(true));\r\n const reqObj = updateUserObj(formikValues);\r\n PATCH(ServiceEndPoints.postUser, reqObj)\r\n .then((res) => {\r\n dispatch(actions.setAppSnackBarData({ msg: 'User updated successfully' }));\r\n setTimeout(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n props.handleButtonClick();\r\n props.getuserListData();\r\n }, 9000);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: err?.response?.data?.[0]?.detail ?? 'Error occurred, please try again',\r\n },\r\n ],\r\n }),\r\n );\r\n setTimeout(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n }, 2000);\r\n });\r\n } else {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [{ type: 'error', msg: 'The form has errors, please correct and try again' }],\r\n }),\r\n );\r\n setFieldTouched('userName', true);\r\n setFieldTouched('emailId', true);\r\n setFieldTouched('role', true);\r\n setFieldTouched('accounts', true);\r\n // return;\r\n }\r\n };\r\n\r\n React.useEffect(() => {\r\n if (props.updateUser) {\r\n setFieldValue('userName', props.updateRowData.userName);\r\n setFieldValue('userId', props.updateRowData.id);\r\n setFieldValue('emailId', props.updateRowData.emailId);\r\n setTimeout(() => {\r\n setFieldValue('role', setDropdownValues(roleOptions, 'value', props.updateRowData.role)); \r\n }, 0);\r\n setFieldValue('accounts', props.updateRowData.accounts);\r\n setFieldValue('isActive', props.updateRowData.status);\r\n }\r\n else if (props.row) {\r\n setFieldValue('userName', '');\r\n setFieldValue('emailId', '');\r\n setFieldValue('role', setDropdownValues(roleOptions, 'value', props.row[0].role));\r\n setFieldValue('accounts', props.row[0].accounts);\r\n }\r\n else {\r\n setFieldValue('userName', '');\r\n setFieldValue('userId', ' ');\r\n setFieldValue('emailId', '');\r\n setFieldValue('role', setDropdownValues(roleOptions, 'value', roleOptions[0]?.value));\r\n setFieldValue('accounts', '');\r\n setFieldValue('isActive', props.updateRowData.status);\r\n }\r\n }, [props.updateUser, props.row, roleOptions]);\r\n\r\n // React.useEffect(()=>{\r\n // if (formikValues.role.value === 'SuperUser')\r\n // {\r\n // setShowConfirmationDialog(true);\r\n // }\r\n // },[formikValues]);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n {props.updateUser === true ? (\r\n \r\n \r\n \r\n ) : (\r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n With this role user get access to \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n\r\n {props.updateUser === true ? (\r\n \r\n \r\n \r\n ) : null}\r\n\r\n {/* \r\n \r\n \r\n \r\n */}\r\n\r\n \r\n \r\n \r\n \r\n 0}\r\n variant=\"contained\"\r\n buttonType=\"submit\"\r\n onClick={() => {\r\n props.updateUser !== true ? postData() : updateData();\r\n }}\r\n className={`${props.updateUser ? 'contained-btn update-btn' : 'contained-btn create-btn'}`}\r\n />\r\n \r\n \r\n \r\n \r\n\r\n );\r\n};\r\nCreateNewRetailUser.propTypes = {\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n setFieldValue: PropTypes.func,\r\n};\r\n\r\nconst roleOptionsRetailer = [\r\n {\r\n value: '',\r\n label: 'Select',\r\n },\r\n {\r\n value: 'Supervisor',\r\n label: 'Supervisor',\r\n },\r\n {\r\n value: 'Shipment Entry',\r\n label: 'Shipment Entry',\r\n },\r\n {\r\n value: 'Reporting & Shipment Entry',\r\n label: 'Reporting & Shipment Entry',\r\n },\r\n {\r\n value: 'Reporting',\r\n label: 'Reporting',\r\n },\r\n {\r\n value: 'Retail SuperUser',\r\n label: 'Retail SuperUser',\r\n },\r\n {\r\n value: 'Basic Shipment Entry',\r\n label: 'Basic Shipment Entry',\r\n },\r\n]\r\nconst roleOptionsReseller = [\r\n {\r\n value: '',\r\n label: 'Select',\r\n },\r\n {\r\n value: 'National SuperUser',\r\n label: 'National SuperUser',\r\n },\r\n {\r\n value: 'Basic Shipment Entry',\r\n label: 'Basic Shipment Entry',\r\n },\r\n {\r\n value: 'Basic Shipment Entry & Reporting',\r\n label: 'Basic Shipment Entry & Reporting',\r\n }\r\n];\r\n\r\nexport default CreateNewRetailUser;\r\n\r\n","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid } from '@material-ui/core';\r\nimport DynamicMaterialTable from '../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\nimport InputButton from '../../framework/Inputs/inputButton/inputButton';\r\nimport { useSelector } from 'react-redux';\r\nimport CustomDialog from '../../framework/dialog/customDialog';\r\nimport CreateNewUser from '../../components/userManagement/createNewUser/createNewUser';\r\nimport CreateNewRetailUser from '../../components/userManagement/createNewRetailUser/createNewRetailUser';\r\n\r\nexport default function UserList(props) {\r\n const {\r\n rows,\r\n columns,\r\n isSearchable,\r\n isSelectable,\r\n sorting,\r\n paging,\r\n pageSize,\r\n pageSizeOptions,\r\n isUsers,\r\n currentAccount,\r\n } = props;\r\n\r\n const [open, setOpen] = useState(false);\r\n const [selectedRows, setSelectedRows] = useState([]);\r\n const [selectedAccountRows, setSelectedAccountRows] = useState([]);\r\n const addDefaultAccountToAllUsers = useSelector((state) => state.addNewAccountToUsers.addNewAccountToUsers);\r\n\r\n const addSelectedRows = (selRows, index) => {\r\n if (isUsers) {\r\n setSelectedRows(selRows);\r\n } else if (currentAccount !== '0' && index) {\r\n setSelectedAccountRows(selRows);\r\n props.checkedUserToAccount(index.id, false);\r\n } else {\r\n props.checkedUserToAccount('', true);\r\n }\r\n };\r\n useEffect(() => {\r\n setSelectedAccountRows([]);\r\n }, [currentAccount]);\r\n\r\n useEffect(()=> {\r\n setTimeout(() => {\r\n props.setFieldValue('setupSearchFor','');\r\n if(props.setupSearchForFlag)\r\n {\r\n props.getuserListData();\r\n props.setSetupSearchForFlag();\r\n } \r\n }, 0); \r\n },[props.formikValues.setupSearchBy.value])\r\n\r\n const addAccountToAllUsers = () => {\r\n props.addAccountToAllUsers(currentAccount);\r\n };\r\n\r\n const addUserToAccount = () => {\r\n props.addToAccount(selectedAccountRows, currentAccount);\r\n };\r\n\r\n const openCreateUserModal = () => {\r\n setOpen(true);\r\n };\r\n const handleCloseModal = () => {\r\n setOpen(false);\r\n };\r\n return (\r\n \r\n \r\n \r\n \r\n {isUsers\r\n ? [\r\n \r\n \r\n 1}\r\n className=\"outlined-btn Clone-user\"\r\n label=\"Clone user\"\r\n onClick={openCreateUserModal}\r\n // onClick={() => setShowConfirmationDialog(true)}\r\n />\r\n \r\n ,\r\n ]\r\n : [\r\n \r\n {!addDefaultAccountToAllUsers && (\r\n \r\n addAccountToAllUsers()}\r\n />\r\n \r\n )}\r\n \r\n addUserToAccount()}\r\n />\r\n \r\n ,\r\n ]}\r\n {props.userDetailsRole?.toLowerCase() === 'superuser' ? \r\n \r\n \r\n :\r\n \r\n \r\n }\r\n \r\n );\r\n}\r\n\r\nUserList.propTypes = {\r\n rows: PropTypes.array,\r\n columns: PropTypes.array,\r\n isSearchable: PropTypes.bool,\r\n isSelectable: PropTypes.bool,\r\n sorting: PropTypes.bool,\r\n paging: PropTypes.bool,\r\n pageSize: PropTypes.number,\r\n isUsers: PropTypes.bool,\r\n addToAccount: PropTypes.func,\r\n addAccountToAllUsers: PropTypes.func,\r\n checkedUserToAccount: PropTypes.func,\r\n hideTotalCount: PropTypes.bool,\r\n};\r\n","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from \"react\";\n\nvar _ref2 = /*#__PURE__*/React.createElement(\"g\", {\n id: \"selected\",\n transform: \"translate(0.707 0.707)\"\n}, /*#__PURE__*/React.createElement(\"path\", {\n id: \"color\",\n d: \"M4.707,7.293,12,0l1.414,1.414L4.707,10.121,0,5.414,1.414,4Z\",\n fill: \"#28ac00\",\n stroke: \"#28ac00\",\n strokeWidth: 1\n}));\n\nfunction SvgStatusYes(_ref, svgRef) {\n var title = _ref.title,\n titleId = _ref.titleId,\n props = _objectWithoutProperties(_ref, [\"title\", \"titleId\"]);\n\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 14.828,\n height: 11.536,\n viewBox: \"0 0 14.828 11.536\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, _ref2);\n}\n\nvar ForwardRef = /*#__PURE__*/React.forwardRef(SvgStatusYes);\nexport default __webpack_public_path__ + \"static/media/status-yes.2ca81b44.svg\";\nexport { ForwardRef as ReactComponent };","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from \"react\";\n\nvar _ref2 = /*#__PURE__*/React.createElement(\"path\", {\n id: \"Icon_ionic-md-close\",\n \"data-name\": \"Icon ionic-md-close\",\n d: \"M18.916,8.663,17.777,7.523,13.22,12.081,8.663,7.523,7.523,8.663l4.557,4.557L7.523,17.777l1.139,1.139,4.557-4.557,4.557,4.557,1.139-1.139L14.359,13.22Z\",\n transform: \"translate(-6.816 -6.816)\",\n fill: \"#f36b08\",\n stroke: \"#f26b08\",\n strokeWidth: 1\n});\n\nfunction SvgStatusNo(_ref, svgRef) {\n var title = _ref.title,\n titleId = _ref.titleId,\n props = _objectWithoutProperties(_ref, [\"title\", \"titleId\"]);\n\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 12.807,\n height: 12.807,\n viewBox: \"0 0 12.807 12.807\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, _ref2);\n}\n\nvar ForwardRef = /*#__PURE__*/React.forwardRef(SvgStatusNo);\nexport default __webpack_public_path__ + \"static/media/status-no.6d6515c6.svg\";\nexport { ForwardRef as ReactComponent };","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from \"react\";\n\nvar _ref2 = /*#__PURE__*/React.createElement(\"defs\", null, /*#__PURE__*/React.createElement(\"style\", null, \".cls-1{fill:none;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:2px;}\"));\n\nvar _ref3 = /*#__PURE__*/React.createElement(\"g\", {\n id: \"Icon_feather-info\",\n \"data-name\": \"Icon feather-info\"\n}, /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_2780\",\n \"data-name\": \"Path 2780\",\n className: \"cls-1\",\n d: \"M28.74,20A8.74,8.74,0,1,1,20,11.22,8.74,8.74,0,0,1,28.74,20Z\"\n}), /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_2781\",\n \"data-name\": \"Path 2781\",\n className: \"cls-1\",\n d: \"M20,23.47V20\"\n}), /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_2782\",\n \"data-name\": \"Path 2782\",\n className: \"cls-1\",\n d: \"M20,16.47h0\"\n}));\n\nfunction SvgInfoIconDark(_ref, svgRef) {\n var title = _ref.title,\n titleId = _ref.titleId,\n props = _objectWithoutProperties(_ref, [\"title\", \"titleId\"]);\n\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n id: \"Layer_1\",\n \"data-name\": \"Layer 1\",\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 40 39.94\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, _ref2, _ref3);\n}\n\nvar ForwardRef = /*#__PURE__*/React.forwardRef(SvgInfoIconDark);\nexport default __webpack_public_path__ + \"static/media/InfoIconDark.68c9c8da.svg\";\nexport { ForwardRef as ReactComponent };","import React, { useState, useEffect } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { useHistory } from 'react-router-dom';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport Grid from '@material-ui/core/Grid';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../../store/actions/index';\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n SearchAddressField: {\r\n marginTop: '10px',\r\n paddingRight: '13px',\r\n },\r\n}));\r\n\r\nconst SelectedAccounts = (props) => {\r\n const classes = useStyles();\r\n const dispatch = useDispatch();\r\n let history = useHistory();\r\n const {\r\n formField: { selectAccount },\r\n setFieldValue,\r\n formikValues,\r\n errors,\r\n setFieldTouched,\r\n existingAccounts,\r\n onAccountChangeChange,\r\n } = props;\r\nuseEffect(() => {\r\n if (formikValues.selectAccount === undefined) {\r\n setFieldValue('selectAccount', existingAccounts[0]);\r\n }\r\n if (formikValues.selectAccount) {\r\n props.onAccountChangeChange(formikValues.selectAccount)\r\n }\r\n}, [formikValues.selectAccount])\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n );\r\n};\r\n\r\nSelectedAccounts.propTypes = {\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n onAccountChange: PropTypes.func,\r\n totalRecords: PropTypes.string,\r\n setFieldValue: PropTypes.func,\r\n isFavourites: PropTypes.object,\r\n setFieldTouched: PropTypes.func,\r\n}\r\n\r\nexport default SelectedAccounts;\r\n","import React from 'react';\r\nimport { connect } from 'react-redux';\r\nimport { AppBar, Tabs, Tab, Grid, IconButton, SvgIcon, Divider } from '@material-ui/core/';\r\nimport { Form, Formik } from 'formik';\r\nimport { ReactComponent as AddIcon } from '../../../src/assets/images/AddIcon.svg';\r\nimport { getYupSchemaFromMetaData } from '../../utils/yupSchema/yupSchemaGenerator';\r\nimport './UserManagement.scss';\r\nimport CreateNewUser from '../../components/userManagement/createNewUser/createNewUser';\r\nimport CreateNewRetailUser from '../../components/userManagement/createNewRetailUser/createNewRetailUser';\r\nimport TabPanel from '../../components/shared/tabPanel';\r\nimport UserList from '../../components/userManagement/UserList';\r\nimport { ServiceEndPoints } from '../../utils/constants/ApiConstant';\r\nimport { withRouter } from 'react-router-dom';\r\nimport { axiosConfig, abortOnGoingCallsFor } from '../../api/axios';\r\nimport CustomDialog from './../../framework/dialog/customDialog';\r\nimport { ReactComponent as statusyes } from '../../assets/images/status-yes.svg';\r\nimport { ReactComponent as statusno } from '../../assets/images/status-no.svg';\r\nimport { ReactComponent as InfoIcon } from '../../assets/images/InfoIconDark.svg';\r\nimport SelectedAccounts from '../../components/userManagement/Accounts/SelectedAccounts';\r\nimport userManagementForm from '../../utils/formConfig/userManagement/userManagementForm';\r\nimport Menu from '@material-ui/core/Menu';\r\nimport MenuItem from '@material-ui/core/MenuItem';\r\nimport { roleOptions, UserManagementSearch, UserRoles } from '../../utils/constants/constants';\r\nimport { basicSort, customTableSort, getCustomerAccountID, formatDate } from '../../utils/helperFunctions';\r\nimport * as actions from '../../store/actions/index';\r\nimport FormRenderer from '../../framework/Inputs/formRenderer/formRenderer';\r\n\r\nconst formikRef = React.createRef(null);\r\nconst { formId, formField } = userManagementForm;\r\nconst userManagementSchema = getYupSchemaFromMetaData(formField, [], []);\r\nconst initialValues = {\r\n setupSearchFor: '',\r\n setupSearchBy: UserManagementSearch[0],\r\n role: roleOptions[0],\r\n};\r\n\r\nconst additionalProps = {\r\n selectionProps: (rowData) => ({\r\n disabled: rowData.isAccountSelected === true && rowData.isAccountDisabled === true ? true : false,\r\n checked: rowData.isAccountSelected === true ? true : false,\r\n }),\r\n showSelectAllCheckbox: false,\r\n};\r\n\r\nconst ITEM_HEIGHT = 48;\r\nclass UserManagement extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n createUser: false,\r\n updateUser: false,\r\n updateSuperUserFlag: false,\r\n setupSearchForFlag : false,\r\n rowData: {},\r\n open: false,\r\n tabIndex: 0,\r\n fromIndex: 1,\r\n totalRecords: 0,\r\n currentAccount: '0',\r\n existingAccounts: [{}],\r\n anchorEl: null,\r\n roleAccess: [],\r\n currentAccess: [],\r\n isTabChanged: false,\r\n isClearBtn: false,\r\n searchText: '',\r\n userListcolumns: [\r\n {\r\n title: 'id',\r\n field: 'id',\r\n hidden: true,\r\n width: 0,\r\n render: (row) => {\r\n return this.customerNumberClicked(row)}>{row.id}
;\r\n },\r\n },\r\n {\r\n title: 'User name',\r\n field: 'userName',\r\n render: (row) => {\r\n return this.customerNumberClicked(row)}>{row.userName}
;\r\n },\r\n customSort: (a, b) => customTableSort(a.userName, b.userName),\r\n width: 150,\r\n },\r\n {\r\n title: 'Role',\r\n field: 'role',\r\n render: (row) => this.customerNumberClicked(row)}>{row.role}
,\r\n sorting: true,\r\n customSort: (a, b) => customTableSort(a.role, b.role),\r\n width: 120,\r\n },\r\n {\r\n field: 'role',\r\n width: 20,\r\n sorting: false,\r\n render: (row) => (\r\n <>\r\n this.handleClick(e, row.role)} style={{ height: '20px', width: '20px' }}>\r\n \r\n \r\n >\r\n ),\r\n },\r\n {\r\n title: 'Email id',\r\n field: 'emailId',\r\n render: (row) => this.customerNumberClicked(row)}>{row.emailId}
,\r\n sorting: true,\r\n customSort: (a, b) => customTableSort(a.emailId, b.emailId),\r\n width: 200,\r\n },\r\n {\r\n title: 'Created by',\r\n field: 'createdBy',\r\n render: (row) => this.customerNumberClicked(row)}>{row.createdBy}
,\r\n sorting: true,\r\n customSort: (a, b) => customTableSort(a.createdBy, b.createdBy),\r\n width: 130,\r\n },\r\n {\r\n title: 'Last updated',\r\n field: 'lastUpdated',\r\n render: (row) => this.customerNumberClicked(row)}>{row.lastUpdated ? formatDate(row.lastUpdated, '/', 'dd/mm/yy') : null}
,\r\n sorting: true,\r\n customSort: (a, b) =>\r\n basicSort(new Date(a.lastUpdated).getTime() || 0, new Date(b.lastUpdated).getTime() || 0),\r\n width: 130,\r\n },\r\n {\r\n title: 'Updated by',\r\n field: 'updatedBy',\r\n customSort: (a, b) => customTableSort(a.updatedBy, b.updatedBy),\r\n render: (row) => this.customerNumberClicked(row)}>{row.updatedBy}
,\r\n sorting: true,\r\n width: 100,\r\n },\r\n {\r\n title: 'Status',\r\n field: 'status',\r\n headerStyle: {\r\n textAlign: 'center',\r\n },\r\n cellStyle: {\r\n textAlign: 'center',\r\n paddingLeft: '4%',\r\n paddingTop: '22px !important',\r\n },\r\n render: (row) => (\r\n <>\r\n this.customerNumberClicked(row)}>
\r\n {row.status}\r\n {row.status === true ? (\r\n \r\n \r\n \r\n ) : (\r\n \r\n \r\n \r\n )}\r\n >\r\n ),\r\n sorting: false,\r\n width: 90,\r\n selection: false,\r\n },\r\n ],\r\n usersToAccountcolumns: [\r\n { title: 'id', field: 'id', hidden: true, width: 0 },\r\n {\r\n title: 'User name',\r\n field: 'userName',\r\n render: (row) => {\r\n return this.customerNumberClicked(row)}>{row.userName}
;\r\n },\r\n customSort: (a, b) => customTableSort(a.userName, b.userName),\r\n width: 150,\r\n },\r\n {\r\n title: 'Role',\r\n field: 'role',\r\n render: (row) => {\r\n return this.customerNumberClicked(row)}>{row.role}
;\r\n },\r\n customSort: (a, b) => customTableSort(a.role, b.role),\r\n width: 150,\r\n },\r\n {\r\n title: 'Email id',\r\n field: 'emailId',\r\n render: (row) => {\r\n return this.customerNumberClicked(row)}>{row.emailId}
;\r\n },\r\n customSort: (a, b) => customTableSort(a.emailId, b.emailId),\r\n width: 200,\r\n },\r\n ],\r\n rows: [],\r\n userList_pageDetails: {\r\n offset: 0,\r\n limit: 0,\r\n totalRecordsLength: 0,\r\n page: 0,\r\n },\r\n userList_final_data: [],\r\n userList_totalCount: 0,\r\n usersToAccount_pageDetails: {\r\n offset: 0,\r\n limit: 0,\r\n totalRecordsLength: 0,\r\n page: 0,\r\n },\r\n usersToAccount_final_data: [],\r\n usersToAccount_totalCount: 0,\r\n userListCount: 0,\r\n pageSize: 50,\r\n pageNumber: 0,\r\n isLoading: false,\r\n userListData: [],\r\n addUsersToTotalRecords: 0,\r\n addUsersToData: [],\r\n };\r\n this.userDetailsPageToken = [''];\r\n this.userAccountsPageToken = [''];\r\n this.onAccountChange = this.onAccountChange.bind(this);\r\n this.loadUserAccount = this.loadUserAccount.bind(this);\r\n this.updateAccountStatus = this.updateAccountStatus.bind(this);\r\n this.checkedUserToAccount = this.checkedUserToAccount.bind(this);\r\n this.loadRolesAndAccess = this.loadRolesAndAccess.bind(this);\r\n }\r\n\r\n componentDidMount() {\r\n formikRef.current.setFieldValue('setupSearchBy', UserManagementSearch[0])\r\n this.loadUserAccount();\r\n this.loadRolesAndAccess();\r\n this.getuserListData();\r\n }\r\n\r\n handleClick = (event, value) => {\r\n let currentRole = this.state.roleAccess.find((role) => role.name.toLowerCase() === value.toLowerCase());\r\n this.setState({ currentAccess: currentRole.value });\r\n this.setState({ anchorEl: event.currentTarget });\r\n };\r\n\r\n handleClose = (value) => {\r\n this.setState({ currentAccess: [] });\r\n this.setState({ anchorEl: null });\r\n };\r\n\r\n loadRolesAndAccess() {\r\n let url = ServiceEndPoints.getRolesAccess;\r\n axiosConfig\r\n .get(url)\r\n .then((response) => {\r\n let roles = [];\r\n response.data.map((userRole) => {\r\n const item = {\r\n name: userRole.roleName,\r\n value: userRole.accessSet,\r\n };\r\n roles.push(item);\r\n });\r\n this.setState({\r\n roleAccess: roles,\r\n });\r\n })\r\n .catch((err) => { });\r\n }\r\n\r\n loadUserAccount() {\r\n if (this.props.userDetails && this.props.userDetails.accounts.length > 0) {\r\n var accounts = this.props.userDetails.accounts;\r\n var lstAccounts = [];\r\n accounts.map((account) => {\r\n const item = {\r\n name: `${account.accountId}-${account.accountName}${(account.configuration.firstMileDropOffAllowed) ? '-FMD' : ''}`,\r\n value: account.accountId,\r\n };\r\n lstAccounts.push(item);\r\n });\r\n this.setState({\r\n existingAccounts: lstAccounts,\r\n });\r\n }\r\n }\r\n\r\n onAccountChange(value) {\r\n // this.setState(\r\n // {\r\n // isTabChanged: true,\r\n // },\r\n // () => {\r\n this.updateAccountStatus(value);\r\n // },\r\n // );\r\n }\r\n\r\n updateAccountStatus(value) {\r\n let newArray = [...this.state.usersToAccount_final_data];\r\n newArray.map((stateValue, index) => {\r\n newArray[index] = { ...stateValue, isAccountSelected: false, isAccountDisabled: false };\r\n });\r\n newArray.map((stateValue, index) => {\r\n let isAccountAvailable = stateValue.accounts.some((val) => {\r\n return Object.keys(val) === 0 ?\r\n val?.toLowerCase() === value.value.toLowerCase() : false\r\n });\r\n if (isAccountAvailable) {\r\n newArray[index] = { ...newArray[index], isAccountSelected: !newArray[index].isAccountSelected };\r\n newArray[index] = { ...newArray[index], isAccountDisabled: !newArray[index].isAccountDisabled };\r\n }\r\n });\r\n this.setState({\r\n usersToAccount_final_data: newArray,\r\n currentAccount: value.value === '' ? '0' : value.value,\r\n });\r\n // tableRef.current && tableRef.current.onQueryChange();\r\n this.getuserListData();\r\n }\r\n\r\n checkedUserToAccount(selectedRow, resetchecked) {\r\n if (resetchecked) {\r\n this.state.userList_final_data.forEach((d) => {\r\n if (d.tableData) d.tableData.checked = false;\r\n });\r\n } else {\r\n const elementsIndex = this.state.usersToAccount_final_data.findIndex(\r\n (element) => element.id.toLowerCase() == selectedRow.toLowerCase(),\r\n );\r\n let newArray = [...this.state.usersToAccount_final_data];\r\n newArray[elementsIndex] = {\r\n ...newArray[elementsIndex],\r\n isAccountSelected: !newArray[elementsIndex].isAccountSelected,\r\n };\r\n this.setState({\r\n usersToAccount_final_data: newArray,\r\n });\r\n }\r\n }\r\n\r\n addAccountToAllUsers = (accountSelected) => {\r\n let itemsToBeAdded = [];\r\n this.state.usersToAccount_final_data.map((account) => {\r\n const itemAccount = account.accounts;\r\n let isAccountAvailable = itemAccount.some((val) => val.toLowerCase() === accountSelected.toLowerCase());\r\n if (!isAccountAvailable) {\r\n const item = {\r\n name: account.userName,\r\n emailId: account.emailId,\r\n customerAccountID: getCustomerAccountID(),\r\n role: account.role,\r\n accounts: account.accounts,\r\n isActive: account.status,\r\n };\r\n itemsToBeAdded.push(item);\r\n }\r\n });\r\n const payload = itemsToBeAdded;\r\n\r\n axiosConfig\r\n .patch(`${ServiceEndPoints.postUsersToAccount}?accountID=${accountSelected}`, payload)\r\n .then((response) => {\r\n this.props.setSnackBar({ msg: 'Account added to all users' });\r\n // if (tableRef.current) {\r\n this.setState({ isTabChanged: true, pageSize: 50, pageNumber: 0 }, () => {\r\n // tableRef.current.onQueryChange();\r\n this.getuserListData();\r\n });\r\n // }\r\n })\r\n .catch((error) => {\r\n alert('Could not add account to user, please try again.');\r\n });\r\n };\r\n\r\n addToAccount = (accountIds, accountSelected) => {\r\n let itemsToBeAdded = [];\r\n accountIds.map((account) => {\r\n const item = {\r\n name: account.userName,\r\n emailId: account.emailId,\r\n customerAccountID: getCustomerAccountID(),\r\n role: account.role,\r\n accounts: account.accounts,\r\n isActive: account.status,\r\n };\r\n itemsToBeAdded.push(item);\r\n });\r\n const payload = itemsToBeAdded;\r\n\r\n axiosConfig\r\n .patch(`${ServiceEndPoints.postUsersToAccount}?accountID=${accountSelected}`, payload)\r\n .then((response) => {\r\n this.props.setSnackBar({ msg: 'Account added to users' });\r\n // tableRef.current && tableRef.current.onQueryChange();\r\n this.getuserListData();\r\n })\r\n .catch((error) => {\r\n alert('Could not add account to user, please try again.');\r\n });\r\n };\r\n\r\n customerNumberClicked = (rowDatas) => {\r\n rowDatas?.role?.toLowerCase() === 'superuser' ? this.setState({ updateSuperUserFlag: true }) : this.setState({ updateSuperUserFlag: false });\r\n if (this.props.userDetails.role?.toLowerCase() === 'superuser') {\r\n this.setState({ open: true, rowData: rowDatas, updateUser: true, createUser: false });\r\n }\r\n else if (this.props.userDetails.role?.toLowerCase() === 'retail superuser') {\r\n console.log(rowDatas.role, this.props.userDetails.role)\r\n if (rowDatas.role?.toLowerCase() !== 'superuser' && rowDatas.role?.toLowerCase() !== 'national superuser') {\r\n this.setState({ open: true, rowData: rowDatas, updateUser: true, createUser: false });\r\n }\r\n }\r\n else if (this.props.userDetails.role?.toLowerCase() === 'national superuser') {\r\n if (rowDatas.role?.toLowerCase() === 'national superuser' || rowDatas.role?.toLowerCase() === 'basic shipment entry' || rowDatas.role?.toLowerCase() === 'basic shipment entry & reporting') {\r\n this.setState({ open: true, rowData: rowDatas, updateUser: true, createUser: false });\r\n }\r\n }\r\n };\r\n\r\n openCreateUserModal = async () => {\r\n this.setState({ open: true, updateUser: false, createUser: true });\r\n };\r\n\r\n handleCloseModal = async (setErrors, resetForm) => {\r\n this.setState({ open: false, updateUser: false, createUser: false });\r\n await resetForm({});\r\n await setErrors({});\r\n formikRef.current.setFieldValue('setupSearchBy', UserManagementSearch[0])\r\n formikRef.current.setFieldValue('setupSearchFor', '')\r\n this.getClear();\r\n };\r\n\r\n handleButtonClick = () => {\r\n this.setState({ open: false });\r\n };\r\n\r\n handleTabChange = (event, index) => {\r\n if (index === 0) {\r\n this.updateAccountStatus({ name: 'Select', value: '' });\r\n formikRef.current.resetForm();\r\n this.state.userList_final_data.forEach((d) => {\r\n if (d.tableData) d.tableData.checked = false;\r\n });\r\n this.userDetailsPageToken.length = 0;\r\n this.userDetailsPageToken = [''];\r\n } else {\r\n this.userAccountsPageToken.length = 0;\r\n this.userAccountsPageToken = [''];\r\n }\r\n this.setState({ tabIndex: index, isTabChanged: true, pageSize: 50, pageNumber: 0 }, () => {\r\n // tableRef.current && tableRef.current.onQueryChange();\r\n this.getuserListData();\r\n });\r\n formikRef.current.setFieldValue('setupSearchBy', UserManagementSearch[0])\r\n formikRef.current.setFieldValue('setupSearchFor', '')\r\n this.getClear()\r\n };\r\n\r\n getuserListData = () => {\r\n this.setState({ isLoading: true });\r\n const offset = this.state.pageSize * this.state.pageNumber;\r\n const limit = this.state.pageSize;\r\n let totalCnt = limit * (this.state.pageNumber + 1);\r\n abortOnGoingCallsFor(ServiceEndPoints.getUsers);\r\n axiosConfig\r\n .get(this.getUrl(offset, limit))\r\n .then((res) => {\r\n const isAddToAccList = this.state.tabIndex === 1;\r\n if (this.state.pageNumber === 0) {\r\n this.userDetailsPageToken.length = 0;\r\n this.userDetailsPageToken = [''];\r\n this.userAccountsPageToken.length = 0;\r\n this.userAccountsPageToken = [''];\r\n } else if (\r\n this.state[isAddToAccList ? 'usersToAccount_pageDetails' : 'userList_pageDetails'].page >\r\n this.state.pageNumber\r\n ) {\r\n this.userDetailsPageToken = this.userDetailsPageToken.slice(0, this.state.userList_pageDetails.page);\r\n this.userAccountsPageToken = this.userAccountsPageToken.slice(0, this.state.usersToAccount_pageDetails.page);\r\n }\r\n\r\n res.data?.skipToken && this.userDetailsPageToken.push(res.data.skipToken);\r\n res.data?.skipToken && this.userAccountsPageToken.push(res.data.skipToken);\r\n\r\n this.setState({\r\n [isAddToAccList ? 'usersToAccount_pageDetails' : 'userList_pageDetails']: {\r\n offset: offset,\r\n limit: limit,\r\n totalRecordsLength: res.data?.skipToken ? totalCnt + 1 : totalCnt,\r\n page: this.state.pageNumber,\r\n },\r\n isTabChanged: false,\r\n });\r\n this.setState({ totalRecords: (res.data || {}).skipToken ? totalCnt + 1 : totalCnt });\r\n this.formatUserListData(res.data, totalCnt);\r\n\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n this.formatUserListData([]);\r\n })\r\n .finally(() => this.setState({ isLoading: false }));\r\n }\r\n\r\n getUrl = (offset, limit) => {\r\n let url = `${ServiceEndPoints.getUsers}?accountsNotRequired=true`;\r\n let searchedValue = formikRef.current.values.setupSearchFor?.trim();\r\n if (searchedValue && formikRef.current.values.setupSearchBy) {\r\n this.setState({ searchText: searchedValue })\r\n if (formikRef.current.values.setupSearchBy.name === 'User name') {\r\n url += `&userName=${encodeURIComponent(searchedValue)}`\r\n }\r\n if (formikRef.current.values.setupSearchBy.name === \"User's email id\") {\r\n url += `&emailID=${encodeURIComponent(searchedValue)}`\r\n }\r\n }\r\n url += '&limit=' + limit;\r\n if (this.state.tabIndex === 0) {\r\n if (this.state.userList_pageDetails && this.state.userList_pageDetails.limit !== limit) {\r\n this.userDetailsPageToken.length = 0;\r\n this.userDetailsPageToken = [''];\r\n }\r\n if (this.userDetailsPageToken[this.state.pageNumber] !== '')\r\n url += '&skipToken=' + this.userDetailsPageToken[this.state.pageNumber];\r\n } else {\r\n if (this.state.usersToAccount_pageDetails && this.state.usersToAccount_pageDetails.limit !== limit) {\r\n this.userAccountsPageToken.length = 0;\r\n this.userAccountsPageToken = [''];\r\n }\r\n if (this.userAccountsPageToken[this.state.pageNumber] !== '')\r\n url += '&skipToken=' + this.userAccountsPageToken[this.state.pageNumber];\r\n }\r\n return url;\r\n };\r\n\r\n formatUserListData = (result, totalCnt = 0) => {\r\n let final_data = [];\r\n ((result || {}).finalResponse || []).forEach((element, index) => {\r\n const accounts = element?.accounts;\r\n var lstAccounts = [];\r\n accounts.map((acc) => {\r\n lstAccounts.push(acc.accountId);\r\n });\r\n\r\n var lastUpdateDate = '';\r\n if (element.updatedAt) {\r\n var ldate = new Date(element.updatedAt);\r\n lastUpdateDate = ldate.getMonth() + 1 + '/' + ldate.getDate() + '/' + ldate.getFullYear();\r\n }\r\n\r\n final_data.push({\r\n id: element.userId,\r\n userName: element?.name,\r\n role: element?.role,\r\n emailId: element?.emailId,\r\n createdBy: element?.createdBy,\r\n lastUpdated: lastUpdateDate,\r\n updatedBy: element?.updatedBy,\r\n status: element?.isActive,\r\n accounts: lstAccounts,\r\n isAccountSelected: lstAccounts.some((val) => val.toLowerCase() === this.state.currentAccount.toLowerCase()),\r\n isAccountDisabled: lstAccounts.some((val) => val.toLowerCase() === this.state.currentAccount.toLowerCase()),\r\n });\r\n });\r\n this.setState({\r\n userList_final_data: final_data,\r\n userList_totalCount: (result || {}).skipToken ? totalCnt + 1 : totalCnt,\r\n usersToAccount_final_data: final_data,\r\n usersToAccount_totalCount: (result || {}).skipToken ? totalCnt + 1 : totalCnt,\r\n });\r\n };\r\n\r\n formikRefResetForm = () => {\r\n formikRef.current.setErrors({});\r\n };\r\n\r\n onPageNumChange(pageNum) {\r\n this.setState({ pageNumber: pageNum }, () => {\r\n this.getuserListData();\r\n });\r\n }\r\n\r\n onPageSizeChange(pageSize) {\r\n this.setState({ pageSize: pageSize }, () => {\r\n this.getuserListData();\r\n });\r\n }\r\n\r\n getUserDetails = (event) => {\r\n event.preventDefault();\r\n this.setState({ isClearBtn: true, pageNumber: 0 ,setupSearchForFlag: true}, () => {\r\n this.getuserListData();\r\n });\r\n }\r\n\r\n getClear = (event = null, queryParams = '') => {\r\n if (event) {\r\n event.preventDefault();\r\n }\r\n formikRef.current.setFieldValue('setupSearchFor', '');\r\n formikRef.current.setFieldTouched('setupSearchFor', false);\r\n this.setState({ pageNumber: 0, isClearBtn: false, searchText: '' }, () => {\r\n this.getuserListData();\r\n });\r\n };\r\n\r\n resetClearButton = () => {\r\n this.setState({ isClearBtn: false })\r\n }\r\n setClearButton = () => {\r\n this.setState({ isClearBtn: true })\r\n }\r\n setSetupSearchForFlag = () => {\r\n this.setState({setupSearchForFlag: false})\r\n }\r\n\r\n render() {\r\n return (\r\n \r\n \r\n {({ values, setValues, setFieldValue, setFieldTouched, errors, resetForm, setErrors }) => {\r\n if (values.setupSearchFor?.trim()) {\r\n console.log(this.state.searchText, values.setupSearchFor.trim())\r\n if (this.state.searchText && values.setupSearchFor.trim() !== this.state.searchText) {\r\n this.state.isClearBtn && this.resetClearButton();\r\n }\r\n else if (values.setupSearchFor.trim() === this.state.searchText && this.state.setupSearchForFlag) {\r\n !this.state.isClearBtn && this.setClearButton();\r\n }\r\n }\r\n return (\r\n \r\n );\r\n }}\r\n \r\n \r\n );\r\n }\r\n}\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n userDetails: state.auth.userDetails,\r\n addressBookSearchParams: state.searchParams,\r\n };\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n setSnackBar: (data) => {\r\n dispatch(actions.setAppSnackBarData(data));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(withRouter(UserManagement));","import React from 'react';\r\nimport { Grid, Checkbox, FormControlLabel } from '@material-ui/core';\r\nimport InputButton from '../../framework/Inputs/inputButton/inputButton';\r\nimport CustomModal from '../../framework/dialog/customDialog';\r\nimport PropTypes from 'prop-types';\r\n\r\nexport default function ReprintLabel(props) {\r\n const {\r\n reprintTitle,\r\n reprintLabel,\r\n reprintCustomsInvoice,\r\n showPrintDialog\r\n } = props;\r\n return (\r\n \r\n \r\n \r\n \r\n }\r\n label=\"Label\"\r\n />\r\n \r\n \r\n \r\n }\r\n label=\"Customs Invoice\"\r\n />\r\n \r\n \r\n Customs invoice will be printed only if applicable for a shipment \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n )\r\n}\r\n\r\nReprintLabel.propTypes = {\r\n reprintTitle: PropTypes.string,\r\n reprintLabel: PropTypes.bool,\r\n reprintCustomsInvoice: PropTypes.bool,\r\n showPrintDialog: PropTypes.func,\r\n handleDialogClose: PropTypes.func,\r\n handleChange: PropTypes.func,\r\n savePrintDialog: PropTypes.func,\r\n};\r\n\r\n","import React, { useEffect, useState } from 'react';\r\nimport { useHistory, useParams } from 'react-router-dom';\r\nimport { connect } from 'react-redux';\r\nimport CustomHeader from '../../../../framework/summaryFormate/CustomHeader';\r\nimport SetupSummary from '../../../../framework/summaryFormate/SetupSummary';\r\nimport { Grid, Box, makeStyles, SvgIcon } from '@material-ui/core';\r\nimport DeliveryOptionsSummary from '../../../../framework/summaryFormate/DeliveryOptionsSummary';\r\nimport CustomModal from '../../../../framework/dialog/customDialog';\r\nimport ReturnOptionsSummary from '../../../../framework/summaryFormate/ReturnOptionsSummary';\r\n\r\nimport { axiosConfig } from '../../../../api/axios';\r\nimport ParcelSummary from '../../../../framework/summaryFormate/ParcelSummary';\r\nimport AdditionalInfoSummary from '../../../../framework/summaryFormate/AdditionalInfoSummary';\r\nimport ProductAndServiceSummary from '../../../../framework/summaryFormate/ProductAndServiceSummary';\r\nimport InputButton from '../../../../framework/Inputs/inputButton/inputButton';\r\nimport AddressFormate from '../../../../framework/addressFormate/AddressFormate';\r\nimport { ServiceEndPoints } from '../../../../utils/constants/ApiConstant';\r\nimport ReprintLabel from '../../../../components/Reprint/ReprintLabel';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../../../store/actions/index';\r\nimport PromptJSPMClientInstallation from '../../../../components/addShipment/Printing/PromptJSPMClientInstallation';\r\nimport CustomDialog from '../../../../framework/dialog/customDialog';\r\nimport { printZplLabels, printPDF, downloadPDF } from '../../../../utils/PrintHelper';\r\nimport ConfirmationDialog from '../../../../components/addressBook/confirmation/confirmation';\r\nimport './dashBoardSummary.scss';\r\nimport CustomDetailsSummary from '../../../../components/shipmentManagement/shipmentSummary/customDetailsSummary/customDetailsSummary';\r\nimport { ReactComponent as EyesIcon } from '../../../../assets/images/eyes.svg';\r\nimport { setDropdownValues } from '../../../../utils/helperFunctions';\r\nimport CustomCaption from '../../../../framework/summaryFormate/CustomCaption';\r\nimport ClearanceDeclarationSummary from '../../../../components/shipmentManagement/shipmentSummary/clearanceDeclarationSummary/clearanceDeclarationSummary';\r\nimport { getClearanceDeclarationDetails } from '../../../../utils/utilsFunctions';\r\nimport { CLERANCE_DECLARATION, DASHBOARD_SUMMARY } from '../../../../utils/constants/constants';\r\n\r\nconst useStyles = makeStyles({\r\n boxContainer: {\r\n '& :last-child': {\r\n borderBottom: 'unset',\r\n },\r\n },\r\n});\r\n\r\nconst DashBoardSummary = (props) => {\r\n const { id } = useParams();\r\n const classes = useStyles();\r\n const [list, setlist] = useState([]);\r\n let history = useHistory();\r\n const [showPrintDialog, setshowPrintDialog] = useState(false);\r\n const [openJSPMPrompt, setJSPMPrompt] = React.useState(false);\r\n const [isDomestic, setisDomestic] = useState(true);\r\n\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n const [state, setState] = useState({\r\n reprintLabel: false,\r\n reprintCustomsInvoice: false,\r\n });\r\n const [showCustomDetails, setShowCustomDetails] = useState(false);\r\n const [customsDetails, setCustomsDetails] = useState({});\r\n const dispatch = useDispatch();\r\n const [accountDetails, setAccountDetails] = useState({});\r\n const [fullCustom, setFullCustom] = useState(false);\r\n const [showClearanceDeclarationDetails, setShowClearanceDeclarationDetails] = useState(false);\r\n const [clearanceDeclarationDetails, setClearanceDeclarationDetails] = useState(null);\r\n const resetReprintState = () => {\r\n setState({ ...state, reprintLabel: false, reprintCustomsInvoice: false });\r\n };\r\n\r\n const handleDialogClose = () => {\r\n setshowPrintDialog(false);\r\n setShowConfirmationDialog(false);\r\n resetReprintState();\r\n };\r\n\r\n const onDialogConfirm = () => {\r\n cancelShipment();\r\n setShowConfirmationDialog(false);\r\n };\r\n\r\n const handlePrintSubmit = (values, errors) => {\r\n let printFormat;\r\n if (props.printerConfiguration?.isDowloadLabelAsPDF) {\r\n printFormat = DASHBOARD_SUMMARY.PDF;\r\n } else {\r\n printFormat = props.printerConfiguration?.labelType === 1 ? DASHBOARD_SUMMARY.ZPL : DASHBOARD_SUMMARY.PDF;\r\n }\r\n let pageSize = props.printerConfiguration?.pageSize ? props.printerConfiguration?.pageSize : 0;\r\n axiosConfig\r\n .post(\r\n `${ServiceEndPoints.reprintShipments}?isLabel=${values.reprintLabel}&pageSize=${pageSize}&isCustomsInvoice=${values.reprintCustomsInvoice}&format=${printFormat}`,\r\n [list.shipmentNumber],\r\n )\r\n .then((response) => {\r\n if (!props.JSPMStatus && !props.printerConfiguration?.isDowloadLabelAsPDF) {\r\n setJSPMPrompt(true);\r\n } else {\r\n let labelResponse = response?.data[0]?.labelResponse;\r\n let customsInvoiceResponse = response?.data[0]?.customsInvoiceResponse;\r\n\r\n labelResponse?.map((lblResponse) => {\r\n lblResponse?.labels?.map((lblValue, index) => {\r\n if (props.printerConfiguration?.isDowloadLabelAsPDF === true) {\r\n let lableName = '';\r\n if (index === 0) {\r\n lableName = '_Label.pdf';\r\n } else if (index === 1) {\r\n lableName = '_ReturnLabel.pdf';\r\n } else {\r\n lableName = '_ReturnInstructions.pdf';\r\n }\r\n downloadPDF(lblValue.label, lableName, lblResponse);\r\n } else {\r\n if (props.printerConfiguration.labelType == 1) {\r\n printZplLabels(lblValue.label, props.printerConfiguration?.labelPrinter);\r\n } else {\r\n printPDF(lblValue.label, props.printerConfiguration?.labelPrinter, 'Label');\r\n }\r\n }\r\n });\r\n });\r\n\r\n customsInvoiceResponse?.map((customResponse) => {\r\n customResponse?.customsInvoice?.map((customValue, index) => {\r\n if (props.printerConfiguration?.isDowloadLabelAsPDF === true) {\r\n let lableName = '';\r\n if (index === 0) {\r\n lableName = '_CustomsInvoice.pdf';\r\n } else if (index === 1) {\r\n lableName = '_CustomsInvoice.pdf';\r\n } else {\r\n lableName = '_CustomsInvoice.pdf';\r\n }\r\n downloadPDF(customValue, lableName, customResponse);\r\n } else {\r\n printPDF(customValue, props.printerConfiguration?.otherReportsPrinter, 'Invoice');\r\n }\r\n });\r\n });\r\n dispatch(actions.setAppSnackBarData({ msg: 'Shipment successfully reprinted' }));\r\n }\r\n })\r\n .catch((error) => {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: `Error in reprinting the shipment:${list.shipmentNumber}`,\r\n },\r\n ],\r\n }),\r\n );\r\n });\r\n };\r\n\r\n const handleChange = (event) => {\r\n setState({ ...state, [event.target.name]: event.target.checked });\r\n };\r\n\r\n const savePrintDialog = () => {\r\n setshowPrintDialog(false);\r\n const values = { reprintLabel: state.reprintLabel, reprintCustomsInvoice: state.reprintCustomsInvoice };\r\n handlePrintSubmit(values);\r\n resetReprintState();\r\n };\r\n\r\n const getDashBoardList = () => {\r\n //dashboard and shipmanagement shipment by id apis are same\r\n axiosConfig\r\n .get(`${ServiceEndPoints.getShipment}/${id}`)\r\n .then((res) => {\r\n if (res.data?.destinationCountry !== DASHBOARD_SUMMARY.DESTINATION_COUNTRY_UK) {\r\n setisDomestic(false);\r\n }\r\n setlist(res.data);\r\n setSelectedAccountDetails(res.data?.accountNumber);\r\n dispatch(\r\n actions.setShipmentId({\r\n shipmentId: res.data?.shipmentNumber,\r\n }),\r\n );\r\n getProductDetails(res.data);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n };\r\n\r\n const handleClose = () => {\r\n setJSPMPrompt(false);\r\n };\r\n\r\n useEffect(() => {\r\n getDashBoardList();\r\n }, []);\r\n\r\n const cancelShipment = () => {\r\n const itemsToBeSelected = [];\r\n const item = {\r\n pickupAccount: list?.accountNumber,\r\n shipmentId: list?.shipmentNumber,\r\n postalCode: list?.deliveryAddress?.postalCode,\r\n };\r\n itemsToBeSelected.push(item);\r\n const payload = itemsToBeSelected;\r\n axiosConfig\r\n .post(ServiceEndPoints.cancelShipment, payload)\r\n .then((response) => {\r\n dispatch(actions.setAppSnackBarData({ msg: 'Shipment successfully cancelled' }));\r\n // history.goBack()\r\n history.push({\r\n pathname: '/dashboard/dashboardDetailsSummary',\r\n state: {\r\n itemsToBeSelected: itemsToBeSelected,\r\n },\r\n });\r\n })\r\n .catch((error) => {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in cancelling the shipment:' + payload[0].shipmentId,\r\n },\r\n ],\r\n }),\r\n );\r\n });\r\n };\r\n\r\n const getCustomsDetails = () => {\r\n axiosConfig\r\n .get(`${ServiceEndPoints.getCustomsDeclaration}?shipmentId=${id}`)\r\n .then((res) => {\r\n setCustomsDetails(res.data);\r\n setShowCustomDetails(true);\r\n })\r\n .catch((err) => {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in fetching customs details',\r\n },\r\n ],\r\n }),\r\n );\r\n });\r\n };\r\n\r\n const setSelectedAccountDetails = (accountId) => {\r\n setAccountDetails(setDropdownValues(props.userDetails.accounts, 'accountId', accountId));\r\n };\r\n\r\n const getProductDetails = (details) => {\r\n axiosConfig\r\n .get(\r\n `${ServiceEndPoints.productCountryFeature}?countrycode=${details?.deliveryAddress?.countryCode}&orderedProduct=${details?.productDetail?.orderedProduct}`,\r\n )\r\n .then((res) => {\r\n if (res.data[0]?.customsLevel === DASHBOARD_SUMMARY.SET_CUSTOM_LEVEL) {\r\n setFullCustom(true);\r\n }\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n };\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n {!isDomestic &&\r\n (fullCustom ? (\r\n \r\n \r\n }\r\n onClick={getCustomsDetails}\r\n isDisabled={showCustomDetails}\r\n style={{ color: '#000000 !important' }}\r\n />\r\n \r\n \r\n \r\n ) : (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n\r\n \r\n \r\n >\r\n ))}\r\n {showCustomDetails && (\r\n <>\r\n \r\n \r\n \r\n >\r\n )}\r\n {/* To view Clearance Declaration details for Domestic*/}\r\n {isDomestic && list?.clearanceDeclaration && (\r\n <>\r\n \r\n \r\n }\r\n onClick={getClearanceDeclarationDetails(\r\n id,\r\n setClearanceDeclarationDetails,\r\n setShowClearanceDeclarationDetails,\r\n dispatch,\r\n )}\r\n isDisabled={showClearanceDeclarationDetails}\r\n />\r\n \r\n \r\n {showClearanceDeclarationDetails && (\r\n \r\n \r\n \r\n )}\r\n >\r\n )}\r\n \r\n\r\n \r\n \r\n history.goBack()} />\r\n \r\n {list && list.status && list.status.replace(/\\s+/g, '').toLowerCase() === 'orderreceived' && (\r\n <>\r\n \r\n {\r\n setShowConfirmationDialog(true);\r\n }}\r\n />\r\n \r\n\r\n \r\n {\r\n setshowPrintDialog(true);\r\n }}\r\n buttonType=\"submit\"\r\n label=\"Reprint\"\r\n />\r\n \r\n >\r\n )}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n JSPMStatus: state.common.isJSPMInstalled,\r\n printerConfiguration: state.common.printerConfiguration,\r\n availablePrinter: state.common.availablePrinter,\r\n userDetails: state.auth.userDetails,\r\n };\r\n};\r\n\r\n// export default DashBoardSummary;\r\nexport default connect(mapStateToProps, null)(DashBoardSummary);\r\n","const bookDriverPickUpForm = {\r\n formId: 'bookDriverPickUpForm',\r\n formField: {\r\n bookCollectionDate: {\r\n props: {\r\n name: 'bookCollectionDate',\r\n label: 'Pick up date',\r\n type: 'date',\r\n isRequired: true,\r\n },\r\n value: '',\r\n validation: {\r\n name: 'bookCollectionDate',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Date is required'],\r\n },\r\n ],\r\n },\r\n },\r\n pickupLocation: {\r\n props: {\r\n name: 'pickupLocation',\r\n label: 'Pick-up location',\r\n type: 'autoComplete',\r\n isRequired: true,\r\n displayField: 'name',\r\n hasDefaultValue: true,\r\n },\r\n // value: ,\r\n validation: {\r\n name: 'pickupLocation',\r\n validationType: 'object',\r\n validations: [{\r\n type: 'test',\r\n params: [\r\n '',\r\n 'Error in creating driver pick up: associated account(s) are on stop. Please contact your account manager or credit control',\r\n (pickupLocation) => {\r\n if (pickupLocation?.status === 'OnStop') {\r\n return false;\r\n }\r\n return true;\r\n },\r\n ],\r\n }],\r\n }\r\n },\r\n earliestTime: {\r\n props: {\r\n name: 'earliestTime',\r\n label: 'Earlie',\r\n type: 'time',\r\n isRequired: true,\r\n },\r\n value: '09:00:00',\r\n },\r\n latestTime: {\r\n props: {\r\n name: 'latestTime',\r\n label: 'Latest time',\r\n type: 'time',\r\n isRequired: true,\r\n },\r\n value: '17:00:00',\r\n },\r\n specialInstructions: {\r\n props: {\r\n name: 'specialInstructions',\r\n label: 'Special instructions',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n inputProps: {\r\n maxLength: 80,\r\n },\r\n },\r\n value: '',\r\n },\r\n },\r\n};\r\n\r\nexport default bookDriverPickUpForm;\r\n","import React, { useState, useEffect } from 'react';\r\n\r\nimport { Box, Grid } from '@material-ui/core';\r\nimport PropTypes from 'prop-types';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { abortOnGoingCallsFor, axiosConfig } from '../../../api/axios';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\nimport {\r\n formatDate,\r\n getCustomerAccountID,\r\n setDropdownValues,\r\n tradingLocationArrayForm,\r\n} from '../../../utils/helperFunctions';\r\nimport { useSelector } from 'react-redux';\r\nimport moment from 'moment';\r\nconst useStyles = makeStyles({\r\n mainConatiner: {\r\n marginTop: '10px',\r\n marginBottom: '10px',\r\n },\r\n});\r\nlet publicHolidays = [];\r\nconst DriverPickUpContainer = (props) => {\r\n const {\r\n formField: { bookCollectionDate, earliestTime, latestTime, specialInstructions, pickupLocation },\r\n setFieldValue,\r\n setFieldTouched,\r\n errorMessage,\r\n formikValues,\r\n setLatestPickup,\r\n setCurrentBookStatus,\r\n setOperationalAccount\r\n } = props;\r\n const classes = useStyles();\r\n\r\n const [workingDays, setWorkingDays] = useState([]);\r\n const [isPickUpBooked, setIsPickUpBooked] = useState(false);\r\n const [isError, setIsError] = useState(false);\r\n const [tradingLocations, setTradingLocations] = useState([]);\r\n const [pickUpDropdownData, setpickUpDropdownData] = useState([]);\r\n const [selectedTradingLocation, setselectedTradingLocation] = useState([]);\r\n const [isHidden, setIsHidden] = useState(false);\r\n const [isDisabled, setisDisabled] = useState(false);\r\n const [isRequestPickUp, setIsRequestPickUp] = useState(false);\r\n const [isOnStop, setIsOnStop] = useState(false);\r\n const userAccounts = useSelector((state) => state.accounts.userAccounts);\r\n\r\n useEffect(() => {\r\n getPickupLocation();\r\n abortOnGoingCallsFor(ServiceEndPoints.getPublicHolidays);\r\n axiosConfig\r\n .get(`${ServiceEndPoints.getPublicHolidays}?countryCode=gb`)\r\n .then((res) => {\r\n // const weekendHolidayPickup = userAccounts.filter((userAcc) => userAcc.configuration.weekendHolidayPickup === true).length > 0\r\n // ? true : false;\r\n // getWorkingDays(res.data.publicHolidays);\r\n publicHolidays = res.data.publicHolidays;\r\n getWorkingDays(publicHolidays);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n }, []);\r\n\r\n const getWorkingDays = (holidayList, weekendHolidayPickup = false) => {\r\n let nextDate = new Date();\r\n const fiveWorkingDays = [];\r\n while (fiveWorkingDays.length < 5) {\r\n let tempVar = new Date(nextDate).setHours(0, 0, 0, 0);\r\n nextDate.setDate(nextDate.getDate() + 1);\r\n tempVar = new Date(tempVar);\r\n if (!weekendHolidayPickup) {\r\n if (\r\n tempVar.getDay() !== 0 &&\r\n tempVar.getDay() !== 6 &&\r\n !(holidayList || []).some((holiday) => new Date(holiday.date).getTime() === tempVar.getTime())\r\n ) {\r\n fiveWorkingDays.push(tempVar);\r\n }\r\n } else {\r\n fiveWorkingDays.push(tempVar);\r\n }\r\n }\r\n setWorkingDays(fiveWorkingDays);\r\n };\r\n\r\n useEffect(() => {\r\n setFieldValue('bookCollectionDate', workingDays.length > 0 ? workingDays[0] : '');\r\n }, [workingDays]);\r\n\r\n useEffect(() => {\r\n !formikValues.bookCollectionDate &&\r\n setFieldValue('bookCollectionDate', workingDays.length > 0 ? workingDays[0] : '');\r\n }, [formikValues.bookCollectionDate]);\r\n\r\n useEffect(() => {\r\n const minTimeing = moment(formikValues.earliestTime, 'HHmmss');\r\n const maxTimeing = moment(formikValues.latestTime, 'HHmmss');\r\n if (maxTimeing.isBefore(minTimeing)) setIsError(true);\r\n else setIsError(false);\r\n }, [formikValues.latestTime]);\r\n\r\n const sortAlphaNum = (a, b) => a?.companyName?.toLowerCase().localeCompare(b?.companyName?.toLowerCase(), 'en', { numeric: true })\r\n\r\n const getPickupLocation = () => {\r\n abortOnGoingCallsFor(ServiceEndPoints.getCustomerTradingLocation);\r\n axiosConfig\r\n .get(`${ServiceEndPoints.getCustomerTradingLocation}?customerAccountId=${getCustomerAccountID()}`)\r\n .then((res) => {\r\n let tradingLocations = res.data.tradingLocations.sort(sortAlphaNum);\r\n setTradingLocations(tradingLocations);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n setTradingLocations([]);\r\n });\r\n };\r\n\r\n const compareAccountStatuswithAtleastone = (userAccounts, status) => {\r\n return (\r\n userAccounts.filter(function (account) {\r\n return status.toString().toLowerCase() === 'active'.toLowerCase()\r\n ? account?.accountStatus.toString().toLowerCase() !== 'closed'.toLowerCase() &&\r\n account?.accountStatus.toString().toLowerCase() !== 'onstop'.toLowerCase()\r\n : account?.accountStatus.toString().toLowerCase() === status.toString().toLowerCase();\r\n }).length > 0\r\n );\r\n };\r\n const compareAllAccountStatus = (userAccounts, status) => {\r\n return (\r\n userAccounts.filter(function (account) {\r\n return account?.accountStatus.toString().toLowerCase() === status.toString().toLowerCase();\r\n }).length == userAccounts.length\r\n );\r\n };\r\n\r\n const moreThenOnetradingLocationArrayForm = (tradingLocations, userAccounts) => {\r\n let accountsArray = [];\r\n let LocationArray = [];\r\n tradingLocations.map((element, i) => {\r\n let tt = element?.accounts ?? [];\r\n let tempArray = userAccounts.filter(({ accountId: _accountId }) =>\r\n tt.some(({ accountId: accountId }) => accountId === _accountId),\r\n );\r\n if (tempArray.length !== 0) {\r\n if (compareAllAccountStatus(tempArray, 'Active') || compareAccountStatuswithAtleastone(tempArray, 'Active')) {\r\n element.location_status = 'AllActive';\r\n } else if (\r\n !compareAccountStatuswithAtleastone(tempArray, 'Active') &&\r\n compareAccountStatuswithAtleastone(tempArray, 'OnStop')\r\n ) {\r\n element.location_status = 'OnStop';\r\n } else if (compareAllAccountStatus(tempArray, 'Closed')) {\r\n element.location_status = 'AllClosed';\r\n }\r\n LocationArray.push(element);\r\n tempArray.map((ele) => {\r\n accountsArray.push(ele);\r\n });\r\n }\r\n });\r\n return [accountsArray, LocationArray];\r\n };\r\n\r\n useEffect(() => {\r\n let result = tradingLocationArrayForm(tradingLocations, userAccounts);\r\n let _tradingLocationArray = result[1];\r\n let matchedUserAccounts = _tradingLocationArray;\r\n if (matchedUserAccounts.length === 1) {\r\n let resultofnone = moreThenOnetradingLocationArrayForm(tradingLocations, userAccounts);\r\n let _accountsArray = resultofnone[0];\r\n let _locationArray = resultofnone[1];\r\n let tradingLocationResponseData = (_locationArray || []).map(\r\n ({ tradingLocationId, location_status, companyName, city, postalCode }) => {\r\n return {\r\n name: `${companyName}, ${city}, ${postalCode}`,\r\n value: tradingLocationId,\r\n status: location_status,\r\n };\r\n },\r\n );\r\n setpickUpDropdownData(tradingLocationResponseData);\r\n if (compareAllAccountStatus(_accountsArray, 'Closed')) {\r\n setIsHidden(true);\r\n setIsRequestPickUp(true);\r\n } else if (compareAccountStatuswithAtleastone(_accountsArray, 'Active')) {\r\n setIsHidden(true);\r\n setIsRequestPickUp(false);\r\n setFieldValue(\r\n 'pickupLocation',\r\n setDropdownValues(tradingLocationResponseData, 'name', tradingLocationResponseData.tradingLocationId),\r\n );\r\n } else if (\r\n !compareAccountStatuswithAtleastone(_accountsArray, 'Active') &&\r\n compareAccountStatuswithAtleastone(_accountsArray, 'OnStop')\r\n ) {\r\n setIsHidden(false);\r\n setIsOnStop(true);\r\n setIsRequestPickUp(true);\r\n setFieldValue(\r\n 'pickupLocation',\r\n setDropdownValues(tradingLocationResponseData, 'name', tradingLocationResponseData.tradingLocationId),\r\n );\r\n setFieldTouched('pickupLocation', true);\r\n }\r\n } else if (matchedUserAccounts.length > 1) {\r\n let resultofMorethenone = moreThenOnetradingLocationArrayForm(tradingLocations, userAccounts);\r\n let _accountsArray = resultofMorethenone[0];\r\n let _locationArray = resultofMorethenone[1];\r\n let rmClosedLocation = _locationArray.filter((e) => e.location_status !== 'AllClosed');\r\n let tradingLocationResponseData = (rmClosedLocation || []).map(\r\n ({ tradingLocationId, location_status, companyName, city, postalCode }) => {\r\n return {\r\n name: `${companyName}, ${city}, ${postalCode}`,\r\n value: tradingLocationId,\r\n status: location_status,\r\n };\r\n },\r\n );\r\n setpickUpDropdownData(tradingLocationResponseData);\r\n setFieldValue(\r\n 'pickupLocation',\r\n setDropdownValues(tradingLocationResponseData, 'name', tradingLocationResponseData.tradingLocationId),\r\n );\r\n setIsHidden(false);\r\n } else {\r\n setIsHidden(true);\r\n setIsRequestPickUp(true);\r\n }\r\n }, [tradingLocations]);\r\n\r\n useEffect(() => {\r\n let _selectedTradingLocation = [];\r\n if (formikValues.pickupLocation) {\r\n if (tradingLocations.length > 0) {\r\n _selectedTradingLocation = tradingLocations.filter(\r\n (e) => e.tradingLocationId == formikValues.pickupLocation.value,\r\n );\r\n setselectedTradingLocation(_selectedTradingLocation);\r\n let matchedAccountAndLocations = tradingLocationArrayForm(_selectedTradingLocation, userAccounts);\r\n setOperationalAccount(matchedAccountAndLocations[0]?.[0])\r\n }\r\n if (tradingLocations.length > 1) {\r\n if (formikValues?.pickupLocation?.status == 'OnStop') {\r\n setIsOnStop(true);\r\n setIsRequestPickUp(true);\r\n setFieldTouched('pickupLocation', true);\r\n } else {\r\n setIsOnStop(false);\r\n setIsRequestPickUp(false);\r\n }\r\n }\r\n } else {\r\n setIsRequestPickUp(true);\r\n if (pickUpDropdownData.length > 0) {\r\n setFieldValue(\r\n 'pickupLocation',\r\n setDropdownValues(pickUpDropdownData, 'name', pickUpDropdownData[0].name),\r\n );\r\n }\r\n else {\r\n getPickupLocation();\r\n }\r\n }\r\n }, [formikValues.pickupLocation]);\r\n\r\n useEffect(() => {\r\n if (workingDays.length > 0 && formikValues.bookCollectionDate && tradingLocations.length > 0) {\r\n abortOnGoingCallsFor(ServiceEndPoints.getPickups);\r\n axiosConfig\r\n .get(\r\n `${ServiceEndPoints.getPickups}?customerAccountId=${getCustomerAccountID()}&startDate=${formatDate(\r\n formikValues.bookCollectionDate,\r\n )}&endDate=${formatDate(formikValues.bookCollectionDate)}`,\r\n )\r\n .then((res) => {\r\n if (res.data?.length > 0) {\r\n let availablePickups = res.data\r\n .filter(\r\n (e) => e.pickupType?.toLowerCase() !== 'carriageforward' && e.pickupType?.toLowerCase() !== 'return',\r\n )\r\n .filter(\r\n (val) =>\r\n val.status !== null &&\r\n val.status?.toLowerCase() !== 'failed' &&\r\n val.status?.toLowerCase() !== 'autogeneratedclosed',\r\n );\r\n let availableTradingLocations = tradingLocations.filter(\r\n (location) =>\r\n location.tradingLocationId === selectedTradingLocation?.[0]?.tradingLocationId &&\r\n availablePickups.some((pickup) => pickup.tradingLocationId === location.tradingLocationId),\r\n );\r\n availableTradingLocations = tradingLocationArrayForm(availableTradingLocations, userAccounts, true)[1];\r\n if (availableTradingLocations.length > 0) {\r\n setIsPickUpBooked(true);\r\n setCurrentBookStatus(true);\r\n } else {\r\n setIsPickUpBooked(false);\r\n setCurrentBookStatus(false);\r\n }\r\n } else if (res.data?.length === 0) {\r\n setIsPickUpBooked(false);\r\n setCurrentBookStatus(false);\r\n } else {\r\n setIsPickUpBooked(false);\r\n setCurrentBookStatus(false);\r\n }\r\n })\r\n .catch((err) => {\r\n if (isRequestPickUp) {\r\n setIsPickUpBooked(false);\r\n setCurrentBookStatus(true);\r\n } else {\r\n setIsPickUpBooked(false);\r\n setCurrentBookStatus(false);\r\n }\r\n })\r\n .finally(() => {\r\n if (isRequestPickUp) {\r\n setCurrentBookStatus(true);\r\n }\r\n });\r\n } else {\r\n if (tradingLocations.length === 0) {\r\n setCurrentBookStatus(true);\r\n }\r\n }\r\n }, [formikValues.bookCollectionDate, workingDays, isRequestPickUp, selectedTradingLocation]);\r\n\r\n useEffect(() => {\r\n if (selectedTradingLocation?.[0]?.postalCode) {\r\n abortOnGoingCallsFor(ServiceEndPoints.getPostcodeDistrict);\r\n axiosConfig\r\n .get(`${ServiceEndPoints.getPostcodeDistrict}?postcode=${selectedTradingLocation[0].postalCode}`)\r\n .then((res) => {\r\n setLatestPickup(res?.data?.latestCollection);\r\n getWorkingDays(\r\n publicHolidays.filter(\r\n (holiday) => holiday.region?.toLowerCase() === res?.data?.ukHolidayRegion?.toLowerCase(),\r\n ),\r\n );\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n getWorkingDays([]);\r\n });\r\n }\r\n }, [selectedTradingLocation]);\r\n\r\n const formatDisplayAddress = (selectedTradingLocation) => {\r\n let addArray = [];\r\n selectedTradingLocation[0].address1 && addArray.push(selectedTradingLocation[0].address1);\r\n selectedTradingLocation[0].address2 && addArray.push(selectedTradingLocation[0].address2);\r\n selectedTradingLocation[0].address3 && addArray.push(selectedTradingLocation[0].address3);\r\n selectedTradingLocation[0].city && addArray.push(selectedTradingLocation[0].city);\r\n selectedTradingLocation[0].postalCode && addArray.push(selectedTradingLocation[0].postalCode);\r\n selectedTradingLocation[0].state && addArray.push(selectedTradingLocation[0].state);\r\n\r\n return addArray.toString();\r\n };\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {isPickUpBooked ? 'Driver pick-up requested' : 'Driver pick-up not requested'}{' '}\r\n \r\n \r\n \r\n \r\n {!isHidden ? (\r\n \r\n \r\n \r\n \r\n \r\n ) : null}\r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {!isHidden ? (\r\n \r\n \r\n \r\n {selectedTradingLocation.length > 0 ? (\r\n \r\n
Pick-up address
\r\n
\r\n {formatDisplayAddress(selectedTradingLocation)}\r\n
\r\n
\r\n ) : null}\r\n \r\n \r\n \r\n ) : null}\r\n \r\n \r\n \r\n );\r\n};\r\n\r\nDriverPickUpContainer.propTypes = {\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n setFieldValue: PropTypes.func,\r\n errors: PropTypes.object,\r\n};\r\n\r\nexport default DriverPickUpContainer;\r\n","import React, { useState, useEffect } from 'react';\r\nimport { Form, Formik } from 'formik';\r\nimport { Grid, Box, Snackbar } from '@material-ui/core';\r\nimport { useHistory } from 'react-router-dom';\r\nimport moment from 'moment';\r\n\r\nimport bookDriverPickUpForm from '../../../utils/formConfig/bookDriverPickUpForm/bookDriverPickUpForm';\r\n\r\nimport DriverPickUpContainer from './DriverPickUpContainer';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport './bookDriverPickUp.scss';\r\nimport {\r\n formatBookDriverPickUpObj,\r\n getDomesticAccounts,\r\n isPickUpAvailableInAccount,\r\n} from '../../../utils/helperFunctions';\r\nimport { axiosConfig } from '../../../api/axios';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { useDispatch, useSelector } from 'react-redux';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { getYupSchemaFromMetaData } from '../../../utils/yupSchema/yupSchemaGenerator';\r\n\r\n// let latestPickup = null;\r\nconst BookDriverPickUp = () => {\r\n const { formId, formField } = bookDriverPickUpForm;\r\n const [latestPickup, setLatestPickup] = useState(null);\r\n const [operationalAccount, setOperationalAccount] = useState(null)\r\n let history = useHistory();\r\n const dispatch = useDispatch();\r\n const initialValues = {};\r\n\r\n for (let property in formField) {\r\n if (Object.prototype.hasOwnProperty.call(formField, property)) {\r\n const field = formField[property];\r\n if (field.props?.type === 'checkbox' || field.props?.type === 'radio') {\r\n initialValues[field.props.name] = field.value;\r\n } else if (field.props?.type === 'array') {\r\n initialValues[field.props.name] = field.values;\r\n } else {\r\n initialValues[field.props.name] = field.value || '';\r\n }\r\n }\r\n }\r\n\r\n const [errorMessage, setErrorMessage] = useState('Latest time cannot be less than earliest time');\r\n const domesticAccounts = useSelector((state) => state.accounts.userAccounts);\r\n const selectedAccount = domesticAccounts.find((account) => isPickUpAvailableInAccount(account)) || {};\r\n const userDetails = useSelector((state) => state.auth.userDetails);\r\n const [isCurrentPickupBooked, setIsCurrentPickUpBooked] = useState(false);\r\n const [driverPickupValidationSchema, setDriverPickupValidationSchema] = useState(\r\n getYupSchemaFromMetaData(formField, [], []),\r\n );\r\n const updateValidationSchema = () => {\r\n setDriverPickupValidationSchema(getYupSchemaFromMetaData(formField, [], []));\r\n };\r\n\r\n const handleSubmit = (values, errors, setFieldValue, resetForm) => {\r\n const validationObject = isFormInValid(errors, values);\r\n if (validationObject.formValid) {\r\n dispatch(actions.setLoaderLayOver(true));\r\n // const minTimeing = moment(values.earliestTime, 'HHmmss');\r\n // const maxTimeing = moment(values.latestTime, 'HHmmss');\r\n // if (minTimeing.isBefore(maxTimeing)) {\r\n if (values) {\r\n const reqObj = formatBookDriverPickUpObj(values, userDetails, operationalAccount);\r\n axiosConfig.post(ServiceEndPoints.pickUpsUrl, reqObj)\r\n .then((res) => {\r\n if (validationObject.afterLatestTime) {\r\n\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'success',\r\n msg: `Your request to book a driver pick-up has been received but you have missed the cut off time of ${latestPickup} to book a driver from your postcode area.`,\r\n },\r\n {\r\n type: 'success',\r\n msg: `It may not be possible to collect your parcels today. Please contact your local depot to confirm.`,\r\n }\r\n ],\r\n hasMultipleMsgs: false\r\n }),\r\n );\r\n }\r\n else {\r\n dispatch(actions.setAppSnackBarData({ msg: 'Your request to book a driver pick-up has been received. You will receive an email confirmation when a driver has been allocated.' }));\r\n }\r\n resetForm();\r\n setIsCurrentPickUpBooked(true);\r\n })\r\n .catch((err) => {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: `Error in booking driver pick up : ${err.response?.data[0]?.detail ?? 'Error occurred while booking driver pick up, please try again'\r\n }`,\r\n },\r\n ],\r\n }),\r\n );\r\n // dispatch(actions.setAppSnackBarData({ type: \"error\", msg: \"Driver pick up booking failed: error\" }));\r\n })\r\n .finally(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n });\r\n }\r\n // } else {\r\n // dispatch(actions.setLoaderLayOver(false));\r\n // dispatch(actions.setAppSnackBarData({ type: 'error', msg: 'Latest time cannot be less than earliest time' }));\r\n // }\r\n } else {\r\n dispatch(actions.setLoaderLayOver(false));\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'The form has errors, please correct and try again',\r\n },\r\n ],\r\n }),\r\n );\r\n // dispatch(actions.setAppSnackBarData({ type: 'error', msg: 'The form has errors, please correct and try again' }));\r\n\r\n }\r\n };\r\n\r\n const isFormInValid = (errors, values) => {\r\n // var earliestTime = values.earliestTime.split(':');\r\n // var latestTime = values.latestTime.split(':');\r\n\r\n // if (!(earliestTime[0] >= 9 && earliestTime[0] <= 17)) {\r\n // return true;\r\n // }\r\n // if (!(latestTime[0] >= 9 && latestTime[0] <= 17)) {\r\n // return true;\r\n // }\r\n var today = new Date();\r\n var time = today.getHours() + \":\" + today.getMinutes() + \":\" + today.getSeconds();\r\n let collectionDate = new Date(values.bookCollectionDate).getDate();\r\n let todayDate = today.getDate();\r\n\r\n const currentSystemTime = moment(time, 'HHmmss')\r\n const validationObject = { formValid: true, afterLatestTime: false };\r\n const minTimeing = moment(values.earliestTime, 'HHmmss');\r\n const maxTimeing = moment(values.latestTime, 'HHmmss');\r\n const latestTimeAccount = latestPickup ? moment(latestPickup, 'HHmmss') : maxTimeing;\r\n\r\n if (collectionDate === todayDate) {\r\n if (latestTimeAccount.isBefore(currentSystemTime)) {\r\n validationObject.afterLatestTime = true;\r\n }\r\n }\r\n // if (latestTimeAccount.isBefore(maxTimeing)) {\r\n // validationObject.afterLatestTime = true;\r\n // }\r\n if (maxTimeing.isBefore(minTimeing)) {\r\n validationObject.formValid = false;\r\n }\r\n return validationObject;\r\n };\r\n\r\n const setCurrentBookStatus = (bookVal) => {\r\n setIsCurrentPickUpBooked(bookVal);\r\n };\r\n\r\n // useEffect(() => {\r\n // selectedAccount?.sender?.postalCode &&\r\n // axiosConfig\r\n // .get(\r\n // `${ServiceEndPoints.getPostcodeDistrict}?postcode=${selectedAccount.sender.postalCode}`,\r\n // )\r\n // .then((res) => {\r\n // latestPickup = res?.data?.latestCollection;\r\n // })\r\n // .catch((err) => console.log(err));\r\n // }, [selectedAccount])\r\n return (\r\n \r\n {({ values, setFieldValue, setErrors, errors, setFieldTouched, resetForm }) => (\r\n \r\n )}\r\n \r\n );\r\n};\r\n\r\nexport default BookDriverPickUp;\r\n","import React, { useState } from \"react\";\r\nimport { Grid, IconButton } from '@material-ui/core';\r\nimport DynamicMaterialTable from '../../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\nimport CustomModal from '../../../framework/dialog/customDialog';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport '../../../styles/styles.scss';\r\n\r\nconst AuditDetails = (props) => {\r\n const { artifactId, amendInfoTableData, showInfoDialog, setShowInfoDialog } = props;\r\n\r\n const amendInfoTableColumns = [\r\n { title: 'id', field: 'artifactId', hidden: true },\r\n {\r\n title: 'Items',\r\n field: 'fieldName',\r\n sorting: true,\r\n width: 80,\r\n },\r\n {\r\n title: 'Old value',\r\n field: 'oldValue',\r\n sorting: false,\r\n width: 180,\r\n },\r\n {\r\n title: 'New value',\r\n field: 'newValue',\r\n sorting: false,\r\n width: 180,\r\n },\r\n ];\r\n\r\n const [ammendInfoColumns] = useState(amendInfoTableColumns);\r\n\r\n const handleDialogClose = () => {\r\n setShowInfoDialog(false);\r\n };\r\n\r\n return (\r\n \r\n \r\n Shipment-{artifactId}
\r\n \r\n \r\n {\r\n handleDialogClose()\r\n }}\r\n\r\n />\r\n \r\n \r\n \r\n );\r\n\r\n};\r\n\r\nAuditDetails.propTypes = {};\r\n\r\nexport default AuditDetails;","import React, { useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, IconButton, SvgIcon, Tooltip } from '@material-ui/core';\r\nimport DynamicMaterialTable from '../../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\nimport { GET } from '../../../api/axios';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { convertTZ } from '../../../utils/helperFunctions';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { SearchIcon } from '@material-ui/data-grid';\r\nimport TableExport from '../../../components/TableExport/TableExport';\r\nimport ClearIcon from '@material-ui/icons/Clear';\r\nimport html2canvas from 'html2canvas';\r\nimport jsPDF from 'jspdf';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../../store/actions/index';\r\nimport AuditDetails from '../auditDetails/auditDetails';\r\nimport { ReactComponent as InfoIcon } from '../../../assets/images/InfoIconDark.svg';\r\n\r\nconst ByShipmentNumber = (props) => {\r\n const {\r\n formikValues,\r\n formField: { shipmentNumber },\r\n setFieldValue,\r\n errors,\r\n } = props;\r\n const headers = [\r\n { label: 'Shipment number', key: 'artifactNumber' },\r\n { label: 'User ID', key: 'user' },\r\n // { label: 'Event name', key: 'artifact' },\r\n { label: 'Audit date', key: 'logDate' },\r\n { label: 'Audit time', key: 'logTime' },\r\n { label: 'Description', key: 'operation' },\r\n ];\r\n\r\n const tableColumns = [\r\n { title: 'id', field: 'artifactId', hidden: true },\r\n {\r\n title: 'User ID',\r\n field: 'user',\r\n sorting: false,\r\n },\r\n {\r\n title: 'Audit date',\r\n field: 'logDate',\r\n sorting: true,\r\n customSort: (a, b) =>\r\n sortTableData(new Date(`${a?.logDate}`.split('/').reverse().join('-')).getTime(), new Date(`${b?.logDate}`.split('/').reverse().join('-')).getTime()),\r\n },\r\n {\r\n title: 'Audit time',\r\n field: 'logTime',\r\n sorting: true,\r\n customSort: (a, b) =>\r\n sortTableData(new Date(`01/01/2021 ${a.logTime}`).getTime(), new Date(`01/01/2021 ${b.logTime}`).getTime()),\r\n },\r\n {\r\n title: 'Description',\r\n field: 'operation',\r\n sorting: false,\r\n },\r\n {\r\n field: 'operation',\r\n title: 'Details',\r\n filtering: false,\r\n sorting: false,\r\n render: (row) => {\r\n return \r\n {row?.activity === 'amend' && row?.artifactDisplayName === 'Shipment' ?\r\n handleInfoClick(row)}\r\n >\r\n \r\n : ''}\r\n
\r\n },\r\n }\r\n ];\r\n\r\n const [tableData, setTableData] = useState([]);\r\n const [tableDataLength, setTableDataLength] = useState([]);\r\n const [columns] = useState(tableColumns);\r\n const [showClearBtn, setShowClearBtn] = useState(false);\r\n const [showInfoDialog, setShowInfoDialog] = useState(false);\r\n const [amendInfoTableData, setAmendInfoTableData] = useState([]);\r\n const [artifactId, setArtifactId] = useState('');\r\n const dispatch = useDispatch();\r\n\r\n const getTableData = (event = {}) => {\r\n dispatch(actions.setLoaderLayOver(true));\r\n event?.stopPropagation?.();\r\n GET(`${ServiceEndPoints.auditLogs}?shipmentNo=${formikValues.shipmentNumber}`)\r\n .then((res) => {\r\n let _temp = _formatTableData(res.data.auditLogs)\r\n setTableData(_temp);\r\n setShowClearBtn(true);\r\n setTimeout(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n }, 2000);\r\n })\r\n .catch((err) => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n console.log(err);\r\n });\r\n };\r\n\r\n const handleInfoClick = (row) => {\r\n setTimeout(() => {\r\n let _temp = _formatInfoTableData(row)\r\n setAmendInfoTableData(_temp);\r\n setShowInfoDialog(true);\r\n }, 0);\r\n\r\n };\r\n\r\n const _formatInfoTableData = (row) => {\r\n setArtifactId(row.artifactId);\r\n let finalInfoData = [];\r\n row?.amendments?.forEach((element) => {\r\n finalInfoData.push({\r\n fieldName: element?.fieldName,\r\n oldValue: element?.oldValue ? element.oldValue : \"-\",\r\n newValue: element?.newValue ? element.newValue : \"-\",\r\n })\r\n });\r\n return finalInfoData;\r\n }\r\n\r\n const _formatTableData = (_result) => {\r\n let _finalData = [];\r\n (_result || []).forEach((_element) => {\r\n let _convertedDateTime = convertTZ(_element.responseTimeStamp)\r\n _finalData.push({\r\n artifactId: _element.artifactId,\r\n artifactNumber: _element.artifactNumber,\r\n user: _element.user,\r\n operation: _element.operation,\r\n logDate: _convertedDateTime.logDate,\r\n logTime: _convertedDateTime.logTime,\r\n artifactDisplayName: _element.artifactDisplayName,\r\n amendments: _element.amendments,\r\n activity: _element.activity,\r\n })\r\n });\r\n return _finalData;\r\n }\r\n const onDataUpdate = () => {\r\n try {\r\n getTableData();\r\n dispatch(actions.setAppSnackBarData({ msg: `Data exported successfully` }));\r\n }\r\n catch (err) {\r\n console.log(err)\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in exporting data, please try again later',\r\n },\r\n ],\r\n }),\r\n );\r\n }\r\n };\r\n\r\n const sortTableData = (a, b) => {\r\n if (a < b) {\r\n return -1;\r\n } else if (a > b) {\r\n return 1;\r\n } else {\r\n return 0;\r\n }\r\n };\r\n\r\n const printDocument = () => {\r\n // const input = document.getElementById('shipmentTable');\r\n // html2canvas(input)\r\n // .then((canvas) => {\r\n // let imgWidth = 208;\r\n // let imgHeight = canvas.height * imgWidth / canvas.width;\r\n // const imgData = canvas.toDataURL('img/png');\r\n // const pdf = new jsPDF('p', 'mm', 'a4');\r\n // pdf.addImage(imgData, 'PNG', 0, 0, imgWidth, imgHeight);\r\n // // pdf.output('dataurlnewwindow');\r\n // pdf.save(\"download.pdf\");\r\n // })\r\n // ;\r\n try {\r\n const unit = \"pt\";\r\n const size = \"A4\"; // Use A1, A2, A3 or A4\r\n const orientation = \"landscape\"; // portrait or landscape\r\n const doc = new jsPDF(orientation, unit, size);\r\n\r\n const title = \"My Awesome Report\";\r\n const headersName = [headers.map(header => header.label)];\r\n const data = tableData.map(elt => [elt.artifactNumber, elt.user, elt.logDate, elt.logTime, elt.operation]);\r\n\r\n let content = {\r\n head: headersName,\r\n body: data,\r\n columnStyles: {\r\n 0: {\r\n columnWidth: 150\r\n },\r\n 1: {\r\n columnWidth: 200\r\n },\r\n 2: {\r\n columnWidth: 100\r\n },\r\n 3: {\r\n columnWidth: 100\r\n },\r\n 4: {\r\n columnWidth: 230\r\n }\r\n },\r\n styles: {\r\n cellWidth: 'wrap',\r\n fontSize: 12,\r\n overflowColumns: 'linebreak'\r\n }\r\n };\r\n\r\n doc.autoTable(content);\r\n doc.save(\"AuditByShipmentNumber.pdf\")\r\n dispatch(actions.setAppSnackBarData({ msg: `Data exported successfully` }));\r\n }\r\n catch (err) {\r\n console.log(err);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in exporting data, please try again later',\r\n },\r\n ],\r\n }),\r\n );\r\n }\r\n }\r\n\r\n const clearTable = () => {\r\n setTableData([]);\r\n setShowClearBtn(false);\r\n setFieldValue('shipmentNumber', '');\r\n };\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n {showClearBtn ? (\r\n \r\n \r\n \r\n ) : (\r\n \r\n \r\n \r\n )}\r\n >\r\n ),\r\n }}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nByShipmentNumber.propTypes = {};\r\n\r\nexport default ByShipmentNumber;\r\n","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Box, Grid, IconButton, Menu, SvgIcon, MenuItem, Select, ListItemIcon, ListItemText, Checkbox, Tooltip } from '@material-ui/core';\r\nimport { GET } from '../../../api/axios';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport DynamicMaterialTable from '../../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport InputDateRange from '../../../framework/date-range/dateRange';\r\nimport originalMoment from 'moment';\r\nimport { extendMoment } from 'moment-range';\r\nimport TableExport from '../../../components/TableExport/TableExport';\r\nimport { Event } from '@material-ui/icons';\r\nimport { basicSort, formatDate, convertTZ } from '../../../utils/helperFunctions';\r\nimport { ReactComponent as FilterIcon } from '../../../assets/images/Filter.svg';\r\nimport { useSelector, useDispatch } from 'react-redux';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { ReactComponent as InfoIcon } from '../../../assets/images/InfoIconDark.svg';\r\nimport AuditDetails from '../auditDetails/auditDetails';\r\n\r\nimport html2canvas from 'html2canvas';\r\nimport jsPDF from 'jspdf';\r\nconst filterButtonStyle = {\r\n padding: '4px !important',\r\n};\r\nconst ITEM_HEIGHT = 48;\r\nconst ITEM_PADDING_TOP = 8;\r\nconst MenuProps = {\r\n PaperProps: {\r\n style: {\r\n maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,\r\n width: 250,\r\n },\r\n },\r\n getContentAnchorEl: null,\r\n anchorOrigin: {\r\n vertical: 'bottom',\r\n horizontal: 'center',\r\n },\r\n transformOrigin: {\r\n vertical: 'top',\r\n horizontal: 'center',\r\n },\r\n};\r\nconst ByUserId = (props) => {\r\n const {\r\n formikValues,\r\n formField: { userId, dateRange },\r\n tabIndex,\r\n setValues,\r\n setFieldError,\r\n setFieldTouched,\r\n setFieldValue,\r\n } = props;\r\n const tableRef = React.createRef();\r\n const lastYearDate = new Date(new Date().setFullYear(new Date().getFullYear() - 1));\r\n\r\n const CustomFilter = props => {\r\n const [selectedVal, setSelectedVal] = useState([]);\r\n function handleChange(e) {\r\n const val = e.target.value;\r\n setSelectedVal(val);\r\n props.onFilterChanged(props.columnDef.tableData.columnOrder, val);\r\n }\r\n\r\n return (\r\n \r\n {(data.length > 1) ? data[0] + '...' : data[0]}
}\r\n // disableUnderline\r\n >\r\n {props.columnDef.filterValues.map((option) => (\r\n \r\n \r\n -1}\r\n />\r\n \r\n \r\n \r\n ))}\r\n \r\n \r\n );\r\n };\r\n const headers = [\r\n { label: 'User ID', key: 'user' },\r\n { label: 'Event name', key: 'artifactDisplayName' },\r\n { label: 'Audit date', key: 'logDate' },\r\n { label: 'Audit time', key: 'logTime' },\r\n { label: 'Description', key: 'operation' },\r\n ];\r\n\r\n const tableColumns = [\r\n { title: 'id', field: 'id', hidden: true },\r\n {\r\n title: (\r\n \r\n
\r\n Event name \r\n
\r\n\r\n
\r\n setShowFilter(true)} style={filterButtonStyle}>\r\n \r\n \r\n
\r\n
\r\n ),\r\n field: 'artifactDisplayName',\r\n filtering: true,\r\n sorting: false,\r\n lookup: {\r\n Shipment: 'Shipment',\r\n 'Pickup': 'Pickup',\r\n Template: 'Template',\r\n AddressBook: 'AddressBook',\r\n // 'User management': 'User management',\r\n Configuration: 'Configuration',\r\n Users: 'Users',\r\n OrderFile: 'OrderFile'\r\n },\r\n filterValues:\r\n ['Shipment', 'Pickup', 'Template', 'AddressBook',\r\n , 'Configuration', 'Users', 'OrderFile'\r\n ],\r\n filterComponent: (props) => ,\r\n },\r\n {\r\n title: 'Audit date',\r\n field: 'logDate',\r\n filtering: false,\r\n sorting: true,\r\n customSort: (a, b) =>\r\n basicSort(new Date(`${a?.logDate}`.split('/').reverse().join('-')).getTime(), new Date(`${b?.logDate}`.split('/').reverse().join('-')).getTime()),\r\n },\r\n {\r\n title: 'Audit time',\r\n field: 'logTime',\r\n filtering: false,\r\n customSort: (a, b) =>\r\n basicSort(new Date(`03/23/2021 ${a.logTime}`).getTime(), new Date(`03/23/2021 ${b.logTime}`).getTime()),\r\n sorting: true,\r\n },\r\n {\r\n title: 'Description',\r\n field: 'operation',\r\n filtering: false,\r\n sorting: false,\r\n },\r\n {\r\n field: 'operation',\r\n filtering: false,\r\n title: 'Details',\r\n sorting: false,\r\n render: (row) => {\r\n return \r\n {row?.activity === 'amend' && row?.artifactDisplayName === 'Shipment' ?\r\n handleInfoClick(row)}\r\n >\r\n \r\n : ''}\r\n
\r\n },\r\n }\r\n ];\r\n\r\n const [anchorEl, setAnchorEl] = useState(null);\r\n const [columns] = useState(tableColumns);\r\n // const [userIdValues, setUserIdValues] = useState([]);\r\n const [ExportData, setExportData] = useState([]);\r\n const [TotalCount, setTotalCount] = useState(0);\r\n const [showFilter, setShowFilter] = useState(false);\r\n const [pageSize, setPageSize] = useState(10);\r\n const [filterChanged, setFilterChanged] = useState(10);\r\n const [tableRawData, setTableRawData] = useState([]);\r\n const [pageDetails, setPageDetails] = useState({\r\n offset: 0,\r\n limit: 0,\r\n totalRecordsLength: 0,\r\n });\r\n const [userIdOptions, setUserIdOptions] = useState([{ name: 'Select', value: '' }]);\r\n const moment = extendMoment(originalMoment);\r\n const todayDate = moment();\r\n const loader = useSelector((state) => state.loaderLayOver.showLoader);\r\n const dispatch = useDispatch();\r\n const [ExportPdfData, setExportPdfData] = useState([]);\r\n\r\n const [showInfoDialog, setShowInfoDialog] = useState(false);\r\n const [amendInfoTableData, setAmendInfoTableData] = useState([]);\r\n const [artifactId, setArtifactId] = useState('');\r\n\r\n const getUrl = (query) => {\r\n let url = ServiceEndPoints.auditLogs;\r\n url += `?offset=${query.page * query.pageSize}`;\r\n url += `&limit=${query.pageSize}`;\r\n setPageSize(query.pageSize);\r\n return (url += getFilterOptions());\r\n };\r\n // useEffect(() => {\r\n // let url = ServiceEndPoints.auditLogs;\r\n // url += `&offset=${0}`;\r\n // GET(url)\r\n // .then((res)=>{\r\n // })\r\n // }, []);\r\n const getFilterOptions = () => {\r\n let filterString = `&userId=${(formikValues.userId || {}).value ? (formikValues.userId || {}).value : ''}`;\r\n filterString += `&startDate=${formikValues.startDate}`;\r\n return (filterString += `&endDate=${formikValues.endDate}`);\r\n };\r\n\r\n\r\n const handleInfoClick = (row) => {\r\n setTimeout(() => {\r\n let _temp = _formatInfoTableData(row)\r\n setAmendInfoTableData(_temp);\r\n setShowInfoDialog(true);\r\n }, 0);\r\n\r\n };\r\n\r\n const _formatInfoTableData = (row) => {\r\n setArtifactId(row.artifactId);\r\n let finalInfoData = [];\r\n row?.amendments?.forEach((element) => {\r\n finalInfoData.push({\r\n fieldName: element?.fieldName,\r\n oldValue: element?.oldValue ? element.oldValue : \"-\",\r\n newValue: element?.newValue ? element.newValue : \"-\",\r\n })\r\n });\r\n return finalInfoData;\r\n }\r\n\r\n const _formatTableData = (_result) => {\r\n let _finalData = [];\r\n (_result || []).forEach((_element) => {\r\n let _convertedDateTime = convertTZ(_element.responseTimeStamp);\r\n _finalData.push({\r\n user: _element.user,\r\n artifactDisplayName: _element.artifactDisplayName,\r\n artifactId: _element.artifactId,\r\n amendments: _element.amendments,\r\n logDate: _convertedDateTime.logDate,\r\n logTime: _convertedDateTime.logTime,\r\n operation: _element.operation,\r\n activity: _element.activity,\r\n })\r\n });\r\n return _finalData;\r\n }\r\n\r\n const getTableData = (query) => {\r\n const offset = query.page * query.pageSize;\r\n const limit = query.pageSize;\r\n\r\n return new Promise((resolve, reject) => {\r\n if (!formikValues.userId.value) {\r\n resolveTableData(resolve, [], query, 0);\r\n }\r\n if ((formikValues.userId.value !== '') && (pageDetails.offset !== query.page * query.pageSize || pageDetails.limit !== query.pageSize || filterChanged)) {\r\n GET(getUrl(query))\r\n .then((res) => {\r\n // setExportData(res.data.auditLogs);\r\n let FinalData = (res.data.auditLogs.length > 0) ? _formatTableData(res.data.auditLogs) : [];\r\n setTableRawData(FinalData);\r\n setTotalCount(res.data === null ? 0 : res.data.totalRecords);\r\n setPageDetails({\r\n offset,\r\n limit,\r\n totalRecordsLength: (res.data || {}).totalRecords,\r\n });\r\n setFilterChanged(false);\r\n filterData(FinalData, query, resolve, res?.data?.totalRecords);\r\n resolveTableData(resolve, FinalData, query, res.data?.totalRecords || 0);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n setTotalCount(0);\r\n resolveTableData(resolve, [], query, 0);\r\n setFilterChanged(false);\r\n });\r\n } else {\r\n filterData(tableRawData, query, resolve, pageDetails.totalRecordsLength);\r\n }\r\n });\r\n };\r\n\r\n const filterData = (tableData, query, resolve, totalRecordsLength) => {\r\n const filteredData = tableData.filter((row) => {\r\n return !query.filters\r\n .filter((individualFilter) => individualFilter.value.length > 0)\r\n .map((mappedObjet) => {\r\n if (\r\n (mappedObjet.value || []).filter((filterValue) => {\r\n const rowValue = mappedObjet.column.field.split('.').reduce((a, b) => a[b], row);\r\n return (filterValue || '').toLowerCase() === (rowValue || '').toLowerCase();\r\n }).length > 0\r\n ) {\r\n return true;\r\n }\r\n return false;\r\n })\r\n .some((checkValue) => checkValue === false);\r\n });\r\n resolveTableData(resolve, filteredData, query, totalRecordsLength);\r\n };\r\n\r\n const resolveTableData = (resolve, tableData, query, totalCount) => {\r\n resolve({\r\n data: tableData,\r\n page: query.page,\r\n totalCount,\r\n filters: [],\r\n });\r\n };\r\n\r\n const onDataUpdate = () => {\r\n let url = ServiceEndPoints.auditLogs;\r\n url += `?offset=${0}`;\r\n url += `&limit=${TotalCount}`;\r\n url += getFilterOptions();\r\n GET(url)\r\n .then((res) => {\r\n let FinalData = (res.data.auditLogs.length > 0) ? _formatTableData(res.data.auditLogs) : [];\r\n setExportData(FinalData);\r\n setExportPdfData(FinalData)\r\n dispatch(actions.setAppSnackBarData({ msg: `Data exported successfully` }));\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n setExportData([]);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in exporting data, please try again later',\r\n },\r\n ],\r\n }),\r\n );\r\n });\r\n };\r\n\r\n const onSelect = (val) => {\r\n if (val && val.start && val.end) {\r\n const dateObj = {\r\n startDate: formatDate(val.start._i, '/').split('/').reverse().join('/'),\r\n endDate: formatDate(val.end._i, '/').split('/').reverse().join('/'),\r\n };\r\n dateObj.dateRange = `${dateObj.startDate} - ${dateObj.endDate}`;\r\n setValues({ ...formikValues, ...dateObj });\r\n setAnchorEl(null);\r\n }\r\n };\r\n\r\n const handleClick = (event) => {\r\n setAnchorEl(event.currentTarget);\r\n };\r\n useEffect(() => {\r\n if (formikValues.userId && formikValues.userId.value !== \"\") {\r\n let url = ServiceEndPoints.auditLogs;\r\n url += `?offset=${0}`;\r\n url += `&limit=${TotalCount}`;\r\n url += getFilterOptions();\r\n GET(url).then((res) => {\r\n let FinalData = (res.data.auditLogs.length > 0) ? _formatTableData(res.data.auditLogs) : [];\r\n setExportPdfData(FinalData)\r\n setExportData(FinalData)\r\n })\r\n }\r\n else {\r\n setExportPdfData([])\r\n setExportData([]);\r\n }\r\n }, [TotalCount, (formikValues.userId || {}).value ? (formikValues.userId || {}).value : ''])\r\n\r\n useEffect(() => {\r\n dispatch(actions.setLoaderLayOver(true));\r\n GET(`${ServiceEndPoints.getUsers}`)\r\n .then((res) => {\r\n let userDataDefault = [{ name: 'Select', value: '' }]\r\n let userResponseData = ((res.data || {}).finalResponse || []).map(({ emailId, userId }) => {\r\n return {\r\n name: emailId,\r\n value: userId,\r\n }\r\n })\r\n let userData = [...userDataDefault, ...userResponseData]\r\n setUserIdOptions(userData)\r\n setTimeout(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n }, 2000);\r\n })\r\n .catch((err) => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n console.log(err);\r\n setUserIdOptions([{ name: 'Select', value: '' }]);\r\n });\r\n setFieldValue('userId', userIdOptions[0]);\r\n setFieldValue('dateRange', 'Select')\r\n }, []);\r\n\r\n const handleClose = () => {\r\n setAnchorEl(null);\r\n };\r\n\r\n useEffect(() => {\r\n if (tabIndex === 1) {\r\n tableRef.current && tableRef.current.onQueryChange();\r\n }\r\n setFilterChanged(true);\r\n }, [formikValues.userId, formikValues.startDate, formikValues.endDate, tabIndex]);\r\n\r\n const dateRangeBlurred = (event) => {\r\n const dateRangeValue = event.target.value;\r\n const dates = dateRangeValue.split('-');\r\n\r\n if (dates.length !== 2) {\r\n setFieldTouched('dateRange', true);\r\n const dateObj = {\r\n startDate: '',\r\n endDate: '',\r\n };\r\n setValues({ ...formikValues, ...dateObj });\r\n setFieldError('dateRange', 'Invalid dates');\r\n } else {\r\n const fromDate = convertDDtoDateObj(dates[0]);\r\n const toDate = convertDDtoDateObj(dates[1]);\r\n if (fromDate instanceof Date && !isNaN(fromDate) && toDate instanceof Date && !isNaN(toDate)) {\r\n setFieldTouched('dateRange', true);\r\n if (fromDate.getTime() < lastYearDate.getTime() || toDate.getTime() > new Date().getTime()) {\r\n setFieldError('dateRange', 'Invalid dates');\r\n const dateObj = {\r\n startDate: '',\r\n endDate: '',\r\n };\r\n setValues({ ...formikValues, ...dateObj });\r\n } else {\r\n const dateObj = {\r\n startDate: formatDate(fromDate, '/').split('/').reverse().join('/'),\r\n endDate: formatDate(toDate, '/').split('/').reverse().join('/'),\r\n };\r\n setValues({ ...formikValues, ...dateObj });\r\n }\r\n } else {\r\n setFieldError('dateRange', 'Invalid dates');\r\n const dateObj = {\r\n startDate: '',\r\n endDate: '',\r\n };\r\n setValues({ ...formikValues, ...dateObj });\r\n }\r\n }\r\n };\r\n\r\n const convertDDtoDateObj = (dateinDDFormat, splitter = '/') => {\r\n const splittedDate = dateinDDFormat.split(splitter);\r\n return new Date(splittedDate[2], splittedDate[1] - 1, splittedDate[0]);\r\n };\r\n\r\n const printDocument = () => {\r\n try {\r\n const unit = \"pt\";\r\n const size = \"A4\"; // Use A1, A2, A3 or A4\r\n const orientation = \"landscape\"; // portrait or landscape\r\n const doc = new jsPDF(orientation, unit, size);\r\n const title = \"My Awesome Report\";\r\n const headersName = [headers.map(header => header.label)];\r\n const data = ExportPdfData.map(elt => [elt.user, elt.artifactDisplayName, elt.logDate, elt.logTime, elt.operation]);\r\n\r\n let content = {\r\n head: headersName,\r\n body: data,\r\n columnStyles: {\r\n 0: {\r\n columnWidth: 200\r\n },\r\n 1: {\r\n columnWidth: 150\r\n },\r\n 2: {\r\n columnWidth: 100\r\n },\r\n 3: {\r\n columnWidth: 100\r\n },\r\n 4: {\r\n columnWidth: 230\r\n }\r\n },\r\n styles: {\r\n cellWidth: 'wrap',\r\n fontSize: 12,\r\n overflowColumns: 'linebreak'\r\n }\r\n };\r\n doc.autoTable(content);\r\n doc.save(\"AuditByUserId.pdf\")\r\n dispatch(actions.setAppSnackBarData({ msg: `Data exported successfully` }));\r\n }\r\n catch (err) {\r\n console.log(err);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in exporting data, please try again later',\r\n },\r\n ],\r\n }),\r\n );\r\n }\r\n }\r\n\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n dateRangeBlurred(event)}\r\n endArguments={{\r\n endAdornment: (\r\n \r\n \r\n \r\n ),\r\n }}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nByUserId.propTypes = {};\r\n\r\nexport default ByUserId;\r\n\r\n// const userIdOptions = [\r\n// {\r\n// name: 'Select',\r\n// value: '',\r\n// },\r\n// {\r\n// name: 'uUDkW7nfEmWSkryUSgNgl18vgxj1',\r\n// value: 'uUDkW7nfEmWSkryUSgNgl18vgxj1',\r\n// },\r\n// {\r\n// name: 'Option 2',\r\n// value: 'option2',\r\n// },\r\n// ];\r\n","const AuditEnquiryForm = {\r\n formId: 'auditEnquiryForm',\r\n formField: {\r\n shipmentNumber: {\r\n props: {\r\n name: 'shipmentNumber',\r\n label: 'Shipment number',\r\n type: 'text',\r\n },\r\n validation: {\r\n name: 'shipmentNumber',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'matches',\r\n params: [/^[A-Za-z0-9]*$/, 'Invalid shipment number'],\r\n },\r\n ],\r\n },\r\n },\r\n exportTo: {\r\n props: {\r\n name: 'exportTo',\r\n label: 'Export to',\r\n type: 'select',\r\n displayField: 'name',\r\n },\r\n },\r\n userId: {\r\n props: {\r\n name: 'userId',\r\n label: 'User id',\r\n type: 'autoComplete',\r\n isRequired: true,\r\n displayField: 'name',\r\n hasDefaultValue: true,\r\n },\r\n },\r\n startDate: {\r\n props: {\r\n name: 'startDate',\r\n label: 'Date range',\r\n type: 'date',\r\n },\r\n },\r\n endDate: {\r\n props: {\r\n name: 'endDate',\r\n label: 'Date range',\r\n type: 'date',\r\n },\r\n },\r\n dateRange: {\r\n props: {\r\n name: 'dateRange',\r\n label: 'Date range',\r\n type: 'input',\r\n placeholder: 'dd/mm/yyyy - dd/mm/yyyy',\r\n },\r\n Value:'Select'\r\n },\r\n },\r\n};\r\n\r\nexport default AuditEnquiryForm;\r\n","import React, { useRef } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, Tab, Tabs } from '@material-ui/core';\r\nimport TabPanel from '../../components/shared/tabPanel';\r\nimport { useState } from 'react';\r\nimport ByShipmentNumber from '../../components/auditEnquiry/byShipmentNumber/byShipmentNumber';\r\nimport ByUserId from '../../components/auditEnquiry/byUserId/byUserId';\r\nimport { Form, Formik } from 'formik';\r\nimport AuditEnquiryForm from '../../utils/formConfig/auditEnquiryForm/auditEnquiryForm';\r\nimport { getYupSchemaFromMetaData } from '../../utils/yupSchema/yupSchemaGenerator';\r\nimport './auditEnquiry.scss';\r\n\r\nconst { formId, formField } = AuditEnquiryForm;\r\n\r\nconst AuditEnquiry = (props) => {\r\n const formikRef = useRef(null);\r\n const [tabIndex, setTabIndex] = useState(0);\r\n\r\n const handleTabChange = (event, value) => {\r\n setTabIndex(value);\r\n formikRef.current.resetForm();\r\n };\r\n const auditEnquiryValidationSchema = getYupSchemaFromMetaData(formField, [], []);\r\n\r\n const initialValues = {};\r\n\r\n for (let property in formField) {\r\n if (Object.prototype.hasOwnProperty.call(formField, property)) {\r\n const field = formField[property];\r\n initialValues[field.props.name] = field.value || '';\r\n }\r\n }\r\n\r\n return (\r\n \r\n \r\n {({ values, errors, setValues, setFieldValue, setFieldError, setFieldTouched }) => {\r\n return (\r\n \r\n );\r\n }}\r\n \r\n \r\n );\r\n};\r\n\r\nAuditEnquiry.propTypes = {};\r\n\r\nexport default AuditEnquiry;\r\n","/* eslint-disable no-unused-vars */\r\nimport React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { makeStyles, withStyles } from '@material-ui/core/styles';\r\nimport clsx from 'clsx';\r\nimport Stepper from '@material-ui/core/Stepper';\r\nimport Step from '@material-ui/core/Step';\r\nimport StepLabel from '@material-ui/core/StepLabel';\r\nimport Check from '@material-ui/icons/Check';\r\nimport SettingsIcon from '@material-ui/icons/Settings';\r\nimport GroupAddIcon from '@material-ui/icons/GroupAdd';\r\nimport VideoLabelIcon from '@material-ui/icons/VideoLabel';\r\nimport StepConnector from '@material-ui/core/StepConnector';\r\nimport Button from '@material-ui/core/Button';\r\nimport { Typography, Grid } from '@material-ui/core';\r\nimport './stepper.scss';\r\n\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n root: {\r\n width: '100%',\r\n },\r\n}));\r\n\r\nconst useQontoStepIconStyles = makeStyles({\r\n root: {\r\n\r\n display: 'flex',\r\n\r\n alignItems: 'center',\r\n },\r\n circle: {\r\n backgroundColor: 'white',\r\n zIndex: 1,\r\n fontSize: 16,\r\n width: 8,\r\n height: 8,\r\n borderRadius: '50%',\r\n width: '32px',\r\n height: '32px',\r\n border: '1px solid #00000073'\r\n\r\n },\r\n active: {\r\n backgroundColor: 'white',\r\n zIndex: 1,\r\n fontSize: 16,\r\n width: 8,\r\n height: 8,\r\n borderRadius: '50%',\r\n width: '32px',\r\n height: '32px',\r\n border: '3px solid #000000',\r\n\r\n },\r\n\r\n completed: {\r\n backgroundColor: '#76BD22',\r\n border: '1px solid #007C39',\r\n zIndex: 1,\r\n fontSize: 16,\r\n width: 8,\r\n height: 8,\r\n borderRadius: '50%',\r\n width: '32px',\r\n height: '32px',\r\n color: 'black',\r\n },\r\n});\r\n\r\n\r\nfunction QontoStepIcon(props) {\r\n const classes = useQontoStepIconStyles();\r\n const { active, completed } = props;\r\n \r\n if (completed) {\r\n return (\r\n \r\n\r\n
{props.icon}
\r\n
\r\n );\r\n } else if (active) {\r\n return (\r\n \r\n )\r\n } else {\r\n return (\r\n \r\n )\r\n }\r\n}\r\nQontoStepIcon.propTypes = {\r\n\r\n /**\r\n * Whether this step is active.\r\n */\r\n active: PropTypes.bool,\r\n\r\n /**\r\n * Mark the step as completed. Is passed to child components.\r\n */\r\n completed: PropTypes.bool,\r\n};\r\n\r\n\r\nexport default function CustomizedSteppers(props) {\r\n const classes = useStyles();\r\n const steps = props.steps;\r\n return (\r\n \r\n \r\n \r\n {steps.map((label) => (\r\n \r\n {label} \r\n \r\n ))}\r\n \r\n \r\n
\r\n );\r\n}\r\n","/* eslint-disable no-lone-blocks */\r\n/* eslint-disable no-unused-vars */\r\n/* eslint-disable react-hooks/exhaustive-deps */\r\nimport React from 'react';\r\nimport { Grid } from '@material-ui/core';\r\nimport Stepper from '../../../../framework/stepper/stepper';\r\nimport './trackingBanner.scss';\r\nimport { useHistory } from 'react-router';\r\nimport { GET } from '../../../../api/axios';\r\nimport { formatDateToSecondFormat } from '../../../../utils/helperFunctions';\r\nimport { getDayOfTheWeek, convertTZwithFormat } from '../../../../utils/helperFunctions';\r\nimport { ServiceEndPoints } from '../../../../utils/constants/ApiConstant';\r\nimport moment from 'moment';\r\nconst TrackingBanner = (props) => {\r\n let getSteps = ['Order received', 'We have your parcel', 'Out for delivery', 'Delivered'];\r\n const [activeStep, setActiveStep] = React.useState(0);\r\n const [estimatedDuration, setEstimatedDuration] = React.useState('Estimated delivery on');\r\n const [estimatedDeliveryDate, setestimatedDeliveryDate] = React.useState([]);\r\n const [estimatedDeliveryStartTime, setestimatedDeliveryStartTime] = React.useState([]);\r\n const [estimatedDeliveryEndTime, setestimatedDeliveryEndTime] = React.useState([]);\r\n const [deliveredTime, setdeliveredTime] = React.useState([]);\r\n const [dayOftheWeek, setdayOftheWeek] = React.useState('');\r\n let ShipmentEventName = [];\r\n let estimatedDeliveryDates = [];\r\n let deliveryStartTime = [];\r\n let shipmentEventCode = [];\r\n let deliveryEndTime = [];\r\n let deliveryDueDate = '';\r\n let deliveryDueStartTime = '';\r\n let deliveryDueEndTime = '';\r\n let deliveredDateTime = [];\r\n let deliveredDateTimeEvent;\r\n let indexOfEvent;\r\n const history = useHistory();\r\n\r\n const convertTime12to24 = time12h => {\r\n const [time, modifier] = time12h.split(\" \");\r\n\r\n let [hours, minutes] = time.split(\":\");\r\n\r\n if (hours === \"12\") {\r\n hours = \"00\";\r\n }\r\n\r\n if (modifier === \"PM\") {\r\n hours = parseInt(hours, 10) + 12;\r\n }\r\n\r\n if (`${hours}:${minutes}` > \"20:00\") {\r\n return null\r\n\r\n }\r\n\r\n return `${hours}:${minutes}`;\r\n\r\n\r\n };\r\n\r\n var convertedTime = convertTime12to24(new Date().toLocaleTimeString());\r\n\r\n\r\n\r\n const getTrackingProcessingData = () => {\r\n const queryParams = history.location.search.split('=');\r\n GET(`${ServiceEndPoints.getShipmentTracking}${queryParams[1]}`)\r\n .then((res) => {\r\n for (const dataObj of res.data.shipmentEventModels) {\r\n ShipmentEventName.push(dataObj.shipmentEvent.shipHarmonisedEvents.trackingPageStatus);\r\n estimatedDeliveryDates.push(dataObj.shipmentEvent.details.deliveryDate);\r\n deliveryStartTime.push(dataObj.shipmentEvent.details.estimatedDeliveryStartTime);\r\n deliveryEndTime.push(dataObj.shipmentEvent.details.estimatedDeliveryEndTime);\r\n deliveredDateTime.push(dataObj.shipmentEvent.dateTime)\r\n shipmentEventCode.push(dataObj.shipmentEvent.code)\r\n }\r\n indexOfEvent = shipmentEventCode.findIndex(e => e === 'T415')\r\n {\r\n res.data.dueDate === null\r\n ? (deliveryDueDate = '')\r\n : (deliveryDueDate = formatDateToSecondFormat(res.data.dueDate));\r\n }\r\n {\r\n res.data.dueStartTime === null\r\n ? (deliveryDueStartTime = '')\r\n : (deliveryDueStartTime = res.data.dueStartTime);\r\n }\r\n res.data.dueEndtime ? (deliveryDueEndTime = '') : (deliveryDueEndTime = (res.data.dueEndTime ? res.data.dueEndTime : null));\r\n const ShipmentValidEventName = ShipmentEventName.filter(eventName => eventName !== \"NA\")\r\n deliveredDateTimeEvent = convertTZwithFormat(deliveredDateTime[0], 'H:mm');\r\n if (ShipmentValidEventName[0] === 'We have your Parcel' || ShipmentValidEventName[0] === 'We have your parcel') {\r\n setEstimatedDuration('Delivery due on');\r\n setActiveStep(2);\r\n setestimatedDeliveryDate(deliveryDueDate);\r\n setestimatedDeliveryStartTime(res.data.dueStartTime);\r\n setestimatedDeliveryEndTime(res.data.dueEndTime);\r\n setdayOftheWeek(getDayOfTheWeek(deliveryDueDate));\r\n\r\n } else if (ShipmentValidEventName[0] === 'Out for delivery') {\r\n // if (convertedTime === null) {\r\n // setActiveStep(2)\r\n // }\r\n // else {\r\n setActiveStep(3)\r\n // }\r\n\r\n setEstimatedDuration('Delivery due on');\r\n ShipmentEventName[0]?.toLowerCase()?.trim() === 'na' ? setestimatedDeliveryDate(deliveryDueDate) : setestimatedDeliveryDate((estimatedDeliveryDates[0]) ? formatDateToSecondFormat(estimatedDeliveryDates[0]) : deliveryDueDate);\r\n\r\n // if (indexOfEvent !== -1) {\r\n // setestimatedDeliveryStartTime(deliveryStartTime[indexOfEvent]);\r\n // setestimatedDeliveryEndTime(deliveryEndTime[indexOfEvent]);\r\n // }\r\n\r\n if (res.data?.eventEstimatedDeliveryStartTime) {\r\n setestimatedDeliveryStartTime(res.data.eventEstimatedDeliveryStartTime);\r\n setestimatedDeliveryEndTime(res.data.eventEstimatedDeliveryEndTime);\r\n }\r\n else {\r\n setestimatedDeliveryStartTime(res.data.dueStartTime);\r\n setestimatedDeliveryEndTime(res.data.dueEndTime);\r\n }\r\n\r\n ShipmentEventName[0]?.toLowerCase()?.trim() === 'na' ? setdayOftheWeek(getDayOfTheWeek((deliveryDueDate))) : setdayOftheWeek(getDayOfTheWeek((estimatedDeliveryDates[0]) ? estimatedDeliveryDates[0] : deliveryDueDate));\r\n } else if (ShipmentValidEventName[0] === 'Delivered') {\r\n setEstimatedDuration('Delivered on');\r\n setActiveStep(4);\r\n ShipmentEventName[0]?.toLowerCase()?.trim() === 'na' ? setestimatedDeliveryDate(deliveryDueDate) : setestimatedDeliveryDate((estimatedDeliveryDates[0]) ? formatDateToSecondFormat(estimatedDeliveryDates[0]) : deliveryDueDate);\r\n setdeliveredTime(deliveredDateTimeEvent)\r\n ShipmentEventName[0]?.toLowerCase()?.trim() === 'na' ? setdayOftheWeek(getDayOfTheWeek((deliveryDueDate))) : setdayOftheWeek(getDayOfTheWeek((estimatedDeliveryDates[0]) ? estimatedDeliveryDates[0] : deliveryDueDate));\r\n } else {\r\n setEstimatedDuration('Estimated delivery on');\r\n setActiveStep(1);\r\n if (deliveryDueDate === '') {\r\n setestimatedDeliveryDate('Will be updated once shipment has been despatched');\r\n setdayOftheWeek('');\r\n }\r\n else {\r\n setestimatedDeliveryDate(deliveryDueDate);\r\n setestimatedDeliveryStartTime(res.data.dueStartTime);\r\n setestimatedDeliveryEndTime(res.data.dueEndTime);\r\n setdayOftheWeek(getDayOfTheWeek(deliveryDueDate));\r\n }\r\n }\r\n })\r\n .catch((err) => { });\r\n };\r\n\r\n React.useEffect(() => {\r\n getTrackingProcessingData();\r\n }, []);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n {estimatedDuration} \r\n \r\n {dayOftheWeek ?\r\n \r\n \r\n {dayOftheWeek}, {estimatedDeliveryDate}\r\n \r\n \r\n {\r\n estimatedDuration === 'Delivered on'\r\n ? (\r\n \r\n at \r\n {deliveredTime} \r\n\r\n \r\n )\r\n : (\r\n \r\n\r\n between \r\n {estimatedDeliveryStartTime} \r\n and \r\n {estimatedDeliveryEndTime} \r\n \r\n )\r\n }\r\n\r\n \r\n :\r\n \r\n \r\n {estimatedDeliveryDate}\r\n \r\n \r\n }\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nexport default TrackingBanner;\r\n","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport {\r\n Grid,\r\n Tabs,\r\n Tab,\r\n TableContainer,\r\n Paper,\r\n Table,\r\n TableHead,\r\n TableRow,\r\n TableCell,\r\n TableBody,\r\n makeStyles,\r\n} from '@material-ui/core';\r\nimport TabPanel from '../../../shared/tabPanel';\r\nimport { useSelector } from 'react-redux';\r\nimport { getParsedFloatValues } from '../../../../utils/helperFunctions';\r\n\r\nconst useStyles = makeStyles({\r\n table: {\r\n minWidth: 650,\r\n border: '1px solid #B5B5B5',\r\n },\r\n});\r\n\r\nconst DimensionDetails = (props) => {\r\n const classes = useStyles();\r\n const [tabIndex, setTabIndex] = useState(0);\r\n const [tableData, setTableData] = useState(props.shipmentDimensions?.declaredValues || []);\r\n const [volumetricWeightDivisor, setVolumetricWeightDivisor] = useState(4000);\r\n\r\n const handleTabChange = (event, value) => {\r\n setTabIndex(value);\r\n };\r\n\r\n const userDetails = useSelector((state) => state.auth.userDetails);\r\n\r\n useEffect(() => {\r\n const dimensionsData = props.shipmentDimensions?.declaredValues || [];\r\n setTableData(\r\n dimensionsData.map((dimension) => {\r\n return {\r\n ...dimension,\r\n volumnWeight: getCaluclatedVolumetricWeight(dimension),\r\n };\r\n }),\r\n );\r\n }, [props.shipmentDimensions, volumetricWeightDivisor]);\r\n\r\n useEffect(() => {\r\n const shipmentAcc = userDetails?.accounts?.find((user) => user.accountId === props.shipmentDetails.accountNumber);\r\n setVolumetricWeightDivisor(shipmentAcc?.configuration?.volumetricWeightDivisor || 4000);\r\n }, [userDetails, props.shipmentDimensions, props.shipmentDetails.accountNumber]);\r\n\r\n const getCaluclatedVolumetricWeight = (row) => {\r\n return getParsedFloatValues((row.length * row.height * row.width) / volumetricWeightDivisor);\r\n };\r\n\r\n const totalVolumetricWeight = (tableData || []).reduce((acc, ele) => acc + (ele || {}).volumnWeight, 0);\r\n const totalDeclaredWeight = (tableData || []).reduce((acc, ele) => acc + (ele || {}).measuredweight, 0);\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Parcel no. \r\n \r\n \r\n Length (cm) \r\n \r\n \r\n Width (cm) \r\n \r\n \r\n Height (cm) \r\n \r\n \r\n Parcel reference \r\n \r\n \r\n Volumetric wt.(kg) \r\n \r\n \r\n Declared wt.(kg) \r\n \r\n \r\n \r\n \r\n {tableData.map((row, index) => (\r\n \r\n \r\n {index + 1}\r\n \r\n {row.length} \r\n {row.width} \r\n {row.height} \r\n {(row.pieceRefId) ? row.pieceRefId : \"-\"} \r\n {row.volumnWeight} \r\n {row.measuredweight} \r\n \r\n ))}\r\n \r\n Total \r\n \r\n \r\n \r\n \r\n \r\n {totalVolumetricWeight} \r\n \r\n \r\n {totalDeclaredWeight} \r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nDimensionDetails.propTypes = {};\r\n\r\nexport default DimensionDetails;\r\n","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, Tab, Tabs, Divider, Icon } from '@material-ui/core';\r\nimport TabPanel from '../../../shared/tabPanel';\r\nimport InputButton from '../../../../framework/Inputs/inputButton/inputButton';\r\nimport { ArrowForward } from '@material-ui/icons';\r\nimport './shipmentDetails.scss';\r\nimport CustomDialog from '../../../../framework/dialog/customDialog';\r\nimport DimensionDetails from '../dimensionDetails/dimensionDetails';\r\nimport { DELIVERY_CHOICES, DELIVERY_TYPES } from '../../../../utils/constants/constants'\r\n\r\nconst ShipmentDetails = (props) => {\r\n const { shipmentDetails } = props;\r\n const [tabIndex, setTabIndex] = useState(0);\r\n const [dialogOpen, setDialogOpen] = useState(false);\r\n const [deliveryType, setdeliveryType] = useState('');\r\n const [currentdeliveryTypeDropDownValue, setcurrentdeliveryTypeDropDownValue] = useState('');\r\n\r\n const handleTabChange = (event, value) => {\r\n setTabIndex(value);\r\n };\r\n\r\n const handleDialog = (value) => {\r\n setDialogOpen(value);\r\n };\r\n\r\n useEffect(() => {\r\n const _isRescheduled = shipmentDetails.isRescheduled;\r\n const _deliveryChoice = shipmentDetails.deliveryChoice;\r\n \r\n const deliveryChoicesMap = {\r\n [DELIVERY_CHOICES.LEAVE_NEIGHBOUR]: DELIVERY_TYPES.LEAVE_NEIGHBOUR,\r\n [DELIVERY_CHOICES.DOORSTEP_ONLY]: DELIVERY_TYPES.DOORSTEP_ONLY,\r\n [DELIVERY_CHOICES.SAFE_LOCATION]: DELIVERY_TYPES.SAFE_LOCATION,\r\n [DELIVERY_CHOICES.DOORSTEP_AGE_VERIFICATION]: DELIVERY_TYPES.DOORSTEP_AGE_VERIFICATION,\r\n [DELIVERY_CHOICES.DOORSTEP_PIN]: DELIVERY_TYPES.DOORSTEP_PIN,\r\n [DELIVERY_CHOICES.DEPOT_PIN]: DELIVERY_TYPES.DEPOT_PIN,\r\n [DELIVERY_CHOICES.DEPOT]: DELIVERY_TYPES.DEPOT,\r\n [DELIVERY_CHOICES.DEPOT_AGE_VERIFICATION]: DELIVERY_TYPES.DEPOT_AGE_VERIFICATION,\r\n [DELIVERY_CHOICES.SERVICE_POINT]: DELIVERY_TYPES.SERVICE_POINT,\r\n [DELIVERY_CHOICES.SAFE_LOCATION_RESCHEDULED]: `Safe place location – ${shipmentDetails.secureLocation}`,\r\n };\r\n \r\n if (!_isRescheduled) {\r\n if (deliveryChoicesMap[_deliveryChoice]) {\r\n setdeliveryType(deliveryChoicesMap[_deliveryChoice]);\r\n setcurrentdeliveryTypeDropDownValue({\r\n name: deliveryChoicesMap[_deliveryChoice],\r\n value: deliveryChoicesMap[_deliveryChoice],\r\n });\r\n }\r\n } else {\r\n if (deliveryChoicesMap[_deliveryChoice]) {\r\n setdeliveryType(deliveryChoicesMap[_deliveryChoice]);\r\n setcurrentdeliveryTypeDropDownValue({\r\n name: deliveryChoicesMap[_deliveryChoice],\r\n value: deliveryChoicesMap[_deliveryChoice],\r\n });\r\n }\r\n }\r\n }, [shipmentDetails]);\r\n\r\n useEffect(() => {\r\n props.onDeliveryTypeChange(currentdeliveryTypeDropDownValue);\r\n }, [currentdeliveryTypeDropDownValue]);\r\n\r\n const getAddressLayout = (addressType) => {\r\n return (\r\n <>\r\n {((shipmentDetails || {})[addressType] || {}).companyName\r\n ? `${((shipmentDetails || {})[addressType] || {}).companyName} `\r\n : `${((shipmentDetails || {})[addressType] || {}).name}`}\r\n \r\n {`${((shipmentDetails || {})[addressType] || {}).address1\r\n ? `${((shipmentDetails || {})[addressType] || {}).address1},`\r\n : ''\r\n } `}\r\n {((shipmentDetails || {})[addressType] || {}).address2\r\n ? `${((shipmentDetails || {})[addressType] || {}).address2}, `\r\n : ''}\r\n \r\n {((shipmentDetails || {})[addressType] || {}).address3\r\n ? `${((shipmentDetails || {})[addressType] || {}).address3}, `\r\n : ''}\r\n {((shipmentDetails || {})[addressType] || {}).city\r\n ? `${((shipmentDetails || {})[addressType] || {}).city}, `\r\n : ''}\r\n \r\n {((shipmentDetails || {})[addressType] || {}).state\r\n ? `${((shipmentDetails || {})[addressType] || {}).state}, `\r\n : ''}\r\n {((shipmentDetails || {})[addressType] || {}).country\r\n ? `${((shipmentDetails || {})[addressType] || {}).country}, `\r\n : ''}\r\n \r\n {((shipmentDetails || {})[addressType] || {}).postalCode}\r\n >\r\n );\r\n };\r\n \r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Account number\r\n \r\n \r\n {(shipmentDetails || {}).accountNumber}\r\n \r\n \r\n \r\n \r\n Shipment number\r\n \r\n \r\n {(shipmentDetails || {}).shipmentNumber}\r\n \r\n \r\n {(shipmentDetails || {}).customerReference\r\n? (\r\n \r\n \r\n Customer reference\r\n \r\n \r\n {' '}\r\n {(shipmentDetails || {}).customerReference}\r\n \r\n \r\n )\r\n: null}\r\n\r\n \r\n \r\n \r\n \r\n \r\n No of items\r\n \r\n \r\n {(shipmentDetails || {}).numberofItems}\r\n \r\n \r\n \r\n \r\n \r\n \r\n Weight\r\n \r\n \r\n {(shipmentDetails || {}).totalWeight} Kgs\r\n \r\n \r\n \r\n \r\n }\r\n onClick={() => handleDialog(true)}\r\n />\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n Parcel handover method\r\n \r\n \r\n {' '}\r\n {(shipmentDetails || {}).parcelHandoverMethod &&\r\n (shipmentDetails || {}).parcelHandoverMethod.toLowerCase() === 'pickup'\r\n ? 'Driver collection'\r\n : 'Drop off at ServicePoint'}\r\n \r\n \r\n\r\n \r\n \r\n \r\n Delivery type\r\n \r\n \r\n {' '}\r\n {/* {(shipmentDetails || {}).deliveryType} */}\r\n {deliveryType}\r\n \r\n \r\n \r\n \r\n Service type\r\n \r\n \r\n {' '}\r\n {(shipmentDetails || {}).serviceType}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Delivery address\r\n \r\n \r\n {getAddressLayout('consigneeAddress')}\r\n \r\n \r\n \r\n\r\n {shipmentDetails.deliveryType === 'ServicePoint'\r\n? (\r\n <>\r\n \r\n \r\n \r\n \r\n Recipient address\r\n \r\n \r\n {getAddressLayout('recipientAddress')}\r\n \r\n \r\n \r\n >\r\n )\r\n: null}\r\n \r\n \r\n \r\n \r\n {shipmentDetails.parcelHandoverMethod === 'PICKUP'\r\n ? \"Collection address\"\r\n : \"Sender address\"\r\n }\r\n \r\n \r\n {shipmentDetails.parcelHandoverMethod === 'PICKUP'\r\n ? getAddressLayout('pickupAddress')\r\n : getAddressLayout('senderAdddress')}\r\n \r\n \r\n \r\n \r\n \r\n handleDialog(false)}\r\n >\r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nShipmentDetails.propTypes = {};\r\n\r\nexport default ShipmentDetails;\r\n","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from \"react\";\n\nvar _ref2 = /*#__PURE__*/React.createElement(\"g\", {\n id: \"Icon_feather-arrow-right\",\n \"data-name\": \"Icon feather-arrow-right\",\n transform: \"translate(18.65 18.919) rotate(180)\"\n}, /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_43207\",\n \"data-name\": \"Path 43207\",\n d: \"M7.5,18H18\",\n transform: \"translate(0 -5.25)\",\n fill: \"none\",\n stroke: \"#000\",\n strokeLinecap: \"round\",\n strokeLinejoin: \"round\",\n strokeWidth: 1.3\n}), /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_43208\",\n \"data-name\": \"Path 43208\",\n d: \"M18,7.5l5.25,5.25L18,18\",\n transform: \"translate(-5.25)\",\n fill: \"none\",\n stroke: \"#000\",\n strokeLinecap: \"round\",\n strokeLinejoin: \"round\",\n strokeWidth: 1.3\n}));\n\nfunction SvgSliderArrowLeft(_ref, svgRef) {\n var title = _ref.title,\n titleId = _ref.titleId,\n props = _objectWithoutProperties(_ref, [\"title\", \"titleId\"]);\n\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 11.8,\n height: 12.339,\n viewBox: \"0 0 11.8 12.339\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, _ref2);\n}\n\nvar ForwardRef = /*#__PURE__*/React.forwardRef(SvgSliderArrowLeft);\nexport default __webpack_public_path__ + \"static/media/slider-arrow-left.e744354b.svg\";\nexport { ForwardRef as ReactComponent };","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from \"react\";\n\nvar _ref2 = /*#__PURE__*/React.createElement(\"g\", {\n id: \"Icon_feather-arrow-right\",\n \"data-name\": \"Icon feather-arrow-right\",\n transform: \"translate(-6.85 -6.581)\"\n}, /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_43207\",\n \"data-name\": \"Path 43207\",\n d: \"M7.5,18H18\",\n transform: \"translate(0 -5.25)\",\n fill: \"none\",\n stroke: \"#000\",\n strokeLinecap: \"round\",\n strokeLinejoin: \"round\",\n strokeWidth: 1.3\n}), /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_43208\",\n \"data-name\": \"Path 43208\",\n d: \"M18,7.5l5.25,5.25L18,18\",\n transform: \"translate(-5.25)\",\n fill: \"none\",\n stroke: \"#000\",\n strokeLinecap: \"round\",\n strokeLinejoin: \"round\",\n strokeWidth: 1.3\n}));\n\nfunction SvgSliderArrowRight(_ref, svgRef) {\n var title = _ref.title,\n titleId = _ref.titleId,\n props = _objectWithoutProperties(_ref, [\"title\", \"titleId\"]);\n\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 11.8,\n height: 12.339,\n viewBox: \"0 0 11.8 12.339\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, _ref2);\n}\n\nvar ForwardRef = /*#__PURE__*/React.forwardRef(SvgSliderArrowRight);\nexport default __webpack_public_path__ + \"static/media/slider-arrow-right.330002c8.svg\";\nexport { ForwardRef as ReactComponent };","import React, { useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport Slider from \"react-slick\";\r\nimport \"slick-carousel/slick/slick.css\";\r\nimport \"slick-carousel/slick/slick-theme.css\";\r\nimport './deliveryPhotographs.scss';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../../../store/actions/index';\r\n//import ArrowLeft from \"../../../../../src/assets/images/arrow-left.svg\";\r\nimport {ReactComponent as ArrowLeft} from \"../../../../assets/images/slider-arrow-left.svg\";\r\nimport {ReactComponent as ArrowRight} from \"../../../../assets/images/slider-arrow-right.svg\";\r\n\r\n\r\nconst DisplayPhotographs = (props) => {\r\n const { shipmentDetails } = props\r\n const dispatch = useDispatch();\r\n const [selectedImage, setSelectedImage] = useState(shipmentDetails[0].imageBase64)\r\n const [selectedEvent, setSelectedEvent] = useState(shipmentDetails[0].eventId)\r\n const [selectedClass, setSelectedClass] = useState(false)\r\n const [Class_name, setClass_name] = useState('')\r\n // shipmentDetails = shipmentDetails.slice(0,2)\r\n //shipmentDetails = shipmentDetails.concat(shipmentDetails)\r\n let settings = {\r\n // dots: true,\r\n infinite: false,\r\n speed: 500,\r\n slidesToShow: shipmentDetails.length >= 3 ? 3 : shipmentDetails.length,\r\n // slidesToScroll: 2,\r\n arrows: true,\r\n // centerPadding:'100px'\r\n adaptiveHeight: true,\r\n prevArrow: ,\r\n nextArrow: \r\n };\r\n const handleSubmit = (selectImg, selectEvent) => {\r\n setSelectedImage(selectImg)\r\n setSelectedEvent(selectEvent)\r\n // setSelectedClass(false)\r\n setSelectedClass(true)\r\n dispatch(actions.setSelectedEvent(selectEvent))\r\n \r\n }\r\n const handleSelect = () => {\r\n if (!selectedClass) {\r\n setSelectedClass(true)\r\n dispatch(actions.setSelectedEvent(selectedEvent))\r\n\r\n }\r\n }\r\n return (\r\n <>\r\n \r\n
{\r\n handleSelect() \r\n} } />\r\n
\r\n \r\n \r\n
\r\n {shipmentDetails.map((tile) => {\r\n return <>\r\n \r\n
{\r\n handleSubmit(tile.imageBase64, tile.eventId) \r\n} } \r\n src={tile.imageBase64} alt={tile.imageAltText}/>\r\n
\r\n >\r\n })}\r\n \r\n
\r\n >\r\n );\r\n};\r\n\r\nDisplayPhotographs.propTypes = {shipmentDetails:PropTypes.array};\r\n\r\nexport default DisplayPhotographs;","import React, { useState, useEffect} from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid } from '@material-ui/core';\r\nimport \"slick-carousel/slick/slick.css\";\r\nimport \"slick-carousel/slick/slick-theme.css\";\r\nimport './deliveryPhotographs.scss';\r\nimport DisplayPhotographs from './displayPhotographs';\r\n\r\nconst DeliveryPhotographs = (props) => {\r\n const { shipmentDetails } = props\r\n const [trackingImages, setTrackingImages] = useState([])\r\n\r\n useEffect(() => {\r\n if (shipmentDetails && shipmentDetails.shipmentEventModels) {\r\n const eventImages = []\r\n shipmentDetails.shipmentEventModels.forEach((shipEvent, i) => {\r\n if (shipEvent.images && shipEvent.images.length > 0) {\r\n shipEvent.images.forEach((img, index) => {\r\n if (img.imageType === 'photo') {\r\n const item = {\r\n eventId: shipEvent.shipmentEvent.code,\r\n imageBase64: atob(img.imageBase64),\r\n imageAltText: img.imageType\r\n }\r\n eventImages.push(item)\r\n }\r\n })\r\n }\r\n })\r\n setTrackingImages(eventImages)\r\n }\r\n }, [shipmentDetails])\r\n\r\n return (\r\n <>\r\n \r\n \r\n \r\n {trackingImages.length > 0\r\n? `Delivery photographs (${trackingImages.length})`\r\n : `Delivery photographs`}\r\n \r\n \r\n \r\n {trackingImages.length > 0\r\n ? \r\n : <>\r\n \r\n No image captured yet!
\r\n When delivered,your parcel
\r\n images will come here
\r\n \r\n >\r\n }\r\n \r\n \r\n \r\n >\r\n );\r\n};\r\n\r\nDeliveryPhotographs.propTypes = {shipmentDetails:PropTypes.object};\r\n\r\nexport default DeliveryPhotographs;\r\n","import React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Accordion, AccordionDetails, AccordionSummary, Grid, Typography } from '@material-ui/core';\r\nimport { ExpandMore } from '@material-ui/icons';\r\nimport './customAccordion.scss';\r\n\r\nconst DashBoardAccordian = ({ heading, defaultExpanded, secondaryheading, children }) => {\r\n return (\r\n \r\n \r\n }\r\n aria-controls=\"panel1a-content\"\r\n id=\"panel1a-header\"\r\n >\r\n \r\n
{heading}
\r\n {secondaryheading !== '' ?
Current:{secondaryheading}
: null}\r\n
\r\n \r\n {children} \r\n \r\n \r\n );\r\n};\r\n\r\nDashBoardAccordian.propTypes = {\r\n heading: PropTypes.string.isRequired,\r\n content: PropTypes.any,\r\n defaultExpanded: PropTypes.bool,\r\n children: PropTypes.object,\r\n secondaryheading: PropTypes.string,\r\n};\r\nDashBoardAccordian.defaultProps = {\r\n defaultExpanded: true,\r\n secondaryheading: '',\r\n};\r\n\r\nexport default DashBoardAccordian;\r\n","export const ChangeDeliveryInstrForm = {\r\n formId: 'changeDeliveryInstrForm',\r\n formField: {\r\n deliveryDueDate: {\r\n props: { name: 'deliveryDueDate', label: '', type: 'radio' },\r\n },\r\n deliveryType: {\r\n props: { name: 'deliveryType', label: 'Delivery type', type: 'select', displayField: 'name' },\r\n },\r\n safePlaceLocation: {\r\n props: { name: 'safePlaceLocation', label: 'Select', type: 'select', displayField: 'name', hasDefaultValue: true},\r\n },\r\n safePlaceLocationAdditionalText: {\r\n props: { name: 'safePlaceLocationAdditionalText', type: 'text', label: 'comments', isRequired: true},\r\n validation: {\r\n name: 'safePlaceLocationAdditionalText',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n ['safePlaceLocation'],\r\n (safePlaceLocation, schema) => {\r\n return (safePlaceLocation && (safePlaceLocation.value === '7' || safePlaceLocation.value === '8'))\r\n ? schema.required('Instructions are required')\r\n : schema.notRequired();\r\n },\r\n ],\r\n },\r\n {\r\n type: 'max',\r\n params: [30, 'Maximum of 30 characters allowed'],\r\n },\r\n ],\r\n },\r\n },\r\n \r\n },\r\n};\r\n","import { React, useEffect } from 'react';\r\nimport Grid from '@material-ui/core/Grid';\r\n\r\nimport FormRenderer from '../../framework/Inputs/formRenderer/formRenderer';\r\nimport { safePlaceLocationData } from '../../utils/constants/constants';\r\n\r\nconst SafePlaceLocation = (props) => {\r\n const { formField, values } = props\r\n const { safePlaceLocation } = values;\r\n\r\n useEffect(() => {\r\n props.set_isDisableddeliveryType(false);\r\n }, [safePlaceLocation])\r\n\r\n const displayAdditionalText = () => {\r\n if (\r\n safePlaceLocation &&\r\n (safePlaceLocation.name === 'Other' ||\r\n safePlaceLocation.name ===\r\n 'If you are self isolating, part of an at risk group or disabled, please tell us about any accessibility delivery needs you have')\r\n ) {\r\n return true;\r\n }\r\n return false;\r\n };\r\n \r\n return (\r\n \r\n \r\n \r\n \r\n {displayAdditionalText()\r\n ? (\r\n \r\n \r\n \r\n )\r\n : null}\r\n \r\n );\r\n};\r\n\r\nexport default SafePlaceLocation;\r\n","import React from 'react';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\nimport Table from '@material-ui/core/Table';\r\nimport TableBody from '@material-ui/core/TableBody';\r\nimport TableCell from '@material-ui/core/TableCell';\r\nimport TableContainer from '@material-ui/core/TableContainer';\r\nimport TableHead from '@material-ui/core/TableHead';\r\nimport TableRow from '@material-ui/core/TableRow';\r\nimport Paper from '@material-ui/core/Paper';\r\nconst useStyles = makeStyles({\r\n table: {\r\n minWidth: 700,\r\n cursor: 'pointer',\r\n height:200\r\n },\r\n tableRow: {\r\n '&$hover:hover': {\r\n backgroundColor: '#FFEEA9',\r\n },\r\n },\r\n rowText: {\r\n verticalAlign: 'text-top',\r\n },\r\n heading: {\r\n fontWeight: 700,\r\n },\r\n hover: {},\r\n});\r\nexport default function ShowLocationDetails(props) {\r\n const { rows, rowClicked, isServicePoint } = props;\r\n const classes = useStyles();\r\n return isServicePoint\r\n? (\r\n \r\n \r\n \r\n {rows.map((row) => (\r\n rowClicked(row)}\r\n selected={props.selectedID === row.servicePointID}\r\n >\r\n \r\n Address: \r\n {row.title} \r\n {row.address.address1} \r\n {row.address.address2} \r\n {row.address.address3} \r\n {row.address.postalTown} \r\n \r\n \r\n Distance: \r\n Distance {parseFloat((row.distance || 0) * (0.00062137)).toFixed(2)} miles \r\n \r\n \r\n Opening Hours: \r\n {row.openingHours.map((openingTime) => (\r\n \r\n {openingTime.dayDescription}-{openingTime.timeDescription}{' '}\r\n \r\n ))}\r\n \r\n \r\n ))}\r\n \r\n
\r\n \r\n )\r\n: (\r\n \r\n \r\n \r\n {rows.map((row, index) => (\r\n rowClicked(row)}\r\n selected={props.selectedID === row.depotId}\r\n >\r\n \r\n Address: \r\n {row.depotAddress.address1} \r\n {row.depotAddress.address2} \r\n {row.depotAddress.address3} \r\n {row.depotAddress.postalTown} \r\n \r\n \r\n Parcel collection opening times: \r\n {row.openingTimes.map((time) => (\r\n \r\n {time.openingTime.day}-{time.openingTime.openTime}-{time.openingTime.closeTime}\r\n \r\n ))}\r\n \r\n \r\n ))}\r\n \r\n
\r\n \r\n );\r\n}\r\n","import React, { useState, useEffect } from 'react';\r\nimport ShowLocationDetails from './showLocationDetails';\r\nimport { ServiceEndPoints } from '../../utils/constants/ApiConstant';\r\nimport { GET } from '../../api/axios';\r\n\r\nconst DeliverToServicePoint = (props) => {\r\n const [servicePoints, setServicePoints] = useState(null);\r\n\r\n useEffect(() => {\r\n const servicePoint = props.shipmentDetails.consigneeAddress.postalCode;\r\n let url = '';\r\n const encodePostcodeURI = encodeURIComponent(servicePoint);\r\n url = `${ServiceEndPoints.getServicePoints}?countryCode=GB&PostCode=${encodePostcodeURI}&ServicePointType=parcelshop`;\r\n GET(url)\r\n .then((res) => {\r\n setServicePoints(res.data.slice(0, 5));\r\n })\r\n .catch((err) => {\r\n alert('Error');\r\n setServicePoints(null);\r\n });\r\n }, []);\r\n\r\n return servicePoints\r\n? (\r\n \r\n )\r\n: (\r\n null\r\n );\r\n};\r\n\r\nexport default DeliverToServicePoint;\r\n","import React, { useState, useEffect } from 'react';\r\n\r\nimport Spinner from '../../framework/spinner/spinner';\r\nimport ShowLocationDetails from './showLocationDetails';\r\n\r\nimport { ServiceEndPoints } from '../../utils/constants/ApiConstant';\r\nimport { GET } from '../../api/axios';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../store/actions/index';\r\n\r\nconst DeliverToDepot = (props) => {\r\n const [servicePoints, setServicePoints] = useState(null);\r\nconst dispatch = useDispatch();\r\n useEffect(() => {\r\n dispatch(actions.setLoaderLayOver(true))\r\n const servicePoint = props.shipmentDetails.consigneeAddress.postalCode;\r\n let url = '';\r\n const encodePostcodeURI = encodeURIComponent(servicePoint);\r\n // url = `${ServiceEndPoints.getServicePoints}?countryCode=GB&PostCode=${encodePostcodeURI}&ServicePointType=parcelshop`;\r\n url = `${ServiceEndPoints.getLocations}/depots?postcode=${encodePostcodeURI}`;\r\n GET(url).then((res) => {\r\n setServicePoints([res.data]);\r\n dispatch(actions.setLoaderLayOver(false))\r\n })\r\n.catch(err => {\r\n console.log(err);\r\n dispatch(actions.setLoaderLayOver(false))\r\n });\r\n }, []);\r\n\r\n return servicePoints ? : null;\r\n};\r\n\r\nexport default DeliverToDepot;\r\n","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from \"react\";\n\nvar _ref2 = /*#__PURE__*/React.createElement(\"g\", {\n id: \"Group_8088\",\n \"data-name\": \"Group 8088\",\n transform: \"translate(-5 -4.969)\",\n opacity: 0.997\n}, /*#__PURE__*/React.createElement(\"g\", {\n id: \"field\"\n}, /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_43009\",\n \"data-name\": \"Path 43009\",\n d: \"M9,5.969a3,3,0,0,0-3,3v22a3,3,0,0,0,3,3H31a3,3,0,0,0,3-3v-22a3,3,0,0,0-3-3H9m0-1H31a4,4,0,0,1,4,4v22a4,4,0,0,1-4,4H9a4,4,0,0,1-4-4v-22A4,4,0,0,1,9,4.969Z\",\n fill: \"#bababa\"\n})), /*#__PURE__*/React.createElement(\"g\", {\n id: \"selected\"\n}, /*#__PURE__*/React.createElement(\"path\", {\n id: \"color\",\n d: \"M18.5,22.055l7.293-7.293,1.414,1.414L18.5,24.883l-4.707-4.707,1.414-1.414Z\"\n})));\n\nfunction SvgAdd(_ref, svgRef) {\n var title = _ref.title,\n titleId = _ref.titleId,\n props = _objectWithoutProperties(_ref, [\"title\", \"titleId\"]);\n\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 30,\n height: 30,\n viewBox: \"0 0 30 30\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, _ref2);\n}\n\nvar ForwardRef = /*#__PURE__*/React.forwardRef(SvgAdd);\nexport default __webpack_public_path__ + \"static/media/add.2a6636f9.svg\";\nexport { ForwardRef as ReactComponent };","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from \"react\";\n\nvar _ref2 = /*#__PURE__*/React.createElement(\"g\", {\n id: \"Group_8088\",\n \"data-name\": \"Group 8088\",\n transform: \"translate(-5 -4.969)\",\n opacity: 0.997\n}, /*#__PURE__*/React.createElement(\"g\", {\n id: \"field\"\n}, /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_43009\",\n \"data-name\": \"Path 43009\",\n d: \"M9,5.969a3,3,0,0,0-3,3v22a3,3,0,0,0,3,3H31a3,3,0,0,0,3-3v-22a3,3,0,0,0-3-3H9m0-1H31a4,4,0,0,1,4,4v22a4,4,0,0,1-4,4H9a4,4,0,0,1-4-4v-22A4,4,0,0,1,9,4.969Z\",\n fill: \"#bababa\"\n})), /*#__PURE__*/React.createElement(\"line\", {\n id: \"Line_455\",\n \"data-name\": \"Line 455\",\n x2: 10,\n y2: 10,\n transform: \"translate(15 14.969)\",\n fill: \"none\",\n stroke: \"#000\",\n strokeWidth: 2\n}), /*#__PURE__*/React.createElement(\"line\", {\n id: \"Line_456\",\n \"data-name\": \"Line 456\",\n x2: 10,\n y2: 10,\n transform: \"translate(25 14.969) rotate(90)\",\n fill: \"none\",\n stroke: \"#000\",\n strokeWidth: 2\n}));\n\nfunction SvgClose(_ref, svgRef) {\n var title = _ref.title,\n titleId = _ref.titleId,\n props = _objectWithoutProperties(_ref, [\"title\", \"titleId\"]);\n\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 30,\n height: 30,\n viewBox: \"0 0 30 30\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, _ref2);\n}\n\nvar ForwardRef = /*#__PURE__*/React.forwardRef(SvgClose);\nexport default __webpack_public_path__ + \"static/media/close.2668bfc2.svg\";\nexport { ForwardRef as ReactComponent };","import React from 'react';\r\nimport { Grid, IconButton, SvgIcon } from '@material-ui/core';\r\n\r\nimport { ReactComponent as CheckIcon } from '../../assets/images/add.svg';\r\nimport { ReactComponent as CloseIcon } from '../../assets/images/close.svg';\r\n\r\nconst DeliveryButtonSet = (props) => {\r\n return (\r\n \r\n \r\n props.onCancel()} disabled={props.isDisabled}>\r\n \r\n \r\n \r\n \r\n props.onSubmit()} disabled={props.isDisabled}>\r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nexport default DeliveryButtonSet;\r\n","import React, { useEffect, useState, useRef } from 'react';\r\nimport { Form, Formik } from 'formik';\r\nimport { Grid } from '@material-ui/core';\r\n\r\nimport DashBoardAccordian from '../../../components/Tracking/DashBoardAccordian/DashBoardAccordian';\r\nimport { ChangeDeliveryInstrForm } from '../../../utils/formConfig/ChangeDeliveryInstr/ChangeDeliveryInstr';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { PUT, GET } from '../../../api/axios';\r\nimport { formatDateToSecondFormat, getDayOfTheWeek } from '../../../utils/helperFunctions';\r\n\r\nimport { changeDeliveryType } from '../../../utils/constants/constants';\r\nimport './ChangeDeliveryAddress.scss';\r\n\r\nimport SafePlaceLocation from '../../../components/Tracking/SafePlaceLocation';\r\nimport DeliverToServicePoint from '../../../components/Tracking/deliverToServicePoint';\r\nimport DeliverToDepot from '../../../components/Tracking/deliverServiceDepot';\r\nimport DeliveryButtonSet from '../../../components/Tracking/changeDeliveryButtons';\r\n\r\nimport './ChangeDeliveryAddress.scss';\r\n\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { useDispatch } from 'react-redux';\r\nimport { getYupSchemaFromMetaData } from '../../../utils/yupSchema/yupSchemaGenerator';\r\nimport { DELIVERY_TYPES, DELIVERY_STATUS, DELIVER_TYPE } from '../../../utils/constants/constants';\r\n\r\n\r\nconst { formField, formId } = ChangeDeliveryInstrForm;\r\n\r\nconst ChangeDeliveryAddress = (props) => {\r\n const { closeDialog, TitleDialog } = props;\r\n const formRef = useRef();\r\n const [initialValues, setIntialValue] = useState(null);\r\n const [offers, setOffers] = useState({});\r\n const [deliveryDates, setDeliveryDates] = useState(null);\r\n const [servicePointSelected, setServicePointSelected] = useState(null);\r\n const [_isDisableddeliveryType, set_isDisableddeliveryType] = useState(true);\r\n const [_isDisabledFordeliveryDueDate, set_isDisabledFordeliveryDueDate] = useState(true);\r\n const [DeliveryTypeValues, setDeliveryTypeValues] = useState('');\r\n const [OldDeliveryTypeValues, setOldDeliveryTypeValues] = useState('');\r\n const [changeDeliveryTypeDropdownValues, setchangeDeliveryTypeDropdownValues] = useState([]);\r\n const [changeDeliveryInstrSchema, setValidationSchema] = React.useState(getYupSchemaFromMetaData(formField, [], []));\r\n const [selectedID, setSelectedID] = useState(null);\r\n const dispatch = useDispatch();\r\n\r\n const setIntialValues = () => {\r\n const initialEmptyValues = {};\r\n for (let property in formField) {\r\n if (Object.prototype.hasOwnProperty.call(formField, property)) {\r\n const field = formField[property];\r\n if (field.props.type === 'checkbox' || field.props.type === 'radio') {\r\n initialEmptyValues[field.props.name] = field.value;\r\n } else {\r\n initialEmptyValues[field.props.name] = field.value || '';\r\n }\r\n }\r\n }\r\n setIntialValue(initialEmptyValues);\r\n dispatch(actions.setLoaderLayOver(false));\r\n };\r\n\r\n //Set value for selected serive point.\r\n const servicePointClicked = (servicePointDetails) => {\r\n setServicePointSelected(servicePointDetails);\r\n setSelectedID(servicePointDetails.servicePointID);\r\n };\r\n\r\n /**\r\n * Updates dropdown values and form field values for delivery types.\r\n * \r\n * @param {Array} myArray - The array of delivery types to be set in the dropdown.\r\n * @param {Object} deliveryType - The current delivery type to be set in the form field.\r\n * @param {string} value - The value of the current delivery type.\r\n */\r\n const updateDropdownValues = (myArray, deliveryType, value) => {\r\n setchangeDeliveryTypeDropdownValues(myArray);\r\n formRef.current.setFieldValue('deliveryType', deliveryType);\r\n setOldDeliveryTypeValues(value);\r\n };\r\n\r\n //function to determine the postcode based on delivery type\r\n const getPostcode = (shipmentDetails) => {\r\n let consigneeAddressPostcode = shipmentDetails?.consigneeAddress?.postalCode;\r\n let recipientAddressPostcode = shipmentDetails?.recipientAddress?.postalCode;\r\n\r\n // Check delivery type and return appropriate postcode\r\n if (shipmentDetails?.deliveryType?.toLowerCase() === DELIVER_TYPE.DEPOT) {\r\n return recipientAddressPostcode;\r\n } else {\r\n return consigneeAddressPostcode;\r\n }\r\n }\r\n\r\n //Get all offers for the shipment.\r\n useEffect(() => {\r\n let postcode = getPostcode(props?.shipmentDetails);\r\n let url = `${ServiceEndPoints.getShipment}/${props.shipmentDetails.shipmentNumber}/offers?postcode=${postcode}`;\r\n dispatch(actions.setLoaderLayOver(true));\r\n GET(url)\r\n .then((response) => {\r\n setOffers(response.data);\r\n setAvailableDates(response.data);\r\n setIntialValues();\r\n let myArray = changeDeliveryType;\r\n\r\n if (response.data.leaveWithNeighbour === DELIVERY_STATUS.NULL) {\r\n myArray = myArray.filter(function (obj) {\r\n return obj.name !== DELIVERY_TYPES.LEAVE_NEIGHBOUR;\r\n });\r\n updateDropdownValues(myArray, props.current_DeliveryType, props.current_DeliveryType.value);\r\n }\r\n if (response.data.preferredLocation === DELIVERY_STATUS.NULL) {\r\n myArray = myArray.filter(function (obj) {\r\n return obj.name !== DELIVERY_TYPES.SAFE_LOCATION;\r\n });\r\n updateDropdownValues(myArray, props.current_DeliveryType, props.current_DeliveryType.value);\r\n }\r\n if (response.data.preferredDepot === DELIVERY_STATUS.NULL) {\r\n myArray = myArray.filter(function (obj) {\r\n return obj.name !== DELIVERY_TYPES.DEPOT &&\r\n obj.name !== DELIVERY_TYPES.DEPOT_PIN &&\r\n obj.name !== DELIVERY_TYPES.DEPOT_AGE_VERIFICATION;\r\n });\r\n updateDropdownValues(myArray, props.current_DeliveryType, props.current_DeliveryType.value);\r\n }\r\n if (response.data.preferredDepot?.deliveryChoiceCategory === DELIVERY_STATUS.NONE) {\r\n myArray = myArray.filter(function (obj) {\r\n return obj.name !== DELIVERY_TYPES.DEPOT_PIN &&\r\n obj.name !== DELIVERY_TYPES.DEPOT_AGE_VERIFICATION;\r\n });\r\n updateDropdownValues(myArray, props.current_DeliveryType, props.current_DeliveryType.value);\r\n }\r\n if (response.data.preferredDepot?.deliveryChoiceCategory === DELIVERY_STATUS.PIN) {\r\n myArray = myArray.filter(function (obj) {\r\n return obj.name !== DELIVERY_TYPES.DEPOT &&\r\n obj.name !== DELIVERY_TYPES.DEPOT_AGE_VERIFICATION;\r\n });\r\n updateDropdownValues(myArray, props.current_DeliveryType, props.current_DeliveryType.value);\r\n }\r\n if (response.data.preferredDepot?.deliveryChoiceCategory === DELIVERY_STATUS.AGE) {\r\n myArray = myArray.filter(function (obj) {\r\n return obj.name !== DELIVERY_TYPES.DEPOT_PIN &&\r\n obj.name !== DELIVERY_TYPES.DEPOT;\r\n });\r\n updateDropdownValues(myArray, props.current_DeliveryType, props.current_DeliveryType.value);\r\n }\r\n if (response.data.deliverToDoorstepOnly === null) {\r\n myArray = myArray.filter(function (obj) {\r\n return obj.name !== DELIVERY_TYPES.DOORSTEP_ONLY &&\r\n obj.name !== DELIVERY_TYPES.DOORSTEP_AGE_VERIFICATION &&\r\n obj.name !== DELIVERY_TYPES.DOORSTEP_PIN\r\n });\r\n updateDropdownValues(myArray, props.current_DeliveryType, props.current_DeliveryType.value);\r\n }\r\n if (response.data.deliverToDoorstepOnly?.deliveryChoiceCategory === DELIVERY_STATUS.NONE) {\r\n myArray = myArray.filter(function (obj) {\r\n return obj.name !== DELIVERY_TYPES.DOORSTEP_AGE_VERIFICATION &&\r\n obj.name !== DELIVERY_TYPES.DOORSTEP_PIN\r\n });\r\n updateDropdownValues(myArray, props.current_DeliveryType, props.current_DeliveryType.value);\r\n }\r\n if (response.data.deliverToDoorstepOnly?.deliveryChoiceCategory === DELIVERY_STATUS.AGE) {\r\n myArray = myArray.filter(function (obj) {\r\n return obj.name !== DELIVERY_TYPES.DOORSTEP_ONLY &&\r\n obj.name !== DELIVERY_TYPES.DOORSTEP_PIN\r\n });\r\n updateDropdownValues(myArray, props.current_DeliveryType, props.current_DeliveryType.value);\r\n }\r\n if (response.data.deliverToDoorstepOnly?.deliveryChoiceCategory === DELIVERY_STATUS.PIN) {\r\n myArray = myArray.filter(function (obj) {\r\n return obj.name !== DELIVERY_TYPES.DOORSTEP_ONLY &&\r\n obj.name !== DELIVERY_TYPES.DOORSTEP_AGE_VERIFICATION\r\n });\r\n updateDropdownValues(myArray, props.current_DeliveryType, props.current_DeliveryType.value);\r\n }\r\n\r\n\r\n if (\r\n response.data.leaveWithNeighbour === DELIVERY_STATUS.NULL &&\r\n response.data.preferredServicePoint === DELIVERY_STATUS.NULL &&\r\n response.data.preferredLocation === DELIVERY_STATUS.NULL &&\r\n response.data.preferredDepot === DELIVERY_STATUS.NULL &&\r\n response.data.deliverToDoorstepOnly === DELIVERY_STATUS.NULL\r\n ) {\r\n // formRef.current.setFieldValue('deliveryType', { name: 'Select', value: '' });\r\n formRef.current.setFieldValue('deliveryType', props.current_DeliveryType);\r\n\r\n }\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n dispatch(actions.setLoaderLayOver(false));\r\n closeDialog();\r\n TitleDialog();\r\n });\r\n }, []);\r\n\r\n const isDisabled = offers ? (\r\n offers.leaveWithNeighbour === DELIVERY_STATUS.NULL &&\r\n offers.preferredServicePoint === DELIVERY_STATUS.NULL &&\r\n offers.preferredLocation === DELIVERY_STATUS.NULL &&\r\n offers.preferredDepot === DELIVERY_STATUS.NULL &&\r\n offers.deliverToDoorstepOnly === DELIVERY_STATUS.NULL\r\n ) : true;\r\n\r\n const renderChangeAddressType = (values, formField) => {\r\n if (values.deliveryType) {\r\n switch (values.deliveryType.value) {\r\n case DELIVERY_TYPES.SAFE_LOCATION:\r\n return \r\n \r\n case DELIVERY_TYPES.DEPOT:\r\n case DELIVERY_TYPES.DEPOT_PIN:\r\n case DELIVERY_TYPES.DEPOT_AGE_VERIFICATION:\r\n return (\r\n {\r\n setSelectedID(row.depotId);\r\n }}\r\n selectedID={selectedID}\r\n />\r\n );\r\n\r\n default:\r\n break;\r\n }\r\n }\r\n };\r\n\r\n const setAvailableDates = (data) => {\r\n if (data && data.preferredDay) {\r\n const validDays = data.preferredDay.validDays.map((day) => {\r\n return {\r\n value: day,\r\n label: `${getDayOfTheWeek(day)},${formatDateToSecondFormat(day)}`,\r\n };\r\n });\r\n setDeliveryDates(validDays);\r\n }\r\n };\r\n\r\n const onDeliveryMethodSubmit = (formValues, errors) => {\r\n if (Object.keys(errors).length === 0 && errors.constructor === Object) {\r\n const { shipmentDetails } = props;\r\n let url = `${ServiceEndPoints.getShipment}/${props.shipmentDetails.shipmentNumber}/`;\r\n let payLoad = {};\r\n\r\n switch (formValues.deliveryType.value) {\r\n case DELIVERY_TYPES.SAFE_LOCATION:\r\n url += 'preferredLocation';\r\n payLoad = {\r\n preferredLocation: parseInt(formValues.safePlaceLocation.value),\r\n postcode: getPostcode(shipmentDetails)\r\n };\r\n break;\r\n case DELIVERY_TYPES.LEAVE_NEIGHBOUR:\r\n url += 'leaveWithNeighbour';\r\n payLoad = {\r\n leaveWithNeighbour: true,\r\n postcode: getPostcode(shipmentDetails)\r\n };\r\n break;\r\n case DELIVERY_TYPES.DOORSTEP_ONLY:\r\n case DELIVERY_TYPES.DOORSTEP_PIN:\r\n case DELIVERY_TYPES.DOORSTEP_AGE_VERIFICATION:\r\n url += 'orders/deliverToDoorstepOnly';\r\n payLoad = {\r\n postcode: getPostcode(shipmentDetails)\r\n };\r\n break;\r\n case DELIVERY_TYPES.DEPOT:\r\n case DELIVERY_TYPES.DEPOT_PIN:\r\n case DELIVERY_TYPES.DEPOT_AGE_VERIFICATION:\r\n url += 'preferredDepot';\r\n payLoad = {\r\n collectionDate: offers?.preferredDepot?.collectionDates?.[0],\r\n postcode: getPostcode(shipmentDetails),\r\n };\r\n break;\r\n default:\r\n break;\r\n }\r\n\r\n PUT(url, payLoad)\r\n .then((res) => {\r\n // alert('Delivery method changed successfully');\r\n dispatch(actions.setAppSnackBarData({ msg: 'Change delivery instruction updated successfully' }));\r\n setOldDeliveryTypeValues(formValues.deliveryType.value);\r\n set_isDisableddeliveryType(true);\r\n props.onChangeDeliveryAddress();\r\n closeDialog();\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n } else {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [{ type: 'error', msg: 'The form has errors, please correct and try again' }],\r\n }),\r\n );\r\n }\r\n };\r\n\r\n const onDeliveryMethodCancel = (setFieldValue) => {\r\n setFieldValue('deliveryType', '');\r\n setFieldValue('safePlaceLocation', '');\r\n setFieldValue('safePlaceLocationAdditionalText', '');\r\n setFieldValue('leaveWithNeighbourText', '');\r\n set_isDisableddeliveryType(true);\r\n };\r\n\r\n const onDeliveryDateSubmit = (formValues) => {\r\n const url = `${ServiceEndPoints.getShipment}/${props.shipmentDetails.shipmentNumber}/preferredDay`;\r\n const payload = {\r\n date: formValues.deliveryDueDate,\r\n postcode: `${props.shipmentDetails.consigneeAddress.postalCode}`,\r\n };\r\n PUT(url, payload)\r\n .then((res) => {\r\n // alert('Delivery date changed successfully');\r\n dispatch(actions.setAppSnackBarData({ msg: 'Change delivery instruction updated successfully' }));\r\n props.onChangeDeliveryAddress();\r\n set_isDisabledFordeliveryDueDate(true);\r\n closeDialog();\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n };\r\n\r\n const onDeliveryDateCancel = (setFieldValue) => {\r\n setFieldValue('deliveryDueDate', '');\r\n set_isDisabledFordeliveryDueDate(true);\r\n };\r\n\r\n const getCurrentDueDate = () => {\r\n const { shipmentDetails } = props;\r\n let currentString = '';\r\n if (shipmentDetails.dueDate) {\r\n let d = new Date(shipmentDetails.dueDate);\r\n let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d);\r\n let mo = new Intl.DateTimeFormat('en', { month: 'numeric' }).format(d);\r\n let da = new Intl.DateTimeFormat('en', { day: 'numeric' }).format(d);\r\n let weekDay = new Intl.DateTimeFormat('en', { weekday: 'long' }).format(d);\r\n\r\n currentString = `${da}/${mo}/${ye}(${weekDay})`;\r\n }\r\n return currentString;\r\n };\r\n\r\n const handleChange = (e) => {\r\n set_isDisabledFordeliveryDueDate(false);\r\n };\r\n\r\n useEffect(() => {\r\n if (formRef.current?.values?.deliveryType) {\r\n if (OldDeliveryTypeValues === formRef.current?.values?.deliveryType?.value) {\r\n set_isDisableddeliveryType(true);\r\n } else {\r\n set_isDisableddeliveryType(false);\r\n }\r\n } else {\r\n set_isDisableddeliveryType(true);\r\n }\r\n }, [DeliveryTypeValues, OldDeliveryTypeValues]);\r\n\r\n return (\r\n \r\n {initialValues ? (\r\n
\r\n \r\n {({ values, setFieldValue, errors }) => {\r\n console.log('values.deliveryType::: ', values.deliveryType);\r\n if (values.deliveryType) {\r\n setDeliveryTypeValues(values.deliveryType);\r\n }\r\n return (\r\n \r\n );\r\n }}\r\n \r\n
\r\n ) : null}\r\n
\r\n );\r\n};\r\n\r\nexport default ChangeDeliveryAddress;\r\n","import React from 'react';\r\nimport { Card, Grid, Box } from '@material-ui/core';\r\nimport Typography from '@material-ui/core/Typography';\r\nimport CustomCaption from '../../../../framework/summaryFormate/CustomCaption';\r\nimport { makeStyles, withStyles } from '@material-ui/core/styles';\r\nimport Slider from \"react-slick\";\r\nimport './TrackingDetails.scss';\r\nimport { ReactComponent as ArrowLeft } from \"../../../../assets/images/slider-arrow-left.svg\";\r\nimport { ReactComponent as ArrowRight } from \"../../../../assets/images/slider-arrow-right.svg\";\r\nimport { GOOGLE_API_KEY } from '../../../../utils/constants/ApiConstant';\r\nimport { convertTZwithFormat } from '../../../../utils/helperFunctions';\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n contentTitle: {\r\n color: '#000',\r\n fontSize: '16px',\r\n display: 'block',\r\n paddingBottom: '5px'\r\n }\r\n}));\r\n\r\nvar settings = {\r\n dots: false,\r\n infinite: false,\r\n speed: 500,\r\n slidesToShow: 1,\r\n slidesToScroll: 1,\r\n arrows: true,\r\n prevArrow: ,\r\n nextArrow: \r\n};\r\nconst TrackingStepperDetails = ({ ContentDetails }) => {\r\n const classes = useStyles();\r\n let listOfImages = [];\r\n let eventMapURL = '';\r\n // let decodedImage = atob(ContentDetails.imageBase64);\r\n // console.log(\"ContentDetails\",ContentDetails);\r\n {\r\n ContentDetails.shipmentImages.map((photo, key) => {\r\n\r\n if (photo.imageType != \"signature\") {\r\n var decodedStringAtoB = atob(photo.imageBase64);\r\n listOfImages.push({ decodedStringAtoB })\r\n }\r\n // Decode the String\r\n }\r\n\r\n )\r\n\r\n if (ContentDetails.latitude && ContentDetails.longitude) {\r\n eventMapURL = `https://www.google.com/maps/embed/v1/place?key=${GOOGLE_API_KEY}&q=${ContentDetails.latitude},${ContentDetails.longitude}&zoom=11`\r\n }\r\n }\r\n return (\r\n \r\n {eventMapURL && `Event Map`}\r\n
\r\n \r\n \r\n {eventMapURL &&\r\n \r\n }\r\n \r\n \r\n\r\n \r\n \r\n {listOfImages.map((img, key) => \r\n
\r\n
)\r\n\r\n }\r\n \r\n \r\n \r\n \r\n \r\n {ContentDetails.labels}\r\n \r\n \r\n {ContentDetails.location}\r\n \r\n \r\n {convertTZwithFormat(ContentDetails.dateAndTime, 'YYYY-MM-DDTHH:mm:ssZ')}\r\n \r\n \r\n \r\n {ContentDetails.deliveryType != \"\" ? : \"\"\r\n }\r\n \r\n {ContentDetails.comments === ''\r\n ? \" \"\r\n : \r\n \r\n }\r\n\r\n {ContentDetails.shipmentImages.map((sign, key) => {\r\n var decodedStringAtoB = atob(sign.imageBase64);\r\n\r\n return (\r\n sign.imageType === 'signature'\r\n ? \r\n \r\n Signature of the receiver\r\n \r\n \r\n \r\n : \"\"\r\n )\r\n })}\r\n\r\n\r\n \r\n \r\n
\r\n );\r\n};\r\n\r\nexport default TrackingStepperDetails;\r\n","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { makeStyles, withStyles } from '@material-ui/core/styles';\r\nimport clsx from 'clsx';\r\nimport Stepper from '@material-ui/core/Stepper';\r\nimport Step from '@material-ui/core/Step';\r\nimport StepLabel from '@material-ui/core/StepLabel';\r\nimport StepConnector from '@material-ui/core/StepConnector';\r\nimport Typography from '@material-ui/core/Typography';\r\nimport { StepContent } from '@material-ui/core';\r\nimport './varticalLinearStepper.scss';\r\nimport CustomDialog from '../dialog/customDialog';\r\nimport { Grid } from '@material-ui/core';\r\nimport TrackingStepperDetails from '../../components/dashboard/Tracking/TrackingDetails/TrackingStepperDetails';\r\nimport { Details } from '@material-ui/icons';\r\nimport { useSelector } from 'react-redux';\r\nimport { convertTZwithFormat, convertTZ } from \"../../utils/helperFunctions\"\r\n\r\nconst QontoConnector = withStyles({\r\n alternativeLabel: {\r\n top: 10,\r\n left: 'calc(-50% + 16px)',\r\n right: 'calc(50% + 16px)',\r\n },\r\n active: {\r\n '& $line': {\r\n borderColor: '#784af4',\r\n },\r\n },\r\n completed: {\r\n '& $line': {\r\n borderColor: '#784af4',\r\n },\r\n },\r\n line: {\r\n borderColor: '#eaeaf0',\r\n borderTopWidth: 3,\r\n borderRadius: 1,\r\n },\r\n})(StepConnector);\r\n\r\nconst useQontoStepIconStyles = makeStyles({\r\n root: {\r\n color: '#eaeaf0',\r\n display: 'flex',\r\n height: 20,\r\n alignItems: 'center',\r\n },\r\n active: {\r\n color: '#D40511',\r\n },\r\n circle: {\r\n width: 8,\r\n height: 8,\r\n borderRadius: '50%',\r\n backgroundColor: 'currentColor',\r\n },\r\n completed: {\r\n backgroundColor: '#fff',\r\n border: '1px solid #8C8C8C',\r\n zIndex: 1,\r\n fontSize: 18,\r\n width: 8,\r\n height: 8,\r\n borderRadius: '50%',\r\n },\r\n});\r\n\r\nfunction QontoStepIcon(props) {\r\n const classes = useQontoStepIconStyles();\r\n const { active, completed } = props;\r\n\r\n return (\r\n \r\n {completed ?
:
}\r\n
\r\n );\r\n}\r\n\r\nQontoStepIcon.propTypes = {\r\n\r\n /**\r\n * Whether this step is active.\r\n */\r\n active: PropTypes.bool,\r\n\r\n /**\r\n * Mark the step as completed. Is passed to child components.\r\n */\r\n completed: PropTypes.bool,\r\n};\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n root: {\r\n width: '100%',\r\n },\r\n stepper: {\r\n flexDirection: 'column-reverse',\r\n },\r\n button: {\r\n marginRight: theme.spacing(1),\r\n },\r\n instructions: {\r\n marginTop: theme.spacing(1),\r\n marginBottom: theme.spacing(1),\r\n },\r\n childStepper: {\r\n width: '100%',\r\n fontSize: '16px',\r\n '&:hover': {\r\n backgroundColor: '#FFEEA9',\r\n cursor: 'pointer',\r\n },\r\n },\r\n selectedStepper: {\r\n width: '100%',\r\n fontSize: '16px',\r\n backgroundColor: '#FFEEA9',\r\n '&:hover': {\r\n cursor: 'pointer',\r\n },\r\n },\r\n minStepper: {\r\n color: '#7F7F7F !important',\r\n },\r\n}));\r\n\r\nexport default function CustomizedSteppers({ trackingDetails, trackingStatus, showPopup, isDelveryHistory }) {\r\n const classes = useStyles();\r\n const [stepContent, setStepContents] = useState([]);\r\n const [ContentDetails, setContentDetails] = useState({});\r\n\r\n const [open, setOpen] = React.useState(false);\r\n\r\n const [activeStep, setActiveStep] = React.useState(0);\r\n const selectedEventDetails = useSelector((state) => state.selectedEvent.selectedEvent);\r\n\r\n const handleClick = (content) => {\r\n console.log(trackingStatus, content)\r\n if (showPopup && (content.shipmentImages.length > 0 ||\r\n (content.latitude && content.longitude))\r\n ) {\r\n setContentDetails(content);\r\n handleModal(true);\r\n }\r\n };\r\n const handleModal = (value) => {\r\n setOpen(value);\r\n };\r\n\r\n const handleClose = (value) => {\r\n setOpen(false);\r\n };\r\n useEffect(() => {\r\n const rawlabels = [];\r\n\r\n if (trackingDetails != 0) {\r\n (trackingDetails || []).forEach((element) => {\r\n rawlabels.unshift({\r\n labels: isDelveryHistory && element.shipmentEvent.shipHarmonisedEvents.texttodisplayinShipTrackingPage.split('(')[1] ? element.shipmentEvent.shipHarmonisedEvents.texttodisplayinShipTrackingPage.split('(')[0] +\" \"+ convertTZwithFormat(element.shipmentEvent.dateTime, 'HH:mm') + \" \" + element.shipmentEvent.shipHarmonisedEvents.texttodisplayinShipTrackingPage.split(')')[1] : element.shipmentEvent.shipHarmonisedEvents.texttodisplayinShipTrackingPage,\r\n dateAndTime: element.shipmentEvent.dateTime,\r\n location: element.shipmentEvent.location.location,\r\n latitude: element.shipmentEvent.location.latitude,\r\n longitude: element.shipmentEvent.location.longitude,\r\n deliveryType: element.shipmentEvent.shipHarmonisedEvents.deliveryAddressType,\r\n comments: element.shipmentEvent.details.comments,\r\n shipmentId: element.shipmentEvent.shipmentId,\r\n shipmentImages: element.images,\r\n code: element.shipmentEvent.code,\r\n deliveryReceivedBy: element.shipmentEvent.details.deliveryReceivedBy,\r\n recipientName: element.shipmentEvent.details.recipientName,\r\n _Code: element.shipmentEvent.code,\r\n });\r\n });\r\n setActiveStep(rawlabels.length - 1);\r\n }\r\n \r\n setStepContents(rawlabels);\r\n }, [trackingDetails, selectedEventDetails]);\r\n\r\n\r\n return (\r\n \r\n
\r\n
}\r\n orientation=\"vertical\"\r\n >\r\n {stepContent.map((content, index) => {\r\n return (\r\n
handleClick(content)}\r\n className={content.code === selectedEventDetails ? classes.selectedStepper : classes.childStepper}\r\n >\r\n \r\n {content.labels} \r\n \r\n \r\n \r\n \r\n {content.location} \r\n {(isDelveryHistory && trackingStatus == \"delivered\") &&\r\n (content.deliveryReceivedBy) ?\r\n {content.deliveryReceivedBy} \r\n : null\r\n }\r\n {(!isDelveryHistory && content._Code == \"DESF\") &&\r\n (content.recipientName) ?\r\n {content.recipientName} \r\n : null\r\n }\r\n {(content.dateAndTime) ? convertTZwithFormat(content.dateAndTime, 'YYYY-MM-DDTHH:mm:ssZ') : content.dateAndTime} \r\n \r\n \r\n {content.shipmentImages.map((sign, key) => {\r\n // Decode the String\r\n var decodedStringAtoB = atob(sign.imageBase64);\r\n return sign.imageType === 'signature'\r\n ? (\r\n \r\n )\r\n : (\r\n ''\r\n );\r\n })}\r\n \r\n \r\n \r\n \r\n );\r\n })}\r\n \r\n
\r\n \r\n \r\n
\r\n
\r\n );\r\n}\r\n","import React, { useEffect, useState } from 'react';\r\n\r\nimport Tabs from '@material-ui/core/Tabs';\r\nimport Tab from '@material-ui/core/Tab';\r\n\r\nimport { AppBar } from '@material-ui/core';\r\n\r\nimport TabPanel from '../../../shared/tabPanel';\r\n\r\nimport VerticalLinearStepper from '../../../../framework/VerticalLinearStepper/VerticalLinearStepper';\r\nimport { useSelector } from 'react-redux';\r\n\r\nfunction TrackingDetails({ shipmentDetails, trackingStatus }) {\r\n const [value, setValue] = useState(0);\r\n const [event, setEvent] = useState([]);\r\n const [shipmentTracking, setShipmentTracking] = useState([]);\r\n const [deliveryTracking, setDeliveryTracking] = useState([]);\r\n\r\n const selectedEventDetails = useSelector((state) => state.selectedEvent.selectedEvent);\r\n\r\n const handleChange = (event, newValue) => {\r\n setValue(newValue);\r\n };\r\n const getTrackingDetails = () => {\r\n // const rowEventDetails = [];\r\n const rawShipmentDetails = [];\r\n const rawDeliveryDetails = [];\r\n\r\n (shipmentDetails.shipmentEventModels || []).forEach((eventdetails) => {\r\n if (\r\n eventdetails.shipmentEvent.shipHarmonisedEvents != null &&\r\n eventdetails.shipmentEvent.shipHarmonisedEvents.shipmentTrackingdetails === 'Shipment tracking details'\r\n ) {\r\n rawShipmentDetails.push(eventdetails);\r\n if (selectedEventDetails === eventdetails.shipmentEvent.code) {\r\n setValue(0);\r\n }\r\n } else if (\r\n eventdetails.shipmentEvent.shipHarmonisedEvents != null &&\r\n eventdetails.shipmentEvent.shipHarmonisedEvents.shipmentTrackingdetails === 'Delivery History'\r\n ) {\r\n rawDeliveryDetails.push(eventdetails);\r\n\r\n if (selectedEventDetails === eventdetails.shipmentEvent.code) {\r\n setValue(1);\r\n }\r\n }\r\n });\r\n // setEvent(rowEventDetails)\r\n setShipmentTracking(rawShipmentDetails);\r\n setDeliveryTracking(rawDeliveryDetails);\r\n };\r\n useEffect(() => {\r\n getTrackingDetails();\r\n }, [shipmentDetails, selectedEventDetails]);\r\n\r\n return (\r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n
\r\n \r\n \r\n
\r\n );\r\n}\r\n\r\nexport default TrackingDetails;\r\n","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from \"react\";\n\nvar _ref2 = /*#__PURE__*/React.createElement(\"g\", {\n id: \"Group_23955\",\n \"data-name\": \"Group 23955\",\n transform: \"translate(-1340 -193)\"\n}, /*#__PURE__*/React.createElement(\"g\", {\n id: \"Rectangle_6954\",\n \"data-name\": \"Rectangle 6954\",\n transform: \"translate(1340 193)\",\n fill: \"none\",\n stroke: \"#000\",\n strokeWidth: 1.5\n}, /*#__PURE__*/React.createElement(\"rect\", {\n width: 19,\n height: 23,\n rx: 3,\n stroke: \"none\"\n}), /*#__PURE__*/React.createElement(\"rect\", {\n x: 0.75,\n y: 0.75,\n width: 17.5,\n height: 21.5,\n rx: 2.25,\n fill: \"none\"\n})), /*#__PURE__*/React.createElement(\"line\", {\n id: \"Line_525\",\n \"data-name\": \"Line 525\",\n x2: 10,\n transform: \"translate(1344.5 198.5)\",\n fill: \"none\",\n stroke: \"#000\",\n strokeLinecap: \"round\",\n strokeWidth: 1.4\n}), /*#__PURE__*/React.createElement(\"line\", {\n id: \"Line_528\",\n \"data-name\": \"Line 528\",\n x2: 10,\n transform: \"translate(1344.5 204.5)\",\n fill: \"none\",\n stroke: \"#000\",\n strokeLinecap: \"round\",\n strokeWidth: 1.4\n}), /*#__PURE__*/React.createElement(\"line\", {\n id: \"Line_530\",\n \"data-name\": \"Line 530\",\n x2: 10,\n transform: \"translate(1344.5 210.5)\",\n fill: \"none\",\n stroke: \"#000\",\n strokeLinecap: \"round\",\n strokeWidth: 1.4\n}), /*#__PURE__*/React.createElement(\"line\", {\n id: \"Line_526\",\n \"data-name\": \"Line 526\",\n x2: 5,\n transform: \"translate(1344.5 201.5)\",\n fill: \"none\",\n stroke: \"#000\",\n strokeLinecap: \"round\",\n strokeWidth: 1.4\n}), /*#__PURE__*/React.createElement(\"line\", {\n id: \"Line_527\",\n \"data-name\": \"Line 527\",\n x2: 5,\n transform: \"translate(1344.5 207.5)\",\n fill: \"none\",\n stroke: \"#000\",\n strokeLinecap: \"round\",\n strokeWidth: 1.4\n}));\n\nfunction SvgOrderNotes(_ref, svgRef) {\n var title = _ref.title,\n titleId = _ref.titleId,\n props = _objectWithoutProperties(_ref, [\"title\", \"titleId\"]);\n\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 19,\n height: 23,\n viewBox: \"0 0 19 23\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, _ref2);\n}\n\nvar ForwardRef = /*#__PURE__*/React.forwardRef(SvgOrderNotes);\nexport default __webpack_public_path__ + \"static/media/order_notes.bf2178b6.svg\";\nexport { ForwardRef as ReactComponent };","import React, { useState, useEffect } from 'react';\r\nimport Grid from '@material-ui/core/Grid';\r\nimport FormRenderer from '../../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { GET } from '../../../../api/axios';\r\nimport { ServiceEndPoints } from '../../../../utils/constants/ApiConstant';\r\nimport { useHistory } from 'react-router-dom';\r\nimport { arrayValuesToQueryStringParam } from '../../../../utils/common';\r\nimport { useDispatch, connect } from 'react-redux';\r\nimport * as actions from '../../../../store/actions/index';\r\nimport { getDefaultDashboardValues, getDefaultDashboardFindValues } from '../../../../utils/helperFunctions';\r\nimport { useSelector } from 'react-redux';\r\n\r\nconst FindShipment = (props) => {\r\n const {\r\n formField: { dashboardSearchBy },\r\n setFieldValue,\r\n formikValues,\r\n searchByOptions,\r\n errors,\r\n setFieldTouched,\r\n resetForm,\r\n setValues,\r\n userAccounts\r\n } = props;\r\n let history = useHistory();\r\n const dispatch = useDispatch();\r\n let dashboardFindShipment = useSelector((state) => state.dashboardTracking.dashboardFindShipment);\r\n useEffect(() => {\r\n // need to change hard coded index values\r\n if (\r\n formikValues.dashboardSearchBy &&\r\n (formikValues.dashboardSearchBy.value === searchByOptions[8].value ||\r\n formikValues.dashboardSearchBy.value === searchByOptions[9].value)\r\n ) {\r\n setFieldValue('dashboardSearchFor', new Date().toISOString().slice(0, 10));\r\n } else {\r\n setFieldValue('dashboardSearchFor', '');\r\n }\r\n if (props.formikValues.dashboardSearchBy) {\r\n dispatch(\r\n actions.setDashboardFindShipment(\r\n props.formikValues.dashboardSearchBy\r\n ))\r\n }\r\n else if (dashboardFindShipment) {\r\n dispatch(\r\n actions.setDashboardFindShipment(\r\n dashboardFindShipment\r\n ))\r\n } else {\r\n dispatch(\r\n actions.setDashboardFindShipment(\r\n searchByOptions[0]\r\n ))\r\n }\r\n\r\n // dispatch(\r\n // actions.setDashboardTracking({\r\n // loadedFrom: '',\r\n // loadedResponse: {},\r\n // userAccounts: _temp_userAccounts,\r\n // dashboardQueryParams: `${getDefaultDashboardFindValues(\r\n // {},\r\n // _temp_userAccounts,\r\n // false,\r\n // )}`,\r\n // }),\r\n // );\r\n }, [formikValues.dashboardSearchBy]);\r\n\r\n useEffect(() => {\r\n if (dashboardFindShipment) {\r\n setTimeout(() => {\r\n setFieldValue('dashboardSearchBy', dashboardFindShipment)\r\n }, 1000);\r\n } else {\r\n setFieldValue('dashboardSearchBy', searchByOptions[0])\r\n }\r\n }, [dashboardFindShipment]);\r\n\r\n const searchShipment = (event = null) => {\r\n event.preventDefault();\r\n let searchedValue = props.formikValues.dashboardSearchFor.trim();\r\n let searchedParams = props.formikValues.dashboardSearchBy.value;\r\n let accountsValue = '';\r\n accountsValue = arrayValuesToQueryStringParam(formikValues.accounts);\r\n\r\n const isCollectionDatesReq = searchedParams === 'dispatchDate' ? true : false;\r\n if (isCollectionDatesReq) {\r\n searchedParams = '';\r\n searchedParams += `fromCollectionDate=${searchedValue}`;\r\n searchedParams += `&toCollectionDate=${searchedValue}`;\r\n }\r\n let url = '';\r\n let _temp_userAccounts = [];\r\n userAccounts.map((element) => {\r\n _temp_userAccounts.push(element.accountId);\r\n });\r\n if (isCollectionDatesReq) {\r\n url = `${ServiceEndPoints.getShipmentDashboard}?${getDefaultDashboardFindValues(\r\n formikValues,\r\n _temp_userAccounts,\r\n true,\r\n false,\r\n )}${searchedParams}`;\r\n } else {\r\n url = `${ServiceEndPoints.getShipmentDashboard}?${getDefaultDashboardFindValues(\r\n formikValues,\r\n _temp_userAccounts,\r\n false,\r\n false,\r\n )}${searchedParams}=${searchedValue}`;\r\n }\r\n url = `${url}&offset=0&limit=10`;\r\n GET(url)\r\n .then((res) => {\r\n if ((((res || {}).data || {}).shipmentModels || []).length === 1) {\r\n history.push(`/dashboard/Tracking?id=${res.data.shipmentModels[0].shipmentId}`);\r\n window.location.reload();\r\n } else {\r\n dispatch(\r\n actions.setDashboardTracking({\r\n loadedFrom: 'findshipment',\r\n loadedResponse: null,\r\n userAccounts: _temp_userAccounts,\r\n dashboardQueryParams: `${getDefaultDashboardFindValues(\r\n {},\r\n _temp_userAccounts,\r\n false,\r\n )}${searchedParams}=${searchedValue}`,\r\n }),\r\n );\r\n history.push('/dashboard/dashboardDetailsBreakdown');\r\n }\r\n })\r\n .catch((err) => {\r\n alert('Shipment not found');\r\n });\r\n };\r\n return (\r\n \r\n \r\n searchShipment(event, '')}\r\n isIconDisabled={\r\n errors.dashboardSearchFor ||\r\n formikValues?.dashboardSearchFor === undefined ||\r\n formikValues?.dashboardSearchFor?.trim() === ''\r\n }\r\n {...dashboardSearchBy.props}\r\n />\r\n \r\n \r\n )\r\n}\r\n\r\n// export default FindShipment;\r\nconst mapStateToProps = (state) => {\r\n return {\r\n // dashboardDetails: ((state || {}).dashboardTracking || {}).dashboardTracking,\r\n userAccounts: (((state || {}).auth || {}).userDetails || {}).accounts,\r\n };\r\n};\r\nexport default connect(mapStateToProps, null)(FindShipment);","import React from 'react';\r\nimport { Form, Formik } from 'formik';\r\nimport './trackingFindShipmentStyle.scss';\r\nimport FindShipment from './TrackingFindShipment';\r\nimport { getYupSchemaFromMetaData } from '../../../../utils/yupSchema/yupSchemaGenerator';\r\nimport { fullSearchDashboardByOptions } from '../../../../utils/constants/constants';\r\nconst TrackingFindShipment = (props) => {\r\n const formField = searchForm;\r\n const newSearchValidationSchema = getYupSchemaFromMetaData(formField, [], []);\r\n\r\n const initialValues = {\r\n // dashboardSearchBy: fullSearchDashboardByOptions[0],\r\n };\r\n\r\n return (\r\n \r\n \r\n {({ values, setFieldValue, errors, setFieldTouched, resetForm, setValues }) => (\r\n \r\n )}\r\n \r\n
\r\n );\r\n};\r\n\r\nexport default TrackingFindShipment;\r\n\r\nconst searchForm = {\r\n dashboardSearchBy: {\r\n props: {\r\n name: 'dashboardSearchFor',\r\n type: 'searchControl',\r\n },\r\n selectProps: {\r\n props: {\r\n name: 'dashboardSearchBy',\r\n label: 'Search For',\r\n placeholder: \"Enter Customer's ref.no\",\r\n },\r\n },\r\n textProps: {\r\n props: {\r\n name: 'dashboardSearchFor',\r\n label: 'Search For',\r\n placeholder: \"Enter Customer's ref.no\",\r\n },\r\n },\r\n validation: {\r\n name: 'dashboardSearchFor',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'dashboardSearchBy',\r\n (dashboardSearchBy, schema) => {\r\n if (dashboardSearchBy) {\r\n return dashboardSearchBy.value === 'recipientName'\r\n ? schema.matches(/[a-zA-Z]+([\\s][a-zA-Z]+)*/, 'Recipient name must be alphabets')\r\n : dashboardSearchBy.value === 'telephoneNumber'\r\n ? schema.matches(/^[0-9,(,),+,\\-,.,[,\\] ].{9,35}/, 'Telephone number is invalid')\r\n : schema;\r\n }\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n};","import React, { useEffect, useState } from \"react\";\r\nimport { Grid, Hidden, makeStyles, SvgIcon } from '@material-ui/core';\r\nimport DynamicMaterialTable from '../../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\nimport Tooltip from \"@material-ui/core/Tooltip\";\r\nimport { ReactComponent as Ordernotes } from '../../../assets/images/order_notes.svg';\r\nimport { ReactComponent as CloseIcon } from '../../../assets/images/closeIcon.svg';\r\nimport { convertTZwithFormat } from \"../../../utils/helperFunctions\";\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n customTooltip: {\r\n backgroundColor: '#fff',\r\n color: '#000000E6',\r\n fontSize: '14px',\r\n width: '700px',\r\n maxWidth: '700px',\r\n maxHeight: '250px',\r\n boxShadow: '10px 8px 5px #00000029',\r\n padding: '8px 15px',\r\n borderRadius: '4',\r\n overflow: 'auto',\r\n },\r\n customArrow: {\r\n color: '#fff',\r\n },\r\n}));\r\n\r\nvar currentId = null;\r\n\r\nconst OrderNotes = (props) => {\r\n const { shipmentDetails, setOpen } = props;\r\n var _open = false;\r\n const [openToolTip, setOpenToolTip] = React.useState(false);\r\n\r\n const handleTooltipClose = () => {\r\n setOpenToolTip(false);\r\n _open = false;\r\n };\r\n\r\n const handleTooltipOpen = () => {\r\n _open = true;\r\n }\r\n const tableColumns = [\r\n { title: 'id', field: 'artifactId', hidden: true },\r\n {\r\n title: 'Date & time',\r\n field: 'noteDateTime',\r\n sorting: true,\r\n render: (row) => {\r\n return {convertTZwithFormat(row?.noteDateTime, 'DD/MM/YYYY')} {convertTZwithFormat(row?.noteDateTime, 'HH:mm')}
\r\n },\r\n width: 180,\r\n },\r\n {\r\n title: 'Note by',\r\n field: 'userId',\r\n sorting: false,\r\n width: 180,\r\n },\r\n {\r\n title: 'Notes',\r\n field: 'note',\r\n sorting: false,\r\n\r\n render: (row) => {\r\n return {row.note && {`${row.note.slice(0, 100)}...`} \r\n }
\r\n },\r\n width: 600,\r\n },\r\n ];\r\n const [tableData, setTableData] = useState([]);\r\n const [columns] = useState(tableColumns);\r\n const classes = useStyles();\r\n\r\n useEffect(() => {\r\n getTableData();\r\n }, [])\r\n\r\n const onRowClicked = (res) => {\r\n if (res.tableData.id == currentId) {\r\n currentId = null;\r\n _open = false;\r\n }\r\n else {\r\n currentId = res.tableData.id;\r\n }\r\n setOpenToolTip(!openToolTip);\r\n };\r\n\r\n const getTableData = (event = {}) => {\r\n let _temp = _formatTableData(shipmentDetails)\r\n setTableData(_temp);\r\n };\r\n\r\n const _formatTableData = (_result) => {\r\n let _finalData = [];\r\n (_result)?.notes?.forEach((_element) => {\r\n _finalData.push(\r\n {\r\n note: _element.note,\r\n noteDateTime: _element.noteDateTime,\r\n userId: _element.userId,\r\n })\r\n });\r\n return _finalData;\r\n }\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n Shipment notes\r\n setOpen(false)} />\r\n
\r\n \r\n\r\n \r\n\r\n { onRowClicked(row) }}\r\n isSelectable={false}\r\n paging={false}\r\n sorting={true}\r\n customMaxHeight={'400px'}\r\n />\r\n \r\n \r\n );\r\n}\r\n\r\nOrderNotes.propTypes = {};\r\n\r\nexport default OrderNotes;","/* eslint-disable react-hooks/exhaustive-deps */\r\n/* eslint-disable no-unused-vars */\r\nimport React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, Paper, Card, SvgIcon, Tooltip } from '@material-ui/core';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport CustomModal from '../../../framework/modal/modal';\r\nimport './tracking.scss';\r\nimport TrackingBanner from '../../../components/dashboard/Tracking/trackingBanner/trackingBanner';\r\nimport ShipmentDetails from '../../../components/dashboard/Tracking/shipmentDetails/shipmentDetails';\r\n\r\nimport DeliveryPhotographs from '../../../components/dashboard/Tracking/deliveryPhotographs/deliveryPhotographs';\r\nimport ChangeDeliveryAddress from '../../Tracking/ChangeDeliveryAddress/ChangeDeliveryAddress';\r\n\r\nimport { GET, POST } from '../../../api/axios';\r\nimport { useHistory } from 'react-router';\r\nimport TrackingDetails from '../../../components/dashboard/Tracking/TrackingDetails/TrackingDetails';\r\n\r\nimport Drawer from '@material-ui/core/Drawer';\r\nimport { ReactComponent as Ordernotes } from '../../../assets/images/order_notes.svg';\r\n\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport TrackingFindShipment from '../dashboard/trackingFindShipment/TrackingFindShipmentMiddleware';\r\nimport OrderNotes from \"../../../components/Tracking/trackingNotes/orderNotes\"\r\nconst Tracking = (props) => {\r\n const [dialogStatus, setDialogStatus] = useState(false);\r\n const [open, setOpen] = React.useState(false);\r\n const [Dialogpopup, setDialogpopup] = useState(false);\r\n const [shipmentDetails, setShipmentDetails] = useState({});\r\n const [trackingStatus, setTrackingStatus] = useState('');\r\n const [currentDeliveryType, setcurrentDeliveryType] = useState('');\r\n const [showDeliveryChangeButton, setShowDeliveryChangeButton] = useState(false);\r\n const history = useHistory();\r\n\r\n useEffect(() => {\r\n getShipmentTrackingDetails();\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (\r\n shipmentDetails?.deliveryType?.toLowerCase() === 'doorstep' || 'depot' &&\r\n (trackingStatus?.toLowerCase()?.trim() === 'wehaveyourparcel' ||\r\n trackingStatus?.toLowerCase()?.trim() === 'orderreceived' ||\r\n trackingStatus?.toLowerCase()?.trim() === 'outfordelivery' ||\r\n trackingStatus?.toLowerCase()?.trim() === 'na' ||\r\n trackingStatus?.trim() === '')\r\n ) {\r\n setShowDeliveryChangeButton(true);\r\n } else {\r\n setShowDeliveryChangeButton(false);\r\n }\r\n }, [trackingStatus, shipmentDetails]);\r\n\r\n const getShipmentTrackingDetails = () => {\r\n const queryParams = history.location.search.split('=');\r\n GET(`${ServiceEndPoints.getShipmentTracking}${queryParams[1]}`)\r\n // GET(`${ServiceEndPoints.getShipmentTracking}${55500001476492}`)\r\n .then((res) => {\r\n (((res || {}).data || {}).shipmentEventModels || []).map((element, index) => {\r\n if (index === 0 && element?.shipmentEvent?.code!=='DNTR') {\r\n setTrackingStatus(\r\n element?.shipmentEvent?.shipHarmonisedEvents?.trackingPageStatus?.replace(/\\s+/g, '').toLowerCase(),\r\n );\r\n }\r\n });\r\n\r\n setShipmentDetails(res.data);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n setShipmentDetails({});\r\n });\r\n };\r\n\r\n const cancelShipment = () => {\r\n const itemsToBeSelected = [];\r\n const item = {\r\n pickupAccount: shipmentDetails?.accountNumber,\r\n shipmentId: shipmentDetails?.shipmentNumber,\r\n postalCode: shipmentDetails?.consigneeAddress?.postalCode,\r\n };\r\n itemsToBeSelected.push(item);\r\n const payload = itemsToBeSelected;\r\n POST(ServiceEndPoints.cancelShipment, payload)\r\n .then((response) => {\r\n alert('Shipment successfully cancelled');\r\n history.goBack();\r\n })\r\n .catch((error) => {\r\n alert('Error in cancelling the shipment:' + payload[0].shipmentId);\r\n });\r\n };\r\n\r\n const handleDrawer = () => {\r\n open ? setOpen(false) : setOpen(true);\r\n };\r\n const onDeliveryTypeChange = (value) => {\r\n setcurrentDeliveryType(value);\r\n };\r\n const onDeliveryInstructionChnage = () => {\r\n // setDialogStatus(false);\r\n setTimeout(function () {\r\n getShipmentTrackingDetails();\r\n }, 2000);\r\n };\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {(trackingStatus === 'orderreceived' && shipmentDetails?.shipmentEventModels?.[0]?.shipmentEvent?.code !== \"T415\") && (\r\n // {trackingStatus === 'orderreceived' && (\r\n \r\n {\r\n cancelShipment();\r\n }}\r\n />\r\n \r\n )}\r\n {showDeliveryChangeButton && shipmentDetails?.consigneeAddress?.country === 'GB' && (\r\n \r\n setDialogStatus(true)}\r\n />\r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n {\r\n setDialogStatus(false);\r\n }}\r\n >\r\n {\r\n setDialogStatus(false);\r\n }}\r\n TitleDialog={() => {\r\n setDialogpopup(true);\r\n }}\r\n shipmentDetails={shipmentDetails}\r\n onChangeDeliveryAddress={onDeliveryInstructionChnage}\r\n current_DeliveryType={currentDeliveryType}\r\n />\r\n \r\n \r\n \r\n {\r\n setDialogpopup(false);\r\n }}\r\n >\r\n Change of delivery not available for this shipment \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nTracking.propTypes = {};\r\n\r\nexport default Tracking;\r\n","import { Divider, Grid, makeStyles, Typography } from '@material-ui/core';\r\nimport React, { useEffect, useState } from 'react';\r\nimport { abortOnGoingCallsFor, axiosConfig } from '../../api/axios';\r\nimport { useSelector } from 'react-redux';\r\n\r\nimport FormRenderer from '../../framework/Inputs/formRenderer/formRenderer';\r\nimport { sortBasedOnNestedOrNot } from '../../utils/helperFunctions';\r\nimport { ServiceEndPoints } from '../../utils/constants/ApiConstant';\r\n\r\nconst useStyles = makeStyles({\r\n paperOpacity: {\r\n opacity: 0.5,\r\n },\r\n disableSpan: {\r\n opacity: '0.5 !important',\r\n },\r\n nonDisableSpan: {\r\n color: '#000 !important',\r\n },\r\n});\r\nexport const AccountFromDetails = (props) => {\r\n const classes = useStyles();\r\n\r\n const {\r\n formField: {\r\n selectAccount,\r\n accountNumber,\r\n tradingAddress,\r\n invoiceAddress,\r\n postalCode,\r\n companyName,\r\n // termsOfDelivery,\r\n returnAddress,\r\n linkedReturnAccountNumber,\r\n fdaRegistrationNumber,\r\n eoriNumber,\r\n vatORtvaNumber,\r\n vatRegistersCheckbox,\r\n vatRadioBox,\r\n iossNumber,\r\n ukimsNumber,\r\n defermentAccountNumber\r\n },\r\n formikValues,\r\n setFieldValue,\r\n accounts,\r\n } = props;\r\n\r\n const [maintainer, setMaintainer] = useState([]);\r\n let userAccounts = useSelector((state) => state.accounts.userAccounts);\r\n const [isVatRegister, setVatRegister] = useState(false);\r\n const [isNotVatRegister, setNotVatRegister] = useState(false);\r\n const [isOutSideUK, setoutSideUK] = useState(false);\r\n\r\n const defaultFields = () => {\r\n setFieldValue('accountNumber', '');\r\n setFieldValue('tradingAddress', '');\r\n setFieldValue('invoiceAddress', '');\r\n setFieldValue('postalCode', '');\r\n setFieldValue('companyName', '');\r\n // setFieldValue('termsOfDelivery', '');\r\n setFieldValue('returnAddress', '');\r\n setFieldValue('linkedReturnAccountNumber', '');\r\n setFieldValue('fdaRegistrationNumber', '');\r\n setFieldValue('eoriNumber', '');\r\n setFieldValue('vatORtvaNumber', '');\r\n setFieldValue('iossNumber', '');\r\n setFieldValue('ukimsNumber', '');\r\n setFieldValue('defermentAccountNumber', '');\r\n setVatRegister(false);\r\n setoutSideUK(false);\r\n setNotVatRegister(false);\r\n };\r\n\r\n const getAccountdetails = (id) => {\r\n defaultFields();\r\n abortOnGoingCallsFor(ServiceEndPoints.getShipConfiguration);\r\n axiosConfig.get(`${ServiceEndPoints.getShipConfiguration}?accountIds=${id}`)\r\n .then((res) => {\r\n setMaintainer(res.data);\r\n setFieldValue('accountNumber', res.data[0].accountId);\r\n setFieldValue(\r\n 'tradingAddress',\r\n res.data[0].sender === null\r\n ? ''\r\n : res.data[0].sender?.address1?.concat(\r\n ', ',\r\n res.data[0].sender?.address2,\r\n ', ',\r\n res.data[0].sender?.address3,\r\n '\\n',\r\n res.data[0].sender?.city,\r\n res.data[0].sender?.state === null || res.data[0].sender?.state === \"\" ? '' : ', ',\r\n res.data[0].sender?.state === null || res.data[0].sender?.state === \"\" ? '' : res.data[0].sender?.state,\r\n '\\n',\r\n res.data[0].sender?.postalCode,\r\n '\\n',\r\n res.data[0].sender?.country,\r\n ),\r\n );\r\n setFieldValue(\r\n 'invoiceAddress',\r\n res.data[0].invoiceAddress === null\r\n ? ''\r\n : res.data[0].invoiceAddress?.address1?.concat(\r\n ', ',\r\n res.data[0].invoiceAddress?.address2,\r\n ', ',\r\n res.data[0].invoiceAddress?.address3,\r\n '\\n',\r\n res.data[0].invoiceAddress?.address4,\r\n res.data[0].invoiceAddress?.address5 === null || res.data[0].invoiceAddress?.address5 === \"\" ? '' : ', ',\r\n res.data[0].invoiceAddress?.address5 === null || res.data[0].invoiceAddress?.address5 === \"\" ? '' : res.data[0].invoiceAddress?.address5,\r\n '\\n',\r\n res.data[0].invoiceAddress?.postalCode,\r\n '\\n',\r\n res.data[0].invoiceAddress?.telephoneNumber,\r\n ),\r\n );\r\n setFieldValue('postalCode', res.data[0].sender === null ? '' : res.data[0].sender?.postalCode);\r\n setFieldValue('companyName', res.data[0].sender === null ? '' : res.data[0].sender?.companyName);\r\n // setFieldValue(\r\n // 'termsOfDelivery',\r\n // res.data[0].customsRegistration === null ? '' : res.data[0].customsRegistration?.termsOfDelivery,\r\n // );\r\n setFieldValue(\r\n 'returnAddress',\r\n !(res?.data[0]?.returnConfiguration)\r\n ? ''\r\n : res.data[0].returnConfiguration.returnRecipient?.address1?.concat(\r\n ',',\r\n res.data[0].returnConfiguration.returnRecipient?.address2,\r\n ', ',\r\n res.data[0].returnConfiguration.returnRecipient?.address3,\r\n '\\n',\r\n res.data[0].returnConfiguration.returnRecipient?.city,\r\n ', ',\r\n res.data[0].returnConfiguration.returnRecipient?.state,\r\n '\\n',\r\n res.data[0].returnConfiguration.returnRecipient?.postalCode,\r\n '\\n',\r\n res.data[0].returnConfiguration.returnRecipient?.country,\r\n ),\r\n );\r\n setFieldValue(\r\n 'linkedReturnAccountNumber',\r\n res.data[0].returnConfiguration === null ? '' : res.data[0].returnConfiguration?.customerReturnAccount,\r\n );\r\n setFieldValue(\r\n 'fdaRegistrationNumber',\r\n res.data[0].customsRegistration === null ? '' : res.data[0].customsRegistration?.fdaNumber,\r\n );\r\n setFieldValue(\r\n 'eoriNumber',\r\n res.data[0].customsRegistration === null ? '' : res.data[0].customsRegistration?.eoriNumber,\r\n );\r\n setFieldValue(\r\n 'vatORtvaNumber',\r\n res.data[0].customsRegistration === null ? '' : res.data[0].customsRegistration?.vatTvaNumber,\r\n );\r\n // setFieldValue('vatRegistersCheckbox',res.data[0].customsRegistration.vatRegisteredOutsideUK)\r\n // setFieldValue('vatRadioBox',res.data[0].customsRegistration.vatRegistered)\r\n setVatRegister(res.data[0].customsRegistration?.vatRegistered);\r\n setoutSideUK(res.data[0].customsRegistration?.vatRegisteredOutsideUK);\r\n setNotVatRegister(!res.data[0].customsRegistration?.vatRegistered);\r\n // if (isNotVatRegister) {\r\n // setFieldValue('vatORtvaNumber', '');\r\n // }\r\n setFieldValue('iossNumber',\r\n res.data[0].customsRegistration === null ? '' : res.data[0].customsRegistration?.iossNumber);\r\n\r\n setFieldValue('ukimsNumber',\r\n res.data[0].customsRegistration?.ukimsNumber === null ? '' : res.data[0].customsRegistration?.ukimsNumber);\r\n setFieldValue('defermentAccountNumber',\r\n res.data[0].customsRegistration?.deferredAccountNumber === null ? '' : res.data[0].customsRegistration?.defermentAccountNumber);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n setFieldValue('selectAccount', accounts[0]);\r\n defaultFields();\r\n }, [accounts]);\r\n\r\n useEffect(() => {\r\n if (formikValues.selectAccount?.accountId) {\r\n getAccountdetails(formikValues.selectAccount.accountId);\r\n }\r\n if (!formikValues.selectAccount && accounts?.length > 0) {\r\n setFieldValue('selectAccount', accounts[0]);\r\n }\r\n }, [formikValues.selectAccount]);\r\n\r\n return (\r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n\r\n \r\n \r\n \r\n {/* */}\r\n \r\n VAT / TVA:{' '}\r\n \r\n VAT registered\r\n {' '}\r\n \r\n Not VAT registered\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {/* */}\r\n \r\n (VAT registered outside of the UK)\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {/* \r\n \r\n */}\r\n \r\n \r\n \r\n
\r\n );\r\n};\r\n","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from \"react\";\n\nvar _ref2 = /*#__PURE__*/React.createElement(\"g\", {\n id: \"noun_Upload_1157132\",\n transform: \"translate(-1.7 -1.45)\"\n}, /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_2760\",\n \"data-name\": \"Path 2760\",\n d: \"M20.124,56.077H2.663a.943.943,0,0,1-.963-.923V46.323a.943.943,0,0,1,.963-.923.93.93,0,0,1,.963.923v7.927H19.181V46.323a.943.943,0,0,1,.963-.923.93.93,0,0,1,.963.923v8.831A1,1,0,0,1,20.124,56.077Z\",\n transform: \"translate(0 -35.129)\",\n fill: \"#d40511\"\n}), /*#__PURE__*/React.createElement(\"path\", {\n id: \"Path_2761\",\n \"data-name\": \"Path 2761\",\n d: \"M35.791,5.434,32.079,1.721a.97.97,0,0,0-1.345,0L26.981,5.434a.956.956,0,0,0-.281.682.91.91,0,0,0,.281.662.944.944,0,0,0,.662.281.956.956,0,0,0,.682-.281l2.047-2.027v9.533a1,1,0,0,0,2.007,0V4.711l2.067,2.067a.97.97,0,0,0,1.345,0,.944.944,0,0,0,.281-.662A.956.956,0,0,0,35.791,5.434Z\",\n transform: \"translate(-19.983 0)\",\n fill: \"#d40511\"\n}));\n\nfunction SvgUpload(_ref, svgRef) {\n var title = _ref.title,\n titleId = _ref.titleId,\n props = _objectWithoutProperties(_ref, [\"title\", \"titleId\"]);\n\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 19.407,\n height: 19.498,\n viewBox: \"0 0 19.407 19.498\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, _ref2);\n}\n\nvar ForwardRef = /*#__PURE__*/React.forwardRef(SvgUpload);\nexport default __webpack_public_path__ + \"static/media/upload.e20fb27b.svg\";\nexport { ForwardRef as ReactComponent };","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, Divider } from '@material-ui/core';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport { POST } from '../../../api/axios';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport Spinner from '../../../framework/spinner/spinner'\r\n\r\nconst classes = {};\r\n\r\nconst ReturnInstructionsPreview = (props) => {\r\n const { formikValues, filePath, closePopup } = props;\r\n const [pdfFile, setPdfFile] = useState('');\r\n\r\n useEffect(() => {\r\n POST(ServiceEndPoints.returnInstructionLabelPreview, {\r\n labelFormat: 'pdf',\r\n returnLabel: true,\r\n returnInstructionLabel: true,\r\n returnInstructions: {\r\n customerLogo: filePath,\r\n customerLogoBase64: filePath,\r\n customerLogoType: 'png',\r\n printLabel: true,\r\n customerInstructions: [\r\n {\r\n CustomerInstruction: formikValues.returnInstructions,\r\n },\r\n ],\r\n },\r\n })\r\n .then((res) => {\r\n setPdfFile(res.data.label);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n }, []);\r\n return (\r\n pdfFile\r\n ? \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n : \r\n\r\n );\r\n};\r\n\r\nReturnInstructionsPreview.propTypes = {};\r\n\r\nexport default ReturnInstructionsPreview;\r\n","import { Grid, IconButton, makeStyles, SvgIcon, Tooltip, Typography } from '@material-ui/core';\r\nimport { Clear, Share } from '@material-ui/icons';\r\nimport React, { useEffect, useRef, useState } from 'react';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport { ReactComponent as InfoIcon } from '../../../assets/images/InfoIcon.svg';\r\nimport { ReactComponent as SomeIcon } from '../../../assets/images/upload.svg';\r\n\r\nimport { GET, POST } from '../../../api/axios';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport CustomDialog from '../../../framework/dialog/customDialog';\r\nimport ReturnInstructionsPreview from '../returnInstructionsPreview/returnInstructionsPreview';\r\nimport { useHistory } from 'react-router';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from '../../../store/actions/index';\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n imagePreview: {\r\n height: '206px',\r\n borderRadius: '4px',\r\n border: '1px solid #ACACAC',\r\n },\r\n iconButton: {\r\n position: 'absolute',\r\n top: '-7px',\r\n right: '-4px',\r\n },\r\n customTooltip: {\r\n backgroundColor: '#fff',\r\n color: '#000000E6',\r\n fontSize: '14px',\r\n boxShadow: '0px 3px 6px #00000029',\r\n padding: '8px 15px',\r\n borderRadius: '0'\r\n },\r\n customArrow: {\r\n color: '#fff',\r\n },\r\n}));\r\n\r\nconst ConfigureReturnLabel = (props) => {\r\n const classes = useStyles();\r\n const history = useHistory();\r\n const dispatch = useDispatch();\r\n const {\r\n formField: {\r\n configureLinkedReturnAccountNumber,\r\n printReturnInstructions,\r\n defaultInstructions,\r\n returnInstructions,\r\n logoFile,\r\n selectAccount,\r\n },\r\n formikValues,\r\n setFieldValue,\r\n accounts,\r\n setValues,\r\n setFieldTouched,\r\n isValid,\r\n } = props;\r\n\r\n const hiddenFileInput = useRef(null);\r\n const [filePath, setFilePath] = useState('');\r\n const [showClearIcon, setShowClearIcon] = useState(false);\r\n const [showPreviewDialog, setShowPreviewDialog] = useState(false);\r\n\r\n const onSelectFile = (event) => {\r\n if (event?.target?.files?.[0]) {\r\n setFieldValue('logoFile', event.target.files[0].name);\r\n const reader = new FileReader();\r\n reader.readAsDataURL(event.target.files[0]);\r\n\r\n reader.onload = (loadedEvent) => {\r\n setFilePath(loadedEvent.target.result?.split?.(',')?.[1]);\r\n setShowClearIcon(true);\r\n const image = new Image();\r\n image.src = loadedEvent.target.result;\r\n image.onload = () => {\r\n const imgObj = {\r\n size: event?.target?.files?.[0]?.size,\r\n height: image.height,\r\n width: image.width,\r\n fileName: event.target.files[0].name,\r\n };\r\n setFieldValue('imageField', imgObj);\r\n setFieldTouched('logoFile', true);\r\n };\r\n };\r\n }\r\n };\r\n\r\n const openFileDialog = () => {\r\n hiddenFileInput.current.click();\r\n };\r\n\r\n const clearFilePath = () => {\r\n setShowClearIcon(false);\r\n setFilePath('');\r\n setFieldValue('logoFile', '');\r\n setFieldValue('imageField', {});\r\n };\r\n\r\n useEffect(() => {\r\n setFilePath('');\r\n const formValues = {\r\n printReturnInstructions: false,\r\n returnInstructions: '',\r\n logoFile: '',\r\n imageField: {},\r\n configureLinkedReturnAccountNumber: '',\r\n };\r\n setValues({ ...formikValues, ...formValues });\r\n\r\n if (formikValues.selectAccount.accountId && formikValues.selectAccount.returnConfiguration && formikValues.selectAccount.returnConfiguration.customerReturnAccount) {\r\n getReturnConfigDetails(formikValues.selectAccount?.returnConfiguration?.customerReturnAccount);\r\n }\r\n if (!formikValues.selectAccount && accounts?.length > 0) {\r\n setFieldValue('selectAccount', accounts[0]);\r\n }\r\n }, [formikValues.selectAccount]);\r\n\r\n const getReturnConfigDetails = (currentReturnAccount) => {\r\n if (currentReturnAccount !== '') {\r\n GET(`${ServiceEndPoints.getReturnInstructionLabel}/${currentReturnAccount}`)\r\n .then((res) => {\r\n setFilePath(res.data?.customerLogoBase64);\r\n if (res.data?.customerLogoBase64 !== '') {\r\n setShowClearIcon(true);\r\n }\r\n else {\r\n setShowClearIcon(false);\r\n setFieldValue('logoFile', '');\r\n setFieldValue('imageField', {});\r\n }\r\n const formValues = {\r\n printReturnInstructions: res.data.printLabel,\r\n returnInstructions: atob(res.data.customerReturnInstructions),\r\n configureLinkedReturnAccountNumber: formikValues.selectAccount?.returnConfiguration?.customerReturnAccount\r\n };\r\n setValues({ ...formikValues, ...formValues });\r\n })\r\n .catch((err) => {\r\n setShowClearIcon(false);\r\n setFilePath('');\r\n const formValues = {\r\n printReturnInstructions: false,\r\n returnInstructions: atob(''),\r\n configureLinkedReturnAccountNumber: formikValues.selectAccount?.returnConfiguration?.customerReturnAccount,\r\n logoFile: '',\r\n imageField: {},\r\n };\r\n setValues({ ...formikValues, ...formValues });\r\n console.log(err);\r\n });\r\n }\r\n }\r\n\r\n const handleSubmit = () => {\r\n const reqObj = {\r\n customerAccount: formikValues.configureLinkedReturnAccountNumber,\r\n printLabel: formikValues.printReturnInstructions,\r\n customerReturnInstructions: btoa(formikValues.returnInstructions),\r\n customerLogo: filePath,\r\n customerLogoType: 'png',\r\n customerLogoBase64: filePath,\r\n };\r\n POST(`${ServiceEndPoints.getReturnInstructionLabel}`, reqObj)\r\n .then((res) => {\r\n dispatch(actions.setAppSnackBarData({ msg: `Account data updated successfully` }));\r\n setFieldValue('logoFile', '')\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in updating account data, please try again later',\r\n },\r\n ],\r\n }),\r\n );\r\n });\r\n };\r\n\r\n const handlePreview = () => {\r\n setShowPreviewDialog(true);\r\n };\r\n const handleCancel = () => {\r\n history.push('/shipment/addShipment');\r\n };\r\n\r\n const closePreviewDialog = () => {\r\n setShowPreviewDialog(false);\r\n };\r\n\r\n const fileClicked = (event) => {\r\n event.target.value = '';\r\n };\r\n const handleChangeOfNewRows = (e) => {\r\n var text = document.getElementById('text').value;\r\n let lines = 1;\r\n let maxLines = 11;\r\n let maxTextForLine = 50;\r\n let textValue = text.replace(/(\\r\\n|\\n|\\r)/gm, \"\").length\r\n if (textValue > 0) {\r\n if (textValue % maxTextForLine === 0) {\r\n lines++;\r\n document.getElementById('text').value = text + '\\n'\r\n }\r\n }\r\n var el = document.getElementById('text');\r\n let lineCount = 0;\r\n var liness = text.split(\"\\n\");\r\n for (var i = 0; i < liness.length; i++) {\r\n if (liness[i].length > 0)\r\n lineCount++;\r\n }\r\n\r\n if (lineCount === maxLines) {\r\n if (textValue === 550) {\r\n e.preventDefault();\r\n\r\n }\r\n }\r\n\r\n }\r\n\r\n useEffect(() => {\r\n const { returnInstructions } = formikValues;\r\n let contentInRows = returnInstructions.split(\"\\n\");\r\n let updatedContent = returnInstructions.split(\"\\n\");\r\n contentInRows.forEach((row, index) => {\r\n if (row.length > 50) {\r\n updatedContent[index] = row.slice(0, 50)\r\n updatedContent.splice(index + 1, 0, row.slice(50, row.length));\r\n }\r\n });\r\n setFieldValue(\"returnInstructions\", updatedContent.slice(0, 11).join(\"\\n\"))\r\n }, [formikValues.returnInstructions])\r\n\r\n\r\n return (\r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ),\r\n }}\r\n fullWidth\r\n />\r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n ),\r\n }}\r\n fullWidth\r\n />\r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Company logo requirements: \r\n File type: Only PNG allowed
\r\n Maximum size: 700 x 200 pixels
\r\n Max resolution: 203 dpi
\r\n Max file size for upload: 500 KB
\r\n \r\n }\r\n arrow\r\n placement=\"left\"\r\n >\r\n \r\n \r\n \r\n ),\r\n }}\r\n />\r\n onSelectFile(event)}\r\n ref={hiddenFileInput}\r\n name=\"imageField\"\r\n onClick={fileClicked}\r\n />\r\n \r\n \r\n {showClearIcon ? (\r\n }\r\n isDisabled={!formikValues.printReturnInstructions}\r\n />\r\n ) : (\r\n }\r\n isDisabled={!formikValues.printReturnInstructions}\r\n />\r\n )}\r\n \r\n \r\n \r\n \r\n \r\n {filePath ? (\r\n
\r\n ) : (\r\n <>\r\n
Logo preview \r\n
\r\n The logo preview will appear here \r\n \r\n >\r\n )}\r\n
\r\n \r\n\r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n {\r\n handlePreview();\r\n }}\r\n isDisabled={!formikValues.printReturnInstructions}\r\n />\r\n \r\n \r\n {\r\n handleSubmit();\r\n }}\r\n buttonType=\"submit\"\r\n label=\"Save\"\r\n isDisabled={!isValid}\r\n />\r\n \r\n \r\n
\r\n \r\n \r\n
\r\n );\r\n};\r\n\r\nexport default ConfigureReturnLabel;\r\n","const AccountForm = {\r\n formId: 'AccountFormId',\r\n formField: {\r\n accountNumber: {\r\n props: {\r\n name: 'accountNumber',\r\n label: 'Account number',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n },\r\n },\r\n companyName: {\r\n props: {\r\n name: 'companyName',\r\n label: 'Company name',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n },\r\n },\r\n postalCode: {\r\n props: {\r\n name: 'postalCode',\r\n label: 'Postal code',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n },\r\n },\r\n invoiceAddress: {\r\n props: {\r\n name: 'invoiceAddress',\r\n label: 'Invoice address',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n },\r\n },\r\n tradingAddress: {\r\n props: {\r\n name: 'tradingAddress',\r\n label: 'Trading address',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n },\r\n },\r\n // termsOfDelivery: {\r\n // props: {\r\n // name: 'termsOfDelivery',\r\n // label: 'Terms of delivery',\r\n // type: 'text',\r\n // placeholder: 'Enter',\r\n // },\r\n // },\r\n returnAddress: {\r\n props: {\r\n name: 'returnAddress',\r\n label: 'Return address',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n },\r\n },\r\n linkedReturnAccountNumber: {\r\n props: {\r\n name: 'linkedReturnAccountNumber',\r\n label: 'Linked return account number',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n },\r\n },\r\n fdaRegistrationNumber: {\r\n props: {\r\n name: 'fdaRegistrationNumber',\r\n label: 'FDA registration',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n },\r\n },\r\n eoriNumber: {\r\n props: {\r\n name: 'eoriNumber',\r\n label: 'EORI number',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n },\r\n },\r\n vatORtvaNumber: {\r\n props: {\r\n name: 'vatORtvaNumber',\r\n label: 'VAT / TVA number',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n },\r\n },\r\n vatRegistersCheckbox: {\r\n props: {\r\n name: 'vatRegistersCheckbox',\r\n label: 'VAT Registered outside of the UK',\r\n type: 'checkbox',\r\n },\r\n },\r\n vatRadioBox: {\r\n props: {\r\n name: 'vatRadioBox',\r\n label: 'VAT / TVA:',\r\n type: 'radio',\r\n },\r\n value: 'no',\r\n },\r\n selectAccount: {\r\n props: {\r\n name: 'selectAccount',\r\n label: 'Select account',\r\n type: 'autoComplete',\r\n // displayId:'accountId',\r\n displayField: 'displayName',\r\n hasDefaultValue: true,\r\n },\r\n },\r\n returnLabelAccount: {\r\n props: {\r\n name: 'returnLabelAccount',\r\n label: 'Select account',\r\n type: 'select',\r\n displayField: 'accountName',\r\n hasDefaultValue: false,\r\n },\r\n },\r\n configureLinkedReturnAccountNumber: {\r\n props: {\r\n name: 'configureLinkedReturnAccountNumber',\r\n label: 'Linked return account number',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n isDisabled: true,\r\n },\r\n value: '',\r\n },\r\n printReturnInstructions: {\r\n props: {\r\n name: 'printReturnInstructions',\r\n label: 'Print return instructions',\r\n type: 'checkbox',\r\n },\r\n value: false,\r\n },\r\n defaultInstructions: {\r\n props: {\r\n name: 'defaultInstructions',\r\n label: 'Default return instructions',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n multiline: true,\r\n rowsMax: 11,\r\n rows: 11,\r\n isDisabled: true,\r\n },\r\n value:\r\n 'Return Instructions within UK \\n \\nReturning your items via DHL eCommerce UK is simple.\\n1. Package your return item ensuring that the parcel is sealed and secure \\n2. Apply the return label to your parcel\\n3. Take the parcel to your preferred ServicePoint who will process it for you\\n \\nGo to https://www.dhl.com/uk-service-point-finder to locate our ServicePoints which are situated in PayPoint stores ',\r\n },\r\n returnInstructions: {\r\n props: {\r\n name: 'returnInstructions',\r\n label: 'Return instructions',\r\n type: 'text',\r\n placeholder: 'Enter specific instructions that you wish to be included',\r\n multiline: true,\r\n rowsMax: 11,\r\n rows: 11,\r\n inputProps: {\r\n maxLength: 560,\r\n },\r\n },\r\n },\r\n logoFile: {\r\n props: {\r\n name: 'logoFile',\r\n label: 'Logo file for upload',\r\n type: 'text',\r\n placeholder: 'Select',\r\n // isDisabled: true,\r\n },\r\n value: '',\r\n validation: {\r\n name: 'logoFile',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'when',\r\n params: [\r\n 'imageField',\r\n (imageField, schema) => {\r\n return schema.test(\r\n 'checkImageSize',\r\n `Maximum size of image file ${imageField?.fileName} cannot exceed 500 KB`,\r\n (logoFileValue) => {\r\n if ((imageField?.size ?? 0) > 500000) {\r\n return false;\r\n }\r\n return true;\r\n },\r\n );\r\n },\r\n ],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n 'imageField',\r\n (imageField, schema) => {\r\n return schema.test(\r\n 'checkImageHeight',\r\n `Height of image file ${imageField?.fileName} cannot exceed 200 px`,\r\n (logoFileValue) => {\r\n if ((imageField?.height ?? 0) > 200) {\r\n return false;\r\n }\r\n return true;\r\n },\r\n );\r\n },\r\n ],\r\n },\r\n {\r\n type: 'when',\r\n params: [\r\n 'imageField',\r\n (imageField, schema) => {\r\n return schema.test(\r\n 'checkImageWidth',\r\n `Length of image file ${imageField?.fileName} cannot exceed 700 px`,\r\n (logoFileValue) => {\r\n if ((imageField?.width ?? 0) > 700) {\r\n return false;\r\n }\r\n return true;\r\n },\r\n );\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n imageField: {\r\n props: {\r\n name: 'imageField',\r\n label: 'Logo file for upload',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n isDisabled: true,\r\n },\r\n value: '',\r\n },\r\n iossNumber: {\r\n props: {\r\n name: 'iossNumber',\r\n label: 'IOSS number',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n },\r\n },\r\n ukimsNumber: {\r\n props: {\r\n name: 'ukimsNumber',\r\n label: 'UKIMS number',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n },\r\n },\r\n defermentAccountNumber: {\r\n props: {\r\n name: 'defermentAccountNumber',\r\n label: 'Deferment number',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n },\r\n },\r\n },\r\n};\r\n\r\nexport default AccountForm;\r\n","import React, { useState, useRef, useEffect } from 'react';\r\nimport { Grid, Paper, Tab, Tabs, IconButton, Tooltip, SvgIcon, makeStyles } from '@material-ui/core';\r\n\r\nimport TabPanel from '../../components/shared/tabPanel';\r\n\r\nimport { Form, Formik } from 'formik';\r\nimport './accounts.scss';\r\nimport { getYupSchemaFromMetaData } from '../../utils/yupSchema/yupSchemaGenerator';\r\nimport { AccountFromDetails } from './AccountFromDetails';\r\nimport ConfigureReturnLabel from '../../components/accounts/configureReturnLabel/configureReturnLabel';\r\nimport AccountForm from '../../utils/formConfig/accounts/accountsForm';\r\nimport { connect } from 'react-redux';\r\nimport { sortBasedOnNestedOrNot } from '../../utils/helperFunctions';\r\nimport { ReactComponent as InfoIcon } from '../../assets/images/InfoIcon.svg';\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n customTooltip: {\r\n backgroundColor: '#fff',\r\n color: '#000000E6',\r\n fontSize: '14px',\r\n boxShadow: '0px 3px 6px #00000029',\r\n padding: '8px 15px',\r\n borderRadius: '0'\r\n },\r\n customArrow: {\r\n color: '#fff',\r\n }\r\n}));\r\n\r\nconst Accounts = ({ userAccounts }) => {\r\n const classes = useStyles();\r\n const { formId, formField } = AccountForm;\r\n const formikRef = useRef(null);\r\n const newMaintainAccountSchema = getYupSchemaFromMetaData(formField, [], []);\r\n\r\n const initialValues = {};\r\n const [tabIndex, setTabIndex] = useState(0);\r\n const [accounts, setAccounts] = useState([]);\r\n const [returnAccounts, setReturnAccounts] = useState([]);\r\n\r\n for (let property in formField) {\r\n if (Object.prototype.hasOwnProperty.call(formField, property)) {\r\n const field = formField[property];\r\n initialValues[field.props.name] = field.value ?? '';\r\n }\r\n }\r\n\r\n const onTabChange = (event, index) => {\r\n setTabIndex(index);\r\n };\r\n\r\n const sortAlphaNum = (a, b) => a?.accountId?.toLowerCase().localeCompare(b?.accountId?.toLowerCase(), 'en', { numeric: true })\r\n\r\n useEffect(() => {\r\n const sortedArray = userAccounts.sort(sortAlphaNum);\r\n setAccounts(sortedArray);\r\n const returnAccountsArray = sortedArray.filter(retAcc => retAcc?.returnConfiguration?.inboxReturnAllowed === true)\r\n setReturnAccounts(returnAccountsArray)\r\n }, [userAccounts]);\r\n\r\n return (\r\n \r\n
\r\n {({ values, setFieldValue, setValues, errors, setFieldTouched, isValid, resetForm }) => (\r\n \r\n )}\r\n \r\n
\r\n );\r\n};\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n userAccounts: (((state || {}).auth || {}).userDetails || {}).accounts,\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, null)(Accounts);\r\n","import React, { useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid } from '@material-ui/core';\r\nimport DynamicMaterialTable from '../../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport ConfirmationDialog from '../../addressBook/confirmation/confirmation';\r\nimport CustomModal from '../../../framework/dialog/customDialog';\r\nexport default function OrdersData(props) {\r\n const {\r\n rows,\r\n columns,\r\n isSearchable,\r\n isSelectable,\r\n sorting,\r\n paging,\r\n pageSize,\r\n pageSizeOptions,\r\n Dialogtitle,\r\n tabIndex,\r\n totalCount,\r\n } = props;\r\n const [selectedRows, setSelectedRows] = useState([]);\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n const [confirmationMsg, setConfirmationMsg] = useState();\r\n const [_deleteAllOrders, setdeleteAllOrders] = useState(false);\r\n const addSelectedRows = (selectedRows) => {\r\n setSelectedRows(selectedRows);\r\n };\r\n const handleDialogClose = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n const onDialogConfirm = () => {\r\n if (_deleteAllOrders) {\r\n props.deleteAllOrder(props.isCollectionRequest, props.isValid);\r\n } else {\r\n props.deleteSelectedOrder(selectedRows);\r\n setSelectedRows([]);\r\n }\r\n setShowConfirmationDialog(false);\r\n };\r\n const onDialogCancel = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n const deleteOrderEntry = () => {\r\n // setConfirmationMsg(`This action will delete ${selectedRows.length} order and can't be undone.Select Delete all to confirm.`)\r\n setConfirmationMsg(`Are you sure you want to delete these ${tabIndex > 1 ? \"collections\" : \"orders\"}?`);\r\n setShowConfirmationDialog(true);\r\n setdeleteAllOrders(false);\r\n };\r\n const deleteAllOrderEntry = () => {\r\n setConfirmationMsg(`All ${tabIndex > 1 ? \"collections\" : \"shipments\"} will be removed, are you sure you want to delete them?`);\r\n setShowConfirmationDialog(true);\r\n setdeleteAllOrders(true);\r\n };\r\n\r\n const createShipmentEntry = () => {\r\n props.createShipment(selectedRows);\r\n setSelectedRows([]);\r\n };\r\n const createSelectedCollections = () => {\r\n props.createSelectedCollections(selectedRows);\r\n setSelectedRows([]);\r\n };\r\n return (\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n deleteAllOrderEntry()}\r\n />\r\n \r\n \r\n deleteOrderEntry()}\r\n />\r\n \r\n {/* : null} */}\r\n {tabIndex === 0\r\n? (\r\n \r\n props.createAllShipments()}\r\n />\r\n \r\n )\r\n: null}\r\n {tabIndex === 0\r\n? (\r\n \r\n createShipmentEntry()}\r\n />\r\n \r\n )\r\n: null}\r\n {tabIndex === 2\r\n? (\r\n \r\n props.createAllCollections()}\r\n />\r\n \r\n )\r\n: null}\r\n {tabIndex === 2\r\n? (\r\n \r\n createSelectedCollections()}\r\n />\r\n \r\n )\r\n: null}\r\n \r\n \r\n );\r\n}\r\n\r\nOrdersData.propTypes = {\r\n rows: PropTypes.array,\r\n columns: PropTypes.array,\r\n isSearchable: PropTypes.bool,\r\n isSelectable: PropTypes.bool,\r\n sorting: PropTypes.bool,\r\n paging: PropTypes.bool,\r\n pageSize: PropTypes.object,\r\n pageSizeOptions: PropTypes.object,\r\n title: PropTypes.string,\r\n confirmationMessage: PropTypes.string,\r\n deleteSelectedOrder: PropTypes.func,\r\n createAllShipments: PropTypes.func,\r\n createShipment: PropTypes.func,\r\n tabIndex: PropTypes.number,\r\n};\r\n","import React from 'react';\r\nimport { connect } from 'react-redux';\r\nimport { withRouter } from 'react-router-dom';\r\nimport OrdersData from './ordersData';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { axiosConfig } from '../../../api/axios';\r\nimport { getCustomerAccountID, customTableSort } from '../../../utils/helperFunctions';\r\n// import { Backdrop } from '@material-ui/core/';\r\n// import CircularProgressWithLabel from '../../../framework/spinner/circularProgressBar';\r\nimport * as actions from '../../../store/actions/index';\r\n\r\nclass Orders extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n totalRecords: 0,\r\n columns: [\r\n { title: 'id', field: 'id', hidden: true, width: 0 },\r\n {\r\n title: 'Customer ref.',\r\n field: 'customerReference',\r\n width: 130,\r\n // customSort: (a, b) => customTableSort(a?.customerReference, b?.customerReference),\r\n sorting: true,\r\n render: (row) => this.orderRoWClicked(row)}>{row.customerReference}
,\r\n },\r\n {\r\n title: 'Business/Customer name',\r\n field: 'customerName',\r\n sorting: true,\r\n width: 220,\r\n render: (row) => this.orderRoWClicked(row)}>{row.customerName}
,\r\n },\r\n {\r\n title: 'Postal code',\r\n field: 'postalCode',\r\n sorting: true,\r\n width: 120,\r\n },\r\n {\r\n title: 'Source',\r\n field: 'source',\r\n sorting: false,\r\n width: 130,\r\n },\r\n {\r\n title: 'Sub-source',\r\n field: 'subSource',\r\n sorting: false,\r\n width: 130,\r\n },\r\n {\r\n title: 'Alternate ref.',\r\n field: 'alternateReference',\r\n sorting: true,\r\n width: 150,\r\n },\r\n {\r\n title: 'Contact',\r\n field: 'contact',\r\n sorting: true,\r\n width: 100,\r\n },\r\n {\r\n title: 'Dispatch date',\r\n field: 'dispatchDate',\r\n sorting: true,\r\n width: 90,\r\n },\r\n ],\r\n orders_pageDetails: {\r\n offset: 0,\r\n limit: 0,\r\n totalRecordsLength: 0,\r\n },\r\n orders_final_data: [],\r\n orders_totalCount: 0,\r\n pageSize: 10,\r\n pageNumber: 0,\r\n isLoading: false,\r\n ordersData: [],\r\n pageNumSizeSortChange: false,\r\n emptyTableMsgOnScanPrint: false,\r\n // counter: 1,\r\n // completionPercentage: 0,\r\n // // inProgress: false,\r\n // OrdersLength: 1\r\n };\r\n this.onClickSetSortOrder = this.onClickSetSortOrder.bind(this);\r\n }\r\n\r\n orderRoWClicked = (rowData) => {\r\n this.props.history.push({\r\n pathname: `/shipment/addShipment/${rowData.id}/true/true`,\r\n state: {\r\n isScanFlag: this.props.isScanFlag,\r\n },\r\n });\r\n };\r\n\r\n componentDidMount() {\r\n this.props.setSortOrder(``);\r\n this.getOrdersData();\r\n }\r\n\r\n componentDidUpdate(prevProps) {\r\n if (this.props.tabIndex === 0 && ((this.props.isSearched !== prevProps.isSearched || this.props.refreshList)\r\n || (this.props.addressBookSearchParams.split('=')[0] !== prevProps.addressBookSearchParams.split('=')[0]\r\n && this.props.addressBookSearchParams.split('=')[1] !== '' && prevProps.addressBookSearchParams !== ''))) {\r\n this.setState({ pageSize: this.state.pageSize, pageNumber: 0 }, () => {\r\n this.getOrdersData();\r\n });\r\n }\r\n }\r\n getOrdersDataGetAPICall(offset, limit) {\r\n this.setState({emptyTableMsgOnScanPrint: false});\r\n axiosConfig\r\n .get(this.getUrl(offset, limit))\r\n .then((res) => {\r\n this.setState({\r\n orders_pageDetails: {\r\n offset: offset,\r\n limit: limit,\r\n totalRecordsLength: (res.data || {}).totalRecords,\r\n },\r\n });\r\n this.setState({ totalRecords: res.data?.totalRecords ? res.data?.totalRecords : 0 });\r\n this.formatOrdersData(res.data);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n this.setState({\r\n orders_pageDetails: {\r\n offset: 0,\r\n limit: 10,\r\n totalRecordsLength: 0,\r\n },\r\n });\r\n this.setState({ totalRecords: 0 });\r\n this.formatOrdersData([]);\r\n })\r\n .finally(() => this.setState({ isLoading: false }));\r\n }\r\n getOrdersDataPostAPICall(offset, limit) {\r\n // this.setState({\r\n // inProgress: true,\r\n // })\r\n axiosConfig\r\n .post(this.postUrl(offset, limit))\r\n .then((res) => {\r\n this.setState({emptyTableMsgOnScanPrint: true,\r\n orders_pageDetails: {\r\n offset: offset,\r\n limit: limit,\r\n totalRecordsLength: (res.data || {}).totalRecords,\r\n },\r\n });\r\n\r\n this.props.setSnackBarMsg({ msg: `1 shipment(s) created successfully` });\r\n this.setState({ totalRecords: res.data?.totalRecords ? res.data?.totalRecords : 0 });\r\n this.formatOrdersData(res.data);\r\n })\r\n .catch(async (err) => {\r\n this.setState({emptyTableMsgOnScanPrint: false });\r\n if (err.response?.status === 422) {\r\n await this.getOrdersDataGetAPICall(offset, limit)\r\n } else {\r\n this.setState({\r\n orders_pageDetails: {\r\n offset: 0,\r\n limit: 10,\r\n totalRecordsLength: 0,\r\n },\r\n orders_final_data: [],\r\n orders_totalCount: 0,\r\n totalRecords: 0,\r\n });\r\n // this.formatOrdersData([]);\r\n }\r\n // this.setState({\r\n // inProgress: false,\r\n // })\r\n })\r\n .finally(() => this.setState({ isLoading: false }));\r\n }\r\n getOrdersData() {\r\n this.props.setRefreshList(false);\r\n this.setState({ isLoading: true});\r\n setTimeout(() => {\r\n const offset = this.state.pageSize * this.state.pageNumber;\r\n const limit = this.state.pageSize;\r\n if (!this.props.isScanPrintFlag) {\r\n this.getOrdersDataGetAPICall(offset, limit)\r\n } else {\r\n if(this.props.addressBookSearchParams && this.props.addressBookSearchParams?.split('=')?.[1] !==''){\r\n this.getOrdersDataPostAPICall(offset, limit)\r\n }\r\n else if(this.props.autoReloadProcessOrders || this.props.isRefersFlag || this.state.pageNumSizeSortChange){\r\n this.getOrdersDataGetAPICall(offset, limit)\r\n this.props.UploadrefreshOrder(false);\r\n this.setState({pageNumSizeSortChange: false});\r\n }\r\n else{\r\n this.setState({ isLoading: false });\r\n }\r\n }\r\n }, 0);\r\n }\r\n\r\n getUrl = (offset, limit) => {\r\n let url = `${ServiceEndPoints.getOrders\r\n }?organization=${getCustomerAccountID()}&isValid=true&iscollectionrequest=false`;\r\n url += '&offset=' + offset;\r\n url += '&limit=' + limit;\r\n url += this.props.sortOrderState;\r\n url += this.props.addressBookSearchParams;\r\n return url;\r\n };\r\n postUrl = (offset, limit) => {\r\n let url = `${ServiceEndPoints.searchandprint\r\n }?organization=${getCustomerAccountID()}&isValid=true&iscollectionrequest=false`;\r\n url += this.props.addressBookSearchParams;\r\n url += `&labelFormat=${this.props?.printerConfiguration?.labelType == 2 ? \"PDF\" : \"ZPL\"}`\r\n return url;\r\n };\r\n\r\n formatOrdersData = (result) => {\r\n let final_data = [];\r\n result?.orders?.forEach((element, index) => {\r\n const consigneeAddress = element?.shipmentModel?.shipments?.[0]?.consigneeAddress;\r\n const recipientAddress = element?.shipmentModel?.shipments?.[0]?.recipientAddress;\r\n const shipmentDetails = element?.shipmentModel?.shipments?.[0]?.shipmentDetails;\r\n final_data.push({\r\n id: element.id,\r\n customerReference: (element || {}).referenceNumber,\r\n customerName:\r\n consigneeAddress?.addressType === 'doorstep'\r\n ? consigneeAddress?.companyName || consigneeAddress?.name\r\n : recipientAddress?.companyName || recipientAddress?.name,\r\n source: element.sourceReference,\r\n subSource: element.subSource,\r\n alternateReference: shipmentDetails?.customerRef2,\r\n contact: consigneeAddress?.addressType === 'doorstep' ? consigneeAddress?.name : recipientAddress?.name,\r\n postalCode:\r\n consigneeAddress?.addressType === 'doorstep' ? consigneeAddress?.postalCode : recipientAddress?.postalCode,\r\n dispatchDate: element?.shipmentModel?.pickup?.date,\r\n printerQueueName: element?.printerQueueName\r\n });\r\n });\r\n if (\r\n this.props.addressBookSearchParams !== '' &&\r\n this.props.addressBookSearchParams !== '&customerReferenceNumber=' &&\r\n this.props.addressBookSearchParams !== '&alternateReference=' &&\r\n this.props.isScanPrintFlag && !(final_data.length > 0)\r\n ) {\r\n this.props.printLabels(result, false);\r\n this.props.onProcessOrdersSelectedItem(true);\r\n this.props._setAddressBookSearchParams(`&customerReferenceNumber=`);\r\n } else {\r\n if (\r\n this.props.addressBookSearchParams !== '' &&\r\n this.props.addressBookSearchParams?.split('=')?.[1] &&\r\n this.props.addressBookSearchParams !== '&customerReferenceNumber=' &&\r\n this.props.addressBookSearchParams !== '&alternateReference=' &&\r\n final_data.length === 1 && !this.props.isScanPrintFlag\r\n ) {\r\n this.props.history.push({\r\n pathname: `/shipment/addShipment/${final_data[0].id}/true/true`,\r\n state: {\r\n isScanFlag: this.props.isScanFlag,\r\n }\r\n });\r\n }\r\n }\r\n this.setState({\r\n orders_final_data: final_data,\r\n orders_totalCount: result.totalRecords ? result.totalRecords : 0,\r\n });\r\n };\r\n\r\n onPageNumChange(pageNum) {\r\n this.setState({ pageNumber: pageNum ,pageNumSizeSortChange: true}, () => {\r\n this.getOrdersData();\r\n });\r\n }\r\n\r\n onPageSizeChange(pageSize) {\r\n this.setState({ pageSize: pageSize }, () => {\r\n this.getOrdersData();\r\n });\r\n }\r\n \r\n onClickSetSortOrder(orderIn, orderBy) {\r\n if(orderIn === 'asc')\r\n {\r\n this.props.setSortOrder(`&sortBy=${orderBy}&sortIn=ascending`);\r\n }\r\n else if(orderIn === 'desc'){\r\n this.props.setSortOrder(`&sortBy=${orderBy}&sortIn=descending`);\r\n }\r\n else{\r\n this.props.setSortOrder(``);\r\n }\r\n this.setState({ pageNumber: 0, pageNumSizeSortChange: true});\r\n this.getOrdersData();\r\n }\r\n\r\n render() {\r\n return (\r\n // \r\n
this.onPageSizeChange(e),\r\n onChangePage: (a) => this.onPageNumChange(a),\r\n }}\r\n page={this.state.pageNumber}\r\n tableLayout=\"fixed\"\r\n deleteAllOrder={this.props.deleteAllOrder}\r\n isCollectionRequest={false}\r\n isValid={true}\r\n onClickSetSortOrder={this.onClickSetSortOrder}\r\n />\r\n );\r\n }\r\n}\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n addressBookSearchParams: state.searchParams,\r\n kepressed: state.keyPressEvent.key,\r\n printerConfiguration: state.common.printerConfiguration,\r\n sortOrderState: state.common.sortOrderState,\r\n autoReloadProcessOrders: state.common.autoReloadProcessOrders,\r\n };\r\n};\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n setSnackBarMsg: (data) => {\r\n dispatch(actions.setAppSnackBarData(data));\r\n },\r\n setSortOrder: (data) => {\r\n dispatch(actions.setSortOrderState(data));\r\n },\r\n _setAddressBookSearchParams: (data) => {\r\n dispatch(actions.setAddressBookSearchParams(data));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(withRouter(Orders));\r\n","import React from 'react';\r\nimport { connect } from 'react-redux';\r\nimport { withRouter } from 'react-router-dom';\r\nimport OrdersData from './ordersData';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { axiosConfig } from '../../../api/axios';\r\nimport { getCustomerAccountID, customTableSort } from '../../../utils/helperFunctions';\r\nimport * as actions from '../../../store/actions/index';\r\n\r\nclass ReviewOrders extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n totalRecords: 0,\r\n columns: [\r\n { title: 'id', field: 'id', hidden: true, width: 0 },\r\n {\r\n title: 'Customer ref.',\r\n field: 'customerReference',\r\n width: 130,\r\n // customSort: (a, b) => customTableSort(a?.customerReference, b?.customerReference),\r\n render: (row) => this.orderRoWClicked(row)}>{row.customerReference}
,\r\n sorting: true,\r\n },\r\n {\r\n title: 'Business/Customer name',\r\n field: 'customerName',\r\n sorting: true,\r\n width: 220,\r\n render: (row) => this.orderRoWClicked(row)}>{row.customerName}
,\r\n },\r\n {\r\n title: 'Postal code',\r\n field: 'postalCode',\r\n sorting: true,\r\n width: 120,\r\n },\r\n {\r\n title: 'Source',\r\n field: 'source',\r\n sorting: false,\r\n width: 130,\r\n },\r\n {\r\n title: 'Sub-source',\r\n field: 'subSource',\r\n sorting: false,\r\n width: 130,\r\n },\r\n {\r\n title: 'Alternative ref.',\r\n field: 'alternateReference',\r\n sorting: true,\r\n width: 150,\r\n },\r\n {\r\n title: 'Contact',\r\n field: 'contact',\r\n sorting: true,\r\n width: 100,\r\n },\r\n {\r\n title: 'Dispatch date',\r\n field: 'dispatchDate',\r\n sorting: true,\r\n width: 90,\r\n },\r\n ],\r\n orders_totalCount: 0,\r\n pageSize: 10,\r\n pageNumber: 0,\r\n isLoading: false,\r\n ordersData: [],\r\n };\r\n this.onClickSetSortOrder = this.onClickSetSortOrder.bind(this);\r\n }\r\n\r\n orderRoWClicked = (rowData) => {\r\n this.props.history.push({\r\n pathname: `/shipment/addShipment/${rowData.id}/true/false`,\r\n state: {\r\n isScanFlag: this.props.isScanFlag,\r\n },\r\n });\r\n };\r\n\r\n componentDidMount() {\r\n this.props.setSortOrder(``);\r\n this.getOrdersData();\r\n }\r\n\r\n componentDidUpdate(prevProps) {\r\n if (this.props.tabIndex === 1 && ((this.props.isSearched !== prevProps.isSearched || this.props.refreshList)\r\n || (this.props.addressBookSearchParams.split('=')[0] !== prevProps.addressBookSearchParams.split('=')[0]\r\n && this.props.addressBookSearchParams.split('=')[1] !== '' && prevProps.addressBookSearchParams !== ''))) {\r\n this.setState({ pageSize: this.state.pageSize, pageNumber: 0 }, () => {\r\n this.getOrdersData();\r\n });\r\n }\r\n }\r\n\r\n getOrdersData() {\r\n this.props.setRefreshList(false);\r\n this.setState({ isLoading: true });\r\n setTimeout(() => {\r\n const offset = this.state.pageSize * this.state.pageNumber;\r\n const limit = this.state.pageSize;\r\n axiosConfig\r\n .get(this.getUrl(offset, limit))\r\n .then((res) => {\r\n this.formatOrdersData(res.data);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n this.formatOrdersData([]);\r\n })\r\n .finally(() => this.setState({ isLoading: false })); \r\n }, 0);\r\n }\r\n\r\n getUrl = (offset, limit) => {\r\n let url = `${ServiceEndPoints.getOrders\r\n }?organization=${getCustomerAccountID()}&isValid=false&iscollectionrequest=false`;\r\n url += '&offset=' + offset;\r\n url += '&limit=' + limit;\r\n url += this.props.sortOrderState;\r\n url += this.props.addressBookSearchParams;\r\n return url;\r\n };\r\n\r\n formatOrdersData = (result) => {\r\n let final_data = [];\r\n ((result || {}).orders || []).forEach((element, index) => {\r\n const consigneeAddress = ((((element || {}).shipmentModel || {}).shipments || [])[0] || {}).consigneeAddress;\r\n const recipientAddress = ((((element || {}).shipmentModel || {}).shipments || [])[0] || {}).recipientAddress;\r\n const shipmentDetails = ((((element || {}).shipmentModel || {}).shipments || [])[0] || {}).shipmentDetails;\r\n final_data.push({\r\n id: element.id,\r\n customerReference: (element || {}).referenceNumber,\r\n customerName:\r\n (consigneeAddress || {}).addressType === 'doorstep'\r\n ? consigneeAddress?.companyName || consigneeAddress?.name\r\n : recipientAddress?.companyName || recipientAddress?.name,\r\n source: element.sourceReference,\r\n subSource: element.subSource,\r\n alternateReference: (shipmentDetails || {}).customerRef2,\r\n contact:\r\n (consigneeAddress || {}).addressType === 'doorstep'\r\n ? (consigneeAddress || {}).name\r\n : (recipientAddress || {}).name,\r\n postalCode:\r\n (consigneeAddress || {}).addressType === 'doorstep'\r\n ? (consigneeAddress || {}).postalCode\r\n : (recipientAddress || {}).postalCode,\r\n dispatchDate: (((element || {}).shipmentModel || {}).pickup || {}).date,\r\n });\r\n });\r\n\r\n if (\r\n this.props.addressBookSearchParams !== '' &&\r\n this.props.addressBookSearchParams?.split('=')?.[1] &&\r\n this.props.addressBookSearchParams !== '&customerReferenceNumber=' &&\r\n this.props.addressBookSearchParams !== '&alternateReference=' &&\r\n final_data.length === 1\r\n ) {\r\n this.props.history.push({\r\n pathname: `/shipment/addShipment/${final_data[0].id}/true/false`,\r\n state: {\r\n isScanFlag: this.props.isScanFlag,\r\n }\r\n });\r\n }\r\n\r\n this.setState({\r\n ordersData: final_data,\r\n orders_totalCount: result.totalRecords ? result.totalRecords : 0,\r\n });\r\n this.props.setReviewOrderCount(result.totalRecords ? result.totalRecords : 0);\r\n };\r\n\r\n onPageNumChange(pageNum) {\r\n this.setState({ pageNumber: pageNum }, () => {\r\n this.getOrdersData();\r\n });\r\n }\r\n\r\n onPageSizeChange(pageSize) {\r\n this.setState({ pageSize: pageSize }, () => {\r\n this.getOrdersData();\r\n });\r\n }\r\n\r\n onClickSetSortOrder(orderIn, orderBy) {\r\n if(orderIn === 'asc')\r\n {\r\n this.props.setSortOrder(`&sortBy=${orderBy}&sortIn=ascending`);\r\n }\r\n else if(orderIn === 'desc'){\r\n this.props.setSortOrder(`&sortBy=${orderBy}&sortIn=descending`);\r\n }\r\n else{\r\n this.props.setSortOrder(``);\r\n }\r\n this.setState({ pageNumber: 0 });\r\n this.getOrdersData();\r\n }\r\n\r\n render() {\r\n return (\r\n this.onPageSizeChange(e),\r\n onChangePage: (a) => this.onPageNumChange(a),\r\n }}\r\n page={this.state.pageNumber}\r\n tableLayout=\"fixed\"\r\n deleteAllOrder={this.props.deleteAllOrder}\r\n isCollectionRequest={false}\r\n isValid={false}\r\n onClickSetSortOrder={this.onClickSetSortOrder}\r\n />\r\n );\r\n }\r\n}\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n addressBookSearchParams: state.searchParams,\r\n sortOrderState: state.common.sortOrderState,\r\n };\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n setSortOrder: (data) => {\r\n dispatch(actions.setSortOrderState(data));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(withRouter(ReviewOrders));\r\n","import React from 'react';\r\nimport { connect } from 'react-redux';\r\nimport { withRouter } from 'react-router-dom';\r\nimport OrdersData from './ordersData';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { axiosConfig } from '../../../api/axios';\r\nimport { getCustomerAccountID, customTableSort } from '../../../utils/helperFunctions';\r\nimport * as actions from '../../../store/actions/index';\r\n\r\nclass Orders extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n columns: [\r\n { title: 'id', field: 'id', hidden: true, width: 0 },\r\n {\r\n title: 'Customer ref.',\r\n field: 'customerReference',\r\n width: 120,\r\n // customSort: (a, b) => customTableSort(a?.customerReference, b?.customerReference),\r\n render: (row) => this.orderRoWClicked(row)}>{row.customerReference}
,\r\n sorting: true,\r\n },\r\n {\r\n title: 'Business/Customer name',\r\n field: 'customerName',\r\n sorting: true,\r\n width: 220,\r\n render: (row) => this.orderRoWClicked(row)}>{row.customerName}
,\r\n },\r\n {\r\n title: 'Collection postal code',\r\n field: 'postalCode',\r\n sorting: true,\r\n width: 200,\r\n },\r\n {\r\n title: 'Source',\r\n field: 'source',\r\n sorting: false,\r\n width: 100,\r\n },\r\n {\r\n title: 'Sub-source',\r\n field: 'subSource',\r\n sorting: false,\r\n width: 100,\r\n },\r\n {\r\n title: 'Contact',\r\n field: 'contact',\r\n sorting: true,\r\n width: 100,\r\n },\r\n {\r\n title: 'Collection date',\r\n field: 'dispatchDate',\r\n sorting: true,\r\n width: 90,\r\n },\r\n ],\r\n orders_totalCount: 0,\r\n pageSize: 10,\r\n pageNumber: 0,\r\n isLoading: false,\r\n ordersData: [],\r\n };\r\n this.onClickSetSortOrder = this.onClickSetSortOrder.bind(this);\r\n }\r\n\r\n orderRoWClicked = (rowData) => {\r\n this.props.history.push({\r\n pathname: `/shipment/collectionRequest/${rowData.id}/true/true`, state: {\r\n isScanFlag: this.props.isScanFlag\r\n }\r\n });\r\n };\r\n\r\n componentDidMount() {\r\n this.props.setSortOrder(``);\r\n this.getOrdersData();\r\n }\r\n\r\n componentDidUpdate(prevProps) {\r\n if (this.props.tabIndex === 2 && ((this.props.isSearched !== prevProps.isSearched || this.props.refreshList)\r\n || (this.props.addressBookSearchParams.split('=')[0] !== prevProps.addressBookSearchParams.split('=')[0]\r\n && this.props.addressBookSearchParams.split('=')[1] !== '' && prevProps.addressBookSearchParams !== ''))) {\r\n this.setState({ pageSize: this.state.pageSize, pageNumber: 0 }, () => {\r\n this.getOrdersData();\r\n });\r\n }\r\n }\r\n\r\n getOrdersData() {\r\n this.props.setRefreshList(false);\r\n this.setState({ isLoading: true });\r\n setTimeout(() => {\r\n const offset = this.state.pageSize * this.state.pageNumber;\r\n const limit = this.state.pageSize;\r\n axiosConfig\r\n .get(this.getUrl(offset, limit))\r\n .then((res) => {\r\n this.formatOrdersData(res.data);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n this.formatOrdersData([]);\r\n })\r\n .finally(() => this.setState({ isLoading: false })); \r\n }, 0);\r\n }\r\n\r\n getUrl = (offset, limit) => {\r\n let url = `${ServiceEndPoints.getOrders\r\n }?organization=${getCustomerAccountID()}&isValid=true&iscollectionrequest=true`;\r\n url += '&offset=' + offset;\r\n url += '&limit=' + limit;\r\n url += this.props.sortOrderState;\r\n url += this.props.addressBookSearchParams;\r\n return url;\r\n };\r\n\r\n formatOrdersData = (result) => {\r\n let final_data = [];\r\n ((result || {}).orders || []).forEach((element, index) => {\r\n const pickupAddress = element?.shipmentModel?.pickupAddress ?? {};\r\n final_data.push({\r\n id: element.id,\r\n customerReference: (element || {}).referenceNumber,\r\n customerName: pickupAddress.companyName || pickupAddress.name,\r\n source: element.sourceReference,\r\n subSource: element.subSource,\r\n contact: pickupAddress.name,\r\n postalCode: pickupAddress.postalCode,\r\n dispatchDate: (((element || {}).shipmentModel || {}).pickup || {}).date,\r\n printerQueueName: element?.printerQueueName\r\n });\r\n });\r\n if (\r\n this.props.addressBookSearchParams !== '' &&\r\n this.props.addressBookSearchParams?.split('=')?.[1] &&\r\n this.props.addressBookSearchParams !== '&customerReferenceNumber=' &&\r\n this.props.addressBookSearchParams !== '&alternateReference=' &&\r\n final_data.length === 1\r\n ) {\r\n this.props.history.push({\r\n pathname: `/shipment/collectionRequest/${final_data[0].id}/true/true`,\r\n state: {\r\n isScanFlag: this.props.isScanFlag,\r\n }\r\n });\r\n }\r\n\r\n this.setState({\r\n ordersData: final_data,\r\n orders_totalCount: result.totalRecords ? result.totalRecords : 0,\r\n });\r\n };\r\n\r\n onPageNumChange(pageNum) {\r\n this.setState({ pageNumber: pageNum }, () => {\r\n this.getOrdersData();\r\n });\r\n }\r\n\r\n onPageSizeChange(pageSize) {\r\n this.setState({ pageSize: pageSize }, () => {\r\n this.getOrdersData();\r\n });\r\n }\r\n\r\n onClickSetSortOrder(orderIn, orderBy) {\r\n if(orderIn === 'asc')\r\n {\r\n this.props.setSortOrder(`&sortBy=${orderBy}&sortIn=ascending`);\r\n }\r\n else if(orderIn === 'desc'){\r\n this.props.setSortOrder(`&sortBy=${orderBy}&sortIn=descending`);\r\n }\r\n else{\r\n this.props.setSortOrder(``);\r\n }\r\n this.setState({ pageNumber: 0 });\r\n this.getOrdersData();\r\n }\r\n\r\n render() {\r\n return (\r\n this.onPageSizeChange(e),\r\n onChangePage: (a) => this.onPageNumChange(a),\r\n }}\r\n page={this.state.pageNumber}\r\n tableLayout=\"fixed\"\r\n deleteAllOrder={this.props.deleteAllOrder}\r\n isCollectionRequest={true}\r\n isValid={true}\r\n onClickSetSortOrder={this.onClickSetSortOrder}\r\n />\r\n );\r\n }\r\n}\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n addressBookSearchParams: state.searchParams,\r\n sortOrderState: state.common.sortOrderState,\r\n };\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n setSortOrder: (data) => {\r\n dispatch(actions.setSortOrderState(data));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(withRouter(Orders));\r\n","import React, { useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid } from '@material-ui/core';\r\nimport DynamicMaterialTable from '../../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport ConfirmationDialog from '../../addressBook/confirmation/confirmation';\r\nimport CustomModal from '../../../framework/dialog/customDialog';\r\nexport default function ReviewCollectionData(props) {\r\n const { rows, columns, isSearchable, isSelectable, sorting, paging, pageSize, pageSizeOptions, title } = props;\r\n const [selectedRows, setSelectedRows] = useState([]);\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n const [confirmationMsg, setConfirmationMsg] = useState();\r\n const [_deleteAllOrders, setdeleteAllOrders] = useState(false);\r\n const addSelectedRows = (selectedRows) => {\r\n setSelectedRows(selectedRows);\r\n };\r\n\r\n const handleDialogClose = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n const onDialogConfirm = () => {\r\n if (_deleteAllOrders) {\r\n props.deleteAllOrder(props.isCollectionRequest, props.isValid);\r\n } else {\r\n props.deleteSelectedOrder(selectedRows);\r\n setSelectedRows([]);\r\n }\r\n setShowConfirmationDialog(false);\r\n };\r\n const onDialogCancel = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n const deleteOrderEntry = () => {\r\n // setConfirmationMsg(`This action will delete ${selectedRows.length} order and can't be undone.Select Delete all to confirm.`)\r\n setConfirmationMsg(`Are you sure you want to delete these collections?`);\r\n setShowConfirmationDialog(true);\r\n setdeleteAllOrders(false);\r\n };\r\n\r\n const deleteAllOrderEntry = () => {\r\n // setConfirmationMsg(`This action will delete ${selectedRows.length} order and can't be undone.Select Delete all to confirm.`)\r\n setConfirmationMsg(`All collections will be removed, are you sure you want to delete them?`);\r\n setShowConfirmationDialog(true);\r\n setdeleteAllOrders(true);\r\n };\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n deleteAllOrderEntry()}\r\n />\r\n \r\n \r\n deleteOrderEntry()}\r\n />\r\n \r\n \r\n \r\n );\r\n}\r\n\r\nReviewCollectionData.propTypes = {\r\n rows: PropTypes.array,\r\n columns: PropTypes.array,\r\n isSearchable: PropTypes.bool,\r\n isSelectable: PropTypes.bool,\r\n sorting: PropTypes.bool,\r\n paging: PropTypes.bool,\r\n pageSize: PropTypes.object,\r\n pageSizeOptions: PropTypes.object,\r\n title: PropTypes.string,\r\n confirmationMessage: PropTypes.string,\r\n deleteSelectedOrder: PropTypes.func,\r\n createAllShipments: PropTypes.func,\r\n createShipment: PropTypes.func,\r\n};\r\n","import React from 'react';\r\nimport { connect } from 'react-redux';\r\nimport './reviewOrders.scss';\r\nimport ReviewCollectionData from './reviewCollectionData';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { customTableSort, getCustomerAccountID } from '../../../utils/helperFunctions';\r\nimport { withRouter } from 'react-router-dom';\r\nimport { axiosConfig } from '../../../api/axios';\r\nimport * as actions from '../../../store/actions/index';\r\n\r\nclass ReviewCollections extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n tabIndex: 0,\r\n totalRecords: 0,\r\n isSearched: false,\r\n columns: [\r\n { title: 'id', field: 'id', hidden: true, width: 0 },\r\n {\r\n title: 'Customer ref.',\r\n field: 'customerReference',\r\n // customSort: (a, b) => customTableSort(a.customerReference, b.customerReference),\r\n render: (row) => this.customerNumberClicked(row)}>{row.customerReference}
,\r\n width: 120,\r\n sorting: true,\r\n },\r\n {\r\n title: 'Business/Customer name',\r\n field: 'customerName',\r\n render: (row) => this.customerNumberClicked(row)}>{row.customerName}
,\r\n sorting: true,\r\n width: 220,\r\n },\r\n {\r\n title: 'Collection postal code',\r\n field: 'postalCode',\r\n render: (row) => this.customerNumberClicked(row)}>{row.postalCode}
,\r\n sorting: true,\r\n width: 200,\r\n },\r\n {\r\n title: 'Source',\r\n field: 'source',\r\n render: (row) => this.customerNumberClicked(row)}>{row.source}
,\r\n sorting: false,\r\n width: 100,\r\n },\r\n {\r\n title: 'Sub-source',\r\n field: 'subSource',\r\n sorting: false,\r\n width: 100,\r\n },\r\n {\r\n title: 'Contact',\r\n field: 'contact',\r\n render: (row) => this.customerNumberClicked(row)}>{row.contact}
,\r\n sorting: true,\r\n width: 80,\r\n },\r\n {\r\n title: 'Collection date',\r\n field: 'dispatchDate',\r\n render: (row) => this.customerNumberClicked(row)}>{row.dispatchDate}
,\r\n sorting: true,\r\n width: 90,\r\n },\r\n ],\r\n orders_totalCount: 0,\r\n pageSize: 10,\r\n pageNumber: 0,\r\n isLoading: false,\r\n ordersData: [],\r\n };\r\n this.onClickSetSortOrder = this.onClickSetSortOrder.bind(this);\r\n }\r\n\r\n customerNumberClicked = (rowData) => {\r\n this.props.history.push({\r\n pathname: `/shipment/collectionRequest/${rowData.id}/true/false`,\r\n state: {\r\n isScanFlag: this.props.isScanFlag,\r\n }\r\n });\r\n };\r\n\r\n componentDidMount() {\r\n this.props.setSortOrder(``);\r\n this.getOrdersData();\r\n }\r\n\r\n componentDidUpdate(prevProps) {\r\n if (this.props.tabIndex === 3 && ((this.props.isSearched !== prevProps.isSearched || this.props.refreshList)\r\n || (this.props.addressBookSearchParams.split('=')[0] !== prevProps.addressBookSearchParams.split('=')[0]\r\n && this.props.addressBookSearchParams.split('=')[1] !== '' && prevProps.addressBookSearchParams !== ''))) {\r\n this.setState({ pageSize: this.state.pageSize, pageNumber: 0 }, () => {\r\n this.getOrdersData();\r\n });\r\n }\r\n }\r\n\r\n getOrdersData() {\r\n this.props.setRefreshList(false);\r\n this.setState({ isLoading: true });\r\n setTimeout(() => {\r\n const offset = this.state.pageSize * this.state.pageNumber;\r\n const limit = this.state.pageSize;\r\n axiosConfig\r\n .get(this.getUrl(offset, limit))\r\n .then((res) => {\r\n this.formatReviewCollectionData(res.data);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n this.formatReviewCollectionData([]);\r\n })\r\n .finally(() => this.setState({ isLoading: false }));\r\n }, 0);\r\n }\r\n\r\n getUrl = (offset, limit) => {\r\n let url = `${ServiceEndPoints.getOrders\r\n }?organization=${getCustomerAccountID()}&isValid=false&iscollectionrequest=true`;\r\n url += '&offset=' + offset;\r\n url += '&limit=' + limit;\r\n url += this.props.sortOrderState;\r\n url += this.props.addressBookSearchParams;\r\n return url;\r\n };\r\n\r\n formatReviewCollectionData = (result) => {\r\n let final_data = [];\r\n result?.orders?.forEach((element) => {\r\n const shipmentDetails = element?.shipmentModel?.shipments?.[0]?.shipmentDetails;\r\n const pickupAddress = element?.shipmentModel?.pickupAddress ?? {};\r\n\r\n final_data.push({\r\n id: element.id,\r\n customerReference: (element || {}).referenceNumber,\r\n customerName: pickupAddress.companyName || pickupAddress.name,\r\n source: element.sourceReference,\r\n subSource: element.subSource,\r\n alternateReference: shipmentDetails?.customerRef2,\r\n contact: pickupAddress.name,\r\n postalCode: pickupAddress.postalCode,\r\n dispatchDate: element?.shipmentModel?.pickup?.date,\r\n });\r\n });\r\n if (\r\n this.props.addressBookSearchParams !== '' &&\r\n this.props.addressBookSearchParams?.split('=')?.[1] &&\r\n this.props.addressBookSearchParams !== '&customerReferenceNumber=' &&\r\n this.props.addressBookSearchParams !== '&alternateReference=' &&\r\n final_data.length === 1\r\n ) {\r\n this.props.history.push({\r\n pathname: `/shipment/collectionRequest/${final_data[0].id}/true/false`,\r\n state: {\r\n isScanFlag: this.props.isScanFlag,\r\n }\r\n });\r\n }\r\n this.setState({\r\n ordersData: final_data,\r\n orders_totalCount: result.totalRecords ? result.totalRecords : 0,\r\n });\r\n this.props.reviewCollectionsTotalCounts(result.totalRecords ? result.totalRecords : 0);\r\n };\r\n\r\n onPageNumChange(pageNum) {\r\n this.setState({ pageNumber: pageNum }, () => {\r\n this.getOrdersData();\r\n });\r\n }\r\n\r\n onPageSizeChange(pageSize) {\r\n this.setState({ pageSize: pageSize }, () => {\r\n this.getOrdersData();\r\n });\r\n }\r\n\r\n onClickSetSortOrder(orderIn, orderBy) {\r\n if(orderIn === 'asc')\r\n {\r\n this.props.setSortOrder(`&sortBy=${orderBy}&sortIn=ascending`);\r\n }\r\n else if(orderIn === 'desc'){\r\n this.props.setSortOrder(`&sortBy=${orderBy}&sortIn=descending`);\r\n }\r\n else{\r\n this.props.setSortOrder(``);\r\n }\r\n this.setState({ pageNumber: 0 });\r\n this.getOrdersData();\r\n }\r\n\r\n render() {\r\n return (\r\n this.onPageSizeChange(e),\r\n onChangePage: (a) => this.onPageNumChange(a),\r\n }}\r\n page={this.state.pageNumber}\r\n deleteAllOrder={this.props.deleteAllOrder}\r\n isCollectionRequest={true}\r\n isValid={false}\r\n tableLayout=\"fixed\"\r\n onClickSetSortOrder={this.onClickSetSortOrder}\r\n />\r\n );\r\n }\r\n}\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n userDetails: state.auth.userDetails,\r\n addressBookSearchParams: state.searchParams,\r\n sortOrderState: state.common.sortOrderState,\r\n };\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n setSortOrder: (data) => {\r\n dispatch(actions.setSortOrderState(data));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(withRouter(ReviewCollections));\r\n","import React, { useState, useEffect } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { useHistory } from 'react-router-dom';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport Grid from '@material-ui/core/Grid';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\nimport { useDispatch, useSelector } from 'react-redux';\r\nimport * as actions from '../../../store/actions/index';\r\nimport { axiosConfig, GET, POST } from '../../../api/axios';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { setDropdownValues, getCustomerAccountID } from '../../../utils/helperFunctions';\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n SearchProcessOrderField: {\r\n marginTop: '-40px',\r\n },\r\n}));\r\n\r\nconst SearchOrders = (props) => {\r\n const inputRef = React.useRef();\r\n const classes = useStyles();\r\n const dispatch = useDispatch();\r\n const {\r\n formField: { processorderSearchFor, isScan, isScanPrint },\r\n setFieldValue,\r\n isFavourites,\r\n searchByOptions,\r\n errors,\r\n setFieldError,\r\n setErrors,\r\n setFieldTouched,\r\n } = props;\r\n let formProcessOrdersearchFor = '';\r\n let [isClearBtn, setIsClearBtn] = useState(false);\r\n const [barCodeLength, setbarCodeLength] = React.useState(0);\r\n const [barCodeStartPosition, setbarCodeStartPosition] = React.useState(0);\r\n const [barCodeEndPosition, setbarCodeEndPosition] = React.useState(0);\r\n const [fieldToSearchBy, setfieldToSearchBy] = React.useState('');\r\n let [isConfigure, setIsConfigure] = useState(false);\r\n const keyPressed = useSelector((state) => state.keyPressEvent.key);\r\n const storedFavorites = sessionStorage.getItem('favorite');\r\n \r\n const getClear = (event = null, queryParams = '') => {\r\n if (event) {\r\n event.preventDefault();\r\n }\r\n setIsClearBtn(false);\r\n props.onProcessOrdersChange(false);\r\n setFieldValue('processorderSearchFor', '');\r\n setFieldTouched('processorderSearchFor', false);\r\n dispatch(actions.setAddressBookSearchParams(''));\r\n };\r\n\r\n const getProcessOrders = (event = null) => {\r\n if (event) {\r\n event.preventDefault();\r\n }\r\n props.onProcessOrdersChange(true);\r\n setIsClearBtn(true);\r\n };\r\n\r\n useEffect(() => {\r\n dispatch(\r\n actions.setAddressBookSearchParams(\r\n `&${props.formikValues.processorderSearchBy.value}=${encodeURIComponent(props.formikValues.processorderSearchFor)}`,\r\n ),\r\n );\r\n }, [props.formikValues.processorderSearchBy, props.formikValues.processorderSearchFor]);\r\n\r\n // useEffect(() => {\r\n // setFieldValue('processorderSearchFor', '');\r\n // setIsClearBtn(false);\r\n // }, [setFieldValue]);\r\n\r\n useEffect(() => {\r\n setIsClearBtn(false);\r\n }, [props.formikValues.processorderSearchFor]);\r\n\r\n useEffect(() => {\r\n if (props.isOnlyOneItem && props.formikValues.isScanPrint) {\r\n // dispatch(actions.setAddressBookSearchParams(`&${props.formikValues.processorderSearchBy.value}=`));\r\n setFieldValue('processorderSearchFor', '');\r\n setFieldTouched('processorderSearchFor', true);\r\n inputRef.current.focus();\r\n props.onProcessOrdersSelectedItem(false);\r\n getProcessOrders();\r\n }\r\n }, [props.isOnlyOneItem]);\r\n\r\n useEffect(() => {\r\n if (props.isRefersFlag) {\r\n setFieldValue('processorderSearchFor', '');\r\n if (storedFavorites && JSON.parse(storedFavorites).length > 0 && searchByOptions.some(obj => obj.value === JSON.parse(storedFavorites)[0].value)) {\r\n setFieldValue('processorderSearchBy', JSON.parse(storedFavorites)[0])\r\n }\r\n else{\r\n setFieldValue('processorderSearchBy', searchByOptions[0]);\r\n }\r\n getProcessOrders();\r\n if(!props.formikValues.isScanPrint){\r\n props.UploadrefreshOrder(false);\r\n }\r\n }\r\n }, [props.isRefersFlag]);\r\n\r\n useEffect(() => {\r\n setFieldValue('processorderSearchFor', '');\r\n setFieldTouched('processorderSearchFor', true);\r\n inputRef.current.focus();\r\n }, [props.formikValues.processorderSearchBy.value]);\r\n\r\n useEffect(() => {\r\n GET(`${ServiceEndPoints.getBarcode}?organization=${getCustomerAccountID()}`)\r\n .then((res) => {\r\n setbarCodeLength(res.data.barCodeLength);\r\n setbarCodeStartPosition(res.data.startPosition);\r\n setbarCodeEndPosition(res.data.finalPosition);\r\n setfieldToSearchBy(res.data.fieldToSearchBy);\r\n setIsConfigure(true);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n\r\n return () => {\r\n dispatch(actions.setAddressBookSearchParams(''));\r\n }\r\n\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (keyPressed === 'Enter' && (props.formikValues.isScan || props.formikValues.isScanPrint) && isConfigure && !isClearBtn) {\r\n dispatch(actions.setKeyPressEvent(''));\r\n formProcessOrdersearchFor = props.formikValues.processorderSearchFor;\r\n if (fieldToSearchBy === 'customerReference') {\r\n setFieldValue(\r\n 'processorderSearchBy',\r\n setDropdownValues(searchByOptions || [], 'value', searchByOptions[0].value),\r\n );\r\n }\r\n if (fieldToSearchBy === 'alternateReference') {\r\n setFieldValue(\r\n 'processorderSearchBy',\r\n setDropdownValues(searchByOptions || [], 'value', searchByOptions[4].value),\r\n );\r\n }\r\n if (barCodeLength !== 0 && barCodeLength !== formProcessOrdersearchFor.length) {\r\n setFieldError('processorderSearchFor', 'Barcode length different than what is configured', false);\r\n }\r\n formProcessOrdersearchFor = formProcessOrdersearchFor.slice(barCodeStartPosition - 1, barCodeEndPosition);\r\n setFieldValue('processorderSearchFor', formProcessOrdersearchFor);\r\n getProcessOrders()\r\n setFieldTouched('processorderSearchFor', true);\r\n }\r\n setIsClearBtn(true);\r\n }, [keyPressed]);\r\n\r\n const ScannerThing = () => {\r\n };\r\n\r\n useEffect(() => {\r\n setFieldValue('processorderSearchFor', '');\r\n if (storedFavorites && JSON.parse(storedFavorites).length > 0 && searchByOptions.some(obj => obj.value === JSON.parse(storedFavorites)[0].value)) {\r\n setFieldValue('processorderSearchBy', JSON.parse(storedFavorites)[0])\r\n }\r\n else{\r\n setFieldValue('processorderSearchBy', searchByOptions[0]);\r\n }\r\n dispatch(actions.setAddressBookSearchParams(''));\r\n }, [props.tabIndex]);\r\n\r\n useEffect(() => {\r\n if (props.formikValues.isScan) {\r\n setFieldTouched('isScan', true);\r\n setFieldValue('isScanPrint', false)\r\n inputRef.current.focus();\r\n // if (props.formikValues.processorderSearchBy !== searchByOptions[5]) {\r\n // setFieldValue('processorderSearchFor', '');\r\n // }\r\n }\r\n props.onProcessOrdersScanFalgChange(props.formikValues.isScan, false)\r\n }, [props.formikValues.isScan, props.formikValues.processorderSearchBy]);\r\n\r\n useEffect(() => {\r\n if (props.formikValues.isScanPrint) {\r\n setFieldTouched('isScanPrint', true);\r\n setFieldValue('isScan', false)\r\n inputRef.current.focus();\r\n // if (props.formikValues.processorderSearchBy != searchByOptions[5]) {\r\n // setFieldValue('processorderSearchFor', '');\r\n // }\r\n }\r\n props.onProcessOrdersScanFalgChange(props.formikValues.isScanPrint, true)\r\n }, [props.formikValues.isScanPrint, props.formikValues.processorderSearchBy]);\r\n\r\n // useEffect(() => {\r\n // if (\r\n // props.formikValues.processorderSearchBy.value === 'dispatchDate' &&\r\n // props.formikValues.processorderSearchFor === ''\r\n // ) {\r\n // setFieldValue('processorderSearchFor', '');\r\n // }\r\n // }, [props.formikValues.processorderSearchBy]);\r\n\r\n return (\r\n \r\n
\r\n {props.tabIndex == 0 &&\r\n \r\n \r\n }\r\n \r\n \r\n \r\n \r\n getProcessOrders(event, '')}\r\n onClearSearch={(event) => getClear(event, '')}\r\n // isIconDisabled={errors.processorderSearchFor}\r\n selectProps={processorderSearchFor.selectProps.props}\r\n textProps={processorderSearchFor.textProps.props}\r\n isClearBtn={isClearBtn}\r\n inputRef={inputRef}\r\n favouriteFlag={true}\r\n {...processorderSearchFor.props}\r\n />\r\n \r\n\r\n {/* {isFavourites\r\n? null\r\n: (\r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n \r\n */}\r\n \r\n
\r\n );\r\n};\r\n\r\nSearchOrders.propTypes = {\r\n formField: PropTypes.object,\r\n formikValues: PropTypes.object,\r\n onProcessOrdersChange: PropTypes.func,\r\n totalRecords: PropTypes.string,\r\n setFieldValue: PropTypes.func,\r\n isFavourites: PropTypes.object,\r\n setFieldTouched: PropTypes.func,\r\n};\r\n\r\nexport default SearchOrders;\r\n","import React, { useEffect } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Form, Formik } from 'formik';\r\nimport SearchOrders from './searchOrders';\r\nimport { getYupSchemaFromMetaData } from '../../../utils/yupSchema/yupSchemaGenerator';\r\n\r\nconst SearchProcessOrders = (props) => {\r\n const formField = searchForm;\r\n const newSearchValidationSchema = getYupSchemaFromMetaData(formField, [], []);\r\n\r\n const initialValues = {\r\n processorderSearchFor: '',\r\n processorderSearchBy: searchByOptions[0],\r\n };\r\n\r\n return (\r\n \r\n \r\n {({ values, setFieldValue, errors, setFieldError, setErrors, setFieldTouched }) => (\r\n \r\n )}\r\n \r\n
\r\n );\r\n};\r\n\r\nSearchProcessOrders.propTypes = {\r\n tabIndex: PropTypes.string,\r\n onProcessOrdersChange: PropTypes.func,\r\n};\r\n\r\nexport default SearchProcessOrders;\r\n\r\nconst searchForm = {\r\n processorderSearchFor: {\r\n props: {\r\n name: 'processorderSearchFor',\r\n type: 'searchControl',\r\n },\r\n selectProps: {\r\n props: {\r\n name: 'processorderSearchBy',\r\n label: 'Search For',\r\n placeholder: \"Enter Customer's Number\",\r\n },\r\n },\r\n textProps: {\r\n props: {\r\n name: 'processorderSearchFor',\r\n label: 'Search For',\r\n placeholder: \"Enter Customer's Number\",\r\n },\r\n },\r\n validation: {\r\n name: 'processorderSearchFor',\r\n validationType: 'string',\r\n // validations: [\r\n // {\r\n // type: 'required',\r\n // params: ['Search for is required'],\r\n // },\r\n // ],\r\n },\r\n },\r\n favoriteSearchFor: {\r\n props: {\r\n name: 'favoriteSearchFor',\r\n type: 'searchControl',\r\n },\r\n selectProps: {\r\n props: {\r\n name: 'favoriteSearchBy',\r\n label: 'Search For',\r\n placeholder: \"Enter Customer's Number\",\r\n },\r\n },\r\n textProps: {\r\n props: {\r\n name: 'favoriteSearchFor',\r\n label: 'Search For',\r\n placeholder: \"Enter Customer's Number\",\r\n },\r\n },\r\n validation: {\r\n name: 'favoriteSearchFor',\r\n validationType: 'string',\r\n // validations: [\r\n // {\r\n // type: 'required',\r\n // params: ['Search for is required'],\r\n // },\r\n // ],\r\n },\r\n },\r\n isScan: {\r\n props: {\r\n name: 'isScan',\r\n label: 'Scanner',\r\n type: 'checkbox',\r\n },\r\n // value: false,\r\n },\r\n isScanPrint: {\r\n props: {\r\n name: 'isScanPrint',\r\n label: 'Scan & print',\r\n type: 'checkbox',\r\n },\r\n // value: false,\r\n },\r\n};\r\n\r\nconst searchByOptions = [\r\n {\r\n value: 'customerReferenceNumber',\r\n name: 'Customer ref.',\r\n },\r\n {\r\n value: 'businessName',\r\n name: 'Customer/Business name',\r\n },\r\n {\r\n value: 'postalCode',\r\n name: 'Postal code',\r\n },\r\n {\r\n value: 'contact',\r\n name: 'Contact',\r\n },\r\n {\r\n value: 'alternateReference',\r\n name: 'Alternative reference',\r\n },\r\n {\r\n value: 'dispatchDate',\r\n name: 'Dispatch date',\r\n },\r\n];\r\n","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from \"react\";\n\nvar _ref2 = /*#__PURE__*/React.createElement(\"g\", {\n id: \"Group_23451\",\n \"data-name\": \"Group 23451\",\n transform: \"translate(-1245.985 -82.327)\"\n}, /*#__PURE__*/React.createElement(\"path\", {\n id: \"Icon_material-refresh\",\n \"data-name\": \"Icon material-refresh\",\n d: \"M19.141,8.261a7.7,7.7,0,1,0,2,7.362h-2a5.771,5.771,0,1,1-5.437-7.7,5.692,5.692,0,0,1,4.061,1.713l-3.1,3.1H21.4V6Z\",\n transform: \"translate(1239.97 76.327)\",\n fill: \"#333\"\n}));\n\nfunction SvgRefresh(_ref, svgRef) {\n var title = _ref.title,\n titleId = _ref.titleId,\n props = _objectWithoutProperties(_ref, [\"title\", \"titleId\"]);\n\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 15.387,\n height: 15.397,\n viewBox: \"0 0 15.387 15.397\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, _ref2);\n}\n\nvar ForwardRef = /*#__PURE__*/React.forwardRef(SvgRefresh);\nexport default __webpack_public_path__ + \"static/media/refresh.f4377166.svg\";\nexport { ForwardRef as ReactComponent };","import React, { useEffect, useRef, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, IconButton, Typography } from '@material-ui/core';\r\nimport { getYupSchemaFromMetaData } from '../../../utils/yupSchema/yupSchemaGenerator';\r\nimport { Formik } from 'formik';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { axiosConfig } from '../../../api/axios';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport { useDispatch } from 'react-redux';\r\nimport * as actions from './../../../store/actions/index';\r\nimport FindImage from '../../../assets/images/polling_path.png';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { getCustomerAccountID } from '../../../utils/helperFunctions';\r\n\r\nconst UploadFile = ({ handleModal, refreshGrid, UploadRefreshGrid }) => {\r\n const formField = getFormField();\r\n const [schemas, setSchemas] = useState([]);\r\n const hiddenFileInput = useRef(null);\r\n const formikRef = useRef(null);\r\n const dispatch = useDispatch();\r\n const [fileExtension, setFileExtension] = useState('');\r\n // const [isfileExtension, setIsFileExtension] = useState(true);\r\n const [uploadedFile, setUploadedFile] = useState(null);\r\n\r\n const validationSchema = getYupSchemaFromMetaData(formField, [], []);\r\n const initialValues = {\r\n schemaName: '',\r\n fileBase64: '',\r\n sourceReference: '',\r\n };\r\n\r\n useEffect(() => {\r\n dispatch(actions.setLoaderLayOver(true));\r\n axiosConfig\r\n .get(`${ServiceEndPoints.getSchemas}?organization=${getCustomerAccountID()}`)\r\n .then((res) => {\r\n let finalData = res.data?.orderFileSchemas.filter(val => val?.isEnabled);\r\n if (!(res.data?.orderFileSchemas.find(schema => schema.schemaName.toLowerCase() === \"select\"))) {\r\n finalData.unshift({ value: \"\", schemaName: \"Select\" })\r\n }\r\n setSchemas(finalData);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n setSchemas([]);\r\n })\r\n .finally(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n });\r\n }, []);\r\n\r\n const onSelectFile = (event) => {\r\n if (\r\n event?.target?.files?.[0]\r\n ) {\r\n setUploadedFile(event.target.files[0])\r\n formikRef.current.setFieldValue('sourceReference', event.target.files[0].name);\r\n const reader = new FileReader();\r\n reader.readAsDataURL(event.target.files[0]);\r\n reader.onload = (loadedEvent) => {\r\n formikRef.current.setFieldValue('fileBase64', loadedEvent.target.result?.split?.(',')?.[1]);\r\n };\r\n }\r\n };\r\n\r\n const openFileDialog = () => {\r\n hiddenFileInput.current.click();\r\n };\r\n\r\n const fileClicked = (event) => {\r\n event.target.value = '';\r\n };\r\n\r\n const handleSubmit = () => {\r\n const extension = formikRef.current?.values?.schemaName?.fileExtension?.slice((formikRef.current?.values?.schemaName?.fileExtension || \"\").lastIndexOf(\".\") + 1)\r\n\r\n if (extension?.toLowerCase()?.trim() === `${uploadedFile?.name?.slice((uploadedFile?.name || \"\").lastIndexOf(\".\") + 1)}`?.toLowerCase()) {\r\n dispatch(actions.setLoaderLayOver(true));\r\n const formikValues = formikRef.current.values;\r\n const encodeURIName = encodeURIComponent(formikValues?.schemaName?.schemaName)\r\n axiosConfig\r\n .post(\r\n `${ServiceEndPoints.orderFileUpload}?organization=${getCustomerAccountID()}&schemaName=${encodeURIName\r\n }&sourceReference=${formikValues.sourceReference}`,\r\n {\r\n fileBase64: formikValues.fileBase64,\r\n },\r\n )\r\n .then((res) => {\r\n handleModal(false);\r\n dispatch(actions.setAppSnackBarData({ msg: 'File uploaded successfully' }));\r\n })\r\n .catch((err) => {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'File upload failed',\r\n },\r\n ],\r\n }),\r\n );\r\n console.log(err);\r\n })\r\n .finally(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n refreshGrid?.();\r\n UploadRefreshGrid?.();\r\n });\r\n }\r\n else {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'The file extension for the selected schema is incorrect',\r\n },\r\n ],\r\n }),\r\n );\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n if (!formikRef.current?.values?.schemaName) {\r\n formikRef.current.setFieldValue('schemaName', schemas[0]);\r\n }\r\n }, [formikRef.current?.values?.schemaName, schemas]);\r\n\r\n return (\r\n \r\n \r\n {({ isValid }) => (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ),\r\n }}\r\n fullWidth\r\n />\r\n \r\n \r\n \r\n Note: Files having orders up to 1000 are allowed, if the number of orders are more please upload file via Order processor\r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n onSelectFile(event)}\r\n ref={hiddenFileInput}\r\n name=\"imageField\"\r\n onClick={fileClicked}\r\n />\r\n \r\n \r\n >\r\n )}\r\n \r\n \r\n );\r\n};\r\n\r\nUploadFile.propTypes = {\r\n handleModal: PropTypes.func.isRequired,\r\n refreshGrid: PropTypes.func,\r\n UploadRefreshGrid: PropTypes.func\r\n};\r\n\r\nexport default UploadFile;\r\n\r\nconst getFormField = () => {\r\n return {\r\n schemaName: {\r\n props: {\r\n name: 'schemaName',\r\n label: 'Select schema',\r\n type: 'select',\r\n isRequired: true,\r\n displayField: 'schemaName',\r\n },\r\n validation: {\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Schema is required'],\r\n },\r\n {\r\n type: 'test',\r\n params: [\r\n '',\r\n 'Schema is required',\r\n (value) => {\r\n if (!value?.id) {\r\n return false;\r\n }\r\n return true;\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n },\r\n fileBase64: {\r\n props: {\r\n name: 'fileBase64',\r\n label: 'Select file',\r\n type: 'text',\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Order file is required'],\r\n },\r\n ],\r\n },\r\n },\r\n sourceReference: {\r\n props: {\r\n name: 'sourceReference',\r\n label: 'Select file',\r\n type: 'text',\r\n isRequired: true,\r\n },\r\n validation: {\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['File is required'],\r\n },\r\n ],\r\n },\r\n },\r\n };\r\n};\r\n","export default \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAASCAYAAAC9+TVUAAAAAXNSR0IArs4c6QAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAEaADAAQAAAABAAAAEgAAAADq+8vrAAABF0lEQVQ4EbWSMW7CQBBFnZADULn2EeAGm9pFwg2cijY3QHR0kI4OcgLSpsKUVHGbzinSQwdV8r60I9mwIEyULz1mZnfma2wTxXH8HUXRz7WkaTq68cNPxBKa6pmB4s5PFSqaOtDvNGObKL9WQ9ukh8Obd2kTOyccS86Faa7ETDZ2SlSeV+pzaanL23Mdl979q0nCFguw/8+S3EFQoU0SOj9AX+4eurACGWVwJHux1YsJhYYeK4cFuV74AOZQU2iTBzpkdCidJeCgppBJreGSwh5nTLPWbfshR8x9bsH5xHpVduClxY+efw9f8Alb6INM1yA5WMAOXkG94h2mEFTGqUzsEyvmvp4RG8nRLRKQMpChHuNPOjL4BXwSRz4UWctKAAAAAElFTkSuQmCC\"","import React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport CircularProgress from '@material-ui/core/CircularProgress';\r\nimport Typography from '@material-ui/core/Typography';\r\nimport Box from '@material-ui/core/Box';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\n\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n primary: {\r\n color: '#76BD22 !important',\r\n height:'230px !important',\r\n width:'230px !important'\r\n },\r\n sizeAndColor:{\r\n fontSize: '2.75rem',\r\n color: '#76BD22 !important',\r\n }\r\n }));\r\n\r\nfunction CircularProgressWithLabel(props) {\r\n const classes = useStyles();\r\n\r\n return (\r\n \r\n \r\n \r\n {props.text} \r\n \r\n \r\n );\r\n}\r\n\r\nCircularProgressWithLabel.propTypes = {\r\n value: PropTypes.number.isRequired,\r\n text: PropTypes.string.isRequired\r\n};\r\n\r\nexport default CircularProgressWithLabel;","import React from 'react';\r\nimport { connect } from 'react-redux';\r\nimport Badge from '@material-ui/core/Badge';\r\nimport { Grid, AppBar, Tabs, Tab, Backdrop, SvgIcon, IconButton } from '@material-ui/core/';\r\nimport TabPanel from '../../../components/shared/tabPanel';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport { GET, POST } from '../../../api/axios';\r\nimport Orders from '../../../components/addShipment/processOrders/orders';\r\nimport ReviewOrders from '../../../components/addShipment/processOrders/reviewOrders';\r\nimport Collections from '../../../components/addShipment/processOrders/collections';\r\nimport ReviewCollections from '../../../components/addShipment/processOrders/reviewCollections';\r\nimport SearchProcessOrders from '../../../components/addShipment/processOrders/searchProcessOrders';\r\nimport './processOrders.scss';\r\nimport { printZplLabels, printPDF } from '../../../utils/PrintHelper';\r\nimport { customTableSort, getCustomerAccountID } from '../../../utils/helperFunctions';\r\nimport { ReactComponent as RefreshIcon } from '../../../assets/images/refresh.svg';\r\nimport { ReactComponent as uploadIcon } from '../../../assets/images/upload.svg';\r\nimport CustomDialog from '../../../framework/dialog/customDialog';\r\nimport UploadFile from '../../../components/addShipment/uploadFile/uploadFile';\r\nimport * as actions from '../../../store/actions/index';\r\nimport CircularProgressWithLabel from '../../../framework/spinner/circularProgressBar';\r\nimport CustomModal from '../../../framework/dialog/customDialog';\r\nimport ConfirmationDialog from '../../../components/addressBook/confirmation/confirmation';\r\n\r\nclass ProcessOrders extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.counter = 0;\r\n this.success = 0;\r\n this.failed = 0;\r\n this.collectionRequest = false;\r\n this.allOrders = [];\r\n this.state = {\r\n formikRef: React.createRef(),\r\n tabIndex: 0,\r\n tabIndex_className: 'Orders-Tab-panel',\r\n completionPercentage: 0,\r\n isSearched: false,\r\n isOnlyOneItem: false,\r\n isScanFlag: false,\r\n isScanPrintFlag: false,\r\n inProgress: false,\r\n reviewOrderCount: '0',\r\n showConfirmationDialog: false,\r\n isRefersFlag: false,\r\n // Collectionscolumns: [\r\n // { title: 'id', field: 'id', hidden: true, width: 0 },\r\n // {\r\n // title: 'Customer reference',\r\n // field: 'customerReference',\r\n // // customSort: (a, b) => customTableSort(a.customerReference, b.customerReference),\r\n // width: 150,\r\n // },\r\n // {\r\n // title: 'Business/Customer name',\r\n // field: 'customerName',\r\n // sorting: true,\r\n // width: 150,\r\n // },\r\n // {\r\n // title: 'Source',\r\n // field: 'source',\r\n // sorting: true,\r\n // width: 200,\r\n // },\r\n // {\r\n // title: 'Postal code',\r\n // field: 'postalCode',\r\n // sorting: true,\r\n // width: 80,\r\n // },\r\n // {\r\n // title: 'Alternative reference',\r\n // field: 'alternateReference',\r\n // sorting: true,\r\n // width: 80,\r\n // },\r\n // {\r\n // title: 'Contact',\r\n // field: 'contact',\r\n // sorting: true,\r\n // width: 100,\r\n // },\r\n // {\r\n // title: 'Collection date',\r\n // field: 'collectionDate',\r\n // sorting: true,\r\n // width: 90,\r\n // },\r\n // ],\r\n ReviewCollectionsTotalCounts: '0',\r\n openModal: false,\r\n };\r\n this.onProcessOrdersChange = this.onProcessOrdersChange.bind(this);\r\n this.onProcessOrdersSelectedItem = this.onProcessOrdersSelectedItem.bind(this);\r\n this.onProcessOrdersScanFalgChange = this.onProcessOrdersScanFalgChange.bind(this);\r\n this.deleteSelectedOrder = this.deleteSelectedOrder.bind(this);\r\n this.deleteAllOrder = this.deleteAllOrder.bind(this);\r\n this.createAllShipments = this.createAllShipments.bind(this);\r\n this.createSelectedShipments = this.createSelectedShipments.bind(this);\r\n this.setReviewOrderCount = this.setReviewOrderCount.bind(this);\r\n this.reviewCollectionsTotalCounts = this.reviewCollectionsTotalCounts.bind(this);\r\n this.createAllCollections = this.createAllCollections.bind(this);\r\n this.createSelectedCollections = this.createSelectedCollections.bind(this);\r\n this.refreshProcessOrder = this.refreshProcessOrder.bind(this);\r\n this.refreshProcessOrder = this.UploadrefreshOrder.bind(this);\r\n this.pauseCount = this.props?.printerConfiguration?.pauseCount ?? 50;\r\n this.getUpdatedCounts();\r\n }\r\n reviewCollectionsTotalCounts = (count) => {\r\n this.setState({ ReviewCollectionsTotalCounts: count });\r\n };\r\n\r\n setReviewOrderCount = (orderCount) => {\r\n this.setState({ reviewOrderCount: orderCount });\r\n };\r\n deleteAllOrder = async (isCollectionRequest, isValid) => {\r\n await POST(`${ServiceEndPoints.deleteOrders}/delete?organization=${getCustomerAccountID()}&isDeleteAll=true&isValid=${isValid}&iscollectionrequest=${isCollectionRequest}`, [])\r\n .then((response) => {\r\n this.props.setSnackBarMsg({ msg: 'Shipment(s) deleted successfully' });\r\n this.refreshProcessOrder(true);\r\n })\r\n .catch((error) => {\r\n this.props.setSnackBarMsg({ type: 'error', msg: 'Orders were not deleted, please try again.' });\r\n this.refreshProcessOrder();\r\n });\r\n }\r\n deleteSelectedOrder = (orders) => {\r\n const itemsToBeDeleted = orders.map((order) => {\r\n return order.id;\r\n });\r\n const payload = itemsToBeDeleted;\r\n POST(`${ServiceEndPoints.deleteOrders}/delete`, payload)\r\n .then((response) => {\r\n this.props.setSnackBarMsg({ msg: 'Shipment(s) deleted successfully' });\r\n this.refreshProcessOrder(true);\r\n })\r\n .catch((error) => {\r\n this.props.setSnackBarMsg({ type: 'error', msg: 'Orders were not deleted, please try again.' });\r\n this.refreshProcessOrder();\r\n });\r\n };\r\n\r\n getUpdatedCounts = () => {\r\n const orderUrl = `${ServiceEndPoints.getOrders\r\n }?organization=${getCustomerAccountID()}&isValid=false&isCollectionRequest=false&offset=0&limit=1`;\r\n GET(orderUrl)\r\n .then((res) => {\r\n this.setReviewOrderCount(res?.data?.totalRecords ?? '0');\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n this.setReviewOrderCount('0');\r\n });\r\n\r\n const collectionUrl = `${ServiceEndPoints.getOrders\r\n }?organization=${getCustomerAccountID()}&isValid=false&isCollectionRequest=true&offset=0&limit=1`;\r\n GET(collectionUrl)\r\n .then((res) => {\r\n this.reviewCollectionsTotalCounts(res?.data?.totalRecords ?? '0');\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n this.reviewCollectionsTotalCounts('0');\r\n });\r\n };\r\n\r\n printLabels = (res, isCollectionRequest,order) => {\r\n const labels = [];\r\n const invoices = [];\r\n res.forEach((shipment) => {\r\n shipment?.shipments[0]?.labels?.forEach((label) => {\r\n labels.push(label);\r\n });\r\n shipment?.shipments[0]?.invoices?.forEach((invoice) => {\r\n invoices.push(invoice);\r\n });\r\n });\r\n if (labels.length > 0) {\r\n this.success += 1;\r\n } else this.failed += 1;\r\n !isCollectionRequest && labels.map((label) => {\r\n if (this.props.printerConfiguration.labelType == 1) {\r\n printZplLabels(label, order?.printerQueueName || this.props.printerConfiguration?.labelPrinter);\r\n } else {\r\n printPDF(label, order?.printerQueueName || this.props.printerConfiguration?.labelPrinter, \"Label\");\r\n }\r\n });\r\n !isCollectionRequest && invoices.map((invoice) => {\r\n printPDF(invoice, this.props.printerConfiguration?.otherReportsPrinter, \"Invoice\");\r\n });\r\n // return true;\r\n }\r\n\r\n createShipmentsFromOrders = (order, isCollectionRequest) => {\r\n const url = `${ServiceEndPoints.createOrders\r\n }?organization=${getCustomerAccountID()}&isCreateAll=false&isCollectionRequest=${isCollectionRequest}&labelFormat=${this.props?.printerConfiguration?.labelType == 2 ? \"PDF\" : \"ZPL\"}`;\r\n const payload = [order.id];\r\n return POST(url, payload)\r\n .then((response) => {\r\n this.printLabels(response.data,isCollectionRequest,order);\r\n return true;\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n this.failed += 1;\r\n return false;\r\n });\r\n };\r\n getIdsWithStatus = (type, status = 'Order processing') => {\r\n let url = `${ServiceEndPoints.orderswithstatus\r\n }?organization=${getCustomerAccountID()}&status=${status}&type=${type}`;\r\n url += this.props.sortOrderState;\r\n return GET(url)\r\n .then((res) => {\r\n return res.data.orders.map(order => { return { ...order, id: order.orderId } }).filter((val) => val.id);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n return [];\r\n });\r\n };\r\n\r\n createOrders = async (orders, isCollectionRequest = false, counter = 0, success = 0, failed = 0) => {\r\n this.counter = counter;\r\n this.collectionRequest = isCollectionRequest;\r\n this.setState({ inProgress: true, showConfirmationDialog: false });\r\n let flag = true;\r\n this.success = success;\r\n this.failed = failed;\r\n let len = orders.length;\r\n while (this.counter < len) {\r\n await this.createShipmentsFromOrders(orders[this.counter], this.collectionRequest);\r\n this.counter++;\r\n this.setState({\r\n completionPercentage: (this.counter / len) * 100,\r\n });\r\n if (this.counter > 0 && this.counter !== len && this.counter % this.pauseCount === 0) {\r\n this.setState({\r\n inProgress: false,\r\n showConfirmationDialog: true,\r\n });\r\n flag = false;\r\n break;\r\n }\r\n }\r\n if (flag) {\r\n setTimeout(() => {\r\n this.setState({\r\n inProgress: false,\r\n completionPercentage: 0,\r\n });\r\n }, 1000);\r\n this.props.setSnackBarMsg({ msg: `${this.success} shipment(s) created successfully` });\r\n this.refreshProcessOrder(true);\r\n }\r\n };\r\n createAllShipments = async () => {\r\n this.allOrders = await this.getIdsWithStatus('order');\r\n if (this.allOrders.length > 0) {\r\n this.setState({\r\n inProgress: true,\r\n });\r\n this.allOrders.length > 0 && this.createOrders(this.allOrders);\r\n }\r\n };\r\n\r\n createSelectedShipments = (orders) => {\r\n this.allOrders = orders;\r\n this.setState({\r\n inProgress: true,\r\n });\r\n this.createOrders(this.allOrders);\r\n };\r\n\r\n createAllCollections = async () => {\r\n this.allOrders = await this.getIdsWithStatus('collection');\r\n if (this.allOrders.length > 0) {\r\n this.setState({\r\n inProgress: true,\r\n });\r\n this.allOrders.length > 0 && this.createOrders(this.allOrders, true);\r\n }\r\n };\r\n\r\n createSelectedCollections = (orders) => {\r\n this.allOrders = orders;\r\n this.setState({\r\n inProgress: true,\r\n });\r\n this.createOrders(this.allOrders, true);\r\n };\r\n\r\n setRefreshList = (value) => {\r\n this.setState({\r\n refreshList: value\r\n })\r\n }\r\n\r\n UploadrefreshOrder = (isRefersFlag = false) => {\r\n this.setState({ isRefersFlag: isRefersFlag });\r\n }\r\n refreshProcessOrder = (refreshAllCounts = false) => {\r\n refreshAllCounts && this.getUpdatedCounts();\r\n this.setState({ isSearched: true, refreshList: true });\r\n };\r\n\r\n onProcessOrdersSelectedItem(value) {\r\n this.setState({ isOnlyOneItem: value })\r\n }\r\n onProcessOrdersChange(value) {\r\n // this.setState({ isSearched: value });\r\n this.setState({ isSearched: !this.state.isSearched })\r\n // this.refreshProcessOrder();\r\n }\r\n\r\n onProcessOrdersScanFalgChange(value, flag) {\r\n if (flag) {\r\n this.setState({ isScanPrintFlag: (value) ? value : false })\r\n } else {\r\n this.setState({ isScanFlag: (value) ? value : false })\r\n }\r\n }\r\n\r\n handleTabChange = (event, index) => {\r\n this.setState({ isSearched: false, isRefersFlag: true});\r\n this.setState({ tabIndex: index });\r\n this.props._setAddressBookSearchParams('');\r\n if (index === 0) {\r\n this.setState({ tabIndex_className: 'Orders-Tab-panel' });\r\n } else if (index === 1) {\r\n this.setState({ tabIndex_className: 'Review-Orders-Tab-panel' });\r\n } else if (index === 2) {\r\n this.setState({ tabIndex_className: 'Collections-Tab-panel' });\r\n } else if (index === 3) {\r\n this.setState({ tabIndex_className: 'Review-Collections-Tab-panel' });\r\n }\r\n };\r\n\r\n componentDidMount = () => {\r\n if (\r\n this.props.history.location &&\r\n this.props.history.location.state !== undefined &&\r\n this.props.history.location.state !== null\r\n ) {\r\n if (this.props.history.location.state.isScanFlag !== undefined) {\r\n this.state.formikRef.current.setFieldValue('isScan', this.props.history.location.state.isScanFlag);\r\n }\r\n if (\r\n this.props.history.location.state.isCollectionRequest &&\r\n this.props.history.location.state.isReviewCollection\r\n ) {\r\n this.setState({ tabIndex: 3 });\r\n } else if (\r\n this.props.history.location.state.isCollectionRequest &&\r\n !this.props.history.location.state.isReviewCollection\r\n ) {\r\n this.setState({ tabIndex: 2 });\r\n } else if (\r\n !this.props.history.location.state.isCollectionRequest &&\r\n this.props.history.location.state.isProcessOrder\r\n ) {\r\n this.setState({ tabIndex: 0 });\r\n } else if (\r\n !this.props.history.location.state.isCollectionRequest &&\r\n !this.props.history.location.state.isProcessOrder\r\n ) {\r\n this.setState({ tabIndex: 1 });\r\n }\r\n }\r\n };\r\n\r\n handleModal = () => {\r\n this.setState({ openModal: this.state.openModal ? false : true });\r\n };\r\n\r\n handleDialogClose = () => {\r\n this.setState({ showConfirmationDialog: false, completionPercentage: 0 });\r\n this.props.setSnackBarMsg({ msg: `${this.success} shipment(s) created successfully` });\r\n this.refreshProcessOrder();\r\n };\r\n\r\n render() {\r\n return (\r\n \r\n \r\n {\r\n this.refreshProcessOrder(true);\r\n }}\r\n >\r\n Refresh \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Review orders \r\n \r\n \r\n \r\n \r\n \r\n }\r\n className=\"Tab-panel\"\r\n >\r\n \r\n \r\n \r\n Review collections \r\n \r\n \r\n \r\n {/* {this.state.ReviewCollectionsTotalCounts} */}\r\n \r\n \r\n }\r\n className=\"Tab-panel\"\r\n />\r\n \r\n this.handleModal()}>\r\n \r\n Upload file \r\n
\r\n \r\n \r\n\r\n\r\n \r\n \r\n \r\n \r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n this.handleModal()}\r\n title=\"Upload file\"\r\n >\r\n {\r\n this.refreshProcessOrder(true);\r\n }}\r\n UploadRefreshGrid={() => {\r\n this.UploadrefreshOrder(true);\r\n }}\r\n />\r\n \r\n\r\n \r\n \r\n \r\n {\r\n this.handleDialogClose();\r\n }}\r\n maxWidth=\"sm\"\r\n >\r\n {\r\n this.createOrders(this.allOrders, this.collectionRequest, this.counter, this.success, this.failed);\r\n }}\r\n OnCancel={() => {\r\n this.handleDialogClose();\r\n }}\r\n />\r\n \r\n \r\n );\r\n }\r\n}\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n JSPMStatus: state.common.isJSPMInstalled,\r\n printerConfiguration: state.common.printerConfiguration,\r\n availablePrinter: state.common.availablePrinter,\r\n genralConfiguration: state.common.commonConfiguration,\r\n sortOrderState: state.common.sortOrderState,\r\n };\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n setSnackBarMsg: (data) => {\r\n dispatch(actions.setAppSnackBarData(data));\r\n },\r\n _setAddressBookSearchParams: (data) => {\r\n dispatch(actions.setAddressBookSearchParams(data));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(ProcessOrders);\r\n","import { Grid } from '@material-ui/core';\r\nimport React from 'react';\r\nimport CustomAccordion from '../../../framework/accordion/customAccordion';\r\nimport FormRenderer from '../../../framework/Inputs/formRenderer/formRenderer';\r\nimport { filedToSearchByOptions } from '../../../utils/constants/constants';\r\n\r\n\r\nconst BarcodeConfigurationDetails = (props) => {\r\n const {\r\n formField: { filedToSearchBy, startPosition, finalPosition, barCodeLength },\r\n formikValues,\r\n setFieldValue,\r\n } = props;\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n );\r\n};\r\n\r\n\r\nexport default BarcodeConfigurationDetails;\r\n","import React, { useEffect, useRef, useState } from 'react';\r\nimport { Grid, Snackbar } from '@material-ui/core';\r\nimport { Form, Formik } from 'formik';\r\nimport { connect, useDispatch } from 'react-redux';\r\nimport ConfirmationDialog from '../../../components/addressBook/confirmation/confirmation';\r\nimport InputButton from '../../../framework/Inputs/inputButton/inputButton';\r\nimport CustomModal from '../../../framework/modal/modal';\r\nimport { getYupSchemaFromMetaData } from '../../../utils/yupSchema/yupSchemaGenerator';\r\n// import barcodeConfigurationForm from '../../../utils/formConfig/configuration/barcodeConfigurationForm/barcodeConfigurationForm';\r\nimport BarcodeConfigurationDetails from './BarcodeConfigurationDetails';\r\nimport { useHistory } from 'react-router-dom';\r\nimport { formatBarcodeObj, setBarcodevaluesToForm, getCustomerAccountID } from '../../../utils/helperFunctions';\r\nimport { axiosConfig, GET, POST } from '../../../api/axios';\r\nimport { filedToSearchByOptions } from '../../../utils/constants/constants';\r\nimport { ServiceEndPoints } from '../../../utils/constants/ApiConstant';\r\nimport * as actions from '../../../store/actions/index';\r\nimport './BarCodeConfiguration.scss';\r\n\r\nconst BarCodeConfiguration = (props) => {\r\n const { formId, formField } = barcodeConfigurationForm;\r\n const formikRef = useRef(null);\r\n const newMainBarCodeSchema = getYupSchemaFromMetaData(formField, [], []);\r\n const [confirmationMsg, setConfirmationMsg] = useState('');\r\n const { onLoad } = props;\r\n\r\n const [showCancelConfirmationDialog, setShowCancelConfirmationDialog] = useState(false);\r\n\r\n const initialValues = {\r\n startPosition: '',\r\n finalPosition: '',\r\n filedToSearchBy: filedToSearchByOptions[0],\r\n barCodeLength: '',\r\n };\r\n const history = useHistory();\r\n const dispatch = useDispatch();\r\n let reqFields = ['filedToSearchBy', 'startPosition', 'finalPosition', 'barCodeLength'];\r\n\r\n const handleSubmit = (values, errors, resetForm) => {\r\n if (!isFormInValid(errors, values) && values.filedToSearchBy.name !== 'Select') {\r\n const reqObj = formatBarcodeObj(values);\r\n axiosConfig\r\n .post(`${ServiceEndPoints.getBarcode}?organization=${getCustomerAccountID()}`, reqObj)\r\n .then((res) => {\r\n dispatch(actions.setAppSnackBarData({ msg: 'Barcode configuration saved successfully' }));\r\n })\r\n .catch((err) => {\r\n console.log(err, 'err');\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'Error in saving schema: Error status',\r\n },\r\n ],\r\n }),\r\n );\r\n // dispatch(actions.setAppSnackBarData({msg:\"Error in saving schema: Error status\"}))\r\n });\r\n } else {\r\n dispatch(\r\n actions.setBottomAlert({\r\n msgs: [\r\n {\r\n type: 'error',\r\n msg: 'The form has errors, please correct and try again',\r\n },\r\n ],\r\n }),\r\n );\r\n // dispatch(actions.setAppSnackBarData({ type: 'error', msg: 'The form has errors, please correct and try again' }));\r\n }\r\n };\r\n\r\n const isFormInValid = (errors, values) => {\r\n for (let err in errors) {\r\n if (reqFields.some((fieldName) => fieldName === err)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n };\r\n\r\n const cancelSchema = () => {\r\n setConfirmationMsg('Are you sure you want to cancel, all unsaved changes will be lost?');\r\n setShowCancelConfirmationDialog(true);\r\n };\r\n const handleDialogClose = () => {\r\n setShowCancelConfirmationDialog(false);\r\n };\r\n\r\n const onDialogCancel = () => {\r\n setShowCancelConfirmationDialog(false);\r\n };\r\n\r\n const onCancelDialogConfirm = () => {\r\n history.goBack();\r\n setShowCancelConfirmationDialog(false);\r\n };\r\n\r\n useEffect(() => {\r\n GET(`${ServiceEndPoints.getBarcode}?organization=${getCustomerAccountID()}`)\r\n .then((res) => {\r\n if (Object.keys(res.data).length > 0) {\r\n res.data['destinationCountry'] = 'GBR';\r\n onLoad({\r\n loadedFrom: 'dropdownResponse',\r\n loadedResponse: { ...res.data },\r\n });\r\n setTimeout(() => {\r\n formikRef.current.setValues(setBarcodevaluesToForm(res.data, formikRef.current.values));\r\n }, 0);\r\n setTimeout(() => {\r\n onLoad({ loadedFrom: '' });\r\n }, 2000);\r\n }\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n }, []);\r\n\r\n return (\r\n \r\n \r\n {({ values, setFieldValue, errors, setFieldTouched, resetForm, setValues }) => (\r\n \r\n )}\r\n \r\n
\r\n );\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n onLoad: (loadedFrom) => {\r\n dispatch(actions.setLoadedFrom(loadedFrom));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(null, mapDispatchToProps)(BarCodeConfiguration);\r\n\r\nconst barcodeConfigurationForm = {\r\n formId: 'barcodeConfigurationForm',\r\n formField: {\r\n filedToSearchBy: {\r\n props: {\r\n name: 'filedToSearchBy',\r\n label: 'Field to search by',\r\n type: 'select',\r\n displayField: 'name',\r\n isRequired: true,\r\n hasDefaultValue: true,\r\n },\r\n validation: {\r\n name: 'filedToSearchBy',\r\n validationType: 'object',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Field to search by is required'],\r\n },\r\n ],\r\n },\r\n },\r\n startPosition: {\r\n props: {\r\n name: 'startPosition',\r\n label: 'Start position',\r\n type: 'text',\r\n isRequired: true,\r\n placeholder: 'Enter',\r\n },\r\n validation: {\r\n name: 'startPosition',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Start position is required'],\r\n },\r\n {\r\n type: 'typeError',\r\n params: ['Should be a valid number'],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Should be a valid number'],\r\n },\r\n ],\r\n },\r\n },\r\n finalPosition: {\r\n props: {\r\n name: 'finalPosition',\r\n label: 'Final position',\r\n type: 'text',\r\n isRequired: true,\r\n placeholder: 'Enter',\r\n },\r\n validation: {\r\n name: 'finalPosition',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Final position is required'],\r\n },\r\n {\r\n type: 'typeError',\r\n params: ['Should be a valid number'],\r\n },\r\n {\r\n type: 'min',\r\n params: [1, 'Should be a valid number'],\r\n },\r\n ],\r\n },\r\n },\r\n barCodeLength: {\r\n props: {\r\n name: 'barCodeLength',\r\n label: 'Barcode length (Ignore if not this length)',\r\n type: 'text',\r\n placeholder: 'Enter',\r\n },\r\n validation: {\r\n name: 'barCodeLength',\r\n validationType: 'number',\r\n validations: [\r\n {\r\n type: 'typeError',\r\n params: ['Should be a valid number'],\r\n },\r\n ],\r\n },\r\n },\r\n },\r\n};\r\n","import { Divider, Grid, List, ListItem, ListItemText } from '@material-ui/core';\r\nimport React from 'react';\r\nimport Typography from '@material-ui/core/Typography';\r\nimport InputButton from '../Inputs/inputButton/inputButton';\r\n\r\n// import { GET } from '../../api/axios';\r\n\r\nconst FaqSideNav = (props) => {\r\n const { showCheckboxes, selectedMenu, catagoryValues, userRole, addFAQ, isUpdate } = props;\r\n\r\n const selectOptions = (data) => {\r\n props.setSelectedMenu(data);\r\n props.setIsUpdate(!isUpdate)\r\n };\r\n\r\n return (\r\n \r\n
\r\n {showCheckboxes && userRole\r\n? (\r\n List of categories \r\n )\r\n: (\r\n Choose the key area where you need help \r\n )}\r\n \r\n\r\n
\r\n\r\n
\r\n {catagoryValues.map((option, key) => {\r\n return (\r\n selectOptions(option.name)} key={key}>\r\n \r\n \r\n );\r\n })}\r\n
\r\n\r\n {userRole\r\n? (\r\n <>\r\n {' '}\r\n
{' '}\r\n
\r\n \r\n addFAQ(e, 'textBox')} />\r\n \r\n {' '}\r\n >\r\n )\r\n: (\r\n <>>\r\n )}\r\n
\r\n );\r\n};\r\n\r\nexport default FaqSideNav;\r\n","import React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Accordion, AccordionDetails, AccordionSummary, Checkbox, FormControlLabel, Grid, Typography } from '@material-ui/core';\r\nimport { ExpandMore } from '@material-ui/icons';\r\nimport ReactHtmlParser from 'react-html-parser';\r\nimport './customAccordion.scss';\r\n\r\nconst CheckBoxCustomAccordion = (props) => {\r\n const { heading, children, defaultExpanded } = props;\r\n\r\n\r\n return (\r\n \r\n \r\n \r\n }\r\n aria-controls=\"panel1a-content\"\r\n id=\"panel1a-header\" \r\n >\r\n {/* */}\r\n \r\n {ReactHtmlParser(heading)}\r\n \r\n \r\n {children} \r\n \r\n \r\n );\r\n};\r\n\r\n// CheckBoxCustomAccordion.propTypes = {\r\n// heading: PropTypes.string.isRequired,\r\n// content: PropTypes.any,\r\n// defaultExpanded: PropTypes.bool,\r\n// children: PropTypes.object,\r\n// };\r\n// CheckBoxCustomAccordion.defaultProps = {\r\n// defaultExpanded: true,\r\n// };\r\n\r\nexport default CheckBoxCustomAccordion;\r\n\r\n","import React, { useState } from 'react'\r\nimport CheckBoxCustomAccordion from '../accordion/CheckBoxCustomAccordion'\r\nimport Typography from '@material-ui/core/Typography'\r\nimport { Checkbox, FormControlLabel } from '@material-ui/core'\r\nimport ReactHtmlParser from 'react-html-parser';\r\nimport './faq.scss'\r\nconst FaqContainer = (props) => {\r\n const {question, answer, index, setIsChecked, isChecked, setIsUnChecked, setShowCheckBoxes, showCheckboxes, defaultExpanded, userRole} = props;\r\n \r\n \r\n const handleSingleCheck = (event) => {\r\n\r\n if (event.target.checked) {\r\n setIsChecked(event.target.name);\r\n\r\n } else {\r\n setIsUnChecked(event.target.name);\r\n\r\n }\r\n\r\n}\r\n\r\n\r\nconst handleClickEvent = () => {\r\n setShowCheckBoxes(true)\r\n}\r\n return (\r\n {\r\n handleClickEvent() \r\n}}\r\n onFocus={(event) => event.stopPropagation()}\r\n control={showCheckboxes && userRole\r\n? {\r\n handleSingleCheck(e) \r\n}} />\r\n: <>>}\r\n label={ \r\n \r\n \r\n {ReactHtmlParser(answer)}\r\n \r\n {/* */}\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n )\r\n}\r\n\r\nexport default FaqContainer\r\n","import { Grid, Typography } from '@material-ui/core';\r\nimport React, { useRef, useEffect, useState } from 'react';\r\nimport FormRenderer from '../Inputs/formRenderer/formRenderer';\r\nimport RichTextEditor from '../Inputs/richTextEditor/richTextEditor';\r\n\r\nconst FaqForm = (props) => {\r\n const {\r\n formField: { catagory, addAnswer, addQuestion, faqCatagory },\r\n setFieldValue,\r\n // isFavourites,\r\n catagoryValues,\r\n errors,\r\n categoryType,\r\n editQuestion,\r\n editAnswer,\r\n // uniqueLeftPanelData,\r\n formikValues,\r\n setNewCategory,\r\n // setFieldTouched,\r\n } = props;\r\nconst [catagoryNameExist, setCatagoryNameExist] = useState(false)\r\n\r\n useEffect(() => {\r\n if (categoryExists(formikValues.catagory)) {\r\n setCatagoryNameExist(true)\r\n setNewCategory(true)\r\n } else {\r\n setCatagoryNameExist(false)\r\n setNewCategory(false)\r\n\r\n }\r\n \r\n }, [formikValues.catagory])\r\n\r\n//Check if object value exists within a Javascript array \r\nfunction categoryExists(categoryName) {\r\n return catagoryValues.some((el) => {\r\n return el.name === categoryName;\r\n }); \r\n}\r\n\r\n return (\r\n \r\n \r\n {categoryType === 'textBox'\r\n? <>\r\n \r\n \r\n Catagory name already exists\r\n \r\n \r\n >\r\n: (\r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {\r\n categoryType === \"textBox\" ? Note: Adding a FAQ for the new category is mandatory : ''}\r\n \r\n \r\n \r\n );\r\n};\r\n\r\nexport default FaqForm;\r\n","import { Grid, Snackbar } from '@material-ui/core';\r\nimport { Form, Formik } from 'formik';\r\nimport React, { useRef, useEffect, useState } from 'react';\r\nimport { axiosConfig, POST } from '../../api/axios';\r\nimport { ServiceEndPoints } from '../../utils/constants/ApiConstant';\r\nimport { connect } from 'react-redux';\r\n\r\nimport { FaqValidatorForm } from '../../utils/formConfig/FaqValidatorForm/FaqValidatorForm';\r\nimport { addFAQReqObj, setValuesToForm } from '../../utils/helperFunctions';\r\nimport { getYupSchemaFromMetaData } from '../../utils/yupSchema/yupSchemaGenerator';\r\n// import { getYupSchemaFromMetaData } from '../../utils/yupSchema/yupSchemaGenerator';\r\nimport * as actions from '../../store/actions/index';\r\n\r\nimport InputButton from '../Inputs/inputButton/inputButton';\r\nimport FaqForm from './FaqForm';\r\nconst { formId, formField } = FaqValidatorForm;\r\nconst CreateNewFaq = (props) => {\r\n const {catagoryValues, selectedMenu} = props;\r\n const { onLoad } = props;\r\n \r\n const formikRef = useRef(null);\r\n const [snackBarMsg, setSnackBarMsg] = useState('');\r\n const [editQuestion, setEditQuestion] = useState('');\r\n const [editAnswer, setEditAnswer] = useState('');\r\n const [newCategory, setNewCategory] = useState(false);\r\n const [categoryID, setCategoryID] = useState('');\r\n\r\n const newFaqValidationSchema = getYupSchemaFromMetaData(formField, [], []);\r\n const initialValues = {\r\n catagory: '',\r\n addQuestion: '',\r\n addAnswer: '',\r\n // faqCatagory:'',\r\n };\r\n const handleSubmit = async (values, errors, categoryType, id) => {\r\n\r\n if (await isFormValid(errors, values, categoryType) && !newCategory) {\r\n const reqObj = addFAQReqObj(values, categoryType, id);\r\n axiosConfig\r\n .post(ServiceEndPoints.faqsUrl, reqObj)\r\n .then((res) => {\r\n // setSnackBarMsg('Customer details stored sucessfully');\r\n formikRef.current.resetForm();\r\n props.handleDialogClose();\r\n props.getAllFaqDetails();\r\n props.setEditDetails('')\r\n props.setIsChecked([])\r\n props.setShowCheckBoxes(false)\r\n props.getFaqDetails(selectedMenu)\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n // setSnackBarMsg('Error!');\r\n });\r\n } else {\r\n // console.log('all fields are required');\r\n props.setIsDialogOpen(true)\r\n }\r\n };\r\n\r\n \r\n const isFormValid = async (errors, values, categoryType) => {\r\n\r\n // let clonedReqFields = [...reqFields];\r\n\r\n const { ...restControls } = errors;\r\n \r\n if (categoryType === 'textBox') {\r\n \r\n return Object.keys(restControls).length === 0;\r\n \r\n } else if (categoryType === 'dropDown') {\r\n\r\n \r\n return (errors.addQuestion === undefined && errors.addAnswer === undefined)\r\n \r\n\r\n }\r\n \r\n\r\n return true;\r\n };\r\nuseEffect(() => {\r\n \r\n if (selectedMenu != '' && props.getCheckBox()) {\r\n catagoryValues.map((category, index) => {\r\n\r\n if (category.value === selectedMenu.replace(/\\s+/g, '')) {\r\n\r\n \r\n // setFieldValue('defaultDomesticAccounts', _tempArray[0])\r\n formikRef.current.setFieldValue('faqCatagory', catagoryValues[index]);\r\n \r\n setCategoryID('')\r\n \r\n }\r\n }) \r\n}\r\n}, [selectedMenu])\r\n\r\n\r\n useEffect(() => {\r\n if (Object.keys(props.editDetails).length > 0 && !props.getCheckBox() ) {\r\n \r\n \r\n catagoryValues.map((category, index) => {\r\n\r\n if (category.value === props.editDetails[0].category.replace(/\\s+/g, '')) {\r\n \r\n \r\n // setFieldValue('defaultDomesticAccounts', _tempArray[0])\r\n formikRef.current.setFieldValue('faqCatagory', catagoryValues[index]);\r\n \r\n setCategoryID(props.editFaqID)\r\n\r\n \r\n }\r\n })\r\n\r\n formikRef.current.setFieldValue('addQuestion', props.editDetails[0].question);\r\n formikRef.current.setFieldValue('addAnswer', props.editDetails[0].answer);\r\n setEditAnswer(props.editDetails[0].answer)\r\n setEditQuestion(props.editDetails[0].question)\r\n \r\n\r\n // formikRef.current.setValues(setValuesToForm(props.editDetails, formikRef.current.values));\r\n onLoad({\r\n loadedFrom: 'dropdownResponse',\r\n loadedResponse: { ...props.editDetails },\r\n });\r\n setTimeout(() => {\r\n onLoad({ loadedFrom: '' });\r\n }, 5000);\r\n }\r\n }, [props.editDetails]);\r\n\r\n \r\n // const htmlRef=useRef(null)\r\n // console.log(\"catagoryValues\",catagoryValues)\r\n\r\n return (\r\n \r\n {\r\n const errors = {};\r\n if (!values.addQuestion) {\r\n errors.addQuestion = 'Question is Required';\r\n }\r\n\r\n if (!values.addAnswer) {\r\n errors.addAnswer = 'Answer is Required';\r\n }\r\n\r\n return errors;\r\n }}\r\n >\r\n {({ values, setFieldValue, errors, setFieldTouched, resetForm, setValues}) => (\r\n \r\n )}\r\n \r\n setSnackBarMsg('')}\r\n autoHideDuration={2000}\r\n message={snackBarMsg}\r\n />\r\n
\r\n );\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n onLoad: (loadedFrom) => {\r\n dispatch(actions.setLoadedFrom(loadedFrom));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(null, mapDispatchToProps)(CreateNewFaq);\r\n","export const FaqValidatorForm = {\r\n formId: 'FaqValidatorForm',\r\n formField: {\r\n catagory: {\r\n props: {\r\n name: 'catagory',\r\n label: 'Catagory',\r\n type: 'text',\r\n // displayField: 'name',\r\n // hasDefaultValue: true,\r\n isRequired: true,\r\n },\r\n validation: {\r\n name: 'catagory',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'required',\r\n params: ['Catagory is required'],\r\n },\r\n ],\r\n },\r\n },\r\n faqCatagory: {\r\n props: {\r\n name: 'faqCatagory',\r\n label: 'Catagory',\r\n type: 'select',\r\n displayField: 'name',\r\n // hasDefaultValue: true,\r\n // isRequired: true,\r\n },\r\n // validation: {\r\n // name: 'faqCatagory',\r\n // validationType: 'object',\r\n // validations: [\r\n // {\r\n // type: 'required',\r\n // params: ['Catagory is required'],\r\n // },\r\n // ],\r\n // },\r\n },\r\n addQuestion: {\r\n props: {\r\n name: 'addQuestion',\r\n label: 'Add question',\r\n type: 'richText',\r\n isRequired: true,\r\n },\r\n validation: {\r\n name: 'addQuestion',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'min',\r\n params: [10, 'Question is required'],\r\n },\r\n ],\r\n },\r\n },\r\n addAnswer: {\r\n props: {\r\n name: 'addAnswer',\r\n label: 'Answer',\r\n type: 'richText',\r\n isRequired: true,\r\n },\r\n validation: {\r\n name: 'addAnswer',\r\n validationType: 'string',\r\n validations: [\r\n {\r\n type: 'min',\r\n params: [10, 'Answer is required'],\r\n },\r\n ],\r\n },\r\n },\r\n }\r\n };\r\n \r\n\r\n","import React, { useState, useEffect } from 'react';\r\nimport clsx from 'clsx';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\nimport CssBaseline from '@material-ui/core/CssBaseline';\r\nimport Drawer from '@material-ui/core/Drawer';\r\nimport Container from '@material-ui/core/Container';\r\nimport { uniq, sortBy, sort } from 'lodash';\r\nimport FaqSideNav from './faqSideNav';\r\nimport FaqContainer from './faqContainer';\r\nimport './faq.scss';\r\nimport InputButton from '../Inputs/inputButton/inputButton';\r\nimport { Grid } from '@material-ui/core';\r\nimport CustomModal from '../modal/modal';\r\nimport CustomDialog from '../dialog/customDialog';\r\nimport CreateNewFaq from './CreateNewFaq';\r\nimport { GET, POST } from '../../api/axios';\r\nimport ConfirmationDialog from '../../components/addressBook/confirmation/confirmation';\r\nimport { UserRoles } from '../../utils/constants/constants';\r\nimport { useSelector } from 'react-redux';\r\nimport { ServiceEndPoints } from '../../utils/constants/ApiConstant';\r\nimport { removeDuplicates, setValuesToForm } from '../../utils/helperFunctions';\r\nconst Faq = () => {\r\n const classes = useStyles();\r\n const [isDialogOpen, setIsDialogOpen] = useState(false);\r\n const [isUpdate, setIsUpdate] = useState(false);\r\n const userRole = useSelector((state) => state?.auth?.userDetails?.role);\r\n // const userRole = UserRoles.Admin;\r\n const [uniqueLeftPanelData, setUniqueLeftPanelData] = useState([]);\r\n const [faqDetails, setFaqDetails] = useState([]);\r\n const [showCheckboxes, setShowCheckBoxes] = useState(false);\r\n const [isChecked, setIsChecked] = useState([]);\r\n const [defaultExpanded, setDefaultExpanded] = useState(false);\r\n const [categoryType, setCategoryType] = useState('');\r\n const [editDetails, setEditDetails] = useState({});\r\n const [editFaqID, setEditFaqID] = useState('');\r\n\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n const [confirmationMessage, setConfirmationMsg] = useState('Are you sure you want to delete these questions?');\r\n const [catagoryValues, setCatagoryValues] = useState([]);\r\n\r\n const [uniqSideNav, setUniqSideNav] = useState([]);\r\n const [selectedMenu, setSelectedMenu] = useState('');\r\n const handleDialogClose = () => {\r\n setIsDialogOpen(false);\r\n setIsUpdate(!isUpdate);\r\n };\r\n\r\n const handleModalClose = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n const onDialogConfirm = () => {\r\n setShowConfirmationDialog(false);\r\n onDelete();\r\n };\r\n const onDialogCancel = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n\r\n const addFAQ = (e, name) => {\r\n setCategoryType(name);\r\n\r\n setIsDialogOpen(true);\r\n };\r\n const getAllFaqDetails = () => {\r\n const categoryArray = []\r\n GET(ServiceEndPoints.faqsUrl)\r\n .then((res) => {\r\n\r\n (res.data || []).forEach((item, key) => {\r\n let categoryObj = {}\r\n if (item.category !== null && item.category != '') {\r\n categoryObj[\"id\"] = key;\r\n categoryObj[\"name\"] = item.category;\r\n categoryObj[\"value\"] = item.category.replace(/\\s+/g, '');\r\n // console.log(\"category\",categoryObj)\r\n // categoryArray((prevArray) => [...prevArray, categoryObj]);\r\n categoryArray.push(categoryObj)\r\n\r\n\r\n }\r\n });\r\n setUniqueLeftPanelData(categoryArray)\r\n\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n });\r\n // setUniqSideNav(arrayList);\r\n };\r\n const getCheckBox = () => {\r\n return isChecked.length === 0\r\n };\r\n\r\n const getFaqDetails = (name) => {\r\n GET(`${ServiceEndPoints.faqsUrl}?category=${name}`)\r\n .then((res) => {\r\n setFaqDetails(res.data);\r\n })\r\n .catch((err) => {\r\n console.log(err);\r\n // let afterDeleteData = catagoryValues.filter((item) => {\r\n // // return item !== name;\r\n // });\r\n getAllFaqDetails();\r\n // getFaqDetails(catagoryValues[0].name);\r\n setSelectedMenu(catagoryValues[0].name)\r\n\r\n // setUniqueLeftPanelData(afterDeleteData);\r\n setFaqDetails([]);\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n getAllFaqDetails();\r\n }, []);\r\n useEffect(() => {\r\n let data = removeDuplicates(uniqueLeftPanelData, item => item.name)\r\n\r\n const sortedDate = data.sort(function (a, b) {\r\n /* Storing case insensitive comparison */\r\n var comparison = a.name.toLowerCase().localeCompare(b.name.toLowerCase());\r\n /* If strings are equal in case insensitive comparison */\r\n if (comparison === 0) {\r\n /* Return case sensitive comparison instead */\r\n return a.name.localeCompare(b.name);\r\n }\r\n /* Otherwise return result */\r\n return comparison;\r\n });\r\n setCatagoryValues(sortedDate);\r\n if (uniqueLeftPanelData.length > 0 && selectedMenu === '') {\r\n setSelectedMenu(sortedDate[0].name)\r\n }\r\n\r\n }, [uniqueLeftPanelData, isUpdate]);\r\n\r\n useEffect(() => {\r\n setIsChecked([]);\r\n setShowCheckBoxes(false);\r\n setDefaultExpanded(false);\r\n if (selectedMenu != '') {\r\n getFaqDetails(selectedMenu);\r\n }\r\n }, [selectedMenu]);\r\n\r\n //delete faq items\r\n const onDelete = () => {\r\n const itemsToBeDeleted = isChecked.map((faqItem) => {\r\n return faqItem;\r\n });\r\n\r\n const payload = itemsToBeDeleted;\r\n POST(`${ServiceEndPoints.faqsUrl}/delete`, payload)\r\n .then((response) => {\r\n getAllFaqDetails()\r\n // console.log(\"selectedMenu\",selectedMenu)\r\n getFaqDetails(selectedMenu);\r\n setIsChecked([])\r\n })\r\n .catch((error) => {\r\n alert('Items were not deleted, please try again.');\r\n });\r\n };\r\n\r\n const handleSingleCheck = (event) => {\r\n let checkBoxlist = [...isChecked];\r\n\r\n checkBoxlist.push(event);\r\n\r\n checkBoxlist = checkBoxlist.reduce((a, b) => {\r\n if (a.indexOf(b) < 0) {\r\n a.push(b);\r\n }\r\n return a;\r\n }, []);\r\n\r\n setIsChecked(checkBoxlist);\r\n };\r\n const handleRemove = (event) => {\r\n let checkBoxlist = [...isChecked];\r\n\r\n checkBoxlist.push(event);\r\n\r\n checkBoxlist = checkBoxlist.filter((name) => name != event);\r\n\r\n setIsChecked(checkBoxlist);\r\n };\r\n\r\n const addAndEditFaq = (e) => {\r\n addFAQ(e, 'dropDown');\r\n const itemsToBeUpdated = isChecked.map((faqItem) => {\r\n setEditFaqID(faqItem);\r\n return faqItem;\r\n });\r\n GET(`${ServiceEndPoints.faqsUrl}?id=${itemsToBeUpdated}`)\r\n .then((res) => {\r\n setEditDetails(res.data);\r\n // getAllFaqDetails()\r\n // getFaqDetails(selectedMenu);\r\n\r\n })\r\n .catch((err) => {\r\n console.log('err');\r\n });\r\n };\r\n\r\n\r\n // function removeDuplicates(data, key) {\r\n\r\n // return [\r\n // ...new Map(data.map(item => [key(item), item])).values()\r\n // ]\r\n\r\n // };\r\n\r\n\r\n return (\r\n \r\n \r\n \r\n {/* */}\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n {(faqDetails || []).map((content, key) => {\r\n return (\r\n \r\n );\r\n })}\r\n \r\n \r\n \r\n {userRole === UserRoles.Admin ? (\r\n 1}\r\n onClick={(e) => addAndEditFaq(e)}\r\n />\r\n ) : null}\r\n \r\n \r\n {showCheckboxes && userRole === UserRoles.Admin ? (\r\n setShowConfirmationDialog(true)}\r\n disabled={isChecked.length === 0}\r\n />\r\n ) : null}\r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n
\r\n );\r\n};\r\n\r\nconst drawerWidth = 268;\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n root: {\r\n display: 'flex',\r\n },\r\n drawerPaper: {\r\n position: 'relative',\r\n width: drawerWidth,\r\n // paddingTop: theme.spacing(4),\r\n paddingBottom: theme.spacing(4),\r\n background: '#fff',\r\n color: '#000',\r\n border: '1px solid #E3E3E3',\r\n textAlign: 'left',\r\n },\r\n content: {\r\n flexGrow: 1,\r\n height: '100%',\r\n overflow: 'auto',\r\n },\r\n container: {\r\n // paddingTop: theme.spacing(4),\r\n paddingBottom: theme.spacing(4),\r\n },\r\n}));\r\n\r\nexport default Faq;\r\n","import React, { useState } from 'react';\r\n\r\nimport { Grid, Paper } from '@material-ui/core';\r\n\r\nimport DynamicMaterialTable from '../../framework/DynamicMaterialTable/DynamicMaterialTable';\r\nimport InputButton from '../../framework/Inputs/inputButton/inputButton';\r\nimport { useHistory } from 'react-router';\r\nimport { useSelector } from 'react-redux';\r\nimport { basicSort, formatDate } from '../../utils/helperFunctions';\r\n\r\nconst ApplicationUpdates = (props) => {\r\n const history = useHistory();\r\n\r\n let tableData = useSelector((state) => state.applicationUpdates.applicationUpdates);\r\n\r\nlet applicationArray = []\r\nlet updatedDate = tableData.map((data, i) => {\r\n const appObj = {}\r\n \r\n appObj[\"id\"] = data.id\r\n appObj[\"createdOn\"] = formatDate(data.createdOn, '/', 'dd/mm/yy')\r\n appObj[\"updateDescription\"] = data.updateDescription;\r\n\r\n applicationArray.push(appObj)\r\n \r\n})\r\n\r\n\r\n const tableColumns = [\r\n { title: 'id', field: 'id', hidden: true },\r\n {\r\n title: 'Update description',\r\n field: 'updateDescription',\r\n sorting: false,\r\n },\r\n {\r\n title: 'Date',\r\n field: 'createdOn',\r\n customSort: (a, b) =>\r\n basicSort(new Date(a.createdOn).getTime(), new Date(b.createdOn).getTime()),\r\n },\r\n ];\r\n\r\n const [columns] = useState(tableColumns);\r\n\r\n const handleBackButton = () => {\r\n history.push('/shipment/addShipment');\r\n\r\n };\r\n\r\n return (\r\n \r\n\r\n \r\n \r\n \r\n \r\n handleBackButton()}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nApplicationUpdates.propTypes = {};\r\n\r\nexport default ApplicationUpdates;\r\n","import React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Snackbar } from '@material-ui/core';\r\nimport MuiAlert from '@material-ui/lab/Alert';\r\nimport { useDispatch, useSelector } from 'react-redux';\r\nimport * as actions from '../../store/actions/index';\r\n\r\nconst AppSnackBar = () => {\r\n const Alert = (props) => {\r\n return ;\r\n };\r\nconst dispatch = useDispatch();\r\nconst snackBarData = useSelector(state => state.common.snackBarData);\r\n\r\n return (\r\n dispatch(actions.resetAppSnackBarData())}\r\n autoHideDuration={snackBarData.inputProps.autoHideDuration}\r\n >\r\n dispatch(actions.resetAppSnackBarData())} severity={snackBarData.type}>\r\n {snackBarData.msg}\r\n \r\n \r\n );\r\n};\r\n\r\n// AppSnackBar.propTypes = {\r\n// horizontalPostion: PropTypes.oneOf(['left', 'center', 'right']),\r\n// verticalPosition: PropTypes.oneOf(['top', 'bottom']),\r\n// autoHideDuration: PropTypes.number,\r\n// snackBarMsg: PropTypes.string.isRequired,\r\n// setSnackBarMsg: PropTypes.func.isRequired,\r\n// severity: PropTypes.oneOf(['error', 'warning', 'info', 'success']),\r\n// };\r\n\r\n// AppSnackBar.defaultProps = {\r\n// horizontalPostion: 'right',\r\n// verticalPosition: 'top',\r\n// autoHideDuration: 3000,\r\n// severity: 'success',\r\n// };\r\n\r\nexport default AppSnackBar;\r\n","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Grid, Drawer, IconButton, makeStyles } from '@material-ui/core';\r\nimport { useDispatch, useSelector } from 'react-redux';\r\nimport { Clear } from '@material-ui/icons';\r\nimport * as actions from '../../store/actions/index';\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n err: {\r\n color: '#D40511',\r\n fontSize: '16px',\r\n paddingLeft: '29px',\r\n },\r\n success: {\r\n color: '#1A7C02',\r\n fontSize: '16px',\r\n paddingLeft: '29px',\r\n },\r\n closeIcon: {\r\n paddingRight: '20px',\r\n },\r\n drawerPaper: {\r\n minHeight: 70,\r\n },\r\n}));\r\n\r\nconst BottomAlert = (props) => {\r\n const [backDrop, setBackDrop] = useState(false);\r\n const [alertDetails, setAlertDetails] = useState({});\r\n const bottomAlertData = useSelector((state) => state.common.bottomAlert);\r\n const classes = useStyles();\r\n const dispatch = useDispatch();\r\n\r\n if (backDrop) {\r\n document.addEventListener('keyup', (event) => {\r\n if (event?.key === 'Enter') {\r\n alertClosed();\r\n }\r\n });\r\n }\r\n\r\n useEffect(() => {\r\n if (bottomAlertData.open) {\r\n setBackDrop(true);\r\n setAlertDetails(bottomAlertData);\r\n } else {\r\n setBackDrop(false);\r\n setAlertDetails(bottomAlertData);\r\n }\r\n }, [bottomAlertData]);\r\n\r\n const alertClosed = () => {\r\n setBackDrop(false);\r\n dispatch(actions.resetBottomAlert());\r\n };\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n {alertDetails?.msgs?.map((message, index, arr) => (\r\n \r\n {`${alertDetails.hasMultipleMsgs ? (index + 1 + \".\") : \"\"}${message.msg}`}
\r\n \r\n ))}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nBottomAlert.propTypes = {};\r\n\r\nexport default BottomAlert;\r\n","import React, { useEffect, useState } from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Switch, Route, Redirect, withRouter, useLocation } from 'react-router-dom';\r\nimport { connect } from 'react-redux';\r\nimport PrivateRoute from '../privateRoute/privateRoute';\r\nimport { makeStyles, Toolbar, Grid, Backdrop, CircularProgress } from '@material-ui/core';\r\nimport CustomModal from '../../framework/dialog/customDialog';\r\nimport ConfirmationDialog from '../../components/addressBook/confirmation/confirmation';\r\nimport { ShowNotification } from '../ShowNotification/ShowNotification';\r\n\r\nimport Header from '../header/header';\r\nimport SideNav from '../sideNav/sideNav';\r\nimport Breadcrumb from '../breadcrumb/breadcrumb';\r\nimport Login from '../login/login';\r\nimport AddShipment from '../../container/shipment/addShipment/addShipment';\r\nimport CarriageForward from '../../container/shipment/carriageForward/carriageForward';\r\nimport TemplateManagement from '../../container/shipment/templateManagement/templateManagement';\r\nimport TemplateManagements from '../../container/shipment/templateManagement/CreateNewTemplate/TemplateManagement';\r\n\r\nimport AddressBook from '../../container/addressBook/AddressBook';\r\nimport AddNewAddress from '../../container/addressBook/addNewAddress/addNewAddress';\r\nimport ShipmentManagement from '../../container/shipment/shipmentManagement/shipmentManagement';\r\nimport ShipmentSummary from '../../container/shipment/shipmentSummary/ShipmentSummary';\r\nimport AddShipmentSummary from '../../container/shipment/addShipment/addShipmentSummary/AddShipmentSummary';\r\nimport Dashboard from '../../container/dashboard/dashboard/dashboard';\r\nimport BookedCollectionSummary from '../../container/shipment/bookedCollectionSummary/BookedCollectionSummary';\r\nimport Summary from '../../components/dashboard/summary/summary';\r\nimport ConfigurationHome from '../../container/configuration/ConfigurationHome';\r\nimport GenralConfiguration from '../../container/configuration/GenralConfiguration/GenralConfiguration';\r\nimport PrinterConfiguration from '../../container/configuration/PrinterConfiguration/PrinterConfiguration';\r\nimport OrderFileConfiguration from '../../container/configuration/OrderFileConfiguration/OrderFileConfiguration';\r\nimport MarketplaceConfig from '../../container/configuration/MarketplaceConfiguration/MarketplaceConfig';\r\nimport UserManagement from '../../container/userManagement/UserManagement';\r\nimport { useDispatch } from 'react-redux';\r\nimport './layout.scss';\r\nimport DashBoardSummary from '../../container/dashboard/dashboard/dashBoardSummary/DashBoardSummary';\r\nimport { useSelector } from 'react-redux';\r\nimport BookDriverPickUp from '../../container/shipment/bookDriverPickUp/BookDriverPickUp';\r\nimport AuditEnquiry from '../../container/auditEnquiry/auditEnquiry';\r\nimport Tracking from '../../container/dashboard/tracking/tracking';\r\nimport Accounts from '../../container/accounts/Accounts';\r\nimport ProcessOrders from '../../container/shipment/processOrders/processOrders';\r\nimport * as actions from '../../store/actions/index';\r\nimport CreateNewSchema from '../../components/configuration/orderFileConfigurations/createNewSchema/createNewSchema';\r\nimport { ServiceEndPoints } from '../../utils/constants/ApiConstant';\r\nimport { axiosConfig } from '../../api/axios';\r\nimport { checkToken, getNonReturnAccounts } from '../../utils/helperFunctions';\r\nimport BarCodeConfiguration from '../../container/configuration/BarCodeConfiguration/BarCodeConfiguration';\r\nimport Faq from '../faq/faq';\r\nimport ApplicationUpdates from '../../container/applicationUpdates/ApplicationUpdates';\r\nimport { UserRoles } from '../../utils/constants/constants';\r\nimport Spinner from '../spinner/spinner';\r\nimport AppSnackBar from '../snackBar/appSnackBar';\r\nimport BottomAlert from '../bottomAlert/bottomAlert';\r\nimport { getDomesticAccounts, isPickUpAvailableInAccount } from '../../utils/helperFunctions';\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n content: {\r\n flexGrow: 1,\r\n padding: '13.6px 0px 13.6px 18.6px',\r\n },\r\n root: {\r\n display: 'flex',\r\n },\r\n}));\r\n\r\nlet loginTries = 0;\r\nconst Layout = (props) => {\r\n let userDetails = useSelector((state) => state.auth.userDetails);\r\n let userAccounts = useSelector((state) => state.accounts.userAccounts);\r\n const domesticAccounts = useSelector((state) => state.accounts.userAccounts);\r\n const selectedAccount = domesticAccounts?.find((account) => isPickUpAvailableInAccount(account)) || {};\r\n const loader = useSelector((state) => state.loaderLayOver.showLoader);\r\n let notificationInfo = useSelector((state) => state.common);\r\n const [isUserDetailsLoaded, setUserDetailsLoaded] = useState(false);\r\n const [isLoginPage, setisLoginPage] = useState(false);\r\n const [isfaqPage, setIsFaqPage] = useState(false);\r\n\r\n const [isDrawerOpen, setDrawerOpen] = useState(false);\r\n const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);\r\n const [isLoginInProgress, setLoginInProgress] = useState(false);\r\n const [isApplication, setIsApplocation] = useState(false);\r\n const [alertOpened, setAlertOpened] = useState(false);\r\n let location = useLocation();\r\n const dispatch = useDispatch();\r\n props.history.listen((location) => {\r\n if (location.pathname.includes('login')) {\r\n setisLoginPage(true);\r\n } else if (location.pathname.includes('faq')) {\r\n setisLoginPage(true);\r\n setIsFaqPage(true);\r\n setIsApplocation(false);\r\n } else if (location.pathname.includes('applicationUpdates')) {\r\n setIsApplocation(true);\r\n setisLoginPage(false);\r\n } else {\r\n setisLoginPage(false);\r\n setIsApplocation(false);\r\n }\r\n });\r\n\r\n const DrawerEventHandler = (data) => {\r\n setDrawerOpen(data);\r\n };\r\n\r\n const validateAddress = (address) => {\r\n const add = {\r\n ...address,\r\n name: address?.name?.trim()?.slice(0, 35),\r\n companyName: address?.companyName?.trim()?.slice(0, 35),\r\n address1: address?.address1?.trim()?.slice(0, 35),\r\n address2: address?.address2?.trim()?.slice(0, 35),\r\n address3: address?.address3?.trim()?.slice(0, 35),\r\n city: address?.city?.trim()?.slice(0, 35),\r\n country: address?.country?.trim()?.slice(0, 35),\r\n email: address?.email?.trim()?.slice(0, 70),\r\n phone: address?.phone?.trim()?.slice(0, 35),\r\n }\r\n return add;\r\n }\r\n const getUserInfo = () => {\r\n dispatch(actions.setLoaderLayOver(true));\r\n loginTries++;\r\n setLoginInProgress(true);\r\n axiosConfig\r\n .get(ServiceEndPoints.getUser)\r\n .then((res) => {\r\n let userDetails = res.data;\r\n sessionStorage.setItem('customerAccountID', userDetails?.customerAccountID);\r\n userDetails.accounts =\r\n userDetails?.accounts.map((account) => {\r\n return {\r\n ...account,\r\n displayName: `${account.accountId}-${account.accountName}${(account.configuration.firstMileDropOffAllowed) ? '-FMD' : ''}`,\r\n deliveryCheck:account?.configuration?.deliveryChecks,\r\n sender: validateAddress(account.sender)\r\n };\r\n }) ?? [];\r\n\r\n props.onAuth(userDetails);\r\n props.setUserAccounts((userDetails || {}).accounts);\r\n const temp = getNonReturnAccounts((userDetails || {}).accounts);\r\n props.setNonReturnUserAccounts(temp || [])\r\n if ((temp || []).length > 0) {\r\n props.setSelectedAccount(temp[0]);\r\n }\r\n setLoginInProgress(false);\r\n\r\n setTimeout(() => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n }, 2000);\r\n })\r\n .catch((err) => {\r\n dispatch(actions.setLoaderLayOver(false));\r\n console.error(err);\r\n if (loginTries < 3) {\r\n getUserInfo();\r\n return;\r\n }\r\n setShowConfirmationDialog(true);\r\n alert('Incorrect User name');\r\n setLoginInProgress(false);\r\n });\r\n };\r\n\r\n const handleDialogClose = () => {\r\n setShowConfirmationDialog(true);\r\n };\r\n\r\n useEffect(() => {\r\n\r\n if (location.pathname === '/faq') {\r\n\r\n setisLoginPage(true);\r\n setIsFaqPage(true);\r\n setIsApplocation(false);\r\n }\r\n\r\n if (checkToken()) {\r\n getUserInfo();\r\n }\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (userDetails) setUserDetailsLoaded(true);\r\n }, [userDetails]);\r\n\r\n const onDialogConfirm = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n const onDialogCancel = () => {\r\n setShowConfirmationDialog(false);\r\n };\r\n\r\n const alertClosed = (isAlert) => {\r\n setAlertOpened(isAlert);\r\n dispatch(actions.setAlertInfo(isAlert));\r\n };\r\n\r\n const classes = useStyles();\r\n\r\n return (\r\n \r\n \r\n \r\n
\r\n {isLoginPage ? [null] :
}\r\n\r\n
\r\n \r\n
\r\n\r\n {isLoginPage && !isfaqPage ? [null] :
}\r\n
\r\n \r\n userDetails?.role === UserRoles.Reporting ? (\r\n \r\n ) : (\r\n \r\n )\r\n }\r\n />\r\n \r\n userDetails?.role === UserRoles.Reporting ? (\r\n \r\n ) : (\r\n \r\n )\r\n }\r\n />\r\n } />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n } />\r\n \r\n
\r\n \r\n
\r\n \r\n \r\n
\r\n {/* \r\n \r\n */}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nLayout.propTypes = {\r\n history: PropTypes.any,\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch) => {\r\n return {\r\n onAuth: (userDetails) => {\r\n dispatch(actions.setAuthDetails(userDetails));\r\n },\r\n setUserAccounts: (userAccounts) => {\r\n dispatch(actions.setUserAccounts(userAccounts));\r\n },\r\n setNonReturnUserAccounts: (nonReturnUserAccounts) => {\r\n dispatch(actions.setNonReturnUserAccounts(nonReturnUserAccounts));\r\n },\r\n setSelectedAccount: (selectedAccount) => {\r\n dispatch(actions.setSelectedAccount(selectedAccount));\r\n },\r\n setFavouriteCustomers: (favouriteCustomers) => {\r\n dispatch(actions.setFavouriteCustomers(favouriteCustomers));\r\n },\r\n };\r\n};\r\n\r\nexport default connect(null, mapDispatchToProps)(withRouter(Layout));\r\n","import React, { useEffect, useState } from 'react';\r\nimport { useSelector } from 'react-redux';\r\nimport { useDispatch } from 'react-redux';\r\nimport './App.scss';\r\nimport { createMuiTheme } from '@material-ui/core';\r\nimport { HashRouter as Router } from 'react-router-dom';\r\nimport { CssBaseline, ThemeProvider } from '@material-ui/core';\r\nimport { Paper } from '@material-ui/core';\r\n\r\nimport DeliveryFont from './assets/fonts/Delivery_W_Rg.woff';\r\nimport Layout from './framework/layout/layout';\r\n\r\nimport { getJSPMStatus, getPrintConfiguration, updateJSPMReference } from './utils/PrintHelper';\r\nimport { getAllGenralConfiguration } from './utils/helperFunctions';\r\nimport * as actions from '../src/store/actions/index';\r\n\r\nconst DeliveryTheme = {\r\n fontFamily: 'Delivery Regular',\r\n fontStyle: 'normal',\r\n src: `local('Delivery'),\r\n local('Delivery-Regular')\r\n url(${DeliveryFont}) format('woff')\r\n `,\r\n};\r\n\r\nconst theme = createMuiTheme({\r\n typography: {\r\n fontFamily: 'Delivery Regular',\r\n fontSize: 14,\r\n letterSpacing: 0,\r\n },\r\n overrides: {\r\n MuiCssBaseline: {\r\n '@global': {\r\n '@font-face': [DeliveryTheme],\r\n },\r\n },\r\n MuiFormLabel: {\r\n asterisk: {\r\n color: 'red',\r\n '&$error': {\r\n color: 'red',\r\n },\r\n },\r\n },\r\n },\r\n});\r\n\r\nconst App = () => {\r\n if (Object.keys(caches).length > 0) {\r\n caches.keys().then(async function (names) {\r\n await Promise.all(names.map(name => caches.delete(name)))\r\n })\r\n window.location.reload();\r\n }\r\n else {\r\n if (!(sessionStorage.getItem(\"reloadCompleted\")) || sessionStorage.getItem(\"reloadCompleted\")===\"false\") {\r\n sessionStorage.setItem(\"reloadCompleted\", true);\r\n window.location.reload();\r\n }\r\n }\r\n\r\n const dispatch = useDispatch();\r\n let userAccounts = useSelector((state) => state.auth.userDetails);\r\n\r\n const printerConfiguration = useSelector((state) => state.common.printerConfiguration)\r\n const [_printerConfiguration, setPrinterConfiguration] = useState(null);\r\n //Get Staus of neoDynamics exe on host machine\r\n // useEffect(() => {\r\n // getJSPMStatus(dispatch, actions);\r\n // }, []);\r\n\r\n useEffect(() => {\r\n if (userAccounts && userAccounts.customerAccountID) {\r\n //Get Printer Configuration of the user.\r\n getPrintConfiguration(dispatch, actions, userAccounts);\r\n\r\n //Get Genral configuration details of the org.\r\n getAllGenralConfiguration(userAccounts.customerAccountID, dispatch, actions);\r\n }\r\n }, [userAccounts]);\r\n\r\n useEffect(() => {\r\n if (_printerConfiguration !== null && _printerConfiguration?.userId) {\r\n updateJSPMReference(_printerConfiguration?.jspmVersion?.toString());\r\n getJSPMStatus(dispatch, actions);\r\n }\r\n }, [_printerConfiguration])\r\n useEffect(() => {\r\n if (printerConfiguration?.userId) {\r\n if (_printerConfiguration === null) {\r\n setPrinterConfiguration(printerConfiguration);\r\n }\r\n }\r\n }, [printerConfiguration])\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n};\r\n\r\nexport default App;\r\n","const reportWebVitals = onPerfEntry => {\r\n if (onPerfEntry && onPerfEntry instanceof Function) {\r\n import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {\r\n getCLS(onPerfEntry);\r\n getFID(onPerfEntry);\r\n getFCP(onPerfEntry);\r\n getLCP(onPerfEntry);\r\n getTTFB(onPerfEntry);\r\n });\r\n }\r\n};\r\n\r\nexport default reportWebVitals;\r\n","\r\nimport * as actionTypes from '../actions/actionsTypes'\r\n\r\nimport { updateObject } from '../../utils/common';\r\n\r\nconst initialState = {\r\n userDetails: null,\r\n};\r\n\r\n\r\nconst saveUserDetails = (state, action) => {\r\n const sortAlphaNum = (a, b) => a?.accountId?.toLowerCase().localeCompare(b?.accountId?.toLowerCase(), 'en', { numeric: true });\r\n action.data.accounts.sort(sortAlphaNum);\r\n return updateObject(state,\r\n {\r\n userDetails: action.data\r\n }\r\n );\r\n};\r\n\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SAVEUSERDETAILS: return saveUserDetails(state, action);\r\n default: return state\r\n }\r\n}\r\n\r\nexport default reducer;","import * as actionTypes from '../actions/actionsTypes';\r\n\r\nimport { updateObject } from '../../utils/common';\r\n\r\nconst initialState = {\r\n userAccounts: [],\r\n nonReturnuserAccounts: [],\r\n selectedAccount: {},\r\n displayAccounts: [],\r\n};\r\n\r\nconst setUSerAccounts = (state, action) => {\r\n return updateObject(state, {\r\n userAccounts: action.data,\r\n });\r\n};\r\nconst setNonReturnUserAccounts = (state, action) => {\r\n return updateObject(state, {\r\n nonReturnuserAccounts: action.data,\r\n });\r\n};\r\n\r\nconst setSelectedAccount = (state, action) => {\r\n return updateObject(state, {\r\n selectedAccount: action.data,\r\n });\r\n};\r\n\r\nconst setDisplayAccounts = (state, action) => {\r\n return updateObject(state, {\r\n displayAccounts: action.data,\r\n })\r\n}\r\n\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SETUSERACCOUNTS:\r\n return setUSerAccounts(state, action);\r\n case actionTypes.SETNONRETURNUSERACCOUNTS:\r\n return setNonReturnUserAccounts(state, action);\r\n case actionTypes.SETSELECTEDACCOUNT:\r\n return setSelectedAccount(state, action);\r\n case actionTypes.SETDISPLAYACCOUNTS:\r\n return setDisplayAccounts(state, action);\r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;\r\n","import * as actionTypes from '../actions/actionsTypes';\r\n\r\nimport { updateObject } from '../../utils/common';\r\n\r\nconst initialState = {\r\n favouriteCustomers: [],\r\n};\r\n\r\nconst setFavouriteCustomers = (state, action) => {\r\n return updateObject(state, {\r\n favouriteCustomers: action.data,\r\n });\r\n};\r\n\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SETFAVOURITECUSTOMERS:\r\n return setFavouriteCustomers(state, action);\r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;\r\n","import * as actionTypes from '../actions/actionsTypes';\r\n\r\nconst initialState = '';\r\n\r\nconst setAddressBookSearchParams = (state, action) => {\r\n return action.data;\r\n};\r\n\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SETADDRESSBOOKSEARCHPARAMS:\r\n return setAddressBookSearchParams(state, action);\r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;\r\n","import * as actionTypes from '../actions/actionsTypes';\r\n\r\nimport { updateObject } from '../../utils/common';\r\n\r\nconst initialState = {\r\n parcelDetails: {},\r\n};\r\n\r\nconst setLoadParcelDimensions = (state, action) => {\r\n return updateObject(state, {\r\n parcelDetails: action.data,\r\n });\r\n};\r\n\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SETLOADPARCELDIMENSIONS:\r\n return setLoadParcelDimensions(state, action);\r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;\r\n","import * as actionTypes from '../actions/actionsTypes';\r\n\r\nimport { updateObject } from '../../utils/common';\r\n\r\nconst initialState = {\r\n loadedFrom: '',\r\n};\r\n\r\nconst setLoadedFrom = (state, action) => {\r\n return updateObject(state, {\r\n loadedFrom: action.data,\r\n });\r\n};\r\n\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SETLOADEDFROM:\r\n return setLoadedFrom(state, action);\r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;\r\n","import * as actionTypes from '../actions/actionsTypes';\r\n\r\nconst initialState = '';\r\n\r\nconst setShipmentManagementSearchParams = (state, action) => {\r\n return action.data;\r\n};\r\n\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SETSHIPMENTMANAGEMENTSEARCHPARAMS:\r\n return setShipmentManagementSearchParams(state, action);\r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;\r\n","import * as actionTypes from '../actions/actionsTypes';\r\nimport { updateObject } from '../../utils/common';\r\n\r\nconst initialState = {\r\n servicePointDelivery: null,\r\n shipmentDetails: null,\r\n iossValueLimits: null,\r\n orderResponseData: {},\r\n postalCodeResponse: {},\r\n};\r\n\r\nconst setAddShipmentData = (state, action) => {\r\n return updateObject(state, { shipmentDetails: action.data });\r\n};\r\n\r\nconst setServicePointDelivery = (state, action) => {\r\n return updateObject(state, {\r\n servicePointDelivery: action.data,\r\n });\r\n};\r\n\r\nconst setIossValueLimits = (state, action) => {\r\n return updateObject(state, {\r\n iossValueLimits: action.data,\r\n });\r\n};\r\n\r\nconst setOrderResponseData = (state, action) => {\r\n return updateObject(state, {\r\n orderResponseData: action.data,\r\n });\r\n};\r\n\r\nconst setPostalCodeData = (state, action) =>{\r\n return updateObject(state,{\r\n postalCodeResponse: action.data,\r\n })\r\n}\r\n\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SETADDSHIPMENTDATA:\r\n return setAddShipmentData(state, action);\r\n case actionTypes.SET_DELIVERYSERVICEPOINT:\r\n return setServicePointDelivery(state, action);\r\n case actionTypes.SET_IOSSVALUELIMIT:\r\n return setIossValueLimits(state, action);\r\n case actionTypes.SET_ORDERRESPONSE:\r\n return setOrderResponseData(state,action);\r\n case actionTypes.SET_POSTALCODERESPONSE:\r\n return setPostalCodeData(state,action);\r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;\r\n","import * as actionTypes from '../actions/actionsTypes';\r\n \r\nimport { updateObject } from '../../utils/common';\r\n\r\nconst initialState = {\r\n dashboardTracking: '',\r\n dashboardFindShipment: '',\r\n};\r\n\r\nconst setDashboardTracking = (state, action) => {\r\n return updateObject(state, {\r\n dashboardTracking: action.data,\r\n });\r\n};\r\nconst setDashboardFindShipment = (state, action) => {\r\n return updateObject(state, {\r\n dashboardFindShipment: action.data,\r\n });\r\n};\r\n\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SETDASHBOARDTRACKING:\r\n return setDashboardTracking(state, action);\r\n case actionTypes.SETDASHBOARDFINDSHIPMANET:\r\n return setDashboardFindShipment(state, action);\r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;\r\n","import * as actionTypes from '../actions/actionsTypes';\r\n\r\nimport { updateObject } from '../../utils/common';\r\n\r\nconst initialState = {\r\n loadedFrom: '',\r\n};\r\n\r\nconst setBackUpResponse = (state, action) => {\r\n return updateObject(state, {\r\n loadedFrom: action.data,\r\n });\r\n};\r\n\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SETBACKUPRESPONSE:\r\n return setBackUpResponse(state, action);\r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;\r\n","import * as actionTypes from '../actions/actionsTypes';\r\nimport { updateObject } from '../../utils/common';\r\n\r\nconst initialState = {\r\n selectedEvent:\"\"\r\n};\r\n\r\nconst setSelectedEvent = (state, action) => {\r\n return updateObject(state, {\r\n selectedEvent: action.data,\r\n });\r\n};\r\n\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SETSELECTEDEVENT:\r\n return setSelectedEvent(state, action);\r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;\r\n","import * as actionTypes from '../actions/actionsTypes';\r\nimport { updateObject } from '../../utils/common';\r\n\r\nconst initialState = {\r\n shipmentId: '',\r\n};\r\n\r\nconst setShipmentId = (state, action) => {\r\n return updateObject(state, {\r\n shipmentId: action.data,\r\n });\r\n};\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SETSHIPMENTID:\r\n return setShipmentId(state, action);\r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;\r\n","import { updateObject } from '../../utils/common';\r\nimport * as actionTypes from '../actions/actionsTypes';\r\n\r\nconst initialState = {\r\n alertNotification: {\r\n displayMsg: '',\r\n severity: '',\r\n showNotification: false,\r\n },\r\n isJSPMInstalled: null,\r\n printerConfiguration: undefined, //default value until api doesn't give response\r\n availablePrinter: [],\r\n commonConfiguration: null,\r\n snackBarData: {\r\n isOpen: false,\r\n type: 'success',\r\n msg: '',\r\n inputProps: {\r\n horizontalPostion: 'right',\r\n verticalPosition: 'top',\r\n autoHideDuration: 5000,\r\n },\r\n },\r\n bottomAlert: {\r\n open: false,\r\n msgs: [],\r\n hasMultipleMsgs: null\r\n },\r\n activeTab: '',\r\n returnReferenceCount: 0,\r\n isReturnReferenceUpdated: false,\r\n allProducts: [],\r\n DhlIossNumber: '',\r\n sortOrderState: '',\r\n autoReloadProcessOrders: false,\r\n};\r\n\r\nconst setAppSnackbarData = (state, action) => {\r\n action.data = { ...action.data, isOpen: true };\r\n return updateObject(state, { snackBarData: updateObject(initialState.snackBarData, action.data) });\r\n};\r\n\r\nconst resetAppSnackBar = (state, action) => {\r\n return updateObject(state, { snackBarData: initialState.snackBarData });\r\n};\r\n\r\nconst setBottomAlert = (state, action) => {\r\n action.data = { ...action.data, open: true };\r\n return updateObject(state, {\r\n bottomAlert: updateObject(initialState.bottomAlert, {\r\n ...action.data,\r\n hasMultipleMsgs: action.data?.hasMultipleMsgs ?? action.data.msgs.length > 1\r\n }),\r\n });\r\n};\r\n\r\nconst resetBottomAlert = (state, action) => {\r\n return updateObject(state, { bottomAlert: initialState.bottomAlert });\r\n};\r\n\r\nconst setUserNotification = (state, action) => {\r\n return updateObject(state, {\r\n alertNotification: {\r\n displayMsg: action.data.displayMsg,\r\n severity: action.data.severity,\r\n showNotification: action.data.showNotification,\r\n },\r\n });\r\n};\r\n\r\nconst setJSPMStatus = (state, action) => {\r\n return updateObject(state, {\r\n isJSPMInstalled: action.data,\r\n });\r\n};\r\n\r\nconst setPrinterConfiguration = (state, action) => {\r\n return updateObject(state, {\r\n printerConfiguration: { ...state.printerConfiguration, ...action.data },\r\n });\r\n};\r\n\r\nconst setAvailablePrinter = (state, action) => {\r\n return updateObject(state, {\r\n availablePrinter: action.data,\r\n });\r\n};\r\n\r\nconst setGenralConfiguration = (state, action) => {\r\n return updateObject(state, {\r\n commonConfiguration: action.data,\r\n });\r\n};\r\n\r\nconst setActiveTab = (state, action) => {\r\n return updateObject(state, {\r\n activeTab: action.data,\r\n });\r\n};\r\n\r\nconst setReturnReferenceCount = (state, action) => {\r\n return updateObject(state, {\r\n returnReferenceCount: action.data,\r\n });\r\n};\r\n\r\nconst setIsReturnReferenceUpdated = (state, action) => {\r\n return updateObject(state, {\r\n isReturnReferenceUpdated: action.data,\r\n });\r\n};\r\n\r\nconst resetReturnReferenceParams = (state, action) => {\r\n return updateObject(state, {\r\n returnReferenceCount: 0,\r\n isReturnReferenceUpdated: false,\r\n });\r\n};\r\n\r\nconst setAllAvailableProducts = (state, action) => {\r\n return updateObject(state, {\r\n allProducts: action.data,\r\n });\r\n};\r\n\r\nconst setDhlIossNumber = (state, action) => {\r\n return updateObject(state, {\r\n DhlIossNumber: action.data,\r\n });\r\n}\r\n\r\nconst setSortOrderState = (state, action) => {\r\n return updateObject(state, {\r\n sortOrderState: action.data,\r\n });\r\n};\r\n\r\nconst setAutoReloadProcessOrders = (state, action) => {\r\n return updateObject(state, {\r\n autoReloadProcessOrders: action.data,\r\n });\r\n};\r\n\r\n// Reducer function to update the service point weight in the state\r\nconst setServicePointWeight = (state, action) => {\r\n return updateObject(state, {\r\n servicePointWeight: action.data,\r\n });\r\n};\r\n\r\n// Reducer function to update the * Method to get the Maximum Weight Per Parcel With Full Customs for windsor in the state\r\nconst setMaximumWeightPerParcelWithFullCustoms = (state, action) => {\r\n return updateObject(state, {\r\n maxWeightFullcustoms: action.data,\r\n });\r\n};\r\n\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SET_NOTIFICATION:\r\n return setUserNotification(state, action);\r\n case actionTypes.SET_JSPMSTATUS:\r\n return setJSPMStatus(state, action);\r\n case actionTypes.SET_PRINTERCONFIGURATION:\r\n return setPrinterConfiguration(state, action);\r\n case actionTypes.SET_AVAILABLEPRINTERS:\r\n return setAvailablePrinter(state, action);\r\n case actionTypes.SET_COMMONCONFIGURATION:\r\n return setGenralConfiguration(state, action);\r\n case actionTypes.SET_APPSNACKBAR:\r\n return setAppSnackbarData(state, action);\r\n case actionTypes.RESET_APPSNACKBAR:\r\n return resetAppSnackBar(state, action);\r\n case actionTypes.SET_BOTTOM_ALERT:\r\n return setBottomAlert(state, action);\r\n case actionTypes.RESET_BOTTOM_ALERT:\r\n return resetBottomAlert(state, action);\r\n case actionTypes.SETACTIVETAB:\r\n return setActiveTab(state, action);\r\n case actionTypes.SET_RETURN_REFERENCE_COUNT:\r\n return setReturnReferenceCount(state, action);\r\n case actionTypes.SET_IS_RETURN_REFERENCE_UPDATED:\r\n return setIsReturnReferenceUpdated(state, action);\r\n case actionTypes.RESET_RETURN_REFERENCE_VALUES:\r\n return resetReturnReferenceParams(state, action);\r\n case actionTypes.SET_ALL_PRODUCTS:\r\n return setAllAvailableProducts(state, action);\r\n case actionTypes.SET_DHL_IOSS_NUMBER:\r\n return setDhlIossNumber(state, action);\r\n case actionTypes.SET_SORT_ORDER_STATE:\r\n return setSortOrderState(state, action);\r\n case actionTypes.SET_AUTORELOAD_PROCESSORDERS:\r\n return setAutoReloadProcessOrders(state,action);\r\n case actionTypes.SET_SERVICE_POINT_WEIGHT:\r\n return setServicePointWeight(state,action); \r\n case actionTypes.SET_MAX_WEIGHT_PER_PARCEL_WITH_FULL_CUSTOMS:\r\n return setMaximumWeightPerParcelWithFullCustoms(state,action); \r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;\r\n","import * as actionTypes from '../actions/actionsTypes';\r\nimport { updateObject } from '../../utils/common';\r\n\r\nconst initialState = {\r\n bookedshipmentId: '',\r\n};\r\n\r\nconst setBookedShipmentId = (state, action) => {\r\n return updateObject(state, {\r\n bookedshipmentId: action.data,\r\n });\r\n};\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SETBOOKEDSHIPMENTID:\r\n return setBookedShipmentId(state, action);\r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;\r\n","import * as actionTypes from '../actions/actionsTypes';\r\nimport { updateObject } from '../../utils/common';\r\n\r\nconst initialState = {\r\n addNewAccountToUsers: '',\r\n};\r\n\r\nconst setAddNewAccountToUsers = (state, action) => {\r\n return updateObject(state, {\r\n addNewAccountToUsers: action.data,\r\n });\r\n};\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SETDEFAULTADDNEWACCOUNT:\r\n return setAddNewAccountToUsers(state, action);\r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;\r\n","import * as actionTypes from '../actions/actionsTypes';\r\n\r\nimport { updateObject } from '../../utils/common';\r\n\r\nconst initialState = {\r\n applicationUpdates: [],\r\n};\r\n\r\nconst setApplicationUpdates = (state, action) => {\r\n \r\n return updateObject(state, {\r\n applicationUpdates: action.data,\r\n });\r\n};\r\n\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SETAPPLICATIONNUPDATES:\r\n return setApplicationUpdates(state, action);\r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;\r\n","import * as actionTypes from '../actions/actionsTypes';\r\nimport { updateObject } from '../../utils/common';\r\n\r\nconst initialState = {\r\n showLoader: false,\r\n};\r\n\r\nconst setLoaderLayOver = (state, action) => {\r\n return updateObject(state, {\r\n showLoader: action.data,\r\n });\r\n};\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SETLOADERLAYOVER:\r\n return setLoaderLayOver(state, action);\r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;\r\n","\r\nimport * as actionTypes from '../actions/actionsTypes';\r\nimport { updateObject } from '../../utils/common';\r\n\r\nconst initialState = {\r\n showAlert: true,\r\n};\r\n\r\nconst setAlertInfo = (state, action) => {\r\n return updateObject(state, {\r\n showAlert: action.data,\r\n });\r\n};\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.SETALERTINFO:\r\n return setAlertInfo(state, action);\r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;","import * as actionTypes from '../actions/actionsTypes';\r\nimport { updateObject } from '../../utils/common';\r\n\r\nconst initialState = {\r\n key: '',\r\n};\r\n\r\nconst setKeyPressEvent = (state, action) => {\r\n return updateObject(state, {\r\n key: action.data,\r\n });\r\n};\r\nconst reducer = (state = initialState, action) => {\r\n switch (action.type) {\r\n case actionTypes.KEYPRESSEVENT:\r\n return setKeyPressEvent(state, action);\r\n default:\r\n return state;\r\n }\r\n};\r\n\r\nexport default reducer;\r\n","import { createStore, combineReducers } from 'redux';\r\n\r\nimport authReducer from './auth';\r\nimport accountReducer from './userAccounts';\r\nimport customerReducer from './favouriteCustomers';\r\nimport addressBookSearchParamsReducer from './addressBookSearchParams';\r\nimport loadParcelDimensionsReducer from './loadParcelDimensions';\r\nimport loadedFromReducer from './loadedFrom';\r\nimport shipmentManagementSearchParamsReducer from './shipmentManagementSearchParams';\r\nimport addShipmentDataReducer from './addShipmentData';\r\nimport dashboardTracking from './dashboardTracking';\r\nimport backUpResponseReducer from './backupResponse';\r\nimport selectedEventReducer from './selectedEvent';\r\nimport shipmentIdReducer from './shipmentId';\r\nimport commonReducer from './common';\r\nimport setBookedShipmentIdReducer from './bookedShipmentId';\r\nimport setDefaultAddNewAccountReducer from './defaultAddNewAccount';\r\nimport setApplicationUpdatesReducer from './applicationUpdates';\r\nimport setLoaderLayOver from './loaderLayOver';\r\nimport setAlertInfo from './alertInfo';\r\nimport setKeyPressEvent from './keyPressEvent';\r\nconst rootReducer = combineReducers({\r\n auth: authReducer,\r\n accounts: accountReducer,\r\n customers: customerReducer,\r\n searchParams: addressBookSearchParamsReducer,\r\n loadParcelDimensions: loadParcelDimensionsReducer,\r\n loadedFrom: loadedFromReducer,\r\n shipmentSearchParams: shipmentManagementSearchParamsReducer,\r\n addShipmentData: addShipmentDataReducer,\r\n backUpResponse: backUpResponseReducer,\r\n dashboardTracking,\r\n selectedEvent: selectedEventReducer,\r\n shipmentId: shipmentIdReducer,\r\n bookedshipmentId: setBookedShipmentIdReducer,\r\n common: commonReducer,\r\n addNewAccountToUsers: setDefaultAddNewAccountReducer,\r\n applicationUpdates: setApplicationUpdatesReducer,\r\n loaderLayOver: setLoaderLayOver,\r\n keyPressEvent: setKeyPressEvent,\r\n alertInfo: setAlertInfo,\r\n});\r\n\r\nexport default rootReducer;\r\n","import React from 'react';\r\nimport ReactDOM from 'react-dom';\r\nimport { Provider } from 'react-redux';\r\nimport './index.css';\r\nimport App from './App';\r\nimport reportWebVitals from './reportWebVitals';\r\nimport rootReducer from './store/reducers/index';\r\nimport './assets/fonts/Delivery_W_Rg.woff';\r\nimport './styles/mixin.scss';\r\nimport './styles/styles.scss';\r\nimport { createStore } from 'redux';\r\nimport AzureAD from \"react-aad-msal\";\r\nimport { signInAuthProvider} from \"../src/utils/authProvider/authProvider\";\r\nconst store = createStore(rootReducer);\r\n\r\nReactDOM.render(\r\n //for B2C LOGIN AUTHORIZATION\r\n\r\n ,\r\n\r\n \r\n \r\n \r\n \r\n ,\r\ndocument.getElementById('root'),\r\n);\r\n\r\n// If you want your app to work offline and load faster, you can change\r\n// unregister() to register() below. Note this comes with some pitfalls.\r\n// Learn more about service workers: https://cra.link/PWA\r\n//serviceWorkerRegistration.register();\r\n\r\n// If you want to start measuring performance in your app, pass a function\r\n// to log results (for example: reportWebVitals(console.log))\r\n// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals\r\nreportWebVitals();\r\n"],"sourceRoot":""}