import React, { memo } from "react"; import { Button, Picker, PickerModes, SegmentedControl, Text, View, } from "react-native-ui-lib"; import { MaterialIcons } from "@expo/vector-icons"; import { modeMap, months } from "./constants"; import { StyleSheet } from "react-native"; import { useAtom } from "jotai"; import { modeAtom, selectedDateAtom } from "@/components/pages/calendar/atoms"; import { format, isSameDay } from "date-fns"; import { useAuthContext } from "@/contexts/AuthContext"; import {useIsMutating} from "react-query"; export const CalendarHeader = memo(() => { const [selectedDate, setSelectedDate] = useAtom(selectedDateAtom); const [mode, setMode] = useAtom(modeAtom); const { profileData } = useAuthContext(); const handleSegmentChange = (index: number) => { const selectedMode = modeMap.get(index); if (selectedMode) { setTimeout(() => { setMode(selectedMode as "day" | "week" | "month"); }, 150); } }; const handleMonthChange = (month: string) => { const currentDay = selectedDate.getDate(); const currentYear = selectedDate.getFullYear(); const newMonthIndex = months.indexOf(month); const updatedDate = new Date(currentYear, newMonthIndex, currentDay); setSelectedDate(updatedDate); }; const isSelectedDateToday = isSameDay(selectedDate, new Date()); return ( {selectedDate.getFullYear()} handleMonthChange(itemValue as string)} trailingAccessory={} topBarProps={{ title: selectedDate.getFullYear().toString(), titleStyle: { fontFamily: "Manrope_500Medium", fontSize: 17 }, }} > {months.map((month) => ( ))} {!isSelectedDateToday && (