'use strict'; import React, {Component} from 'react'; import PropTypes from 'prop-types'; import {Trans} from 'react-i18next'; import {withTranslation} from '../lib/i18n'; import {requiresAuthenticatedUser, Title, withPageHelpers} from '../lib/page'; import { Button, ButtonRow, Fieldset, filterData, Form, FormSendMethod, InputField, TextArea, withForm, withFormErrorHandlers } from '../lib/form'; import {withErrorHandling} from '../lib/error-handling'; import {withComponentMixins} from "../lib/decorator-helpers"; @withComponentMixins([ withTranslation, withForm, withErrorHandling, withPageHelpers, requiresAuthenticatedUser ]) export default class Update extends Component { constructor(props) { super(props); this.state = {}; this.initForm(); } static propTypes = { entity: PropTypes.object } submitFormValuesMutator(data) { return filterData(data, ['adminEmail', 'uaCode', 'mapsApiKey', 'shoutout', 'pgpPassphrase', 'pgpPrivateKey', 'defaultHomepage']); } componentDidMount() { this.getFormValuesFromEntity(this.props.entity); } localValidateFormValues(state) { const t = this.props.t; } @withFormErrorHandlers async submitHandler() { const t = this.props.t; this.disableForm(); this.setFormStatusMessage('info', t('saving')); const submitSuccessful = await this.validateAndSendFormValuesToURL(FormSendMethod.PUT, 'rest/settings'); if (submitSuccessful) { await this.getFormValuesFromURL('rest/settings'); this.enableForm(); this.setFormStatusMessage('success', t('globalSettingsSaved')); } else { this.enableForm(); this.setFormStatusMessage('warning', t('thereAreErrorsInTheFormPleaseFixThemAnd')); } } render() { const t = this.props.t; return (
{t('globalSettings')}