-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nguyen.the.vinh.bao
committed
Jun 5, 2019
1 parent
cb71c0b
commit 13891b2
Showing
25 changed files
with
19,032 additions
and
22 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React, { useState } from 'react'; | ||
import { Avatar, Card, Col, Checkbox } from 'antd'; | ||
|
||
const { Meta } = Card; | ||
const Student = ({ item }) => { | ||
const [value, setValue] = useState(item.isChecked); | ||
|
||
const { fullName, email, isChecked } = item; | ||
|
||
return ( | ||
<Col span={12} style={{ marginBottom: '1rem' }}> | ||
<Card | ||
title={ | ||
<div> | ||
<Avatar | ||
style={{ marginRight: '1rem' }} | ||
shape="square" | ||
size="large" | ||
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" | ||
/> | ||
{fullName} | ||
</div> | ||
} | ||
extra={ | ||
<Checkbox | ||
onChange={() => setValue(!value)} | ||
checked={value} | ||
/> | ||
} | ||
> | ||
<Meta description={email || '[email protected]'} /> | ||
</Card> | ||
</Col> | ||
); | ||
}; | ||
|
||
export default Student; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
import { Statistic, Row, Col, Icon } from 'antd'; | ||
|
||
const CheckStatistic = ({ checkedCount, unCheckedCount, total }) => { | ||
return ( | ||
<Row gutter={16}> | ||
<Col span={12}> | ||
<Statistic | ||
title="Checked" | ||
value={checkedCount} | ||
prefix={<Icon type="check-circle" />} | ||
/> | ||
</Col> | ||
<Col span={12}> | ||
<Statistic | ||
title="Unchecked" | ||
value={unCheckedCount} | ||
suffix={`/ ${total}`} | ||
/> | ||
</Col> | ||
</Row> | ||
); | ||
}; | ||
|
||
export default CheckStatistic; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
import React from 'react'; | ||
// import { Descriptions } from 'antd'; | ||
import { compose } from 'recompose'; | ||
import { Descriptions } from 'antd'; | ||
import getFormattedTime from 'app/helpers/formatTime'; | ||
import withMaybe from 'app/hoc/withMaybe'; | ||
const Description = ({ event }) => { | ||
const { title, classCode, location, start, end } = event; | ||
return ( | ||
// <Descriptions title="Description"> | ||
// <Descriptions.Item label="Course Name">{title}</Descriptions.Item> | ||
// <Descriptions.Item label="ClassCode">{classCode}</Descriptions.Item> | ||
// <Descriptions.Item label="Location">{location}</Descriptions.Item> | ||
// <Descriptions.Item label="Start">{start}</Descriptions.Item> | ||
// <Descriptions.Item label="End">{end}</Descriptions.Item> | ||
// </Descriptions> | ||
<h1>title</h1> | ||
<Descriptions title="Description"> | ||
<Descriptions.Item label="Course Name">{title}</Descriptions.Item> | ||
<Descriptions.Item label="ClassCode">{classCode}</Descriptions.Item> | ||
<Descriptions.Item label="Location">{location}</Descriptions.Item> | ||
<Descriptions.Item label="Start"> | ||
{getFormattedTime(start)} | ||
</Descriptions.Item> | ||
<Descriptions.Item label="End"> | ||
{getFormattedTime(end)} | ||
</Descriptions.Item> | ||
</Descriptions> | ||
); | ||
}; | ||
const nullConditionFn = props => !props.event; | ||
|
||
export default withMaybe(Description); | ||
export default withMaybe(nullConditionFn)(Description); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React, { Component, Fragment } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { compose } from 'recompose'; | ||
import { Empty, Row } from 'antd'; | ||
import Student from 'app/components/Student'; | ||
import { Descriptions } from 'antd'; | ||
import withEither from 'app/hoc/withEither'; | ||
import Spinner from 'app/components/Spinner'; | ||
import withMaybe from 'app/hoc/withMaybe'; | ||
import { updateEvent } from 'app/actions/events'; | ||
const isLoadingConditionFn = props => props.isLoading; | ||
const nullConditionFn = props => !props.students; | ||
const isEmptyConditionFn = props => !props.students.length; | ||
|
||
const withConditionalRenderings = compose( | ||
withEither(isLoadingConditionFn, Spinner), | ||
withMaybe(nullConditionFn), | ||
withEither(isEmptyConditionFn, Empty), | ||
); | ||
|
||
const CheckList = ({ students }) => { | ||
const renderList = () => { | ||
return students.reverse().map(item => { | ||
return <Student key={item._id} item={item} />; | ||
}); | ||
}; | ||
|
||
return ( | ||
<Fragment> | ||
<Descriptions title="Check Attendance" /> | ||
<Row gutter={16}>{renderList()}</Row> | ||
</Fragment> | ||
); | ||
}; | ||
|
||
export default withConditionalRenderings(CheckList); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,87 @@ | ||
import React, { useEffect } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { fetchEventById } from '../../actions/events'; | ||
import { fetchEventById, updateEvent } from '../../actions/events'; | ||
import Description from './components/Description'; | ||
const Event = ({ event, fetchEventById, match, isFetching }) => { | ||
import CheckList from './containers/CheckList'; | ||
import CheckStatistic from './components/CheckStatistic'; | ||
const Event = ({ event, fetchEventById, updateEvent, match, isFetching }) => { | ||
useEffect(() => { | ||
const { eventId } = match.params; | ||
fetchEventById(eventId); | ||
}, {}); | ||
// const handleOnStudentCheckToggle = student => { | ||
// const newStudent = { | ||
// ...student, | ||
// isChecked: !student.isChecked, | ||
// }; | ||
// const updatedStudents = event.students.map(student => { | ||
// if (student._id === newStudent._id) { | ||
// student = newStudent; | ||
// } | ||
// return student; | ||
// }); | ||
// event.students = updatedStudents; | ||
|
||
// updateEvent(event); | ||
// }; | ||
|
||
const testEvent = { | ||
eventId: '10129401294012', | ||
classCode: 'CODE101', | ||
title: 'Web Development', | ||
location: 'ROOM:503', | ||
start: Date.now(), | ||
end: Date.now(), | ||
students: [ | ||
{ | ||
_id: 21123421331234124, | ||
fullName: 'Nguyen The Vinh Bao', | ||
email: '[email protected]', | ||
isChecked: false, | ||
}, | ||
{ | ||
_id: 2112342134123124, | ||
fullName: 'Nguyen Van A', | ||
email: '[email protected]', | ||
isChecked: true, | ||
}, | ||
{ | ||
_id: 211234213412123214, | ||
fullName: 'Nguyen The B', | ||
email: '[email protected]', | ||
isChecked: false, | ||
}, | ||
{ | ||
_id: 211234213412212134, | ||
fullName: 'Nguyen Vinh V', | ||
email: '[email protected]', | ||
isChecked: false, | ||
}, | ||
], | ||
}; | ||
const { students } = testEvent; | ||
|
||
const checkedStudents = students.filter(student => student.isChecked); | ||
const unCheckedStudents = students.filter(student => !student.isChecked); | ||
return ( | ||
<div className="event-page"> | ||
<Description event={event} /> | ||
<div className="event-page__info"> | ||
<div className="event-page__desc"> | ||
<Description event={testEvent} /> | ||
</div> | ||
<div className="event-page__stats"> | ||
<CheckStatistic | ||
checkedCount={checkedStudents.length} | ||
unCheckedCount={unCheckedStudents.length} | ||
total={students.length} | ||
/> | ||
</div> | ||
</div> | ||
|
||
<CheckList | ||
students={students} | ||
|
||
/> | ||
</div> | ||
); | ||
}; | ||
|
@@ -24,5 +95,5 @@ const mapStateToProps = state => { | |
}; | ||
export default connect( | ||
mapStateToProps, | ||
{ fetchEventById }, | ||
{ fetchEventById, updateEvent }, | ||
)(Event); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
@import 'logo'; | ||
@import 'content-box'; | ||
@import 'form-box'; | ||
@import 'calendar'; |
Oops, something went wrong.