bar code imaghe is saved to DB

This commit is contained in:
2024-02-12 15:29:16 +01:00
parent c833a4afe6
commit dc8f7e335a
4 changed files with 44 additions and 17 deletions

View File

@@ -7,7 +7,7 @@ import { BarcodeFormat, DecodeHintType, Result } from '@zxing/library';
export type BillInfo = {
header: string,
currency: string,
ammount: number,
amount: number,
payerName: string,
payerAddress: string,
payerTown: string,
@@ -32,7 +32,7 @@ export type BillInfo = {
* Decoded into:
* header: HRVHUB30
* currency:EUR
* ammount:000000000012422
* amount:000000000012422
* payerName:DEREŽIĆ NIKOLA
* payerAddress:ULICA DIVKA BUDAKA 17/17
* payerTown:10000 ZAGREB
@@ -50,7 +50,7 @@ const parseHubText = (text: string) => {
const [
header,
currency,
ammount,
amount,
payerName,
payerAddress,
payerTown,
@@ -67,7 +67,7 @@ const parseHubText = (text: string) => {
return {
header,
currency,
ammount: parseInt(ammount, 10),
amount: parseInt(amount, 10),
payerName,
payerAddress,
payerTown,
@@ -231,13 +231,7 @@ const copyBarcodeImage = (canvas:HTMLCanvasElement, decoderResult:Result) => {
// Convert the temporary canvas to a data URL
const dataURL = tempCanvas.toDataURL();
// Create a new Image object
const barcodeImage = new Image();
// Set the src of the image object to the data URL
barcodeImage.src = dataURL;
return(barcodeImage);
return(dataURL);
}
/** Finds PDF417 code within a file and decodes it */
@@ -259,7 +253,7 @@ const decodeFromFile = async (file:File) => {
* @param {Event} event - The change event from an HTMLInputElement.
* @return {Promise<HTMLCanvasElement | null>} The canvas with the first page of the PDF, or null if the document is not a PDF.
*/
export async function findDecodePdf417(event: React.ChangeEvent<HTMLInputElement>): Promise<{ billInfo: BillInfo, barcodeImage:HTMLImageElement } | null> {
export async function findDecodePdf417(event: React.ChangeEvent<HTMLInputElement>): Promise<{ billInfo: BillInfo, barcodeImage:string } | null> {
const file = (event.target as HTMLInputElement).files?.[0];
if(!file) {