From e18a42ea6c4a71ce1ef6ae6eab2e947e5e825ed2 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 23 Oct 2025 15:26:49 +0530 Subject: [PATCH] Added logic for verfication serials --- .../views/fields/camera-capture.blade.php | 94 +++++++++++++------ 1 file changed, 64 insertions(+), 30 deletions(-) diff --git a/resources/views/fields/camera-capture.blade.php b/resources/views/fields/camera-capture.blade.php index 7665df1..0926da2 100644 --- a/resources/views/fields/camera-capture.blade.php +++ b/resources/views/fields/camera-capture.blade.php @@ -386,41 +386,75 @@ function cameraCapture() { // await this.verifyOCR(dataUrl); // }, + // async verify() { + // const filePath = this.$refs.hiddenInput.value; // e.g., "temp/capture_1760764396.jpeg" + + // if (!filePath) { + // alert("No captured image found!"); + // return; + // } + + // try { + // const response = await fetch('/verify-ocr', { + // method: 'POST', + // headers: { + // 'Content-Type': 'application/json', + // 'X-CSRF-TOKEN': '{{ csrf_token() }}' + // }, + // body: JSON.stringify({ path: filePath }) + // }); + + // const data = await response.json(); + + // console.log(data); + + // if (data.success) { + // alert("OCR Result: " + data.text); + // console.error(data.text); + // } else { + // alert("OCR Failed: " + data.error); + // console.error(data.error); + // } + // } catch (err) { + // console.error(err.message); + // alert("OCR request failed: " + err.message); + // } + // }, + + async verify() { - const filePath = this.$refs.hiddenInput.value; // e.g., "temp/capture_1760764396.jpeg" + const filePath = this.$refs.hiddenInput.value; // e.g., "temp/capture_1760764396.jpeg" - if (!filePath) { - alert("No captured image found!"); - return; - } + if (!filePath) { + alert("No captured image found!"); + return; + } - try { - const response = await fetch('/verify-ocr', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - 'X-CSRF-TOKEN': '{{ csrf_token() }}' - }, - body: JSON.stringify({ path: filePath }) - }); + try { + const response = await fetch('/verify-ocr', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'X-CSRF-TOKEN': '{{ csrf_token() }}' + }, + body: JSON.stringify({ path: filePath }) + }); - const data = await response.json(); - - console.log(data); - - if (data.success) { - alert("OCR Result: " + data.text); - console.error(data.text); - } else { - alert("OCR Failed: " + data.error); - console.error(data.error); - } - } catch (err) { - console.error(err.message); - alert("OCR request failed: " + err.message); - } - }, + const data = await response.json(); + if (data.success) { + // data.text is now an array of serials + console.log("Serials:", data.text); + alert("OCR Result:\n" + data.text.join("\n")); // show nicely + } else { + console.error("OCR Error:", data.error); + alert("OCR Failed: " + data.error); + } + } catch (err) { + console.error("OCR request failed:", err.message); + alert("OCR request failed: " + err.message); + } +}, async retakePhoto() { this.photoTaken = false;