Skip to content
Snippets Groups Projects
Commit f2c84732 authored by Alexander Schoch's avatar Alexander Schoch
Browse files

start of eventsform

parent cbec029b
No related branches found
No related tags found
No related merge requests found
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>
);
}
import { useState } from "react";
import { useTranslation } from "next-i18next"; import { useTranslation } from "next-i18next";
import { Button } from "@mantine/core";
import EventModal from "../components/eventModal";
export default function Events() { export default function Events() {
const [open, setOpen] = useState(false);
const [event, setEvent] = useState(null);
const { t } = useTranslation("common"); const { t } = useTranslation("common");
return ( return (
<> <>
<h1>{t("events")}</h1> <h1>{t("events")}</h1>
<Button onClick={() => setOpen(true)} variant="light">
{t("addEvent")}
</Button>
<EventModal open={open} event={event} close={() => setOpen(false)} />
</> </>
); );
} }
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
"version": "0.1.0", "version": "0.1.0",
"dependencies": { "dependencies": {
"@apollo/client": "^3.8.1", "@apollo/client": "^3.8.1",
"@mantine/form": "^6.0.20",
"@mantine/notifications": "^5.10.5", "@mantine/notifications": "^5.10.5",
"axios": "^1.5.0", "axios": "^1.5.0",
"eslint": "8.48.0", "eslint": "8.48.0",
...@@ -2601,6 +2602,18 @@ ...@@ -2601,6 +2602,18 @@
"react-dom": ">=16.8.0" "react-dom": ">=16.8.0"
} }
}, },
"node_modules/@mantine/form": {
"version": "6.0.20",
"resolved": "https://registry.npmjs.org/@mantine/form/-/form-6.0.20.tgz",
"integrity": "sha512-htwFVfo60nYEMNwuBiYyJpqArwNnXIU7H70l8lZ+ie9QWERZCHgS7JVUBwFpS3n3iYArKbFBG13PnQAzPHMg2w==",
"dependencies": {
"fast-deep-equal": "^3.1.3",
"klona": "^2.0.5"
},
"peerDependencies": {
"react": ">=16.8.0"
}
},
"node_modules/@mantine/hooks": { "node_modules/@mantine/hooks": {
"version": "5.10.5", "version": "5.10.5",
"resolved": "https://registry.npmjs.org/@mantine/hooks/-/hooks-5.10.5.tgz", "resolved": "https://registry.npmjs.org/@mantine/hooks/-/hooks-5.10.5.tgz",
...@@ -10192,6 +10205,14 @@ ...@@ -10192,6 +10205,14 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/klona": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/klona/-/klona-2.0.6.tgz",
"integrity": "sha512-dhG34DXATL5hSxJbIexCft8FChFXtmskoZYnoPWjXQuebWYCNkVeV3KkGegCK9CP1oswI/vQibS2GY7Em/sJJA==",
"engines": {
"node": ">= 8"
}
},
"node_modules/language-subtag-registry": { "node_modules/language-subtag-registry": {
"version": "0.3.22", "version": "0.3.22",
"resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.22.tgz", "resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.22.tgz",
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
}, },
"dependencies": { "dependencies": {
"@apollo/client": "^3.8.1", "@apollo/client": "^3.8.1",
"@mantine/form": "^6.0.20",
"@mantine/notifications": "^5.10.5", "@mantine/notifications": "^5.10.5",
"axios": "^1.5.0", "axios": "^1.5.0",
"eslint": "8.48.0", "eslint": "8.48.0",
......
...@@ -18,5 +18,8 @@ ...@@ -18,5 +18,8 @@
"mailSuccess": "Formular Versandt", "mailSuccess": "Formular Versandt",
"mailSuccessText": "Das Formular wurde erfolgreich versandt.", "mailSuccessText": "Das Formular wurde erfolgreich versandt.",
"mailFailure": "Fehler", "mailFailure": "Fehler",
"mailFailureText": "Etwas ist beim Versand des Formulars schiefgelaufen." "mailFailureText": "Etwas ist beim Versand des Formulars schiefgelaufen.",
"addEvent": "Event Hinzufügen",
"editEvent": "Event Bearbeiten",
"ENotEmpty": "Dieses Feld bitte ausfüllen"
} }
\ No newline at end of file
...@@ -18,5 +18,8 @@ ...@@ -18,5 +18,8 @@
"mailSuccess": "Form Sent", "mailSuccess": "Form Sent",
"mailSuccessText": "The form was successfully sent", "mailSuccessText": "The form was successfully sent",
"mailFailure": "Error", "mailFailure": "Error",
"mailFailureText": "Something went wrong when sending the form" "mailFailureText": "Something went wrong when sending the form",
"addEvent": "Add Event",
"editEvent": "Edit Event",
"ENotEmpty": "Please fill out this field"
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment