Merge Tag v0.2.12

This commit is contained in:
2025-05-19 12:56:21 +02:00
48 changed files with 3626 additions and 469 deletions

View File

@@ -12,10 +12,11 @@ import { Habit, User } from '@/lib/types'
import { convertMachineReadableFrequencyToHumanReadable, getCompletionsForToday, isTaskOverdue } from '@/lib/utils'
import { useAtom } from 'jotai'
import { Check, Coins, Edit, MoreVertical, Pin, Undo2 } from 'lucide-react'; // Removed unused icons
import { useTranslations } from 'next-intl'
import { usePathname } from 'next/navigation'
import { useEffect, useState } from 'react'
import { HabitContextMenuItems } from './HabitContextMenuItems'
import { Avatar, AvatarFallback, AvatarImage } from './ui/avatar'
import { usePathname } from 'next/navigation'
interface HabitItemProps {
habit: Habit
@@ -50,6 +51,7 @@ export default function HabitItem({ habit, onEdit, onDelete }: HabitItemProps) {
const target = habit.targetCompletions || 1
const isCompletedToday = completionsToday >= target
const [isHighlighted, setIsHighlighted] = useState(false)
const t = useTranslations('HabitItem');
const [usersData] = useAtom(usersAtom)
const { currentUser, hasPermission } = useHelpers()
const canWrite = hasPermission('habit', 'write')
@@ -91,7 +93,7 @@ export default function HabitItem({ habit, onEdit, onDelete }: HabitItemProps) {
</div>
{isTaskOverdue(habit, settings.system.timezone) && (
<span className="ml-2 inline-flex items-center rounded-md bg-red-50 dark:bg-red-900/30 px-2 py-1 text-xs font-medium text-red-700 dark:text-red-400 ring-1 ring-inset ring-red-600/10 dark:ring-red-500/20">
Overdue
{t('overdue')}
</span>
)}
</CardTitle>
@@ -105,15 +107,15 @@ export default function HabitItem({ habit, onEdit, onDelete }: HabitItemProps) {
</CardHeader>
<CardContent className="flex-1">
<p className={`text-sm ${habit.archived ? 'text-gray-400 dark:text-gray-500' : 'text-gray-500'}`}>
When: {convertMachineReadableFrequencyToHumanReadable({
{t('whenLabel', { frequency: convertMachineReadableFrequencyToHumanReadable({
frequency: habit.frequency,
isRecurRule: pathname.includes("habits"),
timezone: settings.system.timezone
})}
})})}
</p>
<div className="flex items-center mt-2">
<Coins className={`h-4 w-4 mr-1 ${habit.archived ? 'text-gray-400 dark:text-gray-500' : 'text-yellow-400'}`} />
<span className={`text-sm font-medium ${habit.archived ? 'text-gray-400 dark:text-gray-500' : ''}`}>{habit.coinReward} coins per completion</span>
<span className={`text-sm font-medium ${habit.archived ? 'text-gray-400 dark:text-gray-500' : ''}`}>{t('coinsPerCompletion', { count: habit.coinReward })}</span>
</div>
</CardContent>
<CardFooter className="flex justify-between gap-2">
@@ -131,19 +133,19 @@ export default function HabitItem({ habit, onEdit, onDelete }: HabitItemProps) {
{isCompletedToday ? (
target > 1 ? (
<>
<span className="sm:hidden">{completionsToday}/{target}</span>
<span className="hidden sm:inline">Completed ({completionsToday}/{target})</span>
<span className="sm:hidden">{t('completedStatusCountMobile', { completed: completionsToday, target })}</span>
<span className="hidden sm:inline">{t('completedStatusCount', { completed: completionsToday, target })}</span>
</>
) : (
'Completed'
t('completedStatus')
)
) : (
target > 1 ? (
<>
<span className="sm:hidden">{completionsToday}/{target}</span>
<span className="hidden sm:inline">Complete ({completionsToday}/{target})</span>
<span className="sm:hidden">{t('completeButtonCountMobile', { completed: completionsToday, target })}</span>
<span className="hidden sm:inline">{t('completeButtonCount', { completed: completionsToday, target })}</span>
</>
) : 'Complete'
) : t('completeButton')
)}
</span>
{habit.targetCompletions && habit.targetCompletions > 1 && (
@@ -165,7 +167,7 @@ export default function HabitItem({ habit, onEdit, onDelete }: HabitItemProps) {
className="w-10 sm:w-auto"
>
<Undo2 className="h-4 w-4" />
<span className="hidden sm:inline ml-2">Undo</span>
<span className="hidden sm:inline ml-2">{t('undoButton')}</span>
</Button>
)}
</div>
@@ -179,7 +181,7 @@ export default function HabitItem({ habit, onEdit, onDelete }: HabitItemProps) {
className="hidden sm:flex"
>
<Edit className="h-4 w-4" />
<span className="ml-2">Edit</span>
<span className="ml-2">{t('editButton')}</span>
</Button>
)}
<DropdownMenu>