Fakultas Ilmu Komputer UI

Commit 8afb351e authored by Reza Qorib's avatar Reza Qorib
Browse files

Merge branch 'Features/CompanyProfile' into 'develop'

Features/company profile

See merge request !24
parents 22f1f255 db8ae455
import React from 'react';
import { Segment, Header, Image, Container, Form, Button, Icon, TextArea } from 'semantic-ui-react';
import TopMenu from './components/TopMenu';
export default class CompanyProfile extends React.Component {
static propTypes = {
user: React.PropTypes.object.isRequired,
};
render() {
const defaultLogo = 'http://semantic-ui.com/images/wireframe/square-image.png';
const data = TopMenu.getInfo(this.props.user);
console.log(data);
return (
<div className="company-profile">
<Segment className="segment-profile-company" >
<Header as="h2" icon textAlign="center">
<Image src="http://semantic-ui.com/images/wireframe/square-image.png" size="small" shape="circular" />
<Image src={data.logo || defaultLogo} size="small" shape="circular" />
</Header>
<Container textAlign="center" className="profile-biodata">
<div className="biodata-company">
<h2>Company</h2>
<h3>Alamat alamat alamat</h3>
<h4>Deskripsi Deskripsi Deskripsi Deskripsi Deskripsi Deskripsi</h4>
<h2>{ data.name }</h2>
<h3>{ data.address }t</h3>
<p>{ data.description }</p>
</div>
</Container>
</Segment>
<Segment className="profile-form-company">
<Header as="h3" textAlign="center">
<Icon name="edit" />
<Header.Content>
Edit Profile Page
</Header.Content>
</Header>
<Form size="small" >
<Form.Field>
<label htmlFor="photo">Logo Perusahaan</label>
<input placeholder="Profile Photo.jpg" name="photo" type="File" />
</Form.Field>
<Form.Field>
<label htmlFor="email">Nama Perusahaan</label>
<input placeholder="Nama Perusahaan" name="email" />
</Form.Field>
<Form.Field>
<label htmlFor="phone">Deskripsi</label>
<TextArea placeholder='Try adding multiple lines' autoHeight />
</Form.Field>
<Button type="submit" size="small" primary floated="right">Submit</Button>
</Form>
</Segment>
{/* <Segment className="profile-form-company">*/}
{/* <Header as="h3" textAlign="center">*/}
{/* <Icon name="edit" />*/}
{/* <Header.Content>*/}
{/* Edit Profile Page*/}
{/* </Header.Content>*/}
{/* </Header>*/}
{/* <Form size="small" >*/}
{/* <Form.Field>*/}
{/* <label htmlFor="photo">Logo Perusahaan</label>*/}
{/* <input placeholder="Profile Photo.jpg" name="photo" type="File" />*/}
{/* </Form.Field>*/}
{/* <Form.Field>*/}
{/* <label htmlFor="email">Nama Perusahaan</label>*/}
{/* <input placeholder="Nama Perusahaan" name="email" />*/}
{/* </Form.Field>*/}
{/* <Form.Field>*/}
{/* <label htmlFor="phone">Deskripsi</label>*/}
{/* <TextArea placeholder='Try adding multiple lines' autoHeight />*/}
{/* </Form.Field>*/}
{/* <Button type="submit" size="small" primary floated="right">Submit</Button>*/}
{/* </Form>*/}
{/* </Segment>*/}
</div>
);
}
......
import React from 'react';
import { Segment, Image, Header, Icon, Checkbox, Container, Button, Form, Grid } from 'semantic-ui-react';
import { Segment, Image, Header, Icon, Checkbox, Container, Button, Form, Grid, Card } from 'semantic-ui-react';
import Server from './lib/Server';
import Storage from './lib/Storage';
import ModalAlert from './components/ModalAlert';
......@@ -45,6 +45,7 @@ export default class ProfilePage extends React.Component {
this.handleSubmit = this.handleSubmit.bind(this);
this.handleFile = this.handleFile.bind(this);
this.gotoLink = this.gotoLink.bind(this);
this.gotoStudentResume = this.gotoStudentResume.bind(this);
this.getProfile();
}
......@@ -119,6 +120,8 @@ export default class ProfilePage extends React.Component {
win.focus();
};
gotoStudentResume = () => this.gotoLink(this.state.resume || '#');
updateForm(show) {
if (show) {
return (
......@@ -190,7 +193,7 @@ export default class ProfilePage extends React.Component {
<Icon name="university" size="big" />
</Grid.Column>
<Grid.Column width={13}>
<h3> { this.state.major }, { this.state.batch } </h3>
<p> { this.state.major }, { this.state.batch } </p>
</Grid.Column>
</Grid>
</Segment>
......@@ -202,7 +205,7 @@ export default class ProfilePage extends React.Component {
<Icon name="mail" size="big" />
</Grid.Column>
<Grid.Column width={13}>
<h3> { this.state.email } </h3>
<p> { this.state.email } </p>
</Grid.Column>
</Grid>
</Segment>
......@@ -213,7 +216,7 @@ export default class ProfilePage extends React.Component {
<Icon name="phone" size="big" />
</Grid.Column>
<Grid.Column width={13}>
<h3> { this.state.phone_number }</h3>
<p> { this.state.phone_number }</p>
</Grid.Column>
</Grid>
</Segment>
......@@ -224,7 +227,7 @@ export default class ProfilePage extends React.Component {
<Icon name="gift" size="big" />
</Grid.Column>
<Grid.Column width={13}>
<h3> { this.state.cityOfBirth}, { this.state.dateOfBirth } </h3>
<p> { this.state.cityOfBirth}, { this.state.dateOfBirth } </p>
</Grid.Column>
</Grid>
</Segment>
......@@ -232,10 +235,10 @@ export default class ProfilePage extends React.Component {
<Container textAlign="center">
<div className="button-profile">
<a href={this.state.resume || '#'} ><Button primary size="small">Resume</Button></a>
<Button onClick={this.gotoStudentResume} primary size="small">Resume</Button>
</div>
<div>
<h4> Bagikan Transkrip : { this.state.bagikanTranskrip }</h4>
<h4> Bagikan Transkrip : { this.state.bagikanTranskrip ? 'Ya' : 'Tidak' }</h4>
</div>
</Container>
</Container>
......
......@@ -2,10 +2,38 @@ import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import CompanyProfile from '../CompanyProfile';
const companyUser = {
role: 'company',
data: {
url: 'http://localhost:8001/api/users/8/',
username: 'Tutuplapak',
email: '',
is_staff: false,
company: {
id: 3,
user: {
url: 'http://localhost:8001/api/users/8/',
username: 'Tutuplapak',
email: '',
is_staff: false,
},
name: 'Tutuplapak',
created: '2017-03-28T07:30:10.535000Z',
updated: '2017-03-28T07:30:10.535000Z',
description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla aliquet semper neque a fermentum. Duis ac tellus vitae augue iaculis ultrices. Curabitur commodo et neque nec feugiat. Morbi ac diam vel nunc commodo cursus. Phasellus nulla sapien, hendrerit vitae bibendum at, sollicitudin eu ante. Maecenas maximus, ante eu sollicitudin convallis, mauris nunc posuere risus, eu porttitor diam lacus vitae enim. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse at lectus a elit sollicitudin tempor. Nullam condimentum, justo nec tincidunt maximus, neque mi vulputate leo, sit amet lacinia massa ex eget sem. Duis ac erat facilisis, fringilla mauris in, consequat neque. In et neque consequat, vehicula magna at, efficitur ante. Mauris ac lacinia nibh.\r\n\r\nProin sagittis, lectus quis maximus varius, libero justo sollicitudin augue, non lacinia risus orci a enim. Curabitur iaculis enim quis ullamcorper commodo. Vivamus id nisi rhoncus, dignissim tellus quis, interdum est. Fusce sollicitudin eu libero ac feugiat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas semper posuere ex, sed accumsan libero iaculis faucibus. Fusce laoreet ac ligula ut consectetur. Donec tortor mauris, rutrum at sodales et, viverra in dolor. Sed bibendum elit et maximus volutpat. Phasellus justo ipsum, laoreet sit amet faucibus eu, ultricies suscipit mauris. Nullam aliquam libero eu ante ultrices mattis. Donec non justo hendrerit neque volutpat placerat. Ut euismod est nec sem mollis, sit amet porttitor massa rhoncus. Aenean id erat sit amet nunc ultrices scelerisque non in ipsum. Curabitur sollicitudin nulla id mi accumsan venenatis.',
verified: true,
logo: 'http://localhost:8001/files/company-logo/8a258a48-3bce-4873-b5d1-538b360d0059.png',
address: 'Jl. Kebayoran Baru nomor 13, Jakarta Barat',
},
supervisor: null,
student: null,
},
};
describe('CompanyProfile', () => {
it('renders without problem', () => {
const companyProfile = ReactTestUtils.renderIntoDocument(
<CompanyProfile />);
<CompanyProfile user={companyUser} />);
expect(companyProfile).to.exist;
});
});
......@@ -35,7 +35,7 @@ export default class TopMenu extends React.Component {
constructor(props) {
super(props);
/* istanbul ignore next */
this.state = { activeItem: 'home' };
this.state = { activeItem: 'Beranda' };
this.logout = this.logout.bind(this);
this.logoutCompany = this.logoutCompany.bind(this);
}
......@@ -72,11 +72,14 @@ export default class TopMenu extends React.Component {
<Menu color="blue" pointing secondary>
<Image as="a" size="small" src="/assets/img/logo.png" href="/" />
<Menu.Menu position="right">
<Menu.Item as={Link} to="/home" name="home" active={activeItem === 'home'} onClick={this.handleItemClick} />
<Menu.Item as={Link} to="/home" name="Beranda" active={activeItem === 'Beranda'} onClick={this.handleItemClick} />
{ this.props.user.role === 'student' &&
<Menu.Item as={Link} to="/profil" name="Profil" active={activeItem === 'Profil'} onClick={this.handleItemClick} />
}
<Menu.Item>
<Popup
trigger={<Image
as={Link} to="/profil" src={data.photo || defaultPicture} avatar
as={Link} to="/profil" src={(this.props.user.role === 'company' ? data.logo : data.photo) || defaultPicture} avatar
onClick={this.handleItemClick}
/>}
flowing
......@@ -86,7 +89,7 @@ export default class TopMenu extends React.Component {
header={data.name}
description={data.user.email}
/>
<Button as={Link} onClick={this.logout} name="logout" color="blue" size="tiny">Logout</Button>
<Button as={Link} onClick={this.logout} name="logout" color="blue" size="tiny">Keluar</Button>
</Popup>
......
......@@ -65,7 +65,7 @@ export default class VacancyList extends React.Component {
),
);
}
if (this.props.user.role === 'admin' || this.props.user.role === 'supervisor') {
if ((this.props.user.role === 'admin' && this.props.user.data.supervisor != null) || this.props.user.role === 'supervisor') {
return this.state.vacancies.map(vacancy => (
<AdminVacancy
key={vacancy.id}
......@@ -88,12 +88,12 @@ export default class VacancyList extends React.Component {
}
companyHeader() {
if (this.props.user.role === 'company') {
if (this.props.user.role === 'admin' || this.props.user.role === 'company') {
return (
<Grid textAlign="center" style={{ paddingTop: '10px' }}>
<div>
<Button size="tiny" as={Link} to="/pelamar" icon="eye" labelPosition="left" color="facebook" content="Lihat Semua Pendaftar" />
<Button size="tiny" as={Link} to="/buat-lowongan" icon="add" labelPosition="left" content="Tambah Lowongan Baru" color="teal" />
</Grid>
</div>
);
}
......@@ -103,7 +103,12 @@ export default class VacancyList extends React.Component {
render = () => (
<div>
<Grid container columns="eleven" doubling>
{ this.companyHeader() }
<Grid textAlign="center" style={{ paddingTop: '10px' }}>
{ this.companyHeader() }<br />
{(this.props.user.role === 'admin' || this.props.user.role === 'supervisor') &&
<Button size="tiny" as={Link} to="/rekap" icon="dashboard" labelPosition="left" color="facebook" content="Rekap Pendaftaran" />
}
</Grid>
<Item.Group relaxed style={{ width: '100%' }}>
{ this.generateVacancies() }
</Item.Group>
......
......@@ -107,7 +107,7 @@ export default class App extends React.Component {
<Route path="/login" component={Login} />
<Route component={all(Dashboard)} onEnter={this.handleAuth}>
<Route path="/transcript/:id" component={company(TranscriptPage)} />
<Route path="/lowongan" component={commonUser(VacancyPage)} />
<Route path="/lowongan" component={all(VacancyPage)} />
<Route path="/admin-lowongan" component={AdminVacancyPage} />
<Route path="/buat-lowongan" component={company(CreateVacancy)} />
<Route path="/buat-lowongan/:id" component={company(CreateVacancy)} />
......
Markdown is supported
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