Skip to content

Commit

Permalink
Merge pull request #358 from NUS-Project-SaBai/nathan/image-from-scan…
Browse files Browse the repository at this point in the history
…-to-registration

pass-image-from-scan-to-registration
  • Loading branch information
lutfir-cpu authored Dec 12, 2024
2 parents 9bd7ebd + e4624ca commit 73c2c98
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions pages/registration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ const Registration = () => {

const [scanModalOpen, setScanModalOpen] = useState(false);

const [scanImageDetails, setScanImageDetails] = useState(null);

const [scanSuggestionsList, setScanSuggestionsList] = useState([]);

const [formDetails, setFormDetails] = useState(REGISTRATION_FORM_FIELDS);
Expand Down Expand Up @@ -176,7 +174,7 @@ const Registration = () => {
});

const submitScan = useWithLoading(async () => {
if (scanImageDetails == null) {
if (imageDetails == null) {
toast.error('Please take a photo before submitting!');
return;
}
Expand All @@ -185,7 +183,7 @@ const Registration = () => {
const scanFormData = new FormData();
scanFormData.append(
'picture',
await urltoFile(scanImageDetails, 'patient_screenshot.jpg', 'image/jpg')
await urltoFile(imageDetails, 'patient_screenshot.jpg', 'image/jpg')
);

const { data: response } = await axiosInstance.post(
Expand All @@ -201,7 +199,7 @@ const Registration = () => {

setScanSuggestionsList(response);

setScanImageDetails(null);
setImageDetails(null);
} catch (error) {
toast.error(`Error scanning face: ${error.meesage}`);
console.error('Error scanning face:', error);
Expand Down Expand Up @@ -267,8 +265,8 @@ const Registration = () => {
onSubmit={submitScan}
>
<PatientScanForm
imageDetails={scanImageDetails}
setImageDetails={setScanImageDetails}
imageDetails={imageDetails}
setImageDetails={setImageDetails}
/>
<RegistrationScanSuggest
setPatient={setPatient}
Expand Down

0 comments on commit 73c2c98

Please sign in to comment.