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 { Controller, useForm } from "react-hook-form"
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 ColorPicker, {
HueSlider,
@ -159,17 +165,29 @@ export const HabitEditForm: React.FC<HabitEditFormProps> = ({ habit }) => {
Save
</Button>
<Button
mode="outlined"
onPress={async () => {
await habitsTrackerPresenter.habitStop(habit)
}}
loading={habitStop.state === "loading"}
disabled={habitStop.state === "loading"}
style={[styles.spacing, { width: "96%" }]}
>
Stop
</Button>
{habit.endDate == null ? (
<Button
mode="outlined"
onPress={async () => {
await habitsTrackerPresenter.habitStop(habit)
}}
loading={habitStop.state === "loading"}
disabled={habitStop.state === "loading"}
style={[styles.spacing, { width: "96%" }]}
>
🛑 Stop Habit (effective tomorrow)
</Button>
) : (
<Text
style={{
textAlign: "center",
marginVertical: 20,
fontSize: 20,
}}
>
🛑 The habit has been stopped! (No further progress can be saved)
</Text>
)}
</ScrollView>
<Snackbar

View File

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