diff --git a/src/actions/homework.js b/src/actions/homework.js index 741e1e4ce48cbe7b62a6447b0548888d5a78e94b..9e7c2e3ef705815775001992060b9c1d496bb12f 100644 --- a/src/actions/homework.js +++ b/src/actions/homework.js @@ -15,7 +15,7 @@ import { GET_TASKS, GET_DOCUMENTS, CORRECT_SOLUTION, SELECT_SOLUTION, - CHECK } from './types'; + CHECK, SETCHECKTRUE } from './types'; export const getTasks = () => ( async (dispatch) => { @@ -272,6 +272,12 @@ export const check = name => ( } ); +export const setchecktrue = name => ( + (dispatch) => { + dispatch({ type: SETCHECKTRUE, target: name }); + } +); + export const selectSolution = solution => ( (dispatch) => { dispatch({ diff --git a/src/actions/types.js b/src/actions/types.js index 7f9a8152d7547cbfb62b94b328f4df50819c23cc..8c01c4acf62b656079740cea5064b86ab0e3070b 100644 --- a/src/actions/types.js +++ b/src/actions/types.js @@ -34,6 +34,7 @@ export const GET_DOCUMENTS = 'get_documents'; export const CORRECT_SOLUTION = 'correct_solution'; export const SELECT_SOLUTION = 'select_solution'; export const CHECK = 'check'; +export const SETCHECKTRUE = 'setchecktrue'; export const GET_EVENTS = 'get_events'; export const GET_EVENT_BY_ID = 'get_event_by_id'; diff --git a/src/components/forms/CorrectSolutionForm.js b/src/components/forms/CorrectSolutionForm.js index 3b6b3ab3bad8a2e1865b7f9ce680f5e44cff16c1..374769bc3444e4ed137b07859da39854eb7e31a0 100644 --- a/src/components/forms/CorrectSolutionForm.js +++ b/src/components/forms/CorrectSolutionForm.js @@ -4,6 +4,7 @@ import { connect } from 'react-redux'; import { correctSolution, writeSolution, check, + setchecktrue, clearWrite, getSolutions, getDocuments, @@ -92,7 +93,10 @@ class CorrectSolutionForm extends Component { <Button color='green' inverted={!accepted} - onClick={() => this.props.check('accepted')} + onClick={() => { + this.props.check('accepted') + this.props.setchecktrue('corrected') + }} > <Checkbox label='ElfogadhatĂł' @@ -159,6 +163,7 @@ export default connect(mapStateToProps, { correctSolution, writeSolution, check, + setchecktrue, clearWrite, getSolutions, getDocuments, diff --git a/src/components/pages/Applications.js b/src/components/pages/Applications.js index 4cf91765dc5b0e94387bfb825bf00d61064d7807..83f13dca75c2a1b6bbc9f36ce5004147015369cf 100644 --- a/src/components/pages/Applications.js +++ b/src/components/pages/Applications.js @@ -5,83 +5,136 @@ import { connect } from 'react-redux'; import { getProfiles, setStatus } from '../../actions/statistics'; import ConfirmModal from '../forms/ConfirmModal'; +const role = [ + { + role: 'Staff', + text: 'Staff', + color: 'blue' + }, + { + role: 'Student', + text: 'Elfogadott', + color: 'green' + }, + { + role: 'Applicant', + text: 'Jelentkezett', + color: 'orange' + }, + { + role: 'Denied', + text: 'ElutasĂtott', + color: 'red' + }, + { + role: 'no', + text: 'Nem jelentkezett', + color: 'red' + }, +]; + class Applications extends Component { UNSAFE_componentWillMount() { this.props.getProfiles(); } - renderApplicants() { + renderApplicants(format) { return this.props.profiles.map((profile) => { return ( - <Table.Row> - <Table.Cell textAlign='center'> - <Link to={`applicant/${profile.id}`}> - {profile.full_name} - </Link> - </Table.Cell> - { profile.signed ? + profile.role === format.role + && (profile.signed === true || + profile.role === 'Staff') ? + <Table.Row key={profile.id}> <Table.Cell textAlign='center'> - { profile.role === 'Student' ? - <Label color='green'>Elfogadva</Label> - : - null - } - { profile.role === 'Staff' ? - <Label color='blue'>Staff</Label> - : - null - } - { profile.role === 'Applicant' ? - <Label color='orange'>Jelentkezett</Label> - : - null - } - { profile.role === 'Denied' ? - <Label color='red'>ElutasĂtva</Label> - : - null - } + <Link to={`applicant/${profile.id}`}> + {profile.full_name} + </Link> </Table.Cell> - : <Table.Cell textAlign='center'> - <Label color='red'>Nem jelentkezett</Label> + { format.role === 'Staff' ? null : + <ConfirmModal + button = {<Button + color='blue' + size='tiny' + > + ADD STAFF STATUS + </Button>} + text='staff jogot adsz neki' + onAccept={() => this.props.setStatus(profile.id, 'Staff')} + /> + } </Table.Cell> - } - <Table.Cell textAlign='center'> - <ConfirmModal - button = {<Button - color='blue' - size='tiny' - > - ADD STAFF STATUS - </Button>} - text='staff jogot adsz neki' - onAccept={() => this.props.setStatus(profile.id, 'Staff')} - /> - </Table.Cell> - </Table.Row> - ); + </Table.Row> + : null + ); + }); + } + + renderNotApplicants(format) { + return this.props.profiles.map((profile) => + { return ( + profile.signed === false && profile.role !== 'Staff'? + <Table.Row key={profile.id}> + <Table.Cell textAlign='center'> + <Link to={`applicant/${profile.id}`}> + {profile.full_name} + </Link> + </Table.Cell> + <Table.Cell textAlign='center'> + { format.role === 'Staff' ? null : + <ConfirmModal + button = {<Button + color='blue' + size='tiny' + > + ADD STAFF STATUS + </Button>} + text='staff jogot adsz neki' + onAccept={() => this.props.setStatus(profile.id, 'Staff')} + /> + } + </Table.Cell> + </Table.Row> + : null + ); }); } + renderTable(format) { + return ( + <Table color='blue' unstackable celled selectable compact> + <Table.Header> + <Table.Row> + <Table.HeaderCell textAlign='center'> + <Label color={format.color}>{format.text}</Label> + </Table.HeaderCell> + <Table.HeaderCell width={3} /> + </Table.Row> + </Table.Header> + <Table.Body> + {format.role === 'no' ? + this.renderNotApplicants(format) + : + this.renderApplicants(format) + } + </Table.Body> + </Table> + ) + } + + + + render() { return ( <Container textAlign='center' style={{paddingTop: '1em', paddingBottom: '5em'}} > - <Table color='blue' unstackable celled selectable compact> - <Table.Header> - <Table.Row> - <Table.HeaderCell>Jelentkezettek</Table.HeaderCell> - <Table.HeaderCell textAlign='center'>JelentkezĂŠs stĂĄtusza:</Table.HeaderCell> - <Table.HeaderCell /> - </Table.Row> - </Table.Header> - - <Table.Body> - {this.renderApplicants()} - </Table.Body> - </Table> + {this.renderTable(role[2])} {/* Applicant */} + {this.renderTable(role[1])} {/* Student */} + {this.renderTable(role[0])} {/* Staff */} + {this.renderTable(role[3])} {/* Denied */} + {this.renderTable(role[4])} {/* Not Signed */} </Container> ); } diff --git a/src/components/pages/EventDetail.js b/src/components/pages/EventDetail.js index b6b7c666a384d151af8f0dfc8599bd9a4fe4256c..a3282e63410536facfb7c744c50536a0df98f6c0 100644 --- a/src/components/pages/EventDetail.js +++ b/src/components/pages/EventDetail.js @@ -37,13 +37,15 @@ class EventDetail extends Component { return this.props.trainees?.map((item) => { const notes = this.props.eventNotes?.filter(note => note.profile === item.id); return ( - <TraineeTableRow - selectedEvent={event} - notes={notes} - trainee={item} - edit={this.state.edit} - key={item.id} - /> + item.role === 'Student' ? + <TraineeTableRow + selectedEvent={event} + notes={notes} + trainee={item} + edit={this.state.edit} + key={item.id} + /> + : null ); }); } diff --git a/src/components/pages/Homework.js b/src/components/pages/Homework.js index 1b3b0eb0d4bf62ba8fe02b994c36efac6e287125..7108ae31f3eceff0092e692bda6886bf9bbed9c1 100644 --- a/src/components/pages/Homework.js +++ b/src/components/pages/Homework.js @@ -346,28 +346,28 @@ class Homework extends Component { : <div> {this.renderHomeworksTable(active, staff)} - {!active && !staff ? - <Header - as='h3' - content={ - <div > - Jelenlegi bitjeid szĂĄma: - <Label color='green' size='large'> - {this.props.user.bits} bit - </Label> - </div> - } - style={{ - fontWeight: 'normal', - marginTop: '0.5em', - }} - textAlign='right' - /> - : null - } </div> - } + {!active && !staff ? + <Header + as='h3' + content={ + <div > + Jelenlegi bitjeid szĂĄma: + <Label color='green' size='large'> + {this.props.user.bits} bit + </Label> + </div> + } + style={{ + fontWeight: 'normal', + marginTop: '0.5em', + marginBottom: '1em' + }} + textAlign='right' + /> + : null + } </Container> </Segment> ); diff --git a/src/components/pages/LeaderBoard.js b/src/components/pages/LeaderBoard.js index dbbf927bf2df38cbe9a02d3d810fbb946e3d45af..25f917b54b35bcc04f642f0f88e886ed7738bfd0 100644 --- a/src/components/pages/LeaderBoard.js +++ b/src/components/pages/LeaderBoard.js @@ -15,20 +15,22 @@ class LeaderBoard extends Component { - (Number(a.homework_bits) + a.events_visited) }).map((trainee) => { return ( - <Table.Row key={trainee.nick}> - <Table.Cell textAlign='center'> - {trainee.full_name} - </Table.Cell> - <Table.Cell textAlign='center' > - {trainee.events_visited} - </Table.Cell> - <Table.Cell textAlign='center'> - {Number(trainee.homework_bits)} - </Table.Cell> - <Table.Cell textAlign='center'> - {Number(trainee.homework_bits) + trainee.events_visited} - </Table.Cell> - </Table.Row> + trainee.role === 'Student' ? + <Table.Row key={trainee.nick}> + <Table.Cell textAlign='center'> + {trainee.full_name} + </Table.Cell> + <Table.Cell textAlign='center' > + {trainee.events_visited} + </Table.Cell> + <Table.Cell textAlign='center'> + {Number(trainee.homework_bits)} + </Table.Cell> + <Table.Cell textAlign='center'> + {Number(trainee.homework_bits) + trainee.events_visited} + </Table.Cell> + </Table.Row> + : null ) }) } diff --git a/src/components/pages/Presence.js b/src/components/pages/Presence.js index 7c343c26e53899b993590c76629b5a57afb8b6b9..02763a732954abccae3773324aca8eff3933cfed 100644 --- a/src/components/pages/Presence.js +++ b/src/components/pages/Presence.js @@ -31,12 +31,14 @@ class Presence extends Component { renderTraineesWithEvents() { return this.props.trainees.map((trainee) => { return ( - <Table.Row key={Math.random()}> - <Table.Cell textAlign='center'> - {trainee.full_name} - </Table.Cell> - {this.renderVisitedStatus(trainee)} - </Table.Row> + trainee.role === 'Student' ? + <Table.Row key={Math.random()}> + <Table.Cell textAlign='center'> + {trainee.full_name} + </Table.Cell> + {this.renderVisitedStatus(trainee)} + </Table.Row> + : null ); }); } diff --git a/src/reducers/CorrectSolutionReducer.js b/src/reducers/CorrectSolutionReducer.js index b64bf26fbbf43b5ce10112b537acfaff91129d97..c3c010bda60f0aca9ad1bba1de21b00d1ba40a4c 100644 --- a/src/reducers/CorrectSolutionReducer.js +++ b/src/reducers/CorrectSolutionReducer.js @@ -1,4 +1,4 @@ -import { WRITE_SOLUTION, CHECK, CLEAR_WRITE, SELECT_SOLUTION } from '../actions/types'; +import { WRITE_SOLUTION, CHECK, SETCHECKTRUE, CLEAR_WRITE, SELECT_SOLUTION } from '../actions/types'; const INITIAL_STATE = { accepted: false, @@ -21,6 +21,11 @@ export default (state = INITIAL_STATE, action) => { ...state, [action.target]: !state[action.target], }; + case SETCHECKTRUE: + return { + ...state, + [action.target]: true, + }; case CLEAR_WRITE: return INITIAL_STATE; default: