import { useCallback, useEffect, useRef, useState } from 'react'; import { useDispatch } from 'react-redux'; import { Form, Checkbox, Flex, Radio, Row, Space, Segmented, Empty, Button, Tooltip, } from 'antd'; import { RiBarcodeFill } from 'react-icons/ri'; import { BsQrCode } from 'react-icons/bs'; import { ArrowRightOutlined, DeleteFilled, EditFilled, LeftOutlined, RightOutlined, } from '@ant-design/icons'; import { CgAlignTop, CgAlignRight, CgAlignLeft, CgAlignCenter, CgAlignBottom, } from 'react-icons/cg'; import { DropDowns } from '../../Components/Forms/DropDown'; import { Messages } from '../../Components/Notifications/Messages'; import { getSession } from '../../Services/Others'; import { changeBreadCrumb, getEmpAccess, } from '../../Features/AppPage/CenterPage'; import { Tables } from '../../Components/Tables/Table'; import { useAuth } from '../../AuthContext'; import Buttons from '../../Components/Forms/Buttons'; import * as globalBarcode from '../../Features/Barcode/Barcode'; import './BarcodeTemplateSetup.scss'; import { FaAngleDown, FaAngleUp } from 'react-icons/fa'; import { MdOutlineQrCodeScanner } from 'react-icons/md'; import { IoBarcodeOutline } from 'react-icons/io5'; import { IoQrCodeOutline } from 'react-icons/io5'; import { GiHorizontalFlip, GiVerticalFlip } from 'react-icons/gi'; const subDirectory = import.meta.env.ENV_BASE_URL; const barCodeImage = 'https://cdn.pixabay.com/photo/2014/04/02/16/19/barcode-306926_1280.png'; const qrCodeImage = 'https://cdn.pixabay.com/photo/2015/03/21/09/34/qr-683354_640.png'; import QrCode from '../../Images/PreviewQrCode.png'; import BarCode from '../../Images/PreviewBarCode.png'; const previewText = 'Barcode Preview'; const mrpText = 'MRP : 450'; const productNameText = 'Product Name'; const mDateText = 'M-Date : 12-12-2002'; const eDateText = 'Exp-Date : 12-12-2004'; const colorText = 'Color : Red'; const sellingPriceText = 'Selling Price : 400'; const barCodePositionText = 'Barcode Position'; const segmentStyle = { padding: 4, display: 'flex', justifyContent: 'center', alignItems: 'center', gap: '0.5rem', }; const items = [ { name: 'Home', link: `${subDirectory}app-page/home`, }, // { // name: "BarcodeQrSetup", // link: `${subDirectory}saleslayouts/barcode&qr-selection`, // }, ]; const positionOption = [ { value: 'L', label: ( Left ), }, { value: 'R', label: ( Right ), }, { value: 'T', label: ( Top ), }, { value: 'B', label: ( Bottom ), }, { value: 'C', label: ( Center ), }, ]; const BarcodeTemplateSetup = () => { const formRef = useRef(null); const CompId = getSession('CompId'); const BranchId = getSession('BranchId'); const AppId = getSession('AppId'); const UserId = getSession('UserId'); const UserType = getSession('UserType'); const { SadminuserAccess } = useAuth(); const SAAccessCommonMaster = SadminuserAccess?.find( (e) => e?.MenuName === 'Barcode / Qr Setup' ); // useDispatch const dispatch = useDispatch(); // useState const [dropdownValue, setDropdownValue] = useState(); const [coresdata, setCoresdata] = useState([]); const [filteredCoreData, setFilteredCoreData] = useState([]); const [value, setValue] = useState(); const [secondValue, setSecondValue] = useState(); const [sizeCheckList, setSizeCheckList] = useState([]); const [checkedList, setCheckedList] = useState([]); const [selectedOption, setSelectedOption] = useState('B'); const checkAll = sizeCheckList?.filter( (filter) => filter.ComponentName !== (selectedOption === 'B' ? 'Qrcode' : 'Barcode') )?.length === checkedList?.length; const [selectedSizeCheckedValues, setSelectedSizeCheckedValues] = useState( [] ); const [sizeName, setSizeName] = useState(null); const [message, setMessage] = useState({ Type: null, Message: null }); const [editMode, setEditMode] = useState(false); const [putMode, setPutMode] = useState(false); const [editinitialRun, setEditInitialRun] = useState(false); const [getSizeData, setGetSizeData] = useState([]); const [empData, setEmpData] = useState(); const [addnewAccess, setaddnewAccess] = useState(true); const secondValueStyle = { flexDirection: secondValue === 'R' ? 'row' : 'row-reverse', }; const valueStyleRow = { flexDirection: value === 'R' ? 'row' : 'row-reverse', }; const valueStyleColumn = { flexDirection: value === 'T' ? 'column' : 'column-reverse', }; const [showAll, setShowAll] = useState(false); const displayedData = showAll ? filteredCoreData : filteredCoreData.slice(0, 6); const columns = [ { title: 'Sl.No', align: 'center', key: 'sno', width: '50px', render: (text, object, index) => ( {index + 1} ), }, { title: 'Size', dataIndex: 'SessionName', key: 'SessionName', width: '50px', align: 'left', render: (text) => {text}, }, { title: 'Options', dataIndex: 'OptionDetails', key: 'OptionDetails', width: '100px', align: 'left', render: (OptionDetails) => ( {OptionDetails?.map((item) => item.OptionName).join(',')} ), ellipsis: true, }, { title: 'Action', dataIndex: 'Action', width: '50px', key: 'Action', render: (_, record, index) => getSizeData?.length >= 1 ? ( UserType === 'Super Admin' || (UserType === 'Super Admin User' && SAAccessCommonMaster?.UpdateAccess === 'Y') || (UserType === 'Employee' && empData?.UpdateAccess === 'Y') || UserType === 'Admin' ? actionsFormatter(record, index) : null } /> { if ( !editMode && (UserType === 'Super Admin' || (UserType === 'Super Admin User' && SAAccessCommonMaster?.DeleteAccess === 'Y') || (UserType === 'Employee' && empData?.DeleteAccess === 'Y') || UserType === 'Admin') ) { const filteredData = getSizeData?.filter( (_, ind) => ind !== index ); setGetSizeData(filteredData); const updatedCoresData = [...coresdata]?.filter( (filter) => !filteredData.some( (some) => some.SessionId === filter.ConfigId ) ); setFilteredCoreData(updatedCoresData); } else { return ''; } }} > ) : null, }, ]; // useCallback const onComplete = useCallback(() => { setMessage({ Type: null, Message: null }); }, []); // useEffect useEffect(() => { dispatch(changeBreadCrumb({ items: items })); getBarcodeSessionData(); }, []); useEffect(() => { if (UserType === 'Employee') { fetchApi(); } }, [UserType]); useEffect(() => { let hasAccess = false; if (UserType === 'Admin' || UserType === 'Super Admin') { hasAccess = true; } else if (UserType === 'Employee') { hasAccess = empData?.AddAccess === 'Y' || SAAccessCommonMaster?.UpdateAccess === 'Y'; } else if (UserType === 'Super Admin User') { hasAccess = SAAccessCommonMaster?.AddAccess === 'Y' || SAAccessCommonMaster?.UpdateAccess === 'Y'; } setaddnewAccess(!hasAccess); }, [empData, SAAccessCommonMaster, UserType]); const fetchApi = async () => { let data = { CompId: CompId, BranchId: BranchId, AppId: AppId, EmpId: UserId, }; let response = await dispatch(getEmpAccess(data)).unwrap(); let datas = response?.data?.data?.[0]?.EmpAccessDetails?.filter( (item) => item.ConfigName === 'Barcode / Qr Setup' ); setEmpData(datas?.[0]); }; useEffect(() => { if (dropdownValue !== undefined && dropdownValue !== null) { const name = coresdata?.find( (find) => find.ConfigId === dropdownValue )?.ConfigName; setSizeName(name); } }, [dropdownValue]); useEffect(() => { if (editMode && editinitialRun) { const { radioValue, secondRadioValue, arrayValue, secondArrayValue } = getPositionOptions(true); if ( sizeName === '50X30 Single' || sizeName === '50X25 Single' || (sizeName === '100X150' && editinitialRun) ) { secondArrayValue !== undefined && secondArrayValue?.length > 0 ? setSecondValue(secondRadioValue) : setSecondValue(); arrayValue !== undefined && arrayValue?.length > 0 ? setValue(radioValue) : setValue(); } else { arrayValue !== undefined && arrayValue?.length > 0 ? (setValue(radioValue), setSecondValue()) : (setValue(), setSecondValue()); } } else if (!editMode) { const { radioValue, secondRadioValue, arrayValue, secondArrayValue } = getPositionOptions(true); if ( sizeName === '50X30 Single' || sizeName === '50X25 Single' || sizeName === '100X150' ) { secondArrayValue !== undefined && secondArrayValue?.length > 0 && setSecondValue(secondRadioValue); arrayValue !== undefined && arrayValue?.length > 0 ? setValue(radioValue) : setValue(); } else { arrayValue !== undefined && arrayValue?.length > 0 ? (setValue(radioValue), setSecondValue()) : (setValue(), setSecondValue()); } } else { setEditInitialRun(true); } }, [sizeName, selectedSizeCheckedValues]); const onChangeFirst = (e) => { setValue(e?.target?.value); }; const onChangeSecondValue = (e) => { setSecondValue(e?.target?.value); }; const actionsFormatter = async (record) => { const { SessionId, OptionDetails, Position, PositionString, CodeType } = record; setEditMode(true); const updatedCoresData = [...coresdata]?.filter( (filter) => filter.ConfigId === SessionId ); setFilteredCoreData(updatedCoresData); setSelectedOption(CodeType); setEditInitialRun(false); setDropdownValue(SessionId); formRef?.current?.setFieldsValue({ Cross: SessionId }); const response = await dispatch( globalBarcode.getBarcodeComponentsBasedOnSessionId(SessionId) ).unwrap(); if (response?.data?.statusCode === 1) { setSizeCheckList(response?.data?.data); const checkedData = OptionDetails?.map((item) => item.OptionId); setSelectedSizeCheckedValues(checkedData); setCheckedList(checkedData); setValue(Position !== '' ? Position : undefined); setSecondValue(PositionString !== '' ? PositionString : undefined); } else { setMessage({ Type: 'error', Message: response?.data?.response }); } }; const CoresOnChange = async (params) => { setDropdownValue(params); formRef.current?.setFieldsValue({ Cross: params }); if (params !== undefined && params !== null) { const response = await dispatch( globalBarcode.getBarcodeComponentsBasedOnSessionId(params) ).unwrap(); if (response?.data?.statusCode === 1) { setSizeCheckList(response?.data?.data); const allCheckboxes = response?.data?.data .filter( (item) => item.ComponentName !== (selectedOption === 'B' ? 'Qrcode' : 'Barcode') ) .map((item) => item.ComponentId); setSelectedSizeCheckedValues(allCheckboxes); setCheckedList(allCheckboxes); const name = coresdata?.find( (find) => find.ConfigId === params )?.ConfigName; if (name === '22X35 3cross' || name === '25X50 2cross') { setValue('T'); // Default to Top setSecondValue(undefined); } else if (name === '100X13 (55MM Printable)') { setValue('L'); // Default to Left setSecondValue(undefined); } else if (name === '100X15 (70MM Printable)') { setValue('R'); // Default to Right setSecondValue(undefined); } } else { setMessage({ Type: 'error', Message: response?.data?.response }); } } }; const getBarcodeSessionData = async () => { let getResponse = await dispatch( globalBarcode.getBarcodeTemplate({ compId: CompId, appId: AppId, branchId: BranchId, }) ).unwrap(); if (getResponse?.data?.statusCode === 1) { if (getResponse?.data?.data?.length > 0) { const { TemplateDetails } = getResponse?.data?.data?.[0]; setPutMode(true); setGetSizeData(TemplateDetails); } else { setPutMode(false); setGetSizeData([]); } } let resp = await dispatch(globalBarcode.getBarcodeSessionsIDs()).unwrap(); if (resp?.data?.statusCode === 1) { setCoresdata(resp?.data?.data); if (getResponse?.data?.data?.length === 0) { setFilteredCoreData(resp?.data?.data); } else { if (getResponse?.data?.data?.length > 0) { const { TemplateDetails } = getResponse?.data?.data?.[0]; const filteredData = await resp?.data?.data?.filter( (filter) => !TemplateDetails.some( (some) => some.SessionId === filter.ConfigId ) ); setFilteredCoreData(filteredData); } } } else { setCoresdata([]); } }; const onCheckboxChange = (checkedValues) => { setCheckedList(checkedValues); setSelectedSizeCheckedValues(checkedValues); }; const onCheckAllChange = (e) => { let Data = sizeCheckList ?.filter( (filter) => filter.ComponentName !== (selectedOption === 'B' ? 'Qrcode' : 'Barcode') ) .map((item) => item.ComponentId); setCheckedList(e.target.checked ? Data : []); setSelectedSizeCheckedValues(e.target.checked ? Data : []); }; const getPositionOptions = () => { let result = { radioValue: '', secondRadioValue: '', arrayValue: [], secondArrayValue: [], }; const componentMap = Object.fromEntries( sizeCheckList?.map((item) => [item.ComponentName, item.ComponentId]) || [] ); const checkComponent = (name) => selectedSizeCheckedValues.includes(componentMap[name]); const mrp = checkComponent('MRP'); const color = checkComponent('Color'); const eDate = checkComponent('E Date'); const mDate = checkComponent('M Date'); const sellingPrice = checkComponent('Selling Price'); const productName = checkComponent('Product Name'); const filterByValues = (values) => { return positionOption?.filter((item) => values.includes(item.value)); }; const CTB = ['C', 'T', 'B']; const BT = ['B', 'T']; const LR = ['L', 'R']; const CT = ['C', 'T']; const CB = ['C', 'B']; const C = ['C']; const T = ['T']; const L = ['L']; const R = ['R']; switch (sizeName) { case '15X15 6cross': case '25X25 4cross': switch (sizeName) { case '15X15 6cross': if (mrp && productName) { result.arrayValue = filterByValues(CTB); result.secondArrayValue = []; result.radioValue = value || 'C'; result.secondRadioValue = ''; } else if (mrp) { result.arrayValue = filterByValues(CB); result.secondArrayValue = []; result.radioValue = (value === 'T' ? 'C' : value) || 'C'; result.secondRadioValue = ''; } else if (productName) { result.arrayValue = filterByValues(CT); result.secondArrayValue = []; result.radioValue = (value == 'B' ? 'T' : value) || 'T'; result.secondRadioValue = ''; } else { result.arrayValue = filterByValues(C); result.secondArrayValue = []; result.radioValue = 'C'; result.secondRadioValue = ''; } break; case '25X25 4cross': if ((mrp || productName) && (eDate || mDate)) { result.arrayValue = filterByValues(CTB); result.secondArrayValue = []; result.radioValue = value || 'C'; result.secondRadioValue = ''; } else if (eDate || mDate) { result.arrayValue = filterByValues(CB); result.secondArrayValue = []; result.radioValue = (value === 'T' ? 'C' : value) || 'C'; result.secondRadioValue = ''; } else if (mrp || productName) { result.arrayValue = filterByValues(CT); result.secondArrayValue = []; result.radioValue = (value == 'B' ? 'C' : value) || 'C'; result.secondRadioValue = ''; } else { result.arrayValue = filterByValues(C); result.radioValue = 'C'; result.secondArrayValue = []; result.secondRadioValue = ''; } break; } return result; case '22X35 3cross': case '25X50 2cross': switch (sizeName) { case '22X35 3cross': if (mrp) { result.arrayValue = filterByValues(BT); result.secondArrayValue = []; result.radioValue = value || 'T'; result.secondRadioValue = ''; } else { result.arrayValue = filterByValues(T); result.secondArrayValue = []; result.secondRadioValue = ''; result.radioValue = 'T'; } break; case '25X50 2cross': if (mrp || productName) { result.arrayValue = filterByValues(BT); result.secondArrayValue = []; result.radioValue = value || 'T'; result.secondRadioValue = ''; } else { result.arrayValue = filterByValues(T); result.secondArrayValue = []; result.radioValue = 'T'; result.secondRadioValue = ''; } break; } return result; case '50X30 Single': case '50X25 Single': case '100X150': switch (sizeName) { case '50X30 Single': if (mrp && (eDate || mDate || productName)) { result.arrayValue = filterByValues(BT); result.secondArrayValue = filterByValues(LR); result.radioValue = value || 'T'; result.secondRadioValue = secondValue || 'R'; } else if (mrp) { result.arrayValue = filterByValues(BT); result.radioValue = value || 'T'; result.secondArrayValue = []; result.secondRadioValue = ''; } else if (eDate || mDate || productName) { result.secondArrayValue = filterByValues(LR); result.secondRadioValue = secondValue || 'R'; result.arrayValue = []; result.radioValue = ''; } else { result.arrayValue = filterByValues(T); result.secondArrayValue = filterByValues(L); result.radioValue = 'T'; result.secondRadioValue = 'L'; } break; case '50X25 Single': if (mrp && mDate) { result.arrayValue = filterByValues(BT); result.secondArrayValue = filterByValues(LR); result.radioValue = value || 'T'; result.secondRadioValue = secondValue || 'L'; } else if (mrp) { result.arrayValue = filterByValues(BT); result.radioValue = value || 'T'; result.secondArrayValue = []; result.secondRadioValue = ''; } else if (mDate) { result.secondArrayValue = filterByValues(LR); result.secondRadioValue = secondValue || 'L'; result.arrayValue = []; result.radioValue = ''; } else { result.arrayValue = filterByValues(T); result.secondArrayValue = filterByValues(L); result.radioValue = 'T'; result.secondRadioValue = 'L'; } break; case '100X150': if ( mrp && (mDate || color || sellingPrice || eDate || productName) ) { result.arrayValue = filterByValues(BT); result.secondArrayValue = filterByValues(LR); result.radioValue = value || 'T'; result.secondRadioValue = secondValue || 'R'; } else if (mrp) { result.arrayValue = filterByValues(BT); result.radioValue = value || 'T'; result.secondArrayValue = []; result.secondRadioValue = ''; } else if (mDate || color || sellingPrice || eDate || productName) { result.secondArrayValue = filterByValues(LR); result.secondRadioValue = secondValue || 'R'; result.arrayValue = []; result.radioValue = ''; } else { result.arrayValue = filterByValues(T); result.secondArrayValue = filterByValues(L); result.radioValue = 'T'; result.secondRadioValue = 'L'; } break; } return result; case '100X15 (70MM Printable)': case '100X13 (55MM Printable)': switch (sizeName) { case '100X15 (70MM Printable)': if (mrp || sellingPrice || productName) { result.arrayValue = filterByValues(LR); result.secondArrayValue = []; result.radioValue = value || 'R'; result.secondRadioValue = ''; } else { result.arrayValue = filterByValues(R); result.secondArrayValue = []; result.radioValue = 'R'; result.secondRadioValue = ''; } break; case '100X13 (55MM Printable)': if (sellingPrice || productName) { result.arrayValue = filterByValues(LR); result.secondArrayValue = []; result.radioValue = value || 'L'; result.secondRadioValue = ''; } else { result.arrayValue = filterByValues(L); result.secondArrayValue = []; result.radioValue = 'L'; result.secondRadioValue = ''; } break; } return result; default: return []; } }; const renderBarcodePositionOptions = () => { const positionOptions = getPositionOptions(); const { arrayValue = [], secondArrayValue = [] } = positionOptions || {}; const isBarcodeSelected = selectedSizeCheckedValues?.includes( sizeCheckList?.find((item) => item.ComponentName === 'Barcode') ?.ComponentId ); const isQrcodeSelected = selectedSizeCheckedValues?.includes( sizeCheckList?.find((item) => item.ComponentName === 'Qrcode') ?.ComponentId ); const isSpecialSize = ['50X30 Single', '50X25 Single', '100X150'].includes( sizeName ); const hasOptions = arrayValue.length > 0 || secondArrayValue.length > 0; if ( selectedSizeCheckedValues?.length > 0 && (isBarcodeSelected || isQrcodeSelected) ) { if (isSpecialSize && hasOptions) { return (
{barCodePositionText}
{arrayValue.length > 0 && ( )} {arrayValue.length > 0 && secondArrayValue.length > 0 && (
)} {secondArrayValue.length > 0 && ( )}
); } else if (!isSpecialSize && arrayValue.length > 0) { return (
{barCodePositionText}
); } } return null; }; const onFinish = async () => { const data = { CompId: CompId, BranchId: BranchId, AppId: AppId, TemplateDetails: getSizeData, CreatedBy: UserId, }; if (putMode) { if (data?.TemplateDetails?.length === 0) { setFilteredCoreData([...coresdata]); } const response = await dispatch( globalBarcode.putBarcodeTemplate(data) ).unwrap(); if (response?.data?.statusCode === 1) { setMessage({ Type: 'success', Message: response?.data?.response }); setEditInitialRun(false); setPutMode(false); getBarcodeSessionData(); } else { setMessage({ Type: 'error', Message: response?.data?.response }); } } else { if (getSizeData?.length > 0) { const response = await dispatch( globalBarcode.postBarcodeTemplate(data) ).unwrap(); if (response?.data?.statusCode === 1) { setMessage({ Type: 'success', Message: response?.data?.response }); setEditInitialRun(false); setPutMode(false); getBarcodeSessionData(); } else { setMessage({ Type: 'error', Message: response?.data?.response }); } } else { setMessage({ Type: 'error', Message: 'Please Setup a Barcode' }); } } }; const handleCancel = (sizeData) => { setSelectedOption('B'); setEditMode(false); setEditInitialRun(false); setSizeCheckList([]); setSelectedSizeCheckedValues([]); setCheckedList([]); setDropdownValue(); formRef?.current?.resetFields(); const updatedCoresData = [...coresdata]?.filter( (filter) => !sizeData.some((some) => some.SessionId === filter.ConfigId) ); setFilteredCoreData(updatedCoresData); }; const handleSizeAddOrSave = () => { const optionDetails = selectedSizeCheckedValues.map((item) => { const { ComponentName } = sizeCheckList?.find( (find) => find.ComponentId === item ); return { OptionName: ComponentName, OptionId: item, }; }); let updatedSizeData = []; if (editMode) { setGetSizeData((prev) => { updatedSizeData = prev?.map((item) => { if (item.SessionId === dropdownValue) { return { ...item, Position: value !== undefined ? value : '', PositionString: secondValue !== undefined ? secondValue : '', OptionDetails: optionDetails, CodeType: selectedOption, }; } return item; }); return updatedSizeData; }); const updatedCoresData = [...coresdata]?.filter( (filter) => filter.ConfigId === dropdownValue ); setFilteredCoreData(updatedCoresData); } else { const { ConfigName } = coresdata?.find( (find) => find.ConfigId === dropdownValue ); setGetSizeData((prev) => { updatedSizeData = [ ...prev, { SessionId: dropdownValue, CodeType: selectedOption, Position: value !== undefined ? value : '', PositionString: secondValue !== undefined ? secondValue : '', OptionDetails: optionDetails, SessionName: ConfigName, }, ]; return updatedSizeData; }); const updatedCoresData = [...coresdata]?.filter( (filter) => !updatedSizeData.some((some) => some.SessionId === filter.ConfigId) ); setFilteredCoreData(updatedCoresData); } handleCancel(updatedSizeData); }; const handleImageTag = (w, h = '40px') => { return ( {previewText} ); }; const handleChangeOption = (param) => { setSelectedOption(param); // Select all checkboxes for the new code type if (sizeCheckList?.length > 0) { const allCheckboxes = sizeCheckList .filter( (item) => item.ComponentName !== (param === 'B' ? 'Qrcode' : 'Barcode') ) .map((item) => item.ComponentId); setCheckedList(allCheckboxes); setSelectedSizeCheckedValues(allCheckboxes); } }; const [rightClickCount, setRightClickCount] = useState(0); const [clickCount, setClickCount] = useState(0); const leftOnclick = () => { if (!dropdownValue || filteredCoreData.length === 0) return; setClickCount(0); const currentIndex = filteredCoreData.findIndex( (item) => item.ConfigId === dropdownValue ); if (currentIndex > 0) { CoresOnChange(filteredCoreData[currentIndex - 1].ConfigId); } else { CoresOnChange(filteredCoreData[filteredCoreData.length - 1].ConfigId); } }; const RightOnclick = () => { if (!dropdownValue || filteredCoreData.length === 0) return; const newClickCount = clickCount + 1; setClickCount(newClickCount); if (newClickCount >= 6 && filteredCoreData.length > 6) { setShowAll(true); setClickCount(0); } const currentIndex = filteredCoreData.findIndex( (item) => item.ConfigId === dropdownValue ); if (currentIndex < filteredCoreData.length - 1) { CoresOnChange(filteredCoreData[currentIndex + 1].ConfigId); } else { CoresOnChange(filteredCoreData[0].ConfigId); setClickCount(0); } }; useEffect(() => { setClickCount(0); }, [showAll]); useEffect(() => { if (filteredCoreData?.length > 0 && !dropdownValue && !editMode) { CoresOnChange(filteredCoreData[0].ConfigId); } }, [filteredCoreData]); useEffect(() => { if (dropdownValue && !editMode) { const currentSize = coresdata?.find( (find) => find.ConfigId === dropdownValue )?.ConfigName; if (currentSize === '22X35 3cross' || currentSize === '25X50 2cross') { setSecondValue(undefined); } else if (currentSize === '100X13 (55MM Printable)') { setSecondValue(undefined); } else if (currentSize === '100X15 (70MM Printable)') { setSecondValue(undefined); } } }, [dropdownValue, coresdata, editMode]); return (

Barcode /{' '} Qr Setup

Easily configure barcode and QR code settings for your products

{' '} Scan Setup

handleChangeOption(value)} // options={[ // { // label: ( //
//
Barcode
// //
// ), // value: 'B', // }, // { // value: 'Q', // label: ( //
//
Qr code
// //
// ), // }, // ]} options={[ { label: (
Barcode
), value: 'B', }, { value: 'Q', label: (
Qr code
), }, ]} />

