aboutsummaryrefslogtreecommitdiffstats
path: root/src/containers/auth/ChangeServerScreen.tsx
blob: 00715a0a29f324bac4c3a1cd3a57dc1c6e9516bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { inject, observer } from 'mobx-react';
import { Component, type ReactElement } from 'react';
import type { StoresProps } from '../../@types/ferdium-components.types';
import type { Actions } from '../../actions/lib/actions';
import ChangeServer from '../../components/auth/ChangeServer';
import type { RealStores } from '../../stores';

interface IProps {
  stores?: RealStores;
  actions?: Actions;
}

@inject('stores', 'actions')
@observer
class ChangeServerScreen extends Component<IProps> {
  constructor(props: StoresProps) {
    super(props);

    this.onSubmit = this.onSubmit.bind(this);
  }

  onSubmit(values: any): void {
    const { server } = values;

    this.props.actions!.settings.update({
      type: 'app',
      data: { server },
    });
    this.props.stores!.router.push('/auth');
  }

  render(): ReactElement {
    const { server } = this.props.stores!.settings.all.app;

    return <ChangeServer onSubmit={this.onSubmit} server={server} />;
  }
}

export default ChangeServerScreen;