Skip to content

Commit

Permalink
Merge pull request #89 from IEEEUCSC/main
Browse files Browse the repository at this point in the history
Added
  • Loading branch information
Udeesha-Prabhashana authored Feb 4, 2024
2 parents d3b6117 + 6826ee0 commit 67aa64d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
19 changes: 15 additions & 4 deletions Frontend/src/Components/TeamRegistration/TeamRegi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function Registration() {
const [teamMemberCount, setTeamMemberCount] = useState(2); // Default to 2 members
const [teamMembers, setTeamMembers] = useState<any[]>(["member1", "member2"]);

// const [slotsRemaining, setSlotsRemaining] = useState(0);
const [slotsRemaining, setSlotsRemaining] = useState(0);

// get from the form
const [university, setUniversity] = useState(
Expand Down Expand Up @@ -51,7 +51,7 @@ export default function Registration() {
background: "#232631",
color: "#fff",
footer:
'<a href="https://chat.whatsapp.com/LJ7CwK4eiRd3jkLntBfoj0" target="_blank"> Join our whatsapp group <br> <img src="https://img.icons8.com/color/48/000000/whatsapp--v1.png"/></a>',
'<a href="" target="_blank"> Join our whatsapp group <br> <img src="https://img.icons8.com/color/48/000000/whatsapp--v1.png"/></a>',
});
if (response.success) {
reset();
Expand All @@ -63,6 +63,17 @@ export default function Registration() {
}
};

// get team count Network.shared.getTeamCount()
useEffect(() => {
const fetchData = async () => {
const result = await Network.shared.getTeamCount();
console.log(result);
setSlotsRemaining(result);
}
fetchData();
}
, []);

return (
<div className="site-section local-bootstrap reg-section">
<div className="container">
Expand Down Expand Up @@ -113,7 +124,7 @@ export default function Registration() {
<div className="col-md-12 aos-init aos-animate" data-aos="fade-up">
{/* form disable if no slots remaining , add class to disable */}
{/* <form onSubmit={handleSubmit(onSubmit)}> */}
<form onSubmit={handleSubmit(onSubmit)} className="form">
<form onSubmit={handleSubmit(onSubmit)} className={slotsRemaining <= 0 ? "disable-form" : "form"}>
{/* Team Information */}
<div className="row form-group">
<div className="col-md-12">
Expand Down Expand Up @@ -300,7 +311,7 @@ export default function Registration() {
className={`btn btn-primary py-2 px-4 text-white ${
isSubmitting ? "btn-loading" : ""
}`}
disabled={isSubmitting}
disabled={isSubmitting || slotsRemaining <= 0}
/>
</div>
</div>
Expand Down
30 changes: 15 additions & 15 deletions Frontend/src/Network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ export class Network {
return await response.json();
}

// public async getTeamCount(): Promise<number> {
// const response = await fetch(process.env.REACT_APP_BACKEND_URL + '/api/team/count', {
// method: 'GET',
// headers: {
// 'Content-Type': 'application/json'
// }
// });

// if (!response.ok) {
// throw new Error(response.statusText);
// }

// const data = await response.json();
// return data.teamCount;
// }
public async getTeamCount(): Promise<number> {
const response = await fetch(process.env.REACT_APP_BACKEND_URL + '/api/teamregi/count', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
});

if (!response.ok) {
throw new Error(response.statusText);
}

const data = await response.json();
return data.teamCount;
}
}

export class ResponseModel {
Expand Down

0 comments on commit 67aa64d

Please sign in to comment.