{/* {(filteredCoreData?.length > 0 || editMode) &&
({ value: option.ConfigId, label: option.ConfigName, })), ]} placeholder="Please Enter Cross" label={} className='field-DropDown' isOnchanges={dropdownValue !== undefined ? true : false} onChangeFunction={(e) => CoresOnChange(e)} valueData={dropdownValue} disabled={editMode} />
} */} {(filteredCoreData?.length > 0 || editMode) && (
{displayedData.map((item) => { const isSelected = dropdownValue === item.ConfigId; const isDisabled = editMode; return (
{ if (!isDisabled) { CoresOnChange(item.ConfigId); } }} > {' '} {item.ConfigName} {item.ConfigName}
); })}
{filteredCoreData.length > 4 && (
setShowAll(!showAll)} > {showAll ? ( <> Show Less ) : ( <> View All )}
)}
)} {dropdownValue !== undefined && (
Select All {sizeCheckList ?.filter( (filter) => filter.ComponentName !== (selectedOption === 'B' ? 'Qrcode' : 'Barcode') ) ?.map((value) => { let tooltipText = null; if (value.ComponentName === 'E Date') { tooltipText = 'This is the expiry date.'; } else if (value.ComponentName === 'M Date') { tooltipText = 'This is the manufacturing date.'; } return ( {tooltipText ? ( {value.ComponentName} ) : ( value.ComponentName )} ); })}
)} {renderBarcodePositionOptions()} {selectedSizeCheckedValues?.length > 0 && dropdownValue !== undefined && (
{editMode ? 'Update ' : 'Add'}
{editMode && (
handleCancel(getSizeData)} > {' '} Cancel{' '}
)}
)}
{getSizeData?.length > 0 && (
)} {!editMode && (
} buttonText={'Submit'} color="901D77" handleSubmit={onFinish} disabled={addnewAccess} />
)}
{/* sree */} {/* Preview Section */}
PREVIEW
); }; export default BarcodeTemplateSetup;