feat: mark cell as failed when decrementing if value is already zero
This commit is contained in:
@@ -114,6 +114,17 @@
|
|||||||
} else {
|
} else {
|
||||||
const oldCount = count;
|
const oldCount = count;
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
|
// If already at zero, mark as failed
|
||||||
|
if (count === 0) {
|
||||||
|
const dateObj = new Date(date + 'T00:00:00.000Z');
|
||||||
|
try {
|
||||||
|
await habitService.upsertCompletion(habitId, dateObj, 0, true);
|
||||||
|
return;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to mark habit as failed:', error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Decrement but don't go below 0 - animate to 0 if needed
|
// Decrement but don't go below 0 - animate to 0 if needed
|
||||||
const newCount = count - increment;
|
const newCount = count - increment;
|
||||||
count = newCount < 0 ? 0 : newCount;
|
count = newCount < 0 ? 0 : newCount;
|
||||||
|
|||||||
Reference in New Issue
Block a user