Valentin Peron commited on
Commit
94f7100
·
2 Parent(s): 60757b5 73d7d71

Merge branch 'main' of hf.co:spaces/ppaihack/PoCInnovation

Browse files
front/src/VerificationScene.tsx CHANGED
@@ -1,4 +1,5 @@
1
  import { useState } from "react";
 
2
  import BoxContainer from "./components/BoxContainer";
3
  import VideoWrapper from "@/components/VideoWrapper.tsx";
4
  import ResultContainer from "@/components/ResultContainer.tsx";
@@ -26,11 +27,12 @@ export default function VerificationScene() {
26
  const [profilePicture, setProfilePicture] = useState<string>();
27
 
28
  const handleNextStep = () => {
29
- if (currentStep == StepType.result) return;
30
  setCurrentStep((currentStep + 1) % stepsArray.length);
31
  };
 
32
  const handlePrevStep = () => {
33
- if (currentStep == StepType.takeId) return;
34
  setCurrentStep((currentStep - 1) % stepsArray.length);
35
  };
36
 
@@ -61,11 +63,23 @@ export default function VerificationScene() {
61
  }
62
  };
63
 
 
 
 
 
 
 
 
 
64
  let stepContent = undefined;
65
 
66
- if (currentStep == StepType.takeId) {
67
  stepContent = (
68
- <>
 
 
 
 
69
  <h1 className="text-black text-2xl mt-20 text-center px-28">
70
  Take a picture of the Capture the front side of your ID Card
71
  </h1>
@@ -76,16 +90,20 @@ export default function VerificationScene() {
76
  height="250px"
77
  width="400px"
78
  />
79
- </>
80
  );
81
  }
82
- if (currentStep == StepType.verifyId) {
83
  stepContent = (
84
- <>
 
 
 
 
85
  <div className="overflow-hidden w-2/3 h-2/4 mt-10">
86
  <img src={idCardPicture} alt="captured" />
87
  </div>
88
- <h1 className="text-2xl font-bold">Is This Picture Correct ?</h1>
89
  <div className="mt-32 space-x-20">
90
  <button
91
  onClick={handlePrevStep}
@@ -100,29 +118,37 @@ export default function VerificationScene() {
100
  Yes
101
  </button>
102
  </div>
103
- </>
104
  );
105
  }
106
 
107
- if (currentStep == StepType.takeFrontPic) {
108
  stepContent = (
109
- <>
 
 
 
 
110
  <h1 className="mt-5 font-bold text-lg">Center your face</h1>
111
  <DarkVideoWrapper
112
  setImage={setProfilePicture}
113
- className="mt-20 w-2/4 h-3/5 overflow-hidden"
114
  handleNextStep={handleNextStep}
115
  />
116
- </>
117
  );
118
  }
119
- if (currentStep == StepType.verifyProfile) {
120
  stepContent = (
121
- <>
 
 
 
 
122
  <div className="overflow-hidden w-2/3 h-2/4 mt-10">
123
  <img src={profilePicture} alt="captured" />
124
  </div>
125
- <h1 className="text-2xl font-bold">Is This Picture Correct ?</h1>
126
  <div className="mt-32 space-x-20">
127
  <button
128
  onClick={handlePrevStep}
@@ -137,17 +163,23 @@ export default function VerificationScene() {
137
  Yes (Submit)
138
  </button>
139
  </div>
140
- </>
141
  );
142
  }
143
 
144
- if (currentStep == StepType.result) {
145
  stepContent = (
146
- <ResultContainer
147
- sendImageToServer={sendImageToServer}
148
- idCardPicture={idCardPicture ?? ""}
149
- profileImage={profilePicture ?? ""}
150
- />
 
 
 
 
 
 
151
  );
152
  }
153
 
@@ -155,7 +187,7 @@ export default function VerificationScene() {
155
  <>
156
  <div className="bg-gray-100">
157
  <BoxContainer headerName="Identity Verification Required">
158
- <div className="h-full w-full flex flex-col items-center overflow-hidden">
159
  {stepContent}
160
  </div>
161
  </BoxContainer>
 
1
  import { useState } from "react";
2
+ import { motion } from "framer-motion";
3
  import BoxContainer from "./components/BoxContainer";
4
  import VideoWrapper from "@/components/VideoWrapper.tsx";
5
  import ResultContainer from "@/components/ResultContainer.tsx";
 
27
  const [profilePicture, setProfilePicture] = useState<string>();
28
 
29
  const handleNextStep = () => {
30
+ if (currentStep === StepType.result) return;
31
  setCurrentStep((currentStep + 1) % stepsArray.length);
32
  };
33
+
34
  const handlePrevStep = () => {
35
+ if (currentStep === StepType.takeId) return;
36
  setCurrentStep((currentStep - 1) % stepsArray.length);
37
  };
38
 
 
63
  }
64
  };
65
 
66
+ // Animation settings for Framer Motion
67
+ const animationProps = {
68
+ initial: { opacity: 0, y: 50 },
69
+ animate: { opacity: 1, y: 0 },
70
+ exit: { opacity: 0, y: -50 },
71
+ transition: { duration: 0.5 },
72
+ };
73
+
74
  let stepContent = undefined;
75
 
76
+ if (currentStep === StepType.takeId) {
77
  stepContent = (
78
+ <motion.div
79
+ key="takeId"
80
+ {...animationProps}
81
+ className="flex flex-col items-center"
82
+ >
83
  <h1 className="text-black text-2xl mt-20 text-center px-28">
84
  Take a picture of the Capture the front side of your ID Card
85
  </h1>
 
90
  height="250px"
91
  width="400px"
92
  />
93
+ </motion.div>
94
  );
95
  }
96
+ if (currentStep === StepType.verifyId) {
97
  stepContent = (
98
+ <motion.div
99
+ key="verifyId"
100
+ {...animationProps}
101
+ className="flex flex-col items-center"
102
+ >
103
  <div className="overflow-hidden w-2/3 h-2/4 mt-10">
104
  <img src={idCardPicture} alt="captured" />
105
  </div>
106
+ <h1 className="text-2xl font-bold mt-10">Is This Picture Correct?</h1>
107
  <div className="mt-32 space-x-20">
108
  <button
109
  onClick={handlePrevStep}
 
118
  Yes
119
  </button>
120
  </div>
121
+ </motion.div>
122
  );
123
  }
124
 
125
+ if (currentStep === StepType.takeFrontPic) {
126
  stepContent = (
127
+ <motion.div
128
+ key="takeFrontPic"
129
+ {...animationProps}
130
+ className="flex flex-col items-center"
131
+ >
132
  <h1 className="mt-5 font-bold text-lg">Center your face</h1>
133
  <DarkVideoWrapper
134
  setImage={setProfilePicture}
135
+ className="mt-12 w-3/4 h-3/5 overflow-hidden"
136
  handleNextStep={handleNextStep}
137
  />
138
+ </motion.div>
139
  );
140
  }
141
+ if (currentStep === StepType.verifyProfile) {
142
  stepContent = (
143
+ <motion.div
144
+ key="verifyProfile"
145
+ {...animationProps}
146
+ className="flex flex-col items-center"
147
+ >
148
  <div className="overflow-hidden w-2/3 h-2/4 mt-10">
149
  <img src={profilePicture} alt="captured" />
150
  </div>
151
+ <h1 className="text-2xl font-bold mt-10">Is This Picture Correct?</h1>
152
  <div className="mt-32 space-x-20">
153
  <button
154
  onClick={handlePrevStep}
 
163
  Yes (Submit)
164
  </button>
165
  </div>
166
+ </motion.div>
167
  );
168
  }
169
 
170
+ if (currentStep === StepType.result) {
171
  stepContent = (
172
+ <motion.div
173
+ key="result"
174
+ {...animationProps}
175
+ className="flex flex-col items-center"
176
+ >
177
+ <ResultContainer
178
+ sendImageToServer={sendImageToServer}
179
+ idCardPicture={idCardPicture ?? ""}
180
+ profileImage={profilePicture ?? ""}
181
+ />
182
+ </motion.div>
183
  );
184
  }
185
 
 
187
  <>
188
  <div className="bg-gray-100">
189
  <BoxContainer headerName="Identity Verification Required">
190
+ <div className="h-full w-full flex flex-col items-center justify-center overflow-hidden">
191
  {stepContent}
192
  </div>
193
  </BoxContainer>
front/src/components/ResultContainer.tsx CHANGED
@@ -18,5 +18,13 @@ export default function ResultContainer({
18
  useEffect(() => {
19
  sendImageToServer(idCardPicture ?? "", profileImage ?? "", setLoading);
20
  }, []);
21
- return <>{loading ? <>Fetching</> : <>Perfect</>}</>;
 
 
 
 
 
 
 
 
22
  }
 
18
  useEffect(() => {
19
  sendImageToServer(idCardPicture ?? "", profileImage ?? "", setLoading);
20
  }, []);
21
+ return (
22
+ <div className="flex w-full h-full items-center justify-center">
23
+ {loading ? (
24
+ <h1 className="text-2xl font-bold text-orange-600">Fetching....</h1>
25
+ ) : (
26
+ <h1 className="text-2xl font-bold text-green-800">Process Completed</h1>
27
+ )}
28
+ </div>
29
+ );
30
  }