2018-07-31 14:44:52 +02:00
|
|
|
//@flow
|
2018-07-31 18:44:01 +02:00
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
|
|
import InputField from "../../components/forms/InputField";
|
|
|
|
|
import { SubmitButton } from "../../components/buttons";
|
|
|
|
|
import { translate } from "react-i18next";
|
|
|
|
|
import type { Group } from "../types/Group";
|
2018-07-31 14:44:52 +02:00
|
|
|
|
|
|
|
|
export interface Props {
|
2018-07-31 18:44:01 +02:00
|
|
|
t: string => string;
|
|
|
|
|
submitForm: Group => void;
|
2018-07-31 14:44:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface State {
|
2018-07-31 18:44:01 +02:00
|
|
|
group: Group;
|
2018-07-31 14:44:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class GroupForm extends React.Component<Props, State> {
|
2018-07-31 18:44:01 +02:00
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {};
|
|
|
|
|
}
|
|
|
|
|
onSubmit = (event: Event) => {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
this.props.submitForm(this.state.group);
|
|
|
|
|
};
|
2018-07-31 14:44:52 +02:00
|
|
|
|
|
|
|
|
render() {
|
2018-07-31 18:44:01 +02:00
|
|
|
const { t } = this.props;
|
2018-07-31 14:44:52 +02:00
|
|
|
return (
|
2018-07-31 18:44:01 +02:00
|
|
|
<form onSubmit={this.onSubmit}>
|
|
|
|
|
<InputField
|
|
|
|
|
label={t("group.name")}
|
|
|
|
|
errorMessage=""
|
|
|
|
|
onChange={this.handleGroupNameChange}
|
|
|
|
|
validationError={false}
|
|
|
|
|
/>
|
|
|
|
|
<InputField
|
|
|
|
|
label={t("group.description")}
|
|
|
|
|
errorMessage=""
|
|
|
|
|
onChange={this.handleDescriptionChange}
|
|
|
|
|
validationError={false}
|
|
|
|
|
/>
|
|
|
|
|
<SubmitButton label={t("group-form.submit")} />
|
2018-07-31 14:44:52 +02:00
|
|
|
</form>
|
2018-07-31 18:44:01 +02:00
|
|
|
);
|
2018-07-31 14:44:52 +02:00
|
|
|
}
|
|
|
|
|
|
2018-07-31 18:44:01 +02:00
|
|
|
handleGroupNameChange = (name: string) => {
|
|
|
|
|
this.setState({
|
|
|
|
|
group: {
|
|
|
|
|
...this.state.group,
|
|
|
|
|
name
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
handleDescriptionChange = (description: string) => {
|
|
|
|
|
this.setState({
|
|
|
|
|
group: {
|
|
|
|
|
...this.state.group,
|
|
|
|
|
description
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
2018-07-31 14:44:52 +02:00
|
|
|
}
|
|
|
|
|
|
2018-07-31 18:44:01 +02:00
|
|
|
export default translate("groups")(GroupForm);
|