diff --git a/assets/js/CompanyRegister.jsx b/assets/js/CompanyRegister.jsx index a498fc22db7971e831c00e5cbb66344157448b89..17604069696c547fb26d9f6b251c0009c16bce6e 100644 --- a/assets/js/CompanyRegister.jsx +++ b/assets/js/CompanyRegister.jsx @@ -10,7 +10,7 @@ export default class companyRegister extends React.Component { <div className="registerForm"> <Card fluid > <Card.Content> - <Form> + <form encType="multipart/form-data" action=""> <Header as='h2' icon textAlign='center'> <Icon name='signup' circular /> <Header.Content> @@ -36,7 +36,7 @@ export default class companyRegister extends React.Component { </Form.Field> <Form.Field required> <label>Logo</label> - <Input + <Input type="File" icon={{ name: 'attach', circular: true, link: true }} placeholder='attach logo' required @@ -59,7 +59,7 @@ export default class companyRegister extends React.Component { <Input placeholder='Provinsi' required /> </Form.Field > <Button type='submit' floated='right' color='blue'>Submit</Button> - </Form> + </form> </Card.Content> </Card> </div> diff --git a/assets/js/__test__/components/LoginForm-test.jsx b/assets/js/__test__/components/LoginForm-test.jsx index 977f317492d52555209ff3caa3d79570d3b379c5..efacc1bb744b7b42f9f8d8ca87a34d7bee49a89d 100644 --- a/assets/js/__test__/components/LoginForm-test.jsx +++ b/assets/js/__test__/components/LoginForm-test.jsx @@ -25,8 +25,8 @@ describe('LoginForm', () => { it('handle email input without problem', () => { const formLogin = ReactTestUtils.renderIntoDocument( - <LoginForm url="" />); - expect(formLogin.state.email).to.equal(''); + <LoginForm type="sso-ui" />); + expect(formLogin.state.username).to.equal(''); const emailNode = ReactTestUtils.scryRenderedDOMComponentsWithTag(formLogin, 'Input')[0]; // const emailNode = ReactDOM.findDOMNode(formLogin.refs.email); const email = 'jojon'; @@ -34,12 +34,12 @@ describe('LoginForm', () => { ReactTestUtils.Simulate.change(emailNode, { target: { value: email } }); expect(emailNode.value).to.equal(email); - expect(formLogin.state.email).to.equal(email); + expect(formLogin.state.username).to.equal(email); }); it('handle password input without problem', () => { const formLogin = ReactTestUtils.renderIntoDocument( - <LoginForm url="" />); + <LoginForm type="sso-ui" />); const passwordNode = ReactTestUtils.scryRenderedDOMComponentsWithTag(formLogin, 'Input')[1]; // const passwordNode = ReactDOM.findDOMNode(formLogin.refs.password); diff --git a/assets/js/components/ModalAlert.jsx b/assets/js/components/ModalAlert.jsx index ce5e26383a19688132a7d85cf43c60cb58e09960..e03d10c884df0b41df68a025da12a5f804ff25e2 100644 --- a/assets/js/components/ModalAlert.jsx +++ b/assets/js/components/ModalAlert.jsx @@ -1,6 +1,7 @@ import React from 'react'; import { Modal, Button, Icon } from 'semantic-ui-react'; import Server from '../lib/Server'; +import Storage from '../lib/Storage'; export default class ModalAlert extends React.Component { static propTypes = { @@ -24,17 +25,20 @@ export default class ModalAlert extends React.Component { close = () => this.setState({ open: false }); handleOpen() { - const requestData = { coverLetter: this.props.coverLetter }; - let studentId = Storage.post('user-data.student.id'); - Server.post(`/students/${studentId}/application`, requestData).then((data) => { + const studentId = Storage.get('user-data').student.id; + const requestData = {vacancy_id: this.props.id, cover_letter: this.props.coverLetter }; + + Server.post(`/students/${studentId}/applied-vacancies/`, requestData).then((data) => { + this.setState({ header: 'Pendaftaran Berhasil', - content: this.successResponse + JSON.stringify(data), + content: this.successResponse, }); }, (error) => { + this.setState({ - responseHeader: 'Pendaftaran Gagal', - responseText: this.failedResponse + JSON.stringify(error), + header: 'Pendaftaran Gagal', + content: this.failedResponse, }); }); } diff --git a/assets/js/components/ModalPendaftaran.jsx b/assets/js/components/ModalPendaftaran.jsx index 746c1171e3310a26c8d6639e0c0bdca62e4ed511..2312fd1dadf1c9276ca331ea591e76bafb7b0b02 100644 --- a/assets/js/components/ModalPendaftaran.jsx +++ b/assets/js/components/ModalPendaftaran.jsx @@ -64,7 +64,7 @@ export default class ModalPendaftaran extends React.Component { <h5> Write your Cover Letter </h5> <Form > - <TextArea placeholder="Tell us more" size='big' /> + <TextArea placeholder="Tell us more" size='big' onChange={this.handleChange}/> </Form> </div> diff --git a/assets/js/components/Vacancy.jsx b/assets/js/components/Vacancy.jsx index 4b993e305fd7d67c88b7421ccf0fe06ecb84da05..bd749e113b15f8cfa07c80a4d9b7cf7cfc5d9393 100644 --- a/assets/js/components/Vacancy.jsx +++ b/assets/js/components/Vacancy.jsx @@ -1,24 +1,42 @@ import React from 'react'; -import { Button, Image as ImageComponent, Item, Rating } from 'semantic-ui-react' +import { Button, Image as ImageComponent, Item, Rating } from 'semantic-ui-react'; import ModalPendaftaran from './ModalPendaftaran'; +import Storage from '../lib/Storage'; +import Server from '../lib/Server'; -const defaultImage = "http://semantic-ui.com/images/wireframe/image.png"; +const defaultImage = 'http://semantic-ui.com/images/wireframe/image.png'; export default class Lowongan extends React.Component { static propTypes = { data: React.PropTypes.object.isRequired, }; + constructor(props) { + super(props); + /* istanbul ignore next */ + this.bookmark = this.bookmark.bind(this); + } + + bookmark() { + const studentId = Storage.get('user-data').student.id; + const data = { vacancy_id: this.props.data.id }; + Server.post(`/students/${studentId}/bookmarked-vacancies/`, data).then((response) => { + console.log(JSON.stringify(response)); + }, (error) => { + console.log(JSON.stringify(error)); + }); + } + render() { return ( <Item > - <Item.Image size="small" src={this.props.data.company.logo ? this.props.data.company.logo: defaultImage} /> + <Item.Image size="small" src={this.props.data.company.logo ? this.props.data.company.logo : defaultImage} /> <Item.Content verticalAlign="middle"> <Item.Extra> <h3>{ this.props.data.name }</h3> <div className="bookmark"> - <Rating icon='star' size='massive' defaultRating={0} maxRating={1} /> + <Rating icon="star" onRate={this.bookmark} size="massive" defaultRating={0} maxRating={1} /> </div> <h4>{ this.props.data.company.name }</h4> <h5>{ this.props.data.company.address }</h5> @@ -26,11 +44,12 @@ export default class Lowongan extends React.Component { <ModalPendaftaran id={this.props.data.id} data={{ header: this.props.data.name, - description: this.props.data.description }} buttonTitle="Daftar" /> + description: this.props.data.description }} buttonTitle="Daftar" + /> </Item.Extra> </Item.Content> </Item> ); } -} \ No newline at end of file +}