Add ESLint disable comments for @next/next/no-img-element warnings where appropriate (barcode images with base64 data URIs don't benefit from Next.js Image optimization) and add missing alt attribute to PDF417 barcode component. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
'use client';
|
|
|
|
import { useState, useEffect, FC } from 'react';
|
|
import { generateBarcode } from '../lib/pdf/pdf417';
|
|
import { renderBarcode } from '../lib/pdf/renderBarcode';
|
|
|
|
export const Pdf417Barcode:FC<{hub3aText:string, className?: string}> = ({hub3aText: hub3a_text, className}) => {
|
|
const [bitmapData, setBitmapData] = useState<string | undefined>(undefined);
|
|
|
|
useEffect(() => {
|
|
const barcodeMatrix = generateBarcode(hub3a_text);
|
|
const bitmap = renderBarcode(barcodeMatrix, 2, 2);
|
|
setBitmapData(bitmap);
|
|
}, [hub3a_text]);
|
|
|
|
// Don't render until bitmap is generated (prevents hydration mismatch)
|
|
if (!bitmapData) {
|
|
return (
|
|
<div style={{ width: "350px", height: "92px" }} className="flex items-center justify-center">
|
|
<span className="loading loading-spinner loading-lg"></span>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
// eslint-disable-next-line @next/next/no-img-element
|
|
<img src={bitmapData} alt="PDF417 Barcode" className={className} style={className ? undefined : { width: "350px", height: "92px" }} />
|
|
);
|
|
} |