fix and update

This commit is contained in:
lendry
2026-06-25 16:01:41 +03:00
parent ce58e6f4c1
commit 3880c68d59
40 changed files with 1715 additions and 215 deletions

View File

@@ -1,11 +1,18 @@
'use client';
import { use } from 'react';
import { IdShell } from '@/components/id/shell';
import { use, useEffect } from 'react';
import { FamilyGroupView } from '@/components/family/family-group-view';
import { useFamilyOverlay } from '@/components/family/family-overlay-provider';
import { IdShell } from '@/components/id/shell';
export default function FamilyGroupPage({ params }: { params: Promise<{ groupId: string }> }) {
const { groupId } = use(params);
const { setSelectedGroupId } = useFamilyOverlay();
useEffect(() => {
setSelectedGroupId(groupId);
}, [groupId, setSelectedGroupId]);
return (
<IdShell active="/family" wide>
<FamilyGroupView groupId={groupId} />

View File

@@ -10,6 +10,7 @@ import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { useRequireAuth } from '@/hooks/use-require-auth';
import { apiFetch, FamilyGroup, fetchFamilyGroups, getApiErrorMessage } from '@/lib/api';
import { defaultFamilyGroupName } from '@/lib/family-defaults';
export default function FamilyPage() {
const router = useRouter();
@@ -17,9 +18,15 @@ export default function FamilyPage() {
const { isReady, isPinLocked } = useRequireAuth();
const { showToast } = useToast();
const [groups, setGroups] = useState<FamilyGroup[]>([]);
const [name, setName] = useState('Моя семья');
const [name, setName] = useState('');
const [creating, setCreating] = useState(false);
useEffect(() => {
if (user?.displayName) {
setName(defaultFamilyGroupName(user.displayName));
}
}, [user?.displayName]);
useEffect(() => {
if (!user || !token || isPinLocked) return;
fetchFamilyGroups(user.id, token)
@@ -63,7 +70,7 @@ export default function FamilyPage() {
<div className="mt-8 flex gap-3">
<Input value={name} onChange={(event) => setName(event.target.value)} placeholder="Название семьи" />
<Button onClick={() => void createGroup()} disabled={creating}>
<Button onClick={() => void createGroup()} disabled={creating || !name.trim()}>
{creating ? 'Создаём...' : (<><Plus className="h-4 w-4" />Создать</>)}
</Button>
</div>