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 {
email: '',
password: '',
errorFlag: false,
vacancies: []
vacancies: [],
};
this.handleItemClick = this.handleItemClick.bind(this);
}
handleItemClick = (e, { name }) => this.setState({ activeItem: name });
fetchVacancies(url) {
Server.get(url).then((data) => {
this.setState({ vacancies: data });
}, () => {
});
}
// fetchVacancies(url) {
// console.log("maho");
// Server.get(url).then((data) => {
// this.setState({ vacancies: data });
// }, () => {
// });
// }
render() {
const data = [{ data1: 'val1' }, { data1: 'val2' }];
......@@ -33,16 +34,13 @@ export default class VacancyPage extends React.Component {
return (<div>
<Tabs selected={0}>
<Pane label="Semua Lowongan" >
<VacancyList vacancies={data} />
{ this.fetchVacancies('/api') }
<VacancyList url="/vacancies/" />
</Pane>
<Pane label="Lamaran saya" >
<VacancyList vacancies={data} />
{ this.fetchVacancies('/api') }
<VacancyList url="/b" />
</Pane>
<Pane label="Lamaran Ditandai" >
<VacancyList vacancies={data} />
{ this.fetchVacancies('/api') }
<VacancyList url="/c" />
</Pane>
</Tabs>
</div>
......
......@@ -4,7 +4,7 @@ export default class Pane extends React.Component {
static displayName = 'Pane';
static propTypes = {
children: React.PropTypes.element.isRequired,
children: React.PropTypes.any.isRequired,
};
render = () => (
......
......@@ -38,7 +38,7 @@ export default class Tabs extends React.Component {
const activeClass = (this.state.selected === index ? 'active' : '');
return (
<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}
</a>
</li>
......
import React from 'react';
import { Item } from 'semantic-ui-react';
import Lowongan from './Lowongan';
import Server from '../lib/Server';
export default class VacancyList extends React.Component {
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() {
return this.props.vacancies.map((vacancy) =>
<Lowongan key={vacancy.id} data={vacancy} />,
return this.state.vacancies.map((vacancy, index) =>
<Lowongan key={index} data={vacancy} />,
);
}
render = () => (
<Item.Group relaxed>
{/*<Item.Group relaxed>*/}
render = () => {
console.log("huehueuhe");
return (
<Item.Group relaxed>
{/*<Item.Group relaxed>*/}
{ this.generateVacancies() }
{/*</Item.Group>*/}
</Item.Group>
)
{/*</Item.Group>*/}
</Item.Group>
);
}
}
\ No newline at end of file
......@@ -7,8 +7,8 @@ export default class Server {
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i += 1) {
const cookie = cookies[i].trim();
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (`${name}`)) {
if (cookie.substring(0, name.length) === (`${name}`)) {
// Does this cookie string begin with the name we want?
/* istanbul ignore next */
return decodeURIComponent(cookie.substring(name.length + 1));
}
......
......@@ -35,7 +35,7 @@ router.register(r'login', LoginViewSet)
router.register(r'vacancies', VacancyViewSet)
router.register(r'students/(?P<student_id>\d+)/bookmarked-vacancies', BookmarkedVacancyByStudentViewSet,
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')
......
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