+
+ {label}
+
-
- {items.map((item, key) => (
-
- {item}
-
- ))}
+
+ {Object.entries(items).map(([value, label]) => (
+
+ {label}
+
+ ))}
+
+
+ {this.renderError()}
);
}
@@ -85,6 +91,32 @@ export default class Dropdown extends FormComponent {
};
}
+ getActiveItem() {
+ const {items} = this.props;
+ let {activeItem} = this.state;
+
+ if (!activeItem) {
+ activeItem = {
+ label: this.props.label,
+ value: ''
+ };
+
+ if (!activeItem.label) {
+ const firstItem = Object.entries(items)[0];
+ activeItem = {
+ label: firstItem[1],
+ value: firstItem[0]
+ };
+ }
+ }
+
+ return activeItem;
+ }
+
+ getValue() {
+ return this.getActiveItem().value;
+ }
+
onToggle = (event) => {
event.preventDefault();
diff --git a/src/components/ui/form/FormComponent.jsx b/src/components/ui/form/FormComponent.jsx
index 190d01e..25aa90a 100644
--- a/src/components/ui/form/FormComponent.jsx
+++ b/src/components/ui/form/FormComponent.jsx
@@ -1,4 +1,4 @@
-import React, { Component } from 'react';
+import { Component } from 'react';
import { intlShape } from 'react-intl';
@@ -9,6 +9,13 @@ export default class FormComponent extends Component {
intl: intlShape.isRequired
};
+ /**
+ * Formats message resolving intl translations
+ *
+ * @param {string|object} message - message string, or intl message descriptor with an `id` field
+ *
+ * @return {string}
+ */
formatMessage(message) {
if (message && message.id && this.context && this.context.intl) {
message = this.context.intl.formatMessage(message);
@@ -16,4 +23,10 @@ export default class FormComponent extends Component {
return message;
}
+
+ /**
+ * Focuses this field
+ */
+ focus() {
+ }
}
diff --git a/src/services/api/feedback.js b/src/services/api/feedback.js
index 340d24d..cf1cbe4 100644
--- a/src/services/api/feedback.js
+++ b/src/services/api/feedback.js
@@ -1,4 +1,4 @@
import request from 'services/request';
-export default ({subject = '', email = '', message = ''}) =>
- request.post('/api/feedback', {subject, email, message});
+export default ({subject = '', email = '', message = '', category = ''}) =>
+ request.post('/api/feedback', {subject, email, message, category});