Skip to content

Commit

Permalink
Fix: id form btn loading glitch
Browse files Browse the repository at this point in the history
  • Loading branch information
Akalanka47000 committed Oct 14, 2023
1 parent 5cd536a commit f3db54e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@azure/storage-blob": "12.15.0",
"@reduxjs/toolkit": "1.9.5",
"@sentry/react": "7.69.0",
"@sliit-foss/bashaway-ui": "0.8.0",
"@sliit-foss/bashaway-ui": "0.10.3",
"async-mutex": "^0.4.0",
"firebase": "10.2.0",
"framer-motion": "10.14.0",
Expand Down
11 changes: 4 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/components/identification-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const IdentificationForm = () => {

const [formData, setFormData] = useState(team?.members);
const [idFiles, setIdFiles] = useState([]);
const [isUploading, setIsUploading] = useState(false);

useEffect(() => {
if (team) setFormData(team.members);
Expand All @@ -49,14 +50,13 @@ const IdentificationForm = () => {
) {
return toast({ variant: "destructive", title: "Please make sure that all required fields are filled" });
}
setIsUploading(true);
const members = await Promise.all(
formData.map(async (member, index) => {
if (idFiles[index]) {
member["student_id_url"] = await uploadIdCard(team.name, member.name, idFiles[index]);
}
if (idFiles[index]) member["student_id_url"] = await uploadIdCard(team.name, member.name, idFiles[index]);
return member;
})
);
).finally(() => setIsUploading(false));
await updateProfile({
id: team._id,
data: { members }
Expand Down Expand Up @@ -157,7 +157,7 @@ const IdentificationForm = () => {
))}
</Accordion>
<AlertDialogFooter className="mt-4">
<Button type="submit" loading={isLoading}>
<Button type="submit" loading={isLoading || isUploading}>
Submit and continue
</Button>
</AlertDialogFooter>
Expand Down

0 comments on commit f3db54e

Please sign in to comment.