Skip to content

Commit

Permalink
Fixed admin Position Add Form.
Browse files Browse the repository at this point in the history
  • Loading branch information
beabravedude committed Jan 23, 2025
1 parent 4fefa75 commit 90a4c5a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion actions/eventPosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const saveEventPosition = async (event: Event, formData: FormData, admin?
return { errors: [{ message: 'Positions are locked for this event' }] };
}

if ((await prisma.eventPosition.count({ where: { eventId: event.id, userId: session.user.id } })) > 0) {
if ((await prisma.eventPosition.count({ where: { eventId: event.id, userId: admin ? formData.get('userId') as string : session.user.id } })) > 0) {
return { errors: [{ message: admin ? 'This controller already has a position request' : 'You have already requested a position for this event' }] };
}

Expand Down
2 changes: 1 addition & 1 deletion components/EventPosition/EventPositionRequestForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default function EventPositionRequestForm({ admin, currentUser, event, ev
</Grid2>
<Grid2 size={6}>
{ admin && <FormSaveButton text="Add" icon={<Add />} /> }
{ !eventPosition && !event.positionsLocked && <FormSaveButton text="Request" icon={<Add />} /> }
{ !admin && !eventPosition && !event.positionsLocked && <FormSaveButton text="Request" icon={<Add />} /> }
{ !admin && eventPosition && !event.positionsLocked && <Button type="button" variant="contained" color="error" startIcon={<Delete />} onClick={() => deleteEventPosition(event, eventPosition.id)}>Delete</Button> }
{ !admin && event.positionsLocked && <Typography sx={{ mt: 2, }}>Positions are locked for this event.</Typography> }
{ !admin && <Typography sx={{ mt: 2, }}>You will recieve an email once your final position and time has been published.</Typography> }
Expand Down

0 comments on commit 90a4c5a

Please sign in to comment.