import { Component, linkEvent } from 'inferno'; import { Site, SiteForm as SiteFormI } from '../interfaces'; import { WebSocketService } from '../services'; import { capitalizeFirstLetter } from '../utils'; import * as autosize from 'autosize'; import { i18n } from '../i18next'; import { T } from 'inferno-i18next'; interface SiteFormProps { site?: Site; // If a site is given, that means this is an edit onCancel?(): any; } interface SiteFormState { siteForm: SiteFormI; loading: boolean; } export class SiteForm extends Component { private emptyState: SiteFormState ={ siteForm: { name: null }, loading: false } constructor(props: any, context: any) { super(props, context); this.state = this.emptyState; if (this.props.site) { this.state.siteForm = { name: this.props.site.name, description: this.props.site.description, } } } componentDidMount() { autosize(document.querySelectorAll('textarea')); } render() { return (
{`${this.props.site ? capitalizeFirstLetter(i18n.t('edit')) : capitalizeFirstLetter(i18n.t('name'))} ${i18n.t('your_site')}`}