Commit 475e212d by tungnq

TODO: Thực hiện refactor code lần 1

parent dd76d0fc
...@@ -300,6 +300,7 @@ const ClassSchedule = ({events = [], onDateSelect, onEventPress}) => { ...@@ -300,6 +300,7 @@ const ClassSchedule = ({events = [], onDateSelect, onEventPress}) => {
getEventsForDate={getEventsForDate} getEventsForDate={getEventsForDate}
parseLocalDate={parseLocalDate} parseLocalDate={parseLocalDate}
formatDateToDisplay={formatDateToDisplay} formatDateToDisplay={formatDateToDisplay}
formatDateToString={formatDateToString}
isCurrentMonth={isCurrentMonth} isCurrentMonth={isCurrentMonth}
isToday={isToday} isToday={isToday}
navigateMonth={navigateMonth} navigateMonth={navigateMonth}
......
...@@ -25,6 +25,7 @@ const ClassScheduleView = ({ ...@@ -25,6 +25,7 @@ const ClassScheduleView = ({
getEventsForDate, getEventsForDate,
parseLocalDate, parseLocalDate,
formatDateToDisplay, formatDateToDisplay,
formatDateToString,
isCurrentMonth, isCurrentMonth,
isToday, isToday,
navigateMonth, navigateMonth,
...@@ -75,7 +76,7 @@ const ClassScheduleView = ({ ...@@ -75,7 +76,7 @@ const ClassScheduleView = ({
); );
}; };
const renderDayCell = (date, index) => { const renderDayCell = (date, index, formatDateToString) => {
const dayEvents = getEventsForDate(date); const dayEvents = getEventsForDate(date);
const isSelected = selectedDate === formatDateToString(date); const isSelected = selectedDate === formatDateToString(date);
const isTodayDate = isToday(date); const isTodayDate = isToday(date);
...@@ -126,12 +127,6 @@ const ClassScheduleView = ({ ...@@ -126,12 +127,6 @@ const ClassScheduleView = ({
); );
}; };
const formatDateToString = (date) => {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
return `${year}-${month}-${day}`;
};
const renderCalendarGrid = () => { const renderCalendarGrid = () => {
...@@ -141,7 +136,7 @@ const ClassScheduleView = ({ ...@@ -141,7 +136,7 @@ const ClassScheduleView = ({
weeks.push( weeks.push(
<View key={i} style={styles.weekRow}> <View key={i} style={styles.weekRow}>
{week.map((date, dayIndex) => {week.map((date, dayIndex) =>
renderDayCell(date, i * 7 + dayIndex), renderDayCell(date, i * 7 + dayIndex, formatDateToString),
)} )}
</View>, </View>,
); );
......
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