Fakultas Ilmu Komputer UI

Commit d86740f3 authored by M. Reza Qorib's avatar M. Reza Qorib
Browse files

#140654507 #13 finalize vacancy logic flow

parent 91664b20
...@@ -13,19 +13,20 @@ export default class VacancyPage extends React.Component { ...@@ -13,19 +13,20 @@ export default class VacancyPage extends React.Component {
email: '', email: '',
password: '', password: '',
errorFlag: false, errorFlag: false,
vacancies: [] vacancies: [],
}; };
this.handleItemClick = this.handleItemClick.bind(this); this.handleItemClick = this.handleItemClick.bind(this);
} }
handleItemClick = (e, { name }) => this.setState({ activeItem: name }); handleItemClick = (e, { name }) => this.setState({ activeItem: name });
fetchVacancies(url) { // fetchVacancies(url) {
Server.get(url).then((data) => { // console.log("maho");
this.setState({ vacancies: data }); // Server.get(url).then((data) => {
}, () => { // this.setState({ vacancies: data });
}); // }, () => {
} // });
// }
render() { render() {
const data = [{ data1: 'val1' }, { data1: 'val2' }]; const data = [{ data1: 'val1' }, { data1: 'val2' }];
...@@ -33,16 +34,13 @@ export default class VacancyPage extends React.Component { ...@@ -33,16 +34,13 @@ export default class VacancyPage extends React.Component {
return (<div> return (<div>
<Tabs selected={0}> <Tabs selected={0}>
<Pane label="Semua Lowongan" > <Pane label="Semua Lowongan" >
<VacancyList vacancies={data} /> <VacancyList url="/vacancies/" />
{ this.fetchVacancies('/api') }
</Pane> </Pane>
<Pane label="Lamaran saya" > <Pane label="Lamaran saya" >
<VacancyList vacancies={data} /> <VacancyList url="/b" />
{ this.fetchVacancies('/api') }
</Pane> </Pane>
<Pane label="Lamaran Ditandai" > <Pane label="Lamaran Ditandai" >
<VacancyList vacancies={data} /> <VacancyList url="/c" />
{ this.fetchVacancies('/api') }
</Pane> </Pane>
</Tabs> </Tabs>
</div> </div>
......
...@@ -4,7 +4,7 @@ export default class Pane extends React.Component { ...@@ -4,7 +4,7 @@ export default class Pane extends React.Component {
static displayName = 'Pane'; static displayName = 'Pane';
static propTypes = { static propTypes = {
children: React.PropTypes.element.isRequired, children: React.PropTypes.any.isRequired,
}; };
render = () => ( render = () => (
......
...@@ -38,7 +38,7 @@ export default class Tabs extends React.Component { ...@@ -38,7 +38,7 @@ export default class Tabs extends React.Component {
const activeClass = (this.state.selected === index ? 'active' : ''); const activeClass = (this.state.selected === index ? 'active' : '');
return ( return (
<li key={index}> <li key={index}>
<a className={activeClass} onClick={this.handleClick.bind(this, index)}> <a className={activeClass} href="#" onClick={this.handleClick.bind(this, index)}>
{child.props.label} {child.props.label}
</a> </a>
</li> </li>
......
import React from 'react'; import React from 'react';
import { Item } from 'semantic-ui-react'; import { Item } from 'semantic-ui-react';
import Lowongan from './Lowongan'; import Lowongan from './Lowongan';
import Server from '../lib/Server';
export default class VacancyList extends React.Component { export default class VacancyList extends React.Component {
static propTypes = { static propTypes = {
vacancies: React.PropTypes.array.isRequired, url: React.PropTypes.string.isRequired,
}; };
constructor(props) {
super(props);
this.state = { vacancies: [] };
console.log(Server.isLoggedIn());
Server.get(this.props.url).then((data) => {
console.log(data);
this.setState({ vacancies: data });
}, () => {
});
this.generateVacancies = this.generateVacancies.bind(this);
}
generateVacancies() { generateVacancies() {
return this.props.vacancies.map((vacancy) => return this.state.vacancies.map((vacancy, index) =>
<Lowongan key={vacancy.id} data={vacancy} />, <Lowongan key={index} data={vacancy} />,
); );
} }
render = () => ( render = () => {
<Item.Group relaxed> console.log("huehueuhe");
{/*<Item.Group relaxed>*/} return (
<Item.Group relaxed>
{/*<Item.Group relaxed>*/}
{ this.generateVacancies() } { this.generateVacancies() }
{/*</Item.Group>*/} {/*</Item.Group>*/}
</Item.Group> </Item.Group>
) );
}
} }
\ No newline at end of file
...@@ -7,8 +7,8 @@ export default class Server { ...@@ -7,8 +7,8 @@ export default class Server {
const cookies = document.cookie.split(';'); const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i += 1) { for (let i = 0; i < cookies.length; i += 1) {
const cookie = cookies[i].trim(); const cookie = cookies[i].trim();
// Does this cookie string begin with the name we want? if (cookie.substring(0, name.length) === (`${name}`)) {
if (cookie.substring(0, name.length + 1) === (`${name}`)) { // Does this cookie string begin with the name we want?
/* istanbul ignore next */ /* istanbul ignore next */
return decodeURIComponent(cookie.substring(name.length + 1)); return decodeURIComponent(cookie.substring(name.length + 1));
} }
......
...@@ -35,7 +35,7 @@ router.register(r'login', LoginViewSet) ...@@ -35,7 +35,7 @@ router.register(r'login', LoginViewSet)
router.register(r'vacancies', VacancyViewSet) router.register(r'vacancies', VacancyViewSet)
router.register(r'students/(?P<student_id>\d+)/bookmarked-vacancies', BookmarkedVacancyByStudentViewSet, router.register(r'students/(?P<student_id>\d+)/bookmarked-vacancies', BookmarkedVacancyByStudentViewSet,
base_name='bookmarked-vacancy-list') base_name='bookmarked-vacancy-list')
router.register(r'students/(?P<student_id>\d+)/applications', ApplicationViewSet, router.register(r'students/(?P<student_id>\d+)/applied-vacancies', ApplicationViewSet,
base_name='applications') base_name='applications')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment