0.0.1.2
This commit is contained in:
@@ -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}世)
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user