import React from 'react' import { useBarcode } from 'next-barcode' import { getGlobalStyle } from '../../../helpers' import { validateBarcode } from './helper' interface BarCodesProps { value: string format?: 'EAN13' } export const BarCodes: React.FC = ({ value = '', format = 'EAN13' }) => { const empty = !value const { inputRef } = useBarcode({ value: empty ? '0000000000000' : value, options: { background: getGlobalStyle('--color-background-gray-light'), format, displayValue: true } }) const isValid = validateBarcode(value, format) if (isValid) { return (
) } return (
Código de barras inválido
) } BarCodes.displayName = 'BarCodes'