Skip to content

Commit

Permalink
fix: prevent unregistered booking (#95)
Browse files Browse the repository at this point in the history
* fix: prevent booking without registrations

* chore: fix build error
  • Loading branch information
Shurtu-gal committed Oct 13, 2023
1 parent a852b8e commit d1ab3e9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/EventCard/Card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ const EventCard = ({ event, registered }) => {
const { authenticated, userData, token } = useContext(AuthContext);
const [disabled, setDisabled] = useState(false);

const bookingAllowed =
authenticated && (userData?.rollNumber || userData?.festID?.includes('innovision-2023'));

const api = Api.getInstance();

const handleClick = () => {
Expand Down Expand Up @@ -92,7 +95,8 @@ const EventCard = ({ event, registered }) => {
variant='outline'
text={registered ? 'Registered' : 'Register For Event'}
onClick={registered ? null : handleClick}
disabled={disabled || !authenticated || registered}
disabled={disabled || !bookingAllowed || registered}
tooltip={!bookingAllowed ? 'Kindly register for the fest first' : ''}
/>
</CardButtonContainer>
</Front>
Expand Down Expand Up @@ -121,7 +125,8 @@ const EventCard = ({ event, registered }) => {
variant='outline'
text={registered ? 'Registered' : 'Register For Event'}
onClick={registered ? null : handleClick}
disabled={disabled || !authenticated || registered}
disabled={disabled || !bookingAllowed || registered}
tooltip={!bookingAllowed ? 'Kindly register for the fest first' : ''}
/>
</CardButtonContainer>
</Back>
Expand Down

0 comments on commit d1ab3e9

Please sign in to comment.