fix: habit end date filtering + habit stop wording

This commit is contained in:
Théo LUDWIG 2024-05-01 14:15:54 +02:00
parent 172e8edf78
commit 748ac2476c
Signed by: theoludwig
GPG Key ID: ADFE5A563D718F3B
2 changed files with 31 additions and 13 deletions

View File

@ -4,7 +4,13 @@ import { zodResolver } from "@hookform/resolvers/zod"
import { useState } from "react" import { useState } from "react"
import { Controller, useForm } from "react-hook-form" import { Controller, useForm } from "react-hook-form"
import { ScrollView, StyleSheet, View } from "react-native" import { ScrollView, StyleSheet, View } from "react-native"
import { Button, HelperText, Snackbar, TextInput } from "react-native-paper" import {
Button,
HelperText,
Snackbar,
Text,
TextInput,
} from "react-native-paper"
import { SafeAreaView } from "react-native-safe-area-context" import { SafeAreaView } from "react-native-safe-area-context"
import ColorPicker, { import ColorPicker, {
HueSlider, HueSlider,
@ -159,6 +165,7 @@ export const HabitEditForm: React.FC<HabitEditFormProps> = ({ habit }) => {
Save Save
</Button> </Button>
{habit.endDate == null ? (
<Button <Button
mode="outlined" mode="outlined"
onPress={async () => { onPress={async () => {
@ -168,8 +175,19 @@ export const HabitEditForm: React.FC<HabitEditFormProps> = ({ habit }) => {
disabled={habitStop.state === "loading"} disabled={habitStop.state === "loading"}
style={[styles.spacing, { width: "96%" }]} style={[styles.spacing, { width: "96%" }]}
> >
Stop 🛑 Stop Habit (effective tomorrow)
</Button> </Button>
) : (
<Text
style={{
textAlign: "center",
marginVertical: 20,
fontSize: 20,
}}
>
🛑 The habit has been stopped! (No further progress can be saved)
</Text>
)}
</ScrollView> </ScrollView>
<Snackbar <Snackbar

View File

@ -94,7 +94,7 @@ export const HabitsList: React.FC<HabitsListProps> = (props) => {
.filter((habitItem) => { .filter((habitItem) => {
return ( return (
(habitItem.habit.endDate != null && (habitItem.habit.endDate != null &&
habitItem.habit.endDate <= selectedDate) || habitItem.habit.endDate >= selectedDate) ||
habitItem.habit.endDate == null habitItem.habit.endDate == null
) )
}) })