Skip to content
Snippets Groups Projects
Profile.js 3.75 KiB
Newer Older
  • Learn to ignore specific revisions
  • import React, { Component } from 'react';
    
    import { Container, Segment, Form, Dropdown, Divider, Header } from 'semantic-ui-react';
    
    import { connect } from 'react-redux';
    import { textChange, submitRegistration, groupChange } from '../../actions';
    
    const options = [
      { key: 'DT', text: 'DevTeam', value: 'DT' },
      { key: 'NET', text: 'NeTeam', value: 'NET' },
      { key: 'ST', text: 'SecurITeam', value: 'ST' },
      { key: 'SYS', text: 'SysAdmin', value: 'SYS' },
      { key: 'HAT', text: 'Hallgatói Tudásbázis', value: 'HAT' },
    ];
    
    class Profile extends Component {
      componentWillMount() {
        if (!this.props.id) {
          this.props.history.push('/home');
        }
      }
    
    Tamás Szabó's avatar
    Tamás Szabó committed
        const {
    
    Tamás Szabó's avatar
    Tamás Szabó committed
          nick, groups, motivationAbout, motivationProfession, motivationExercise, signed, id,
    
    Tamás Szabó's avatar
    Tamás Szabó committed
        } = this.props;
    
    Barnabás Czémán's avatar
    Barnabás Czémán committed
          <Container
            style={{
              marginBottom: '0.5em',
              marginTop: '0.5em',
            }}
          >
            <Divider horizontal>
              <Header as='h2' content='Profil (Jelentkezés)' />
            </Divider>
            <Segment textAlign='center'>
              <Form>
                <Divider horizontal>Becenév</Divider>
                <Form.Input
                  fluid
                  name='nick'
                  onChange={e => this.props.textChange(e)}
                  placeholder='Becenév'
                  value={nick}
                />
    
    
    Tamás Szabó's avatar
    Tamás Szabó committed
                <Divider horizontal>Motiváció</Divider>
    
    Barnabás Czémán's avatar
    Barnabás Czémán committed
                <Form.TextArea
                  rows={10}
    
    Tamás Szabó's avatar
    Tamás Szabó committed
                  name='motivationAbout'
    
    Barnabás Czémán's avatar
    Barnabás Czémán committed
                  onChange={e => this.props.textChange(e)}
    
    Tamás Szabó's avatar
    Tamás Szabó committed
                  placeholder='Mesélj nekünk egy kicsit magadról. Milyen szakmai vagy más eredményeket értél el, amikre büszke vagy?'
                  value={motivationAbout}
    
    Tamás Szabó's avatar
    Tamás Szabó committed
                <Divider horizontal />
                <Form.TextArea
                  rows={10}
                  name='motivationProfession'
                  onChange={e => this.props.textChange(e)}
                  placeholder='Mit vársz el a képzéstõl, miért szeretnél rá jelentkezni, szerinted mire tudod majd használni az itt megszerzett tudást? Mit szeretnél elérni a szakmádban?'
                  value={motivationProfession}
                />
    
                <Divider horizontal />
                <Form.TextArea
                  rows={10}
                  name='motivationExercise'
                  onChange={e => this.props.textChange(e)}
                  placeholder='Itt egy feladat kérdése lesz, éjfélig megcsináljuk a kérdést.'
                  value={motivationExercise}
                />
    
                <Divider horizontal>Érdekelődés</Divider>
    
    Barnabás Czémán's avatar
    Barnabás Czémán committed
                <Dropdown
                  fluid
                  multiple
                  selection
                  placeholder='DevTeam, ...'
                  onChange={(_, v) => this.props.groupChange(v.value)}
                  options={options}
                  defaultValue={groups}
                />
                <br />
                <Form.Checkbox
                  name='signed'
                  label='Szeretnék jelentkezni a KSZK-ba'
                  onChange={(_, v) =>
                    this.props.textChange({ target: { name: v.name, value: v.checked } })
                  }
                  checked={signed}
                />
                <Form.Button
                  onClick={() => this.props.submitRegistration({
    
    Tamás Szabó's avatar
    Tamás Szabó committed
                    nick, motivationAbout, motivationProfession, motivationExercise, signed, groups, id,
    
    Barnabás Czémán's avatar
    Barnabás Czémán committed
                  })}
                >
                  Mentés
                </Form.Button>
              </Form>
    
    Barnabás Czémán's avatar
    Barnabás Czémán committed
          </Container>
    
    Tamás Szabó's avatar
    Tamás Szabó committed
    const mapStateToProps = ({
      user: {
    
    Tamás Szabó's avatar
    Tamás Szabó committed
        nick, groups, motivationAbout, motivationProfession, motivationExercise, signed, id,
    
    Tamás Szabó's avatar
    Tamás Szabó committed
      },
    }) => ({
      nick,
      groups,
    
    Tamás Szabó's avatar
    Tamás Szabó committed
      motivationAbout,
      motivationProfession,
      motivationExercise,
    
    Tamás Szabó's avatar
    Tamás Szabó committed
      signed,
      id,
    });
    
    
    export default connect(mapStateToProps, { textChange, submitRegistration, groupChange })(Profile);