Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,15 @@ export function InfoStep({ form, eventCategoryOptions, locationOptions }: Props)
<FormLabel>{t(KEY.common_capacity)}</FormLabel>
<FormControl>
<Input
type="number"
{...field}
type="text"
inputMode="numeric"
name={field.name}
ref={field.ref}
onBlur={field.onBlur}
value={field.value ?? ''}
onChange={(e) => {
const v = e.target.value;
field.onChange(v === '' ? '' : Number.parseInt(v));
const v = e.target.value.replace(/\D/g, '');
field.onChange(v);
}}
/>
</FormControl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,7 @@ export const steps: EventCreatorStep[] = [
title_nb: 'Dato og informasjon',
title_en: 'Date & info',
validate: (d) => {
return !!(
d.start_dt &&
d.duration !== undefined &&
d.duration > 0 &&
d.category &&
d.host &&
d.location &&
d.capacity !== undefined &&
d.capacity > 0
);
return !!(d.start_dt && d.duration !== undefined && d.duration > 0 && d.category && d.host && d.location);
},
},
{
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/schema/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ export const EVENT_DURATION = z.number().min(1, { message: KEY.event_form_durati
export const EVENT_END_DT = z.string().optional();
export const EVENT_HOST = z.string().min(1, { message: KEY.event_form_host_required });
export const EVENT_LOCATION = z.string().min(1, { message: KEY.event_form_location_required });
export const EVENT_CAPACITY = z.number().min(1, { message: KEY.event_form_capacity_min }).optional();
export const EVENT_CAPACITY = z.preprocess((value) => {
if (value === '' || value === undefined || value === null) {
return undefined;
}
if (typeof value === 'string') {
return Number.parseInt(value, 10);
}
return value;
}, z.number().min(1, { message: KEY.event_form_capacity_min }).optional());
export const EVENT_VISIBILITY_FROM_DT = z.string().min(1, { message: KEY.event_form_visibility_from_required });
export const EVENT_VISIBILITY_TO_DT = z.string().optional();
export const EVENT_PAID_OPTION = z.string().url().optional();
Expand Down
Loading