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: { enable_downvotes: true, open_registration: true, enable_nsfw: true, 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, enable_downvotes: this.props.site.enable_downvotes, open_registration: this.props.site.open_registration, enable_nsfw: this.props.site.enable_nsfw, }; } } componentDidMount() { autosize(document.querySelectorAll('textarea')); } render() { return (
{`${ this.props.site ? capitalizeFirstLetter(i18n.t('edit')) : capitalizeFirstLetter(i18n.t('name')) } ${i18n.t('your_site')}`}