Validation error
This commit is contained in:
@@ -173,7 +173,7 @@ export default function CreatePage() {
|
|||||||
case 'FEEDBACK':
|
case 'FEEDBACK':
|
||||||
return content.feedbackUrl || 'https://example.com/feedback';
|
return content.feedbackUrl || 'https://example.com/feedback';
|
||||||
case 'BARCODE':
|
case 'BARCODE':
|
||||||
return content.value || '123456789';
|
return content.value || '';
|
||||||
default:
|
default:
|
||||||
return 'https://example.com';
|
return 'https://example.com';
|
||||||
}
|
}
|
||||||
@@ -1062,6 +1062,7 @@ export default function CreatePage() {
|
|||||||
qrContent ? (
|
qrContent ? (
|
||||||
<div className="p-2 bg-white">
|
<div className="p-2 bg-white">
|
||||||
<Barcode
|
<Barcode
|
||||||
|
key={`${qrContent}-${content.format}-${foregroundColor}`}
|
||||||
value={qrContent}
|
value={qrContent}
|
||||||
format={content.format || 'CODE128'}
|
format={content.format || 'CODE128'}
|
||||||
lineColor={foregroundColor}
|
lineColor={foregroundColor}
|
||||||
|
|||||||
@@ -190,6 +190,9 @@ END:VCARD`;
|
|||||||
case 'FEEDBACK':
|
case 'FEEDBACK':
|
||||||
qrContent = body.content.feedbackUrl || 'https://example.com/feedback';
|
qrContent = body.content.feedbackUrl || 'https://example.com/feedback';
|
||||||
break;
|
break;
|
||||||
|
case 'BARCODE':
|
||||||
|
qrContent = body.content.value || '123456789';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
qrContent = body.content.url || 'https://example.com';
|
qrContent = body.content.url || 'https://example.com';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { QRCodeSVG } from 'qrcode.react';
|
import { QRCodeSVG } from 'qrcode.react';
|
||||||
|
import Barcode from 'react-barcode';
|
||||||
import { Card, CardContent } from '@/components/ui/Card';
|
import { Card, CardContent } from '@/components/ui/Card';
|
||||||
import { Badge } from '@/components/ui/Badge';
|
import { Badge } from '@/components/ui/Badge';
|
||||||
import { Dropdown, DropdownItem } from '@/components/ui/Dropdown';
|
import { Dropdown, DropdownItem } from '@/components/ui/Dropdown';
|
||||||
@@ -208,6 +209,19 @@ END:VCARD`;
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div id={`qr-svg-${qr.id}`} className={qr.style?.cornerStyle === 'rounded' ? 'rounded-lg overflow-hidden' : ''}>
|
<div id={`qr-svg-${qr.id}`} className={qr.style?.cornerStyle === 'rounded' ? 'rounded-lg overflow-hidden' : ''}>
|
||||||
|
{qr.contentType === 'BARCODE' && qr.type === 'STATIC' ? (
|
||||||
|
<Barcode
|
||||||
|
key={`${qr.content?.value}-${qr.content?.format}`}
|
||||||
|
value={qr.content?.value || '123456789'}
|
||||||
|
format={(qr.content?.format as any) || 'CODE128'}
|
||||||
|
lineColor={qr.style?.foregroundColor || '#000000'}
|
||||||
|
background={qr.style?.backgroundColor || '#FFFFFF'}
|
||||||
|
width={1.5}
|
||||||
|
height={60}
|
||||||
|
displayValue={true}
|
||||||
|
fontSize={10}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
<QRCodeSVG
|
<QRCodeSVG
|
||||||
value={qrUrl}
|
value={qrUrl}
|
||||||
size={96}
|
size={96}
|
||||||
@@ -216,11 +230,12 @@ END:VCARD`;
|
|||||||
level="H"
|
level="H"
|
||||||
imageSettings={qr.style?.imageSettings ? {
|
imageSettings={qr.style?.imageSettings ? {
|
||||||
src: qr.style.imageSettings.src,
|
src: qr.style.imageSettings.src,
|
||||||
height: qr.style.imageSettings.height * (96 / 200), // Scale logo for smaller QR
|
height: qr.style.imageSettings.height * (96 / 200),
|
||||||
width: qr.style.imageSettings.width * (96 / 200),
|
width: qr.style.imageSettings.width * (96 / 200),
|
||||||
excavate: qr.style.imageSettings.excavate,
|
excavate: qr.style.imageSettings.excavate,
|
||||||
} : undefined}
|
} : undefined}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export const createQRSchema = z.object({
|
|||||||
|
|
||||||
isStatic: z.boolean().optional(),
|
isStatic: z.boolean().optional(),
|
||||||
|
|
||||||
contentType: z.enum(['URL', 'VCARD', 'GEO', 'PHONE', 'SMS', 'WHATSAPP', 'TEXT', 'PDF', 'APP', 'COUPON', 'FEEDBACK'], {
|
contentType: z.enum(['URL', 'VCARD', 'GEO', 'PHONE', 'SMS', 'WHATSAPP', 'TEXT', 'PDF', 'APP', 'COUPON', 'FEEDBACK', 'BARCODE'], {
|
||||||
errorMap: () => ({ message: 'Invalid content type' })
|
errorMap: () => ({ message: 'Invalid content type' })
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ export const bulkQRSchema = z.object({
|
|||||||
z.object({
|
z.object({
|
||||||
title: z.string().min(1).max(100),
|
title: z.string().min(1).max(100),
|
||||||
content: z.string().min(1).max(5000),
|
content: z.string().min(1).max(5000),
|
||||||
contentType: z.enum(['URL', 'VCARD', 'GEO', 'PHONE', 'SMS', 'WHATSAPP', 'TEXT', 'PDF', 'APP', 'COUPON', 'FEEDBACK']),
|
contentType: z.enum(['URL', 'VCARD', 'GEO', 'PHONE', 'SMS', 'WHATSAPP', 'TEXT', 'PDF', 'APP', 'COUPON', 'FEEDBACK', 'BARCODE']),
|
||||||
})
|
})
|
||||||
).min(1, 'At least one QR code is required')
|
).min(1, 'At least one QR code is required')
|
||||||
.max(100, 'Maximum 100 QR codes per bulk creation'),
|
.max(100, 'Maximum 100 QR codes per bulk creation'),
|
||||||
|
|||||||
Reference in New Issue
Block a user