This repository has been archived by the owner on May 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop application from applicant list
- Loading branch information
Showing
12 changed files
with
216 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
client/src/components/pepite/Applicant/DropApplication/DropApplicationForm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React, { PropTypes } from 'react' | ||
import { FormGroup, ControlLabel, Button } from 'react-bootstrap' | ||
import ValidatedFormControl from '../../../common/ValidatedFormControl' | ||
import ValidatedComponent from '../../../common/ValidatedComponent' | ||
import Textarea from 'react-textarea-autosize' | ||
|
||
const DropApplicationForm = ({reason, error, onChange, dropApplication}) => { | ||
return ( | ||
<form> | ||
<FormGroup className="required"> | ||
<ControlLabel>Raison de l'abandon</ControlLabel> | ||
<ValidatedComponent error={error}> | ||
<Textarea className="form-control" name="reason" rows={5} placeholder="raison" onChange={onChange} value={reason} /> | ||
</ValidatedComponent> | ||
</FormGroup> | ||
<Button bsStyle="danger" onClick={dropApplication}>Confirmer l'abandon</Button> | ||
</form> | ||
) | ||
} | ||
|
||
DropApplicationForm.propTypes = { | ||
reason: PropTypes.object, | ||
onChange: PropTypes.func.isRequired, | ||
error: PropTypes.object, | ||
dropApplication: PropTypes.func.isRequired | ||
} | ||
|
||
export default DropApplicationForm |
92 changes: 92 additions & 0 deletions
92
client/src/components/pepite/Applicant/DropApplication/DropApplicationPage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import React, { PropTypes } from 'react' | ||
import toastr from 'toastr' | ||
import { connect } from 'react-redux' | ||
import { bindActionCreators } from 'redux' | ||
|
||
import DropApplicationForm from './DropApplicationForm' | ||
import * as applicationActions from '../../../../actions/applicationActions' | ||
|
||
class DropApplicationPage extends React.Component { | ||
constructor(props, context) { | ||
super(props, context) | ||
this.state = { | ||
reason: '', | ||
errors: '' | ||
} | ||
this.updateReason = this.updateReason.bind(this) | ||
this.dropApplication = this.dropApplication.bind(this) | ||
} | ||
|
||
componentDidMount() { | ||
if (this.props.applicationId) { | ||
this.props.actions.loadApplication(this.props.applicationId).catch((err) => { | ||
toastr.error(err) | ||
}) | ||
} | ||
} | ||
|
||
updateReason(event) { | ||
const reason = event.target.value | ||
this.setState({ | ||
reason | ||
}) | ||
} | ||
|
||
dropApplication(event) { | ||
event.preventDefault() | ||
const reason = this.state.reason | ||
if (reason || reason.length || reason.trim()) { | ||
this.props.actions.dropApplication(this.props.applicationId, reason).then(() => { | ||
toastr.success(`Candidature de ${this.props.applicantFullname} abandonnée`) | ||
this.context.router.push('/pepite/applicant') | ||
}) | ||
.catch((err) => { | ||
toastr.error(err) | ||
}) | ||
} else { | ||
this.setState({ | ||
error: 'obligatoire' | ||
}) | ||
} | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="container back-content"> | ||
<div className="page-header"> | ||
<h1>Abandonner la candidature de {this.props.applicantFullname}</h1> | ||
</div> | ||
<DropApplicationForm | ||
committeeAnswer={this.state.committeeAnswer} | ||
onChange={this.updateReason} | ||
errors={this.state.errors} | ||
dropApplication={this.dropApplication} /> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
function mapStateToProps(state, ownProps) { | ||
return { | ||
applicationId: ownProps.params.id, | ||
applicantFullname: `${state.contact.firstname} ${state.contact.name}` | ||
} | ||
} | ||
|
||
function mapDispatchToProps(dispatch) { | ||
return { | ||
actions: bindActionCreators(applicationActions, dispatch), | ||
} | ||
} | ||
|
||
DropApplicationPage.propTypes = { | ||
actions: PropTypes.object.isRequired, | ||
applicantFullname: PropTypes.string.isRequired, | ||
applicationId: PropTypes.string | ||
} | ||
|
||
DropApplicationPage.contextTypes = { | ||
router: React.PropTypes.object.isRequired | ||
} | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(DropApplicationPage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
client/src/components/pepite/Applicant/PepiteRefusedApplicantRow.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/*global API_URI*/ | ||
import React, { PropTypes } from 'react' | ||
import { Glyphicon } from 'react-bootstrap' | ||
import GraduationLabel from './GraduationLabel' | ||
import { Link } from 'react-router' | ||
|
||
const PepiteRefusedApplicantRow = ({ application }) => { | ||
return ( | ||
<tr> | ||
<td>{application.contact.schoolYear}</td> | ||
<td>{application.contact.name}</td> | ||
<td>{application.contact.firstname}</td> | ||
<td>{application.contact.email}</td> | ||
<td>{application.career.diploma.establishment}</td> | ||
<td><GraduationLabel application={application} /></td> | ||
<td><a className="btn btn-info btn-xs" target="_blank" href={`/application/${application._id}/print`}><Glyphicon glyph="print" /></a></td> | ||
</tr> | ||
) | ||
} | ||
|
||
PepiteRefusedApplicantRow.propTypes = { | ||
application: PropTypes.object.isRequired | ||
} | ||
|
||
export default PepiteRefusedApplicantRow |
32 changes: 32 additions & 0 deletions
32
client/src/components/pepite/Applicant/PepiteRefusedTable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { PropTypes } from 'react' | ||
import { Glyphicon } from 'react-bootstrap' | ||
import PepiteRefusedApplicantRow from './PepiteRefusedApplicantRow' | ||
import TableHeader from '../../common/Table/TableHeader' | ||
|
||
const PepiteRefusedTable = ({ applicants, sort }) => { | ||
return ( | ||
<table className="table table-hover"> | ||
<thead> | ||
<tr> | ||
<TableHeader onSort={sort} field="contact.schoolYear">Promotion</TableHeader> | ||
<TableHeader onSort={sort} field="contact.name">Nom</TableHeader> | ||
<TableHeader onSort={sort} field="contact.firstname">Prénom</TableHeader> | ||
<TableHeader onSort={sort} field="contact.email">Email</TableHeader> | ||
<TableHeader onSort={sort} field="career.diploma.establishment">Établissement</TableHeader> | ||
<th>Statut</th> | ||
<th>Version imprimable</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{applicants.map((application, i) => { return (<PepiteRefusedApplicantRow key={i} application={application} />) })} | ||
</tbody> | ||
</table> | ||
) | ||
} | ||
|
||
PepiteRefusedTable.propTypes = { | ||
applicants: PropTypes.array.isRequired, | ||
sort: PropTypes.func.isRequired | ||
} | ||
|
||
export default PepiteRefusedTable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters