2024-04-08 23:21:36 +02:00
|
|
|
import { useMemo, useState } from "react"
|
|
|
|
import { View } from "react-native"
|
|
|
|
import { Agenda } from "react-native-calendars"
|
|
|
|
import { Text } from "react-native-paper"
|
2024-03-15 14:19:58 +01:00
|
|
|
import { SafeAreaView } from "react-native-safe-area-context"
|
|
|
|
|
2024-05-02 01:08:27 +02:00
|
|
|
import { getISODate, getNowDateUTC } from "@/utils/dates"
|
2024-04-08 23:21:36 +02:00
|
|
|
|
2024-03-15 23:24:08 +01:00
|
|
|
const HistoryPage: React.FC = () => {
|
2024-04-08 23:21:36 +02:00
|
|
|
const today = useMemo(() => {
|
2024-05-02 01:08:27 +02:00
|
|
|
return getNowDateUTC()
|
2024-04-08 23:21:36 +02:00
|
|
|
}, [])
|
|
|
|
const todayISO = getISODate(today)
|
|
|
|
|
|
|
|
const [selectedDate, setSelectedDate] = useState<Date>(today)
|
|
|
|
const selectedISODate = getISODate(selectedDate)
|
2024-03-15 15:30:19 +01:00
|
|
|
|
2024-03-15 14:19:58 +01:00
|
|
|
return (
|
2024-03-24 23:41:23 +01:00
|
|
|
<SafeAreaView
|
|
|
|
style={[
|
|
|
|
{
|
|
|
|
flex: 1,
|
2024-04-08 23:21:36 +02:00
|
|
|
backgroundColor: "white",
|
2024-03-24 23:41:23 +01:00
|
|
|
},
|
|
|
|
]}
|
|
|
|
>
|
2024-04-08 23:21:36 +02:00
|
|
|
<Agenda
|
|
|
|
firstDay={1}
|
|
|
|
showClosingKnob
|
|
|
|
showOnlySelectedDayItems
|
|
|
|
onDayPress={(date) => {
|
|
|
|
setSelectedDate(new Date(date.dateString))
|
2024-03-15 15:30:19 +01:00
|
|
|
}}
|
|
|
|
markedDates={{
|
2024-04-08 23:21:36 +02:00
|
|
|
[todayISO]: { marked: true },
|
2024-03-15 15:30:19 +01:00
|
|
|
}}
|
2024-04-08 23:21:36 +02:00
|
|
|
selected={selectedISODate}
|
|
|
|
renderList={() => {
|
|
|
|
return (
|
|
|
|
<View>
|
|
|
|
<Text>{selectedDate.toISOString()}</Text>
|
|
|
|
</View>
|
|
|
|
)
|
2024-03-15 15:30:19 +01:00
|
|
|
}}
|
|
|
|
/>
|
2024-03-15 14:19:58 +01:00
|
|
|
</SafeAreaView>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2024-03-15 23:24:08 +01:00
|
|
|
export default HistoryPage
|