From 5f58c4dc3dfc332ab0a35c1e88e7e9fc6d55cd91 Mon Sep 17 00:00:00 2001 From: Jamie Pine Date: Mon, 26 Jan 2026 22:28:29 -0800 Subject: [PATCH] Refactor VoiceProfiles components and remove ProfileDetail - Removed the ProfileDetail component to streamline the ProfileCard functionality. - Updated ProfileCard to eliminate the detail view and associated state management. - Enhanced ProfileForm to manage audio samples more effectively, including improved UI for sample management. - Adjusted SampleList to ensure proper button types for better accessibility. --- .../components/VoiceProfiles/ProfileCard.tsx | 14 +--- .../VoiceProfiles/ProfileDetail.tsx | 66 ---------------- .../components/VoiceProfiles/ProfileForm.tsx | 76 +++++++++++-------- .../components/VoiceProfiles/SampleList.tsx | 4 +- 4 files changed, 47 insertions(+), 113 deletions(-) delete mode 100644 app/src/components/VoiceProfiles/ProfileDetail.tsx diff --git a/app/src/components/VoiceProfiles/ProfileCard.tsx b/app/src/components/VoiceProfiles/ProfileCard.tsx index 7b4be063..d386599b 100644 --- a/app/src/components/VoiceProfiles/ProfileCard.tsx +++ b/app/src/components/VoiceProfiles/ProfileCard.tsx @@ -1,4 +1,4 @@ -import { Download, Edit, Eye, Mic, Trash2 } from 'lucide-react'; +import { Download, Edit, Mic, Trash2 } from 'lucide-react'; import { useState } from 'react'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; @@ -16,14 +16,12 @@ import type { VoiceProfileResponse } from '@/lib/api/types'; import { useDeleteProfile, useExportProfile } from '@/lib/hooks/useProfiles'; import { cn } from '@/lib/utils/cn'; import { useUIStore } from '@/stores/uiStore'; -import { ProfileDetail } from './ProfileDetail'; interface ProfileCardProps { profile: VoiceProfileResponse; } export function ProfileCard({ profile }: ProfileCardProps) { - const [detailOpen, setDetailOpen] = useState(false); const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); const deleteProfile = useDeleteProfile(); const exportProfile = useExportProfile(); @@ -85,14 +83,6 @@ export function ProfileCard({ profile }: ProfileCardProps) {
- { - e.stopPropagation(); - setDetailOpen(true); - }} - aria-label="View details" - /> - - diff --git a/app/src/components/VoiceProfiles/ProfileDetail.tsx b/app/src/components/VoiceProfiles/ProfileDetail.tsx deleted file mode 100644 index 60527aa3..00000000 --- a/app/src/components/VoiceProfiles/ProfileDetail.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import { Badge } from '@/components/ui/badge'; -import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, -} from '@/components/ui/dialog'; -import { useProfile } from '@/lib/hooks/useProfiles'; -import { formatDate } from '@/lib/utils/format'; -import { SampleList } from './SampleList'; - -interface ProfileDetailProps { - profileId: string; - open: boolean; - onOpenChange: (open: boolean) => void; -} - -export function ProfileDetail({ profileId, open, onOpenChange }: ProfileDetailProps) { - const { data: profile, isLoading } = useProfile(profileId); - - if (isLoading) { - return ( - - -
Loading profile...
-
-
- ); - } - - if (!profile) { - return null; - } - - return ( - - - - {profile.name} - Manage samples and view profile details - - -
- {profile.description && ( -
-

Description

-

{profile.description}

-
- )} - -
- {profile.language} - - Created {formatDate(profile.created_at)} - -
- -
- -
-
-
-
- ); -} diff --git a/app/src/components/VoiceProfiles/ProfileForm.tsx b/app/src/components/VoiceProfiles/ProfileForm.tsx index f10798f9..19e6c13a 100644 --- a/app/src/components/VoiceProfiles/ProfileForm.tsx +++ b/app/src/components/VoiceProfiles/ProfileForm.tsx @@ -47,6 +47,7 @@ import { useUIStore } from '@/stores/uiStore'; import { AudioSampleRecording } from './AudioSampleRecording'; import { AudioSampleSystem } from './AudioSampleSystem'; import { AudioSampleUpload } from './AudioSampleUpload'; +import { SampleList } from './SampleList'; // Helper function to get audio duration from File async function getAudioDuration(file: File & { recordedDuration?: number }): Promise { @@ -325,7 +326,7 @@ export function ProfileForm() { }, }); toast({ - title: 'Profile updated', + title: 'Voice updated', description: `"${data.name}" has been updated successfully.`, }); } else { @@ -446,17 +447,17 @@ export function ProfileForm() { - {editingProfileId ? 'Edit Profile' : 'Create Voice Profile'} + {editingProfileId ? 'Edit Voice' : 'Create Voice Profile'} {editingProfileId - ? 'Update your voice profile details.' + ? 'Update your voice profile details and manage samples.' : 'Create a new voice profile with an audio sample to clone the voice.'}
-
+
{/* Left column: Profile info */}
- {/* Right column: Sample upload section - only show when creating */} - {isCreating && ( -
-
-

Add Sample

-

- Provide an audio sample to clone the voice. You can add more samples later. -

-
+ {/* Right column: Sample management */} +
+ {isCreating ? ( + <> +
+

Add Sample

+

+ Provide an audio sample to clone the voice. You can add more samples later. +

+
- ( - - Reference Text - -