partial implementation of bar code parsing from PDF

This commit is contained in:
2024-02-09 16:02:18 +01:00
parent f41124ced7
commit 84332b81af
6 changed files with 238 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ import { useFormState } from "react-dom";
import { updateOrAddBill } from "../lib/actions/billActions";
import Link from "next/link";
import { formatYearMonth } from "../lib/format";
import { pdf2canvas } from "../lib/pdf/pdf2png";
// Next.js does not encode an utf-8 file name correctly when sending a form with a file attachment
// This is a workaround for that
@@ -34,10 +35,14 @@ export const BillEditForm:FC<BillEditFormProps> = ({ location, bill }) => {
const [ isPaid, setIsPaid ] = React.useState<boolean>(paid);
const billPaid_handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const billPaid_handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setIsPaid(event.target.checked);
}
const billAttachment_handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
pdf2canvas(event);
}
return(
<div className="card card-compact card-bordered bg-base-100 shadow-s">
<div className="card-body">
@@ -70,7 +75,7 @@ export const BillEditForm:FC<BillEditFormProps> = ({ location, bill }) => {
</Link>
: null
}
<input id="billAttachment" name="billAttachment" type="file" className="file-input file-input-bordered max-w-sm w-full file-input-xs my-2 block" />
<input id="billAttachment" name="billAttachment" type="file" className="file-input file-input-bordered max-w-sm w-full file-input-xs my-2 block" onChange={billAttachment_handleChange} />
<div id="status-error" aria-live="polite" aria-atomic="true">
{state.errors?.billAttachment &&
state.errors.billAttachment.map((error: string) => (