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}) => {
getEventsForDate={getEventsForDate}
parseLocalDate={parseLocalDate}
formatDateToDisplay={formatDateToDisplay}
formatDateToString={formatDateToString}
isCurrentMonth={isCurrentMonth}
isToday={isToday}
navigateMonth={navigateMonth}
......
......@@ -25,6 +25,7 @@ const ClassScheduleView = ({
getEventsForDate,
parseLocalDate,
formatDateToDisplay,
formatDateToString,
isCurrentMonth,
isToday,
navigateMonth,
......@@ -75,7 +76,7 @@ const ClassScheduleView = ({
);
};
const renderDayCell = (date, index) => {
const renderDayCell = (date, index, formatDateToString) => {
const dayEvents = getEventsForDate(date);
const isSelected = selectedDate === formatDateToString(date);
const isTodayDate = isToday(date);
......@@ -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 = () => {
......@@ -141,7 +136,7 @@ const ClassScheduleView = ({
weeks.push(
<View key={i} style={styles.weekRow}>
{week.map((date, dayIndex) =>
renderDayCell(date, i * 7 + dayIndex),
renderDayCell(date, i * 7 + dayIndex, formatDateToString),
)}
</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