Skip to content

Commit

Permalink
Add containers
Browse files Browse the repository at this point in the history
  • Loading branch information
monikaracka committed Jun 13, 2024
1 parent 3306498 commit 8e63715
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ export default function Home() {
<main className="flex min-h-screen flex-col items-center p-24">

<MyButton />
<div className="flex flex-col justify-between">
<div className="border-solid border-2 w-5 h-[100dvh]"></div>
<div className="border-solid border-2 w-5 h-full"></div>
</div>
</main>
);
}
19 changes: 17 additions & 2 deletions src/components/button.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
"use client";

import { useEffect, useState } from "react";
import { ChangeEventHandler, useEffect, useState } from "react";
import { ImageLike, createWorker } from "tesseract.js";

const MyButton = () => {
const [selectedFile, setSelectedFile] = useState<ImageLike>("");
const [text, setText] = useState<string>("");
const [cardNumber, setCardNumber] = useState<string>("");

const scanNumber = async (event: any) => {
const photo = event.target?.files[0];

if (photo) {
//recognize text from photo
const worker = await createWorker("eng");
const ret = await worker.recognize(photo);
const textFromPhoto = ret.data.text;
await worker.terminate();
//filter numbers from text
const numberFromText = textFromPhoto.replace(/[^0-9]/g, "");
setCardNumber(numberFromText);
}
};

const handleFileChange = (event: any) => {
const file = event.target.files[0];
const file = event.target?.files[0];
console.log(file);

setSelectedFile(file);
Expand Down

0 comments on commit 8e63715

Please sign in to comment.