From 127f1ec00284a193e864e17cce7fd1eb618fab4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chif=20Gerg=C5=91?= <chifgeri97@gmail.com> Date: Sat, 2 Feb 2019 17:14:37 +0100 Subject: [PATCH] Display groups in Applicant detail, remove add staff button when user is staff --- src/components/pages/ApplicantProfile.js | 32 ++++++++++++++++++++++-- src/components/pages/Applications.js | 23 +++++++++-------- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/components/pages/ApplicantProfile.js b/src/components/pages/ApplicantProfile.js index 535617c..a8595aa 100644 --- a/src/components/pages/ApplicantProfile.js +++ b/src/components/pages/ApplicantProfile.js @@ -1,16 +1,36 @@ import React, { Component } from 'react'; -import { Container, Header, Item, Button, Label } from 'semantic-ui-react'; +import { Container, Header, Item, Button, Label, List } from 'semantic-ui-react'; import { connect } from 'react-redux'; import { getSelectedProfile, setStatus } from '../../actions/statistics'; import ConfirmModal from '../forms/ConfirmModal'; +const options = [ + { key: 'DT', text: 'DevTeam' }, + { key: 'NET', text: 'NETeam' }, + { key: 'ST', text: 'SecurITeam' }, + { key: 'SYS', text: 'SysAdmin' }, + { key: 'HAT', text: 'HallgatĂłi TudĂĄsbĂĄzis' }, +]; + class ApplicantProfile extends Component { componentWillMount() { this.props.getSelectedProfile(this.props.match.params.id); } + renderGroups() { + const { groups } = this.props.selectedProfile; + const groupNames = options.map(item => (groups.includes(item.key) ? item.text : null)); + return groupNames.map(item => ( + <List.Item> + <List.Content> + <List.Header>{item}</List.Header> + </List.Content> + </List.Item> + )); + } + render() { - const { id, signed, role, full_name, nick, motivation_about, motivation_exercise, motivation_profession } + const { id, signed, groups, role, full_name, nick, motivation_about, motivation_exercise, motivation_profession } = this.props.selectedProfile; return ( <Container style={{ padding: '60px' }}> @@ -28,6 +48,14 @@ class ApplicantProfile extends Component { <p>{motivation_profession}</p> <Header as='h3'>Feladatok megoldĂĄsa:</Header> <p>{motivation_exercise}</p> + <Header as='h3'>ĂrdeklĹdĂŠs:</Header> + { groups ? + <List horizontal> + {this.renderGroups()} + </List> + : + null + } </Container> <Container textAlign='center' style={{ padding: '20px' }}> <Header as='h3'>StĂĄtusz:</Header> diff --git a/src/components/pages/Applications.js b/src/components/pages/Applications.js index 68e6ce9..934252c 100644 --- a/src/components/pages/Applications.js +++ b/src/components/pages/Applications.js @@ -52,16 +52,19 @@ class Applications extends Component { </Table.Cell> } <Table.Cell> - <ConfirmModal - button = {<Button - color='blue' - size='tiny' - > - Staff jog adĂĄs - </Button>} - text='staff jogot adsz neki' - onAccept={() => this.props.setStatus(profile.id, 'Staff')} - /> + { profile.role !== 'Staff' ? + <ConfirmModal + button={<Button + color='blue' + size='tiny' + > + Staff jog adĂĄs + </Button>} + text='staff jogot adsz neki' + onAccept={() => this.props.setStatus(profile.id, 'Staff')} + /> + : + null } </Table.Cell> </Table.Row> ); -- GitLab