diff --git a/backend/uploads/4198d24a-5804-4cd3-be63-7111ecfdf989_khatta_vada__Gujarati_Gharavada__Gujarati_vada__vada_recipe.mp3 b/backend/uploads/4198d24a-5804-4cd3-be63-7111ecfdf989_khatta_vada__Gujarati_Gharavada__Gujarati_vada__vada_recipe.mp3 new file mode 100644 index 0000000..d87b06a Binary files /dev/null and b/backend/uploads/4198d24a-5804-4cd3-be63-7111ecfdf989_khatta_vada__Gujarati_Gharavada__Gujarati_vada__vada_recipe.mp3 differ diff --git a/frontend/src/components/AudioPostCard.jsx b/frontend/src/components/AudioPostCard.jsx index 8b9659f..e7dbd9d 100644 --- a/frontend/src/components/AudioPostCard.jsx +++ b/frontend/src/components/AudioPostCard.jsx @@ -1,4 +1,4 @@ -import { Clock, Download, ExternalLink } from 'lucide-react' +import { Clock, Download, ExternalLink, User } from 'lucide-react' import { useState, useEffect } from 'react' import { api } from '../api' import AudioPlayer from './AudioPlayer' @@ -7,6 +7,7 @@ export default function AudioPostCard({ post, onViewPost }) { const [transcript, setTranscript] = useState(null) const [loadingTranscript, setLoadingTranscript] = useState(false) const [downloading, setDownloading] = useState(false) + const [author, setAuthor] = useState(null) useEffect(() => { console.log('Post data:', post) @@ -14,6 +15,22 @@ export default function AudioPostCard({ post, onViewPost }) { console.log('Status:', post.status) }, [post]) + // Load author data + useEffect(() => { + if (post.user_id) { + loadAuthor() + } + }, [post.user_id]) + + const loadAuthor = async () => { + try { + const userData = await api.getUser(post.user_id) + setAuthor(userData) + } catch (err) { + console.error('Failed to load author:', err) + } + } + const formatDate = (dateString) => { return new Date(dateString).toLocaleDateString('en-US', { year: 'numeric', @@ -81,10 +98,32 @@ export default function AudioPostCard({ post, onViewPost }) { } } + const getAuthorDisplayName = () => { + if (!author) return 'Loading...' + return author.display_name || author.email?.split('@')[0] || 'Unknown Author' + } + + const getAuthorInitials = () => { + if (!author) return '?' + const name = author.display_name || author.email?.split('@')[0] || '?' + return name.charAt(0).toUpperCase() + } + return (
{/* Post Header */}
+ {/* Author Info */} +
+
+ {getAuthorInitials()} +
+
+

{getAuthorDisplayName()}

+

{formatDate(post.created_at)}

+
+
+
@@ -96,9 +135,6 @@ export default function AudioPostCard({ post, onViewPost }) { )}
- - {formatDate(post.created_at)} - {post.status} - {post.language && ( - - {post.language.toUpperCase()} - + <> + + + {post.language.toUpperCase()} + + )}
{/* Action Buttons */}
- {post.status === 'ready' && ( - )}
@@ -175,9 +211,6 @@ export default function AudioPostCard({ post, onViewPost }) {

No transcript available

)}
- - - )} diff --git a/frontend/src/pages/History.jsx b/frontend/src/pages/History.jsx index e432d79..acfc697 100644 --- a/frontend/src/pages/History.jsx +++ b/frontend/src/pages/History.jsx @@ -115,11 +115,7 @@ export default function History({ user, onViewPost }) { {/* My Posted Archives */} -
-

- - My Posted Archives -

+
{posts.length > 0 ? (
diff --git a/frontend/src/pages/PostDetail.jsx b/frontend/src/pages/PostDetail.jsx index bfa51b3..a457995 100644 --- a/frontend/src/pages/PostDetail.jsx +++ b/frontend/src/pages/PostDetail.jsx @@ -1,5 +1,5 @@ import { useState, useEffect, useRef } from 'react' -import { ArrowLeft, Clock, Download, Share2, Calendar, Globe, Lock, Play, Pause, Volume2 } from 'lucide-react' +import { ArrowLeft, Clock, Download, Share2, Calendar, Globe, Lock, Play, Pause, Volume2, User } from 'lucide-react' import { api } from '../api' export default function PostDetail({ postId, user, onBack }) { @@ -9,6 +9,7 @@ export default function PostDetail({ postId, user, onBack }) { const [loading, setLoading] = useState(true) const [error, setError] = useState(null) const [downloading, setDownloading] = useState(false) + const [author, setAuthor] = useState(null) // Audio player state const [isPlaying, setIsPlaying] = useState(false) @@ -32,6 +33,22 @@ export default function PostDetail({ postId, user, onBack }) { } }, [post?.audio_url]) + // Load author when post loads + useEffect(() => { + if (post?.user_id) { + loadAuthor() + } + }, [post?.user_id]) + + const loadAuthor = async () => { + try { + const userData = await api.getUser(post.user_id) + setAuthor(userData) + } catch (err) { + console.error('Failed to load author:', err) + } + } + const loadPostData = async () => { setLoading(true) setError(null) @@ -91,6 +108,17 @@ export default function PostDetail({ postId, user, onBack }) { return match ? match[1].trim() : null } + const getAuthorDisplayName = () => { + if (!author) return 'Loading...' + return author.display_name || author.email?.split('@')[0] || 'Unknown Author' + } + + const getAuthorInitials = () => { + if (!author) return '?' + const name = author.display_name || author.email?.split('@')[0] || '?' + return name.charAt(0).toUpperCase() + } + // Audio player handlers const togglePlay = () => { if (!audioRef.current || !post?.audio_url) return @@ -219,6 +247,17 @@ export default function PostDetail({ postId, user, onBack }) { {/* Header Card */}
+ {/* Author Info */} +
+
+ {getAuthorInitials()} +
+
+

{getAuthorDisplayName()}

+

{formatDate(post.created_at)}

+
+
+ {/* Title and Meta */}
@@ -234,11 +273,6 @@ export default function PostDetail({ postId, user, onBack }) { {/* Metadata */}
-
- - {formatDate(post.created_at)} -
-

Metadata

+ {author && ( + <> +
Author:
+
{getAuthorDisplayName()}
+ + )} {metadata.source_file && ( <>
Source File: