Basic functionality in place, need improved errors and logged in redirect

This commit is contained in:
Tom Moor
2018-11-03 20:27:57 -07:00
parent 07e61bd347
commit 21b1c0747c
24 changed files with 512 additions and 130 deletions

View File

@@ -25,12 +25,14 @@ class Details extends React.Component<Props> {
form: ?HTMLFormElement;
@observable name: string;
@observable subdomain: string;
@observable subdomain: ?string;
@observable avatarUrl: ?string;
componentDidMount() {
if (this.props.auth.team) {
this.name = this.props.auth.team.name;
const { team } = this.props.auth;
if (team) {
this.name = team.name;
this.subdomain = team.subdomain;
}
}
@@ -41,11 +43,16 @@ class Details extends React.Component<Props> {
handleSubmit = async (ev: SyntheticEvent<*>) => {
ev.preventDefault();
await this.props.auth.updateTeam({
name: this.name,
avatarUrl: this.avatarUrl,
});
this.props.ui.showToast('Settings saved', 'success');
try {
await this.props.auth.updateTeam({
name: this.name,
avatarUrl: this.avatarUrl,
subdomain: this.subdomain,
});
this.props.ui.showToast('Settings saved', 'success');
} catch (err) {
this.props.ui.showToast('Could not save');
}
};
handleNameChange = (ev: SyntheticInputEvent<*>) => {
@@ -115,22 +122,24 @@ class Details extends React.Component<Props> {
required
short
/>
<Input
label="Subdomain"
name="subdomain"
value={this.subdomain}
onChange={this.handleSubdomainChange}
placeholder="Optional"
short
/>
{this.subdomain && (
<HelpText small>
You will be able to access your wiki at{' '}
<strong>{this.subdomain}.getoutline.com</strong>
</HelpText>
{process.env.SUBDOMAINS_ENABLED && (
<React.Fragment>
<Input
label="Subdomain"
name="subdomain"
value={this.subdomain}
onChange={this.handleSubdomainChange}
placeholder="Optional"
short
/>
{this.subdomain && (
<HelpText small>
You will be able to access your wiki at{' '}
<strong>{this.subdomain}.getoutline.com</strong>
</HelpText>
)}
</React.Fragment>
)}
<Button type="submit" disabled={isSaving || !this.isValid}>
{isSaving ? 'Saving…' : 'Save'}
</Button>