This commit is contained in:
freedakgmail
2025-11-23 09:13:25 +08:00
parent 81dbf709aa
commit bade25ff26
378 changed files with 769815 additions and 2334 deletions
+5 -5
View File
@@ -34,7 +34,7 @@ export function MemberForm({ initialData, existingMembers = [], onSubmit, onCanc
surname: initialData?.surname || "李",
givenName: initialData?.givenName || "",
fullName: initialData?.fullName || "",
gender: initialData?.gender || "male",
gender: (initialData?.gender || "MALE").toUpperCase() as "MALE" | "FEMALE",
generation: initialData?.generation || maxGeneration,
spouseIds: initialData?.spouseIds || [],
childrenIds: initialData?.childrenIds || [],
@@ -247,8 +247,8 @@ export function MemberForm({ initialData, existingMembers = [], onSubmit, onCanc
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="male"> (Male)</SelectItem>
<SelectItem value="female"> (Female)</SelectItem>
<SelectItem value="MALE"> (Male)</SelectItem>
<SelectItem value="FEMALE"> (Female)</SelectItem>
</SelectContent>
</Select>
</div>
@@ -287,7 +287,7 @@ export function MemberForm({ initialData, existingMembers = [], onSubmit, onCanc
<SelectContent>
<SelectItem value="none"> (None)</SelectItem>
{potentialRelatives
.filter((m) => m.gender === "male" && m.generation === (formData.generation || 1) - 1)
.filter((m) => m.gender === "MALE" && m.generation === (formData.generation || 1) - 1)
.map((m) => (
<SelectItem key={m.id} value={m.id}>
{m.fullName} ({m.generation})
@@ -319,7 +319,7 @@ export function MemberForm({ initialData, existingMembers = [], onSubmit, onCanc
<SelectContent>
<SelectItem value="none"> (None)</SelectItem>
{potentialRelatives
.filter((m) => m.gender === "female" && m.generation === (formData.generation || 1) - 1)
.filter((m) => m.gender === "FEMALE" && m.generation === (formData.generation || 1) - 1)
.map((m) => (
<SelectItem key={m.id} value={m.id}>
{m.fullName} ({m.generation})
+9 -5
View File
@@ -3,8 +3,10 @@
import { useState, useEffect } from "react"
import { db } from "@/lib/db"
import { Button } from "@/components/ui/button"
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog"
import { X, Plus, ZoomIn } from "lucide-react"
import { Card } from "@/components/ui/card"
import { X, Upload, Image as ImageIcon } from "lucide-react"
import { uploadImage } from "@/lib/image-upload"
import { useDialog } from "@/components/ui/alert-dialog-custom"
import { v4 as uuidv4 } from "uuid"
import imageCompression from "browser-image-compression"
@@ -15,6 +17,7 @@ interface PhotoGalleryProps {
}
export function PhotoGallery({ photoIds = [], onChange, readonly = false }: PhotoGalleryProps) {
const { showAlert, showConfirm } = useDialog()
const [photos, setPhotos] = useState<{ id: string; url: string }[]>([])
const [selectedPhoto, setSelectedPhoto] = useState<string | null>(null)
const [isUploading, setIsUploading] = useState(false)
@@ -85,15 +88,16 @@ export function PhotoGallery({ photoIds = [], onChange, readonly = false }: Phot
onChange([...photoIds, ...newPhotoIds])
} catch (error) {
console.error('上传照片失败:', error)
alert('上传照片失败')
await showAlert('上传照片失败', '错误')
} finally {
setIsUploading(false)
e.target.value = ''
}
}
const handleDelete = (photoId: string) => {
if (confirm('确定要删除这张照片吗?')) {
const handleDelete = async (photoId: string) => {
const confirmed = await showConfirm('确定要删除这张照片吗?', '删除照片')
if (confirmed) {
onChange(photoIds.filter(id => id !== photoId))
}
}
+8 -6
View File
@@ -6,10 +6,10 @@ import { Input } from "@/components/ui/input"
import { Textarea } from "@/components/ui/textarea"
import { Label } from "@/components/ui/label"
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog"
import { Plus, Edit, Trash, BookOpen, Calendar } from "lucide-react"
import type { FamilyStory } from "@/types/family"
import { v4 as uuidv4 } from "uuid"
import { useDialog } from "@/components/ui/alert-dialog-custom"
interface StoryManagerProps {
stories?: FamilyStory[]
@@ -18,7 +18,8 @@ interface StoryManagerProps {
}
export function StoryManager({ stories = [], onChange, readonly = false }: StoryManagerProps) {
const [isDialogOpen, setIsDialogOpen] = useState(false)
const { showAlert, showConfirm } = useDialog()
const [isEditing, setIsEditing] = useState(false)
const [editingStory, setEditingStory] = useState<FamilyStory | null>(null)
const [formData, setFormData] = useState<Partial<FamilyStory>>({
title: "",
@@ -38,15 +39,16 @@ export function StoryManager({ stories = [], onChange, readonly = false }: Story
setIsDialogOpen(true)
}
const handleDelete = (storyId: string) => {
if (confirm("确定要删除这个故事吗?")) {
const handleDelete = async (storyId: string) => {
const confirmed = await showConfirm("确定要删除这个故事吗?", "删除故事")
if (confirmed) {
onChange(stories.filter(s => s.id !== storyId))
}
}
const handleSave = () => {
const handleSave = async () => {
if (!formData.title || !formData.content) {
alert("请填写标题和内容")
await showAlert("请填写标题和内容", "提示")
return
}