Merge Tag 'v0.2.31'

This commit is contained in:
2026-03-09 12:32:35 +01:00
22 changed files with 627 additions and 135 deletions

View File

@@ -14,7 +14,7 @@ import {
} from '@/components/ui/dropdown-menu'
import { updateLastNotificationReadTimestamp } from '@/app/actions/data';
import { d2t, getNow, t2d } from '@/lib/utils';
import { User, CoinTransaction } from '@/lib/types';
import { CoinTransaction } from '@/lib/types';
export default function NotificationBell() {
const t = useTranslations('NotificationBell');
@@ -121,7 +121,7 @@ export default function NotificationBell() {
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="p-0 w-80 md:w-96">
<NotificationDropdown
currentUser={currentUser as User | null} // Cast needed as as currentUser can be undefined
currentUser={currentUser ?? null}
unreadNotifications={unreadNotifications}
displayedReadNotifications={displayedReadNotifications}
habitsData={habitsData} // Pass necessary data down

View File

@@ -8,19 +8,19 @@ import {
TooltipProvider,
TooltipTrigger,
} from '@/components/ui/tooltip';
import { CoinTransaction, HabitsData, User, UserData, WishlistData } from '@/lib/types';
import { CoinTransaction, HabitsData, PublicUser, PublicUserData, WishlistData } from '@/lib/types';
import { t2d } from '@/lib/utils';
import { Info } from 'lucide-react';
import { useTranslations } from 'next-intl';
import Link from 'next/link';
interface NotificationDropdownProps {
currentUser: User | null;
currentUser: PublicUser | null;
unreadNotifications: CoinTransaction[];
displayedReadNotifications: CoinTransaction[];
habitsData: HabitsData;
wishlistData: WishlistData;
usersData: UserData;
usersData: PublicUserData;
}
// Helper function to get the name of the related item
@@ -47,7 +47,7 @@ export default function NotificationDropdown({
const t = useTranslations('NotificationDropdown');
// Helper function to generate notification message, now using t
const getNotificationMessage = (tx: CoinTransaction, triggeringUser?: User, relatedItemName?: string): string => {
const getNotificationMessage = (tx: CoinTransaction, triggeringUser?: PublicUser, relatedItemName?: string): string => {
const username = triggeringUser?.username || t('defaultUsername');
const itemName = relatedItemName || t('defaultItemName');
switch (tx.type) {

View File

@@ -1,7 +1,7 @@
'use client';
import { toast } from '@/hooks/use-toast';
import { User } from '@/lib/types';
import { SafeUser } from '@/lib/types';
import { User as UserIcon } from 'lucide-react';
import { useTranslations } from 'next-intl';
import { useState } from 'react';
@@ -11,7 +11,7 @@ import { Input } from './ui/input';
import { Label } from './ui/label';
interface PasswordEntryFormProps {
user: User;
user: SafeUser;
onCancel: () => void;
onSubmit: (password: string) => Promise<void>;
error?: string;
@@ -24,7 +24,7 @@ export default function PasswordEntryForm({
error
}: PasswordEntryFormProps) {
const t = useTranslations('PasswordEntryForm');
const hasPassword = !!user.password;
const hasPassword = user.hasPassword ?? false;
const [password, setPassword] = useState('');
const handleSubmit = async (e: React.FormEvent) => {

View File

@@ -59,7 +59,7 @@ export default function UserForm({ userId, onCancel, onSuccess }: UserFormProps)
const [avatarPath, setAvatarPath] = useState(user?.avatarPath)
const [username, setUsername] = useState(user?.username || '');
const [password, setPassword] = useState<string | undefined>('');
const [disablePassword, setDisablePassword] = useState(user?.password === '' || serverSettings.isDemo);
const [disablePassword, setDisablePassword] = useState(user ? !user.hasPassword : serverSettings.isDemo);
const [error, setError] = useState('');
const [avatarFile, setAvatarFile] = useState<File | null>(null);
const [isAdmin, setIsAdmin] = useState(user?.isAdmin || false);
@@ -173,7 +173,7 @@ export default function UserForm({ userId, onCancel, onSuccess }: UserFormProps)
avatarPath,
permissions,
isAdmin,
password: disablePassword ? '' : (password || u.password) // use the correct password to update atom
hasPassword: disablePassword ? false : (password ? true : !!u.hasPassword)
} : u
),
}));

View File

@@ -3,7 +3,7 @@
import { signIn } from '@/app/actions/user';
import { toast } from '@/hooks/use-toast';
import { currentUserAtom, usersAtom } from '@/lib/atoms';
import { SafeUser, User } from '@/lib/types';
import { SafeUser } from '@/lib/types';
import { cn } from '@/lib/utils';
import { Description } from '@radix-ui/react-dialog';
import { useAtom } from 'jotai';
@@ -15,8 +15,6 @@ import UserForm from './UserForm';
import { Avatar, AvatarFallback, AvatarImage } from './ui/avatar';
import { Dialog, DialogContent, DialogHeader, DialogTitle } from './ui/dialog';
function UserCard({
user,
onSelect,
@@ -24,7 +22,7 @@ function UserCard({
showEdit,
isCurrentUser,
}: {
user: User,
user: SafeUser,
onSelect: () => void,
onEdit: () => void,
showEdit: boolean,
@@ -99,7 +97,7 @@ function UserSelectionView({
onEditUser,
onCreateUser,
}: {
users: User[],
users: SafeUser[],
currentUserFromHook?: SafeUser,
onUserSelect: (userId: string) => void,
onEditUser: (userId: string) => void,