Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Fasilkom UI Open Source Software
Kape
Commits
0b75339e
Commit
0b75339e
authored
Apr 09, 2017
by
M. Reza Qorib
Browse files
[#140652771] #18 Refactor VacancyPage for company
parent
811e65e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
assets/js/VacancyPage.jsx
View file @
0b75339e
...
...
@@ -6,38 +6,78 @@ import VacancyList from './components/VacancyList';
export
default
class
VacancyPage
extends
React
.
Component
{
static
getRole
()
{
const
student
=
Storage
.
get
(
'
user-data
'
).
student
;
const
company
=
Storage
.
get
(
'
user-data
'
).
company
;
if
(
student
)
{
return
{
id
:
student
.
id
,
type
:
'
student
'
};
}
else
if
(
company
)
{
return
{
id
:
company
.
id
,
type
:
'
company
'
};
}
return
{
id
:
'
0
'
,
type
:
'
error
'
};
}
constructor
(
props
)
{
super
(
props
);
/* istanbul ignore next */
const
role
=
VacancyPage
.
getRole
();
this
.
state
=
{
email
:
''
,
password
:
''
,
errorFlag
:
false
,
vacancies
:
[],
id
:
role
.
type
,
role
:
role
.
type
,
};
this
.
handleItemClick
=
this
.
handleItemClick
.
bind
(
this
);
}
handleItemClick
=
(
e
,
{
name
})
=>
this
.
setState
({
activeItem
:
name
});
generateVacancies
()
{
if
(
this
.
state
.
role
===
'
student
'
)
{
return
(
<
Tabs
selected
=
{
0
}
>
<
Pane
label
=
"Semua Lowongan"
>
<
VacancyList
key
=
{
1
}
studentId
=
{
this
.
state
.
id
}
url
=
"/vacancies/"
/>
</
Pane
>
<
Pane
label
=
"Lamaran saya"
>
<
VacancyList
key
=
{
2
}
status
=
"Batal"
studentId
=
{
this
.
state
.
id
}
url
=
{
`/students/
${
this
.
state
.
id
}
/applied-vacancies/`
}
/>
</
Pane
>
<
Pane
label
=
"Lamaran Ditandai"
>
<
VacancyList
key
=
{
3
}
studentId
=
{
this
.
state
.
id
}
url
=
{
`/students/
${
this
.
state
.
id
}
/bookmarked-vacancies/`
}
/>
</
Pane
>
</
Tabs
>
);
}
else
if
(
this
.
state
.
role
===
'
company
'
)
{
return
(
<
VacancyList
key
=
{
1
}
studentId
=
{
this
.
state
.
id
}
url
=
"/vacancies/"
/>
);
}
console
.
log
(
this
.
state
);
return
(
<
div
>
<
h3
>
Anda tidak terautentifikasi. Harap logout dan login
kembali dengan akun yang benar
</
h3
>
</
div
>
);
}
render
()
{
const
student
=
Storage
.
get
(
'
user-data
'
).
student
;
return
(
<
div
className
=
"halamanLowongan"
>
<
Tabs
selected
=
{
0
}
>
<
Pane
label
=
"Semua Lowongan"
>
<
VacancyList
key
=
{
1
}
studentId
=
{
student
.
id
}
url
=
"/vacancies/"
/>
</
Pane
>
<
Pane
label
=
"Lamaran saya"
>
<
VacancyList
key
=
{
2
}
status
=
"Batal"
studentId
=
{
student
.
id
}
url
=
{
`/students/
${
student
.
id
}
/applied-vacancies/`
}
/>
</
Pane
>
<
Pane
label
=
"Lamaran Ditandai"
>
<
VacancyList
key
=
{
3
}
studentId
=
{
student
.
id
}
url
=
{
`/students/
${
student
.
id
}
/bookmarked-vacancies/`
}
/>
</
Pane
>
</
Tabs
>
</
div
>
<
div
className
=
"applicant"
>
{
this
.
generateVacancies
()
}
</
div
>
);
}
}
assets/js/__test__/VacancyPage-test.jsx
View file @
0b75339e
...
...
@@ -61,6 +61,17 @@ describe('VacancyList', () => {
supervisor
:
null
,
student
:
null
,
};
const
errorSession
=
{
url
:
'
http://localhost:8001/api/users/8/
'
,
username
:
'
Tutuplapak
'
,
email
:
''
,
is_staff
:
false
,
company
:
null
,
supervisor
:
null
,
student
:
null
,
};
it
(
'
renders for companies without problem
'
,
()
=>
{
Storage
.
set
(
'
user-data
'
,
companySession
);
const
vacancyPage
=
ReactTestUtils
.
renderIntoDocument
(
...
...
@@ -74,7 +85,15 @@ describe('VacancyList', () => {
const
vacancyPage
=
ReactTestUtils
.
renderIntoDocument
(
<
VacancyPage
studentId
=
{
1
}
url
=
"test"
/>);
expect
(
vacancyPage
).
to
.
exist
;
expect
(
vacancyPage
.
state
.
role
).
to
.
equal
(
'
company
'
);
expect
(
vacancyPage
.
state
.
role
).
to
.
equal
(
'
student
'
);
});
it
(
'
renders without problem for error case
'
,
()
=>
{
Storage
.
set
(
'
user-data
'
,
errorSession
);
const
vacancyPage
=
ReactTestUtils
.
renderIntoDocument
(
<
VacancyPage
studentId
=
{
1
}
url
=
"test"
/>);
expect
(
vacancyPage
).
to
.
exist
;
expect
(
vacancyPage
.
state
.
role
).
to
.
equal
(
'
error
'
);
});
});
assets/js/__test__/components/VacancyList-test.jsx
View file @
0b75339e
...
...
@@ -22,7 +22,7 @@ describe('VacancyList', () => {
updated
:
'
2017-03-28T07:34:13.122093Z
'
,
verified
:
true
,
}];
const
response2
=
{
hello
:
'
not-world
'
};
//
const response2 = { hello: 'not-world' };
it
(
'
renders without problem
'
,
()
=>
{
fetchMock
.
get
(
'
*
'
,
response
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment