This commit is contained in:
Ayaz Hafiz 2023-07-16 22:57:21 -05:00
parent 87bb6c8437
commit 7d3e7ffdfb
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
4 changed files with 21 additions and 570 deletions

View file

@ -25,9 +25,9 @@ export default function FileInput({ setResult }: FileInputProps) {
return;
}
const file = files[0];
const buf = await file.arrayBuffer();
const buf = await file.text();
try {
const events: AllEvents = JSON.parse(new TextDecoder().decode(buf));
const events: AllEvents = JSON.parse(buf);
setResult({ kind: "ok", events });
} catch (e) {
setResult({ kind: "err", error: "Invalid checkmate file." });
@ -36,18 +36,13 @@ export default function FileInput({ setResult }: FileInputProps) {
}
return (
<div>
<label htmlFor="small-file-input" className="sr-only">
Choose file
</label>
<input
type="file"
name="small-file-input"
id="small-file-input"
onChange={(e) => setFile(e)}
className="block w-full border border-gray-200 shadow-sm rounded-md text-sm
file:bg-roc-purple-bg file:border-0 file:mr-4 file:py-2 file:px-4"
></input>
</div>
<input
type="file"
name="small-file-input"
id="small-file-input"
onChange={(e) => setFile(e)}
className="block w-full border border-gray-200 shadow-sm rounded-md text-sm
file:bg-roc-purple-bg file:border-0 file:mr-4 file:py-2 file:px-4 cursor-pointer"
></input>
);
}