import { Component, linkEvent } from 'inferno'; import { Site, SiteForm as SiteFormI } from '../interfaces'; import { WebSocketService } from '../services'; import * as autosize from 'autosize'; 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 ? 'Edit' : 'Name'} your Site`}