fix: Corrigindo capas das histórias

This commit is contained in:
Lucas Santana 2025-01-23 19:01:03 -03:00
parent ea5c5e87f1
commit e154dd2372
3 changed files with 24 additions and 13 deletions

View File

@ -293,6 +293,7 @@ function RecordingHistoryCard({ recording }: { recording: StoryRecording }) {
text={recording.transcription || 'Transcrição não disponível'} text={recording.transcription || 'Transcrição não disponível'}
isUpperCase={isUpperCase} isUpperCase={isUpperCase}
className="text-sm text-gray-600 whitespace-pre-wrap" className="text-sm text-gray-600 whitespace-pre-wrap"
highlightSyllables={isHighlighted}
/> />
</div> </div>
</div> </div>

View File

@ -77,7 +77,7 @@ export function StudentDashboardPage() {
.eq('student_id', session.user.id) .eq('student_id', session.user.id)
.eq('story_pages.page_number', 1) // Garante que pegamos a primeira página .eq('story_pages.page_number', 1) // Garante que pegamos a primeira página
.order('created_at', { ascending: false }) .order('created_at', { ascending: false })
.limit(3); .limit(6);
if (error) throw error; if (error) throw error;
setRecentStories(data || []); setRecentStories(data || []);
@ -252,10 +252,7 @@ export function StudentDashboardPage() {
{story.cover && ( {story.cover && (
<div className="relative aspect-video"> <div className="relative aspect-video">
<img <img
src={supabase.storage src={`${story.cover[0].image_url}?width=400&height=300&quality=80&format=webp`}
.from('story-images')
.getPublicUrl(story.cover.image_url).data.publicUrl +
`?width=400&height=300&quality=80&format=webp`}
alt={story.title} alt={story.title}
className="w-full h-48 object-cover" className="w-full h-48 object-cover"
loading="lazy" loading="lazy"

View File

@ -25,8 +25,16 @@ export function StudentStoriesPage() {
const query = supabase const query = supabase
.from('stories') .from('stories')
.select('*') .select(`
.eq('student_id', session.user.id); *,
pages:story_pages (
image_url
)
`)
.eq('student_id', session.user.id)
.order('created_at', { ascending: false })
.order('page_number', { foreignTable: 'story_pages', ascending: true })
.limit(1, { foreignTable: 'story_pages' });
if (statusFilter !== 'all') { if (statusFilter !== 'all') {
query.eq('status', statusFilter); query.eq('status', statusFilter);
@ -197,16 +205,21 @@ export function StudentStoriesPage() {
className="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden cursor-pointer hover:shadow-md transition" className="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden cursor-pointer hover:shadow-md transition"
onClick={() => navigate(`/aluno/historias/${story.id}`)} onClick={() => navigate(`/aluno/historias/${story.id}`)}
> >
{story.cover && ( {!story.pages?.[0]?.image_url && (
<div className="bg-gray-100 aspect-video flex items-center justify-center">
<BookOpen className="h-12 w-12 text-gray-400" />
</div>
)}
{story.pages?.[0]?.image_url && (
<div className="relative aspect-video"> <div className="relative aspect-video">
<img <img
src={supabase.storage src={story.pages[0].image_url}
.from('story-images') alt={`Capa da história: ${story.title}`}
.getPublicUrl(story.cover.image_url).data.publicUrl +
`?width=400&height=300&quality=80&format=webp`}
alt={story.title}
className="w-full h-48 object-cover" className="w-full h-48 object-cover"
loading="lazy" loading="lazy"
onError={(e) => {
e.currentTarget.style.display = 'none';
}}
/> />
</div> </div>
)} )}