feat: work shifts by QR codes

This commit is contained in:
2024-11-20 13:09:55 +04:00
parent bf774f5c04
commit 39f746f435
15 changed files with 501 additions and 2 deletions

View File

@@ -0,0 +1,38 @@
import { ContextModalProps } from "@mantine/modals";
import { Text } from "@mantine/core";
import { useWindowEvent } from "@mantine/hooks";
import { useState } from "react";
type Props = {
label: string;
onScan: (value: string) => void;
closeOnScan?: boolean;
};
const ScanningModal = ({
context,
id,
innerProps,
}: ContextModalProps<Props>) => {
const [inputValues, setInputValues] = useState<string>("");
const { label, onScan, closeOnScan } = innerProps;
useWindowEvent("keydown", (event) => {
event.preventDefault();
console.log(inputValues);
setInputValues(prevState => prevState + event.key);
if (event.key === "Enter") {
onScan(inputValues);
if (closeOnScan) {
context.closeContextModal(id);
}
}
});
return (
<Text>{label}</Text>
);
};
export default ScanningModal;