Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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 @@ -291,9 +291,7 @@ export function EventCreatorAdminPage() {
data.duration > 0 &&
data.category &&
data.host &&
data.location &&
data.capacity !== undefined &&
data.capacity > 0
data.location
);
},
template: (
Expand Down Expand Up @@ -406,11 +404,15 @@ export function EventCreatorAdminPage() {
<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
10 changes: 9 additions & 1 deletion frontend/src/schema/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ export const EVENT_DURATION = z.number().min(1, { message: 'Varighet må være s
export const EVENT_END_DT = z.string().optional();
export const EVENT_HOST = z.string().min(1, { message: 'Arrangør er påkrevd' });
export const EVENT_LOCATION = z.string().min(1, { message: 'Lokale er påkrevd' });
export const EVENT_CAPACITY = z.number().min(1, { message: 'Kapasitet må være større enn 0' }).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: 'Kapasitet må være større enn 0' }).optional());
export const EVENT_VISIBILITY_FROM_DT = z.string().min(1, { message: 'Synlig fra dato er påkrevd' });
export const EVENT_VISIBILITY_TO_DT = z.string().optional();
export const EVENT_PAID_OPTION = z.string().url().optional();
Expand Down
Loading