Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Class Project
Kape
Commits
6b5494e7
Commit
6b5494e7
authored
Nov 04, 2019
by
Arga Ghulam Ahmad
Browse files
Set up the route to feedback page
parent
aa9b2280
Pipeline
#23915
passed with stages
in 7 minutes and 28 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
assets/js/index.jsx
View file @
6b5494e7
import
React
from
'
react
'
;
import
ReactDOM
from
'
react-dom
'
;
import
{
Router
,
Route
,
browserHistory
,
Redirect
}
from
'
react-router
'
;
import
{
Router
,
Route
,
browserHistory
,
Redirect
,
}
from
'
react-router
'
;
import
Dashboard
from
'
./Dashboard
'
;
import
Login
from
'
./Login
'
;
import
VacancyPage
from
'
./VacancyPage
'
;
...
...
@@ -14,19 +16,19 @@ import TranscriptPage from './TranscriptPage';
import
AdminVacancyPage
from
'
./AdminVacancyPage
'
;
import
CompanyPage
from
'
./CompanyPage
'
;
import
SupervisorPage
from
'
./SupervisorPage
'
;
import
FeedbackPage
from
'
./FeedbackPage
'
;
export
default
class
App
extends
React
.
Component
{
static
getRole
()
{
if
(
Server
.
isLoggedIn
())
{
const
data
=
Storage
.
get
(
'
user-data
'
);
if
(
data
.
is_staff
)
{
return
'
admin
'
;
}
else
if
(
data
.
supervisor
)
{
}
if
(
data
.
supervisor
)
{
return
'
supervisor
'
;
}
else
if
(
data
.
student
)
{
}
if
(
data
.
student
)
{
return
'
student
'
;
}
else
if
(
data
.
company
)
{
}
if
(
data
.
company
)
{
return
'
company
'
;
}
return
'
error
'
;
...
...
@@ -41,29 +43,34 @@ export default class App extends React.Component {
this
.
handleHome
=
this
.
handleHome
.
bind
(
this
);
}
authorization
=
allowedRoles
=>
WrappedComponent
=>
(
/* eslint-disable no-multi-comp */
class
WithAuthorization
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
user
:
{
role
:
App
.
getRole
(),
data
:
Storage
.
get
(
'
user-data
'
),
},
};
}
authorization
=
(
allowedRoles
)
=>
(
WrappedComponent
)
=>
(
/* eslint-disable no-multi-comp */
class
WithAuthorization
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
user
:
{
role
:
App
.
getRole
(),
data
:
Storage
.
get
(
'
user-data
'
),
},
};
}
render
()
{
const
{
role
}
=
this
.
state
.
user
;
// const props = this.props;
if
(
allowedRoles
.
includes
(
role
))
{
return
<
WrappedComponent
{
...
this
.
props
}
{
...
this
.
state
}
/>;
}
return
<
div
>
{
browserHistory
.
push
(
'
/home
'
)
}
</
div
>;
render
()
{
const
{
role
}
=
this
.
state
.
user
;
// const props = this.props;
if
(
allowedRoles
.
includes
(
role
))
{
return
<
WrappedComponent
{
...
this
.
props
}
{
...
this
.
state
}
/>;
}
});
return
(
<
div
>
{
'
'
}
{
browserHistory
.
push
(
'
/home
'
)
}
{
'
'
}
</
div
>
);
}
});
handleAuth
=
(
nextState
,
replace
)
=>
{
if
(
!
Server
.
isLoggedIn
())
replace
({
pathname
:
'
/login
'
});
...
...
@@ -111,6 +118,7 @@ export default class App extends React.Component {
<
Route
path
=
"/pelamar"
component
=
{
company
(
ApplicantPage
)
}
/>
<
Route
path
=
"/profil-mahasiswa"
component
=
{
student
(
ProfilePage
)
}
own
/>
<
Route
path
=
"/profil-perusahaan"
component
=
{
company
(
CompanyProfile
)
}
/>
<
Route
path
=
"/feedback"
component
=
{
all
(
FeedbackPage
)
}
/>
<
Route
path
=
"/mahasiswa/:id"
component
=
{
grownups
(
ProfilePage
)
}
/>
<
Route
path
=
"/perusahaan/:id"
component
=
{
facultyMember
(
CompanyProfile
)
}
/>
<
Route
path
=
"/perusahaan"
component
=
{
staff
(
CompanyPage
)
}
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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