1
1
mirror of https://github.com/theoludwig/p61-project.git synced 2024-07-17 07:00:12 +02:00

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,17 +165,29 @@ export const HabitEditForm: React.FC<HabitEditFormProps> = ({ habit }) => {
Save Save
</Button> </Button>
<Button {habit.endDate == null ? (
mode="outlined" <Button
onPress={async () => { mode="outlined"
await habitsTrackerPresenter.habitStop(habit) onPress={async () => {
}} await habitsTrackerPresenter.habitStop(habit)
loading={habitStop.state === "loading"} }}
disabled={habitStop.state === "loading"} loading={habitStop.state === "loading"}
style={[styles.spacing, { width: "96%" }]} disabled={habitStop.state === "loading"}
> style={[styles.spacing, { width: "96%" }]}
Stop >
</Button> 🛑 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> </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
) )
}) })