From 51658286ac89ef7c844c652fb2ebf6a56891cab5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Chif=20Gerg=C5=91?= <chifgeri97@gmail.com>
Date: Tue, 22 Jan 2019 21:55:50 +0100
Subject: [PATCH] Add more status label based on the profiles role

---
 src/actions/statistics.js            |  5 ++--
 src/components/pages/Applications.js | 44 ++++++++++++++++++++--------
 2 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/src/actions/statistics.js b/src/actions/statistics.js
index fca39b3..719fad4 100644
--- a/src/actions/statistics.js
+++ b/src/actions/statistics.js
@@ -136,12 +136,11 @@ export const getProfiles = () => (
   }
 );
 
-export const setStaffStatus = id => (
+export const setStatus = (id, status) => (
   async (dispatch) => {
     try {
       const response = await axios.patch(`/api/v1/profiles/${id}/`, {
-        signed: true,
-        role: 'Staff',
+        role: status,
       });
       if (response.data.id) {
       }
diff --git a/src/components/pages/Applications.js b/src/components/pages/Applications.js
index 0ce391c..3d5a7ae 100644
--- a/src/components/pages/Applications.js
+++ b/src/components/pages/Applications.js
@@ -1,8 +1,8 @@
 import React, { Component } from 'react';
 import { Link } from 'react-router-dom';
-import { Container, Table, Icon, Button } from 'semantic-ui-react';
+import { Container, Table, Label, Button } from 'semantic-ui-react';
 import { connect } from 'react-redux';
-import { getProfiles, setStaffStatus } from '../../actions/statistics';
+import { getProfiles, setStatus } from '../../actions/statistics';
 
 class Applications extends Component {
   componentWillMount() {
@@ -18,19 +18,37 @@ class Applications extends Component {
             {profile.full_name}
           </Link>
         </Table.Cell>
-        <Table.Cell textAlign='center'>
-          { profile.role === 'Student' ?
-            <Icon color='green' name='checkmark' />
-            :
-              profile.role === 'Staff' ?
-              <strong>Staff</strong>
+        { profile.signed ?
+          <Table.Cell textAlign='center'>
+            { profile.role === 'Student' ?
+              <Label color='green'>Elfogadva</Label>
               :
-              <Icon color='red' name='cancel' />
-          }
-        </Table.Cell>
+              null
+            }
+            { profile.role === 'Staff' ?
+              <Label color='blue'>Staff</Label>
+              :
+              null
+            }
+            { profile.role === 'Apllicant' ?
+              <Label color='yellow'>Jelentkezett</Label>
+              :
+              null
+            }
+            { profile.role === 'Denied' ?
+              <Label color='red'>ElutasĂ­tva</Label>
+              :
+              null
+            }
+          </Table.Cell>
+          :
+          <Table.Cell textAlign='center'>
+            <Label color='red'>Nem jelentkezett</Label>
+          </Table.Cell>
+        }
         <Table.Cell>
           <Button
-            onClick={() => this.props.setStaffStatus(profile.id)}
+            onClick={() => this.props.setStatus(profile.id, 'Staff')}
             color='blue'
             size='tiny'
           >
@@ -70,4 +88,4 @@ class Applications extends Component {
 
 const mapStateToProps = ({ trainees: { profiles }, user }) => ({ profiles, user });
 
-export default connect(mapStateToProps, { getProfiles, setStaffStatus })(Applications);
+export default connect(mapStateToProps, { getProfiles, setStatus })(Applications);
-- 
GitLab