Skip to content

Commit

Permalink
Improve error handling and user guidance in registration form file up…
Browse files Browse the repository at this point in the history
…loads
  • Loading branch information
joywin2003 committed Nov 28, 2024
1 parent f43b923 commit 10cc9bc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/common/registration-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export default function RegistrationForm() {
toast.error("No files uploaded. Please try again.");
return;
}

try {
if (res.length === 2) {
form.setValue("idCard", res[0].url);
Expand All @@ -116,7 +115,7 @@ export default function RegistrationForm() {
},
onUploadError: (error) => {
console.error("Upload error:", error);
toast.error("Image upload failed. Please try again later.");
toast.error("Image upload failed. Please inform us at [email protected] or click the contact us button at buttom right corner.");
},
});

Expand Down Expand Up @@ -185,8 +184,12 @@ export default function RegistrationForm() {
const allFiles = uploadedFiles.flatMap((file) => file.files);

if (allFiles.length > 0) {
await startUpload(allFiles);
toast.success("✅ Files uploaded successfully!");
const uploadResult = await startUpload(allFiles);
if (!uploadResult) {
toast.error("Error uploading files. Please contact support from the contact us button at buttom right corner.");
}else{
toast.success("✅ Files uploaded successfully!");
}
} else {
toast.warning("⚠️ No files to upload.");
}
Expand Down

0 comments on commit 10cc9bc

Please sign in to comment.