-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
f5bec8d
commit 28f7b0e
Showing
13 changed files
with
283 additions
and
283 deletions.
There are no files selected for viewing
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
// import { | ||
// eachDayOfInterval, | ||
// eachHourOfInterval, | ||
// eachMonthOfInterval, | ||
// eachWeekOfInterval, | ||
// endOfDay, | ||
// endOfMonth, | ||
// endOfYear, | ||
// format, | ||
// differenceInDays, | ||
// getWeekOfMonth, | ||
// isSameDay, | ||
// isSameMonth, | ||
// isSameWeek, | ||
// isWithinInterval, | ||
// startOfDay, | ||
// startOfMonth, | ||
// startOfYear, | ||
// } from "date-fns"; | ||
// import { DateRange } from "react-day-picker"; | ||
|
||
// /*##############################################(CALENDER-UTILITY)##############################################*/ | ||
// // A flexible and reusable calender and appointment utility function that can be used | ||
// // across different calendar implementations. You can define your own appointment structure and provide | ||
// // a way to extract dates in a composable manner. | ||
// // @Status: (Preview) - Not tested | ||
|
||
// /***********************************(Types)***********************************/ | ||
// export interface GenericCalendarAppointment { | ||
// start: Date | string; | ||
// [key: string]: any; | ||
// } | ||
|
||
// /***********************************(Calculate New Dates)***********************************/ | ||
// /** | ||
// * Calculate new start and end dates based on view mode and index change | ||
// */ | ||
// export const calculateNewDates = ( | ||
// viewMode: string, | ||
// index: number, | ||
// currentIndex: number, | ||
// dateRange: DateRange | ||
// ) => { | ||
// let start = new Date(dateRange.from as Date); | ||
// let end = new Date(dateRange.to as Date); | ||
// const delta = (currentIndex - index) * -1; | ||
|
||
// switch (viewMode) { | ||
// case "day": | ||
// // Adjust hours for day view | ||
// start.setHours(start.getHours() + delta); | ||
// end.setHours(end.getHours() + delta); | ||
// break; | ||
// case "week": | ||
// case "month": | ||
// // Adjust days for week and month views | ||
// start.setDate(start.getDate() + delta); | ||
// end.setDate(end.getDate() + delta); | ||
// break; | ||
// case "year": | ||
// // Set to specific month for year view | ||
// start = new Date(dateRange.from as Date); | ||
// start.setMonth(index); | ||
// end = new Date(start); | ||
// end.setMonth(start.getMonth() + 1); | ||
// break; | ||
// } | ||
// return { start, end }; | ||
// }; | ||
|
||
// /***********************************(Filter Appointments)***********************************/ | ||
// /** | ||
// * Filter appointments based on date range and view mode | ||
// */ | ||
// export const filterAppointments = <T extends GenericCalendarAppointment>( | ||
// appt: T, | ||
// index: number, | ||
// dateRange: DateRange, | ||
// viewMode: string, | ||
// getAppointmentDate: (appointment: T) => Date | ||
// ): boolean => { | ||
// const apptDate = getAppointmentDate(appt); | ||
// // Check if appointment is within the date range | ||
// if ( | ||
// !dateRange.from || | ||
// !dateRange.to || | ||
// !isWithinInterval(apptDate, { start: dateRange.from, end: dateRange.to }) | ||
// ) { | ||
// return false; | ||
// } | ||
// return isAppointmentInSlot(apptDate, index, viewMode, dateRange); | ||
// }; | ||
|
||
// /*##############################################(APPOINTMENT)##############################################*/ | ||
|
||
// /***********************************(Is Appointment In Slot)***********************************/ | ||
// /** | ||
// * Check if an appointment should be displayed in a specific slot | ||
// */ | ||
// const isAppointmentInSlot = ( | ||
// apptDate: Date, | ||
// index: number, | ||
// viewMode: string, | ||
// dateRange: DateRange | ||
// ): boolean => { | ||
// if (!dateRange.from) return false; | ||
|
||
// switch (viewMode) { | ||
// case "day": | ||
// // Check if appointment is in the correct hour and day | ||
// return ( | ||
// apptDate.getHours() === index && isSameDay(apptDate, dateRange.from) | ||
// ); | ||
// case "week": | ||
// // Check if appointment is on the correct day of the week | ||
// return ( | ||
// apptDate.getDay() - | ||
// (6 - | ||
// differenceInDays( | ||
// new Date(dateRange.to!), | ||
// new Date(dateRange.from) | ||
// )) === | ||
// index && isSameWeek(apptDate, dateRange.from) | ||
// ); | ||
// case "month": | ||
// // Check if appointment is in the correct week of the month | ||
// return ( | ||
// getWeekOfMonth(apptDate) === index && | ||
// isSameMonth(apptDate, dateRange.from) | ||
// ); | ||
// case "year": | ||
// // Check if appointment is in the correct month | ||
// return apptDate.getMonth() === index; | ||
// default: | ||
// return false; | ||
// } | ||
// }; | ||
|
||
// // Generate labels for different view modes | ||
// export const getLabelsForView = ( | ||
// viewMode: "day" | "week" | "month" | "year", | ||
// dateRange: { start: Date; end: Date } | ||
// ): string[] => { | ||
// switch (viewMode) { | ||
// case "day": | ||
// // Hourly labels (e.g., "14:00") | ||
// return eachHourOfInterval({ | ||
// start: startOfDay(dateRange.start), | ||
// end: endOfDay(dateRange.end), | ||
// }).map((hour: string | number | Date) => format(hour, "HH:mm")); | ||
// case "week": | ||
// // Daily labels (e.g., "Mon the 1st") | ||
// return eachDayOfInterval({ | ||
// start: dateRange.start, | ||
// end: dateRange.end, | ||
// }).map( | ||
// (day: string | number | Date) => | ||
// `${format(day, "ccc ")} the ${format(day, "do")}` | ||
// ); | ||
// case "month": | ||
// // Weekly labels (e.g., "1st week of Jan") | ||
// return eachWeekOfInterval({ | ||
// start: startOfMonth(dateRange.start), | ||
// end: endOfMonth(dateRange.end), | ||
// }).map( | ||
// (week: string | number | Date) => | ||
// `${format(week, "wo")} week of ${format(week, "MMM")}` | ||
// ); | ||
// case "year": | ||
// // Monthly labels (e.g., "Jan") | ||
// return eachMonthOfInterval({ | ||
// start: startOfYear(dateRange.start), | ||
// end: endOfYear(dateRange.end), | ||
// }).map((month: string | number | Date) => format(month, "MMM")); | ||
// default: | ||
// return []; | ||
// } | ||
// }; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.