Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { useTranslation } from "next-i18next";
import { Grid, Modal, Text, Textarea, TextInput } from "@mantine/core";
import { useForm } from "@mantine/form";
//import { DateTimePicker } from '@mantine/dates';
export default function EventModal({ open, close, event }) {
const { t } = useTranslation("common");
const initialValues = {
title: "",
description: "",
speaker: "",
start: null,
end: null,
place: "",
signUp: "",
isStammtisch: false,
};
const form = useForm({
initialValues: initialValues,
validate: {
title: (value) => (value ? null : t("ENotEmpty")),
description: (value) => (value ? null : t("ENotEmpty")),
speaker: (value) => (value ? null : t("ENotEmpty")),
start: (value) => (value ? null : t("ENotEmpty")),
end: (value) => (value ? null : t("ENotEmpty")),
place: (value) => (value ? null : t("ENotEmpty")),
signUp: (value) => (value ? null : t("ENotEmpty")),
},
});
const setEvent = () => {
if (event) {
form.setValues({ ...event });
} else {
form.setValues(initialValues);
}
};
return (
<Modal opened={open} onClose={close} fz="xl" size="xl">
<Text variant="h2" fw={700}>
{event ? t("editEvent") : t("addEvent")}
</Text>
<form onSubmit={form.onSubmit((values) => submit(values))}>
<Grid>
<Grid.Col sm={12} md={6}>
<TextInput
withAsterisk
label={t("title")}
placeholder="Introduction to Free Software"
{...form.getInputProps("title")}
/>
</Grid.Col>
<Grid.Col sm={12} md={6}>
<TextInput
withAsterisk
label={t("speaker")}
placeholder="Maxime Musterfrau"
{...form.getInputProps("speaker")}
/>
</Grid.Col>
<Grid.Col sm={12}>
<Textarea
withAsterisk
label={t("description")}
placeholder="Lorem Ipsum..."
{...form.getInputProps("description")}
/>
</Grid.Col>
<Grid.Col sm={12} md={6}>
<TextInput
withAsterisk
label={t("place")}
placeholder="ETH HG F 7"
{...form.getInputProps("place")}
/>
</Grid.Col>
<Grid.Col sm={12} md={6}></Grid.Col>
<Grid.Col sm={12} md={6}>
<TextInput
withAsterisk
label={t("signUp")}
placeholder="https://..."
{...form.getInputProps("signUp")}
/>
</Grid.Col>
</Grid>
</form>
</Modal>
);
}