Skip to content

Commit

Permalink
Merge pull request #42 from sancodes/refactor_function_property_names…
Browse files Browse the repository at this point in the history
…_timeTableView.js

Refactor function or property names #31 - TimeTableView.js
  • Loading branch information
gomjellie authored Jul 3, 2021
2 parents bed468a + 356eca2 commit 03c9c8b
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/components/TimeTable/TimeTableView.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export default class TimeTableView extends Component {
constructor(props) {
super(props);
this.state = {
currentMoment: props.pivotDate,
currentDate: props.pivotDate,
};
const { pivotTime, pivotEndTime } = this.props;
this.calendar = null;
setLocale(props.locale);
this.times = this.generateTimes(pivotTime, pivotEndTime);
this.times = this.genTimes(pivotTime, pivotEndTime);
}

componentDidMount() {
Expand All @@ -32,14 +32,14 @@ export default class TimeTableView extends Component {

UNSAFE_componentWillReceiveProps(nextProps) {
if (nextProps.selectedDate) {
this.setState({ currentMoment: nextProps.selectedDate });
this.setState({ currentDate: nextProps.selectedDate });
}
if (nextProps.locale !== this.props.locale) {
setLocale(nextProps.locale);
}
}

generateTimes = (pivotTime, endPivotTime) => {
genTimes = (pivotTime, endPivotTime) => {
const times = [];
for (let i = pivotTime; i < endPivotTime; i += 1) {
times.push(i);
Expand All @@ -49,24 +49,24 @@ export default class TimeTableView extends Component {

render() {
const {
numberOfDays,
nDays,
headerStyle,
formatDateHeader,
dateHeaderFormat,
onEventPress,
pivotTime,
} = this.props;
const events = assignColor(this.props.events);
const { currentMoment } = this.state;
const { currentDate } = this.state;
// const dates = this.prepareDates(currentMoment, numberOfDays);
const date = moment(currentMoment);
const date = moment(currentDate);
return (
<View style={styles.container}>
<View style={styles.header}>
<Header
style={headerStyle}
formatDate={formatDateHeader}
selectedDate={currentMoment}
numberOfDays={numberOfDays}
formatDate={dateHeaderFormat}
selectedDate={currentDate}
numberOfDays={nDays}
/>
</View>
<ScrollView ref={this.props.scrollViewRef}>
Expand All @@ -87,7 +87,7 @@ export default class TimeTableView extends Component {
key={date}
times={this.times}
selectedDate={date.toDate()}
numberOfDays={numberOfDays}
numberOfDays={nDays}
onEventPress={onEventPress}
events={events}
/>
Expand All @@ -102,11 +102,11 @@ export default class TimeTableView extends Component {
TimeTableView.propTypes = {
scrollViewRef: PropTypes.func,
events: Events.propTypes.events,
numberOfDays: PropTypes.oneOf([1, 3, 5, 6, 7]).isRequired,
nDays: PropTypes.oneOf([1, 3, 5, 6, 7]).isRequired,
pivotTime: PropTypes.number,
pivotEndTime: PropTypes.number,
pivotDate: PropTypes.instanceOf(Date).isRequired,
formatDateHeader: PropTypes.string,
dateHeaderFormat: PropTypes.string,
onEventPress: PropTypes.func,
headerStyle: PropTypes.object,
locale: PropTypes.string,
Expand All @@ -118,5 +118,5 @@ TimeTableView.defaultProps = {
pivotTime: 8,
pivotEndTime: 22,
pivotDate: genTimeBlock('mon'),
formatDateHeader: "dddd",
dateHeaderFormat: "dddd",
};

0 comments on commit 03c9c8b

Please sign in to comment.