"use strict";(self.webpackChunkinfluxdb_ui=self.webpackChunkinfluxdb_ui||[]).push([[429],{99460:(t,e,a)=>{a.a(t,(async(t,r)=>{try{a.r(e),a.d(e,{default:()=>h});var n=a(67294),s=a(46458),o=a(47886),u=a(96486),i=a(98555),l=a(13357),c=t([l]);l=(c.then?(await c)():c)[0];class m extends n.PureComponent{constructor(t){super(t),this.handleCreateOrg=async()=>{const{org:t,bucket:e}=this.state,{createOrgWithBucket:a}=this.props;await a(t,e)},this.closeModal=()=>{this.props.history.goBack()},this.handleChangeOrgInput=t=>{const e=t.target.value,a=t.target.name,r=Object.assign(Object.assign({},this.state.org),{[a]:e});if(!e)return this.setState({org:r,orgNameInputStatus:i.ComponentStatus.Error,orgErrorMessage:this.randomErrorMessage(a,"organization")});this.setState({org:r,orgNameInputStatus:i.ComponentStatus.Valid,orgErrorMessage:""})},this.handleChangeBucketInput=t=>{const e=t.target.value,a=t.target.name,r=Object.assign(Object.assign({},this.state.bucket),{[a]:e});if(!e)return this.setState({bucket:r,bucketNameInputStatus:i.ComponentStatus.Error,bucketErrorMessage:this.randomErrorMessage(a,"bucket")});this.setState({bucket:r,bucketNameInputStatus:i.ComponentStatus.Valid,bucketErrorMessage:""})},this.randomErrorMessage=(t,e)=>{const a=[`Imagine that! ${(0,u.startCase)(e)} without a ${t}`,`${(0,u.startCase)(e)} needs a ${t}`,`You're not getting far without a ${t}`,`The ${e} formerly known as...`,`Pick a ${t}, any ${t}`,`Any ${t} will do`];return(0,u.sample)(a)},this.state={org:{name:""},bucket:{name:"",retentionRules:[],readableRetention:"forever"},orgNameInputStatus:i.ComponentStatus.Default,bucketNameInputStatus:i.ComponentStatus.Default,orgErrorMessage:"",bucketErrorMessage:""}}render(){const{org:t,orgNameInputStatus:e,orgErrorMessage:a,bucket:r,bucketNameInputStatus:s,bucketErrorMessage:o}=this.state;return n.createElement(i.Overlay,{visible:!0},n.createElement(i.Overlay.Container,{maxWidth:500},n.createElement(i.Overlay.Header,{title:"Create Organization",onDismiss:this.closeModal,testID:"create-org-overlay--header"}),n.createElement(i.Form,{onSubmit:this.handleCreateOrg},n.createElement(i.Overlay.Body,null,n.createElement(i.Form.Element,{label:"Organization Name",errorMessage:a},n.createElement(i.Input,{placeholder:"Give your organization a name",name:"name",autoFocus:!0,value:t.name,onChange:this.handleChangeOrgInput,status:e,testID:"create-org-name-input"})),n.createElement(i.Form.Element,{label:"Bucket Name",errorMessage:o},n.createElement(i.Input,{placeholder:"Give your bucket a name",name:"name",autoFocus:!1,value:r.name,onChange:this.handleChangeBucketInput,status:s,testID:"create-org-name-input"}))),n.createElement(i.Overlay.Footer,null,n.createElement(i.Button,{text:"Cancel",color:i.ComponentColor.Tertiary,onClick:this.closeModal}),n.createElement(i.Button,{text:"Create",type:i.ButtonType.Submit,color:i.ComponentColor.Primary,status:this.submitButtonStatus,testID:"create-org-submit-button"})))))}get submitButtonStatus(){const{org:t,bucket:e}=this.state;return t.name&&e.name?i.ComponentStatus.Default:i.ComponentStatus.Disabled}}const g={createOrgWithBucket:l.DX},h=(0,s.$j)(null,g)((0,o.EN)(m));r()}catch(t){r(t)}}))}}]);
//# sourceMappingURL=4d004036e9.js.map