import { Form, Empty } from 'antd'; import { GiHorizontalFlip, GiVerticalFlip } from 'react-icons/gi'; import { FaPlus } from 'react-icons/fa6'; import { InputField } from '../../Components/Forms/InputField.jsx'; import { DefaultModal } from '../../Components/Modal/DefaultModal.jsx'; import Buttons from '../../Components/Forms/Buttons'; import { validateSafeInput } from '../../Services/Others'; import { useEffect } from 'react'; const StickerPrintModel = ({ open, handleCancel, formRef, onFinish, MultiCode, activeTab, setActiveTab, selectedRecords, coresdata, dropdownValue, CoresOnChange, barcodeTemplateDetails, detail, proName, nickName, ProdId, size, CopiesOnChange, printProductName, totalCopies, setstockWiseQrcode, setProductWiseQrcode, setNickName, templateOptions, }) => { const secondValueStyle = { flexDirection: templateOptions.secondValue === 'R' ? 'row' : 'row-reverse', }; const valueStyleRow = { flexDirection: templateOptions.value === 'R' ? 'row' : 'row-reverse', }; const valueStyleColumn = { flexDirection: templateOptions.value === 'T' ? 'column' : 'column-reverse', }; 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'; const previewText = 'Barcode Preview'; const formatDate = (dateStr) => { const d = new Date(dateStr); const day = String(d.getDate()).padStart(2, '0'); const months = [ 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC', ]; const month = months[d.getMonth()]; const year = String(d.getFullYear()).slice(-2); return `${day}-${month}-${year}`; }; const colorText = 'Color : Red'; const handleImageTag = (w, h = '40px', barcodeOrQr) => { return ( {previewText} ); }; useEffect(() => { if (coresdata?.length > 0 && open) { CoresOnChange(coresdata?.[0].ConfigName); } }, [open, coresdata]); return ( {MultiCode && (
setActiveTab('stock')} > Stock Wise{' '} ({selectedRecords?.length})
{ e.stopPropagation(); setstockWiseQrcode(true); }} style={{ animation: activeTab === 'stock' ? 'blink 1s infinite' : 'none', }} > Add
setActiveTab('product')} > Product Wise{' '} ({selectedRecords?.length})
{ e.stopPropagation(); setProductWiseQrcode(true); }} style={{ animation: activeTab === 'product' ? 'blink 1s infinite' : 'none', }} > Add
)}
{coresdata?.map((option) => (
CoresOnChange(option.ConfigName)} className={`radio-sidebar-item ${dropdownValue === option.ConfigName ? 'selected' : ''}`} >
{option.ConfigName}
))}
PREVIEW
{(() => { const template = barcodeTemplateDetails?.find( (find) => find.SessionName === dropdownValue ); const templateAvailable = template === undefined ? false : true; const checkComponent = (name) => template?.OptionDetails?.some( (some) => some.OptionName === name ); const mrp = checkComponent('MRP'); const qrcode = checkComponent('Qrcode'); const barcode = checkComponent('Barcode'); 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 barcodeOrQr = template?.CodeType ? template?.CodeType === 'B' : true; const templateValue = template?.Position !== '' ? template?.Position : ''; switch (dropdownValue) { case '15X15 6cross': return templateAvailable ? ( !(productName || barcode || qrcode || mrp) ? ( ) : ( <>
{[...Array(6)].map((_, index) => (
{(barcode || qrcode) && templateValue === 'T' && handleImageTag( barcodeOrQr ? 50 : 20, 20, barcodeOrQr )} {productName && (
12 ? 'text-ellipsis' : ''}`} > {nickName ? nickName : proName ? proName : 'Product Name'}
)} {(barcode || qrcode) && templateValue === 'C' && handleImageTag( barcodeOrQr ? 50 : 20, 20, barcodeOrQr )} {mrp && (
{'₹:' + (detail?.MRP ? detail?.MRP : 0.0)}
)} {(barcode || qrcode) && templateValue === 'B' && handleImageTag( barcodeOrQr ? 50 : 20, 20, barcodeOrQr )}
))}

Vertical

{' '}
- {'15mm'}

Horizontal

{' '}
- {'15mm'}

) ) : ( <>
{Array.from({ length: 6 }).map((_, index) => (
{`QR
))}

Vertical

{' '}
- {'15mm'}

Horizontal

{' '}
- {'15mm'}

); case '22X35 3cross': return templateAvailable ? ( !(barcode || qrcode || mrp) ? ( ) : ( <>
{[...Array(3)].map((_, index) => (
{(barcode || qrcode) && handleImageTag( barcodeOrQr ? 100 : 35, 35, barcodeOrQr )} {(productName || mrp) && (
{productName && (
12 ? 'text-ellipsis' : ''}`} > {nickName ? nickName : proName || 'Product Name'}
)} {mrp && (
{'₹:' + (detail?.MRP ? detail?.MRP : 10.0)}
)}
)}
))}

Vertical

{' '}
- {'22mm'}

Horizontal

{' '}
- {'35mm'}

) ) : ( <>
{Array?.from({ length: 3 })?.map( (_, index) => (

8 ? 'text-ellipsis' : ''}`} > {proName || 'Product Name'} ( {size || '1 PCS'})

{ProdId || 'QR579890770'}

) )}

Vertical

{' '}
- {'22mm'}

Horizontal

{' '}
- {'35mm'}

); case '25X25 4cross': return templateAvailable ? ( !( productName || mDate || eDate || barcode || qrcode || mrp ) ? ( ) : ( <>
{[...Array(4)].map((_, index) => (
{(barcode || qrcode) && templateValue === 'T' && handleImageTag( barcodeOrQr ? 60 : 35, 35, barcodeOrQr )} {productName && (
12 ? 'text-ellipsis' : ''}`} > {nickName ? nickName : proName ? proName : 'Product Name'}
)} {mrp && (
{'₹:' + (detail?.MRP ? detail?.MRP : 10.0)}
)} {(barcode || qrcode) && templateValue === 'C' && handleImageTag( barcodeOrQr ? 60 : 35, 35, barcodeOrQr )} {mDate && (
)} {eDate && (
DD-MM-YYYY
)} {(barcode || qrcode) && templateValue === 'B' && handleImageTag( barcodeOrQr ? 60 : 35, 35, barcodeOrQr )}
))}

Vertical

{' '}
- {'25mm'}

Horizontal

{' '}
- {'25mm'}

) ) : ( <>
{Array.from({ length: 4 })?.map( (_, index) => (

12 ? 'text-ellipsis' : ''}`} > {nickName ? nickName : proName ? proName : 'Product Name'} ({size || '1 PCS'})

barcode

{ProdId || 'QR8575956'}

) )}

Vertical

{' '}
- {'25mm'}

Horizontal

{' '}
- {'25mm'}

); case '25X50 2cross': return templateAvailable ? ( !(productName || barcode || qrcode || mrp) ? ( ) : ( <>
{[...Array(2)].map((_, index) => (
{(barcode || qrcode) && handleImageTag( barcodeOrQr ? 140 : 30, 30, barcodeOrQr )} {productName && (
12 ? 'text-ellipsis' : ''}`} > {nickName ? nickName : proName ? proName : 'Product Name'}
)} {mrp && (
{'₹:' + (detail?.MRP ? detail?.MRP : 10.0)}
)}
))}

Vertical

{' '}
- {'25mm'}

Horizontal

{' '}
- {'50mm'}

) ) : ( <>
{Array.from({ length: 2 })?.map( (_, index) => (

12 ? 'text-ellipsis' : ''}`} > {proName || 'Product Name'} ( {size || '1 PCS'})

{ProdId || 'QR74478578'}

) )}

Vertical

{' '}
- {'25mm'}

Horizontal

{' '}
- {'50mm'}

); case '50X30 Single': return templateAvailable ? ( !( productName || mDate || eDate || barcode || qrcode || mrp ) ? ( ) : ( <>
{productName && (
12 ? 'text-ellipsis' : ''}`} > {nickName ? nickName : proName ? proName : 'Product Name'}
)} {mDate && detail?.ProdVariantPriceDetails?.[0] ?.ManufDate && (
{formatDate( detail ?.ProdVariantPriceDetails?.[0] ?.ManufDate )}
)} {eDate && detail?.ProdVariantPriceDetails?.[0] ?.ExpDate && (
{formatDate( detail ?.ProdVariantPriceDetails?.[0] ?.ExpDate )}
)}
{(barcode || qrcode) && handleImageTag( barcodeOrQr ? 70 : 35, 35, barcodeOrQr )} {mrp && (
{'MRP : ' + (detail?.MRP || 10.0)}
)}

Vertical

{' '}
- {'30mm'}

Horizontal

{' '}
- {'50mm'}

) ) : ( <>

12 ? 'text-ellipsis' : ''}`} > {proName || 'Product Name'} ( {size || '1 PCS'})

{ProdId || 'QR987968'}

Vertical

{' '}
- {'30mm'}

Horizontal

{' '}
- {'50mm'}

); case '50X25 Single': return templateAvailable ? ( !( productName || mDate || barcode || qrcode || mrp ) ? ( ) : ( <>
{productName && (
12 ? 'text-ellipsis' : ''}`} > {nickName ? nickName : proName ? proName : 'Product Name'}
)} {mDate && detail?.ProdVariantPriceDetails?.[0] ?.ManufDate && (
{formatDate( detail ?.ProdVariantPriceDetails?.[0] ?.ManufDate )}
)}
{(barcode || qrcode) && handleImageTag( barcodeOrQr ? 70 : 35, 35, barcodeOrQr )} {mrp && (
{'MRP : ' + (detail?.MRP || '10.0')}
)}

Vertical

{' '}
- {'25mm'}

Horizontal

{' '}
- {'50mm'}

) ) : ( <>

12 ? 'text-ellipsis' : ''}`} > {proName || 'Product Name'} ( {size || '1 PCS'})

{ProdId || 'QR8798639'}

Vertical

{' '}
- {'25mm'}

Horizontal

{' '}
- {'50mm'}

); case '100X13 (55MM Printable)': return templateAvailable ? ( !( productName || sellingPrice || barcode || qrcode ) ? ( ) : ( <>
{(barcode || qrcode) && handleImageTag( barcodeOrQr ? 140 : 35, 35, barcodeOrQr )}
{productName && (
12 ? 'text-ellipsis' : ''}`} > {nickName ? nickName : proName ? proName : 'Product Name'}
)} {sellingPrice && (
{`Selling Price : ` + (detail?.SellPrice || '10.0')}
)}

Vertical

{' '}
- {'13mm'}

Horizontal

{' '}
- {'100mm'}

) ) : ( <>

12 ? 'text-ellipsis' : ''}`} > {proName || 'Product Name'} ( {size || '1 PCS'})

{ProdId || 'QR0970970'}

Vertical

{' '}
- {'13mm'}

Horizontal

{' '}
- {'100mm'}

); case '100X15 (70MM Printable)': return templateAvailable ? ( !( productName || sellingPrice || barcode || qrcode || mrp ) ? ( ) : ( <>
{productName && (
12 ? 'text-ellipsis' : ''}`} > {nickName ? nickName : proName ? proName : 'Product Name'}
)} {mrp && (
{'MRP : ' + (detail?.MRP || '10.0')}
)} {sellingPrice && (
{`Selling Price : ` + (detail?.SellPrice || '10.0')}
)}
{(barcode || qrcode) && handleImageTag( barcodeOrQr ? 90 : 40, null, barcodeOrQr )}

Vertical

{' '}
- {'15mm'}

Horizontal

{' '}
- {'100mm'}

) ) : ( <>

12 ? 'text-ellipsis' : ''}`} > {proName || 'Product Name'} ( {size || '1 PCS'})

{ProdId || 'QR858755'}

Vertical

{' '}
- {'15mm'}

Horizontal

{' '}
- {'100mm'}

); case '100X150': return templateAvailable ? ( !( productName || sellingPrice || mDate || eDate || color || barcode || qrcode || mrp ) ? ( ) : ( <>
{productName && (
12 ? 'text-ellipsis' : ''}`} > {nickName ? nickName : proName ? proName : 'Product Name'}
)} {sellingPrice && (
{`Selling Price : ` + detail?.SellPrice}
)} {mDate && detail?.ProdVariantPriceDetails?.[0] ?.ManufDate && (
{formatDate( detail ?.ProdVariantPriceDetails?.[0] ?.ManufDate )}
)} {eDate && detail?.ProdVariantPriceDetails?.[0] ?.ExpDate && (
{formatDate( detail ?.ProdVariantPriceDetails?.[0] ?.ExpDate )}
)} {color && (
{colorText}
)}
{(barcode || qrcode) && handleImageTag( barcodeOrQr ? 140 : 35, 35, barcodeOrQr )} {mrp && (
{'MRP : ' + (detail?.MRP || '10.0')}
)}

Vertical

{' '}
- {'150mm'}

Horizontal

{' '}
- {'100mm'}

) ) : ( <>

{detail?.BrName}

Product Name:{' '}

12 ? 'text-ellipsis' : ''}`} > {nickName ? nickName : proName ? proName : 'Product Name'}

SIZE:{' '} {size || '1 PCS'}

Id:{' '} {ProdId || 'QR86868'}

MRP:{' '} {'MRP : ' + (detail?.MRP || '10.0')}

Selling Price:{' '} {detail?.SellPrice || '10.0'}

Vertical

{' '}
- {'150mm'}

Horizontal

{' '}
- {'100mm'}

); default: return ; } })()}

{dropdownValue}

{!MultiCode && ( { await validateSafeInput(value); return Promise.resolve(); }, }, ]} > Copies} isOnChange={false} onChange={(e) => { CopiesOnChange(e?.target?.value); }} /> )} {proName?.length > 12 && printProductName && !MultiCode && ( <>
Note: Product name is very long. Please add a short/nick name to proceed print.
{ setNickName(e?.target?.value); }} maxLength={12} /> )}
{(!MultiCode || totalCopies > 0) && ( )} {MultiCode && totalCopies === 0 && ( )}
} /> ); }; export default StickerPrintModel;