remove request to hint and remove upload from device
This commit is contained in:
parent
0f0301cc3d
commit
ca758e2dfa
@ -1,6 +1,4 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import useSteps from "../../../hooks/palmistry/use-steps";
|
||||
import Button from "../button/button";
|
||||
import BiometricData from "../biometric-data/biometric-data";
|
||||
import UploadModal from "../upload-modal/upload-modal";
|
||||
@ -16,7 +14,6 @@ type Props = {
|
||||
};
|
||||
|
||||
export default function StepUpload(props: Props) {
|
||||
const steps = useSteps();
|
||||
const api = useApi();
|
||||
const dispatch = useDispatch();
|
||||
|
||||
@ -25,7 +22,6 @@ export default function StepUpload(props: Props) {
|
||||
const [recognitionErrorModalIsOpen, setRecognitionErrorModalIsOpen] =
|
||||
useState(false);
|
||||
const [palmCameraModalIsOpen, setPalmCameraModalIsOpen] = useState(false);
|
||||
const [palmPhoto, setPalmPhoto] = useState<string>();
|
||||
|
||||
// const imitateRequestError = () => {
|
||||
// setTimeout(() => {
|
||||
@ -53,9 +49,8 @@ export default function StepUpload(props: Props) {
|
||||
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onloadend = () => {
|
||||
setPalmPhoto(reader.result as string);
|
||||
};
|
||||
// reader.onloadend = () => {
|
||||
// };
|
||||
|
||||
reader.readAsDataURL(event.target.files[0]);
|
||||
};
|
||||
@ -78,25 +73,10 @@ export default function StepUpload(props: Props) {
|
||||
const onTakePhoto = async (photo: string) => {
|
||||
const file = DataURIToBlob(photo);
|
||||
await getLines(file);
|
||||
setPalmPhoto(photo as string);
|
||||
setUploadMenuModalIsOpen(false);
|
||||
setPalmCameraModalIsOpen(false);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (palmPhoto) {
|
||||
fetch("https://palmistry.hint.app/api/processing", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ image: palmPhoto }),
|
||||
});
|
||||
setIsUpladProcessing(false);
|
||||
steps.saveCurrent(palmPhoto);
|
||||
steps.goNext();
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [palmPhoto]);
|
||||
|
||||
useEffect(() => {
|
||||
if (recognitionErrorModalIsOpen || palmCameraModalIsOpen) {
|
||||
props.onOpenModal(true);
|
||||
@ -611,7 +591,7 @@ export default function StepUpload(props: Props) {
|
||||
className="palmistry-container__take-palm-button"
|
||||
disabled={isUpladProcessing}
|
||||
active={!isUpladProcessing}
|
||||
onClick={() => setUploadMenuModalIsOpen(true)}
|
||||
onClick={() => setPalmCameraModalIsOpen(true)}
|
||||
isProcessing={isUpladProcessing}
|
||||
>
|
||||
{(isUpladProcessing && "Loading photo") || "Take a picture now"}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user