Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Pages/Events/CreateEventFormQuestionBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default function CreateEventFormQuestionBlock({
</div>
)}

{(question.type === 'multiple_choice' || question.type === 'dropdown') && (
{(question.type === 'multiple_choice' || question.type === 'dropdown' || question.type === 'checkbox') && (
<div className="mt-3 space-y-2">
<span className="text-sm text-gray-500 dark:text-gray-400">Answer options</span>
{(question.answer_options || []).map((option, optIndex) => (
Expand Down
52 changes: 38 additions & 14 deletions src/Pages/Events/CreateEventPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function toApiRegistrationForm(questions) {
base.answer_details = { max_chars: q.answer_details.max_chars };
}
if (
(q.type === 'multiple_choice' || q.type === 'dropdown') &&
(q.type === 'multiple_choice' || q.type === 'dropdown' || q.type === 'checkbox') &&
q.answer_options &&
q.answer_options.length
) {
Expand Down Expand Up @@ -126,7 +126,7 @@ export default function CreateEventPage() {
if (newType === 'textbox') {
return { ...base, answer_details: { max_chars: 200 } };
}
if (newType === 'multiple_choice' || newType === 'dropdown') {
if (newType === 'multiple_choice' || newType === 'dropdown' || newType === 'checkbox') {
return { ...base, answer_options: ['Option 1', 'Option 2'] };
}
return base;
Expand Down Expand Up @@ -183,6 +183,9 @@ export default function CreateEventPage() {
setSubmitError('Please select a minimum visible role for private events.');
return;
}
if (maxAttendees !== UNLIMITED_ATTENDEES && (maxAttendees === '' || maxAttendees <= 0)) {
setSubmitError('Please enter a valid max attendees, or check "No limit".');
}

const payload = {
id: eventId,
Expand Down Expand Up @@ -332,18 +335,39 @@ export default function CreateEventPage() {
<div className="label">
<span className="label-text">Max attendees</span>
</div>
<input
type="number"
min="1"
className="max-w-xs input input-bordered"
value={maxAttendees === UNLIMITED_ATTENDEES ? '' : maxAttendees}
onChange={(e) =>
setMaxAttendees(
e.target.value ? parseInt(e.target.value, 10) : UNLIMITED_ATTENDEES,
)
}
placeholder="No limit"
/>
<div className="flex items-center gap-4">
<input
type="number"
min="1"
className="max-w-xs input input-bordered"
value={maxAttendees === UNLIMITED_ATTENDEES ? '' : maxAttendees}
disabled={maxAttendees === UNLIMITED_ATTENDEES}
onChange={(e) => {
if (!e.target.value) {
setMaxAttendees('');
return;
}
const val = parseInt(e.target.value, 10);
if (!isNaN(val)) setMaxAttendees(val);
}}
placeholder="e.g. 50"
/>
<label className="flex gap-2 items-center text-sm cursor-pointer label">
<input
type="checkbox"
className="checkbox checkbox-sm"
checked={maxAttendees === UNLIMITED_ATTENDEES}
onChange={(e) => {
if (e.target.checked) {
setMaxAttendees(UNLIMITED_ATTENDEES);
} else {
setMaxAttendees('');
}
}}
/>
<span className="label-text font-medium">No limit</span>
</label>
</div>
</div>

<div className="grid gap-4 sm:grid-cols-2">
Expand Down
Loading