initial audiocove integration

This commit is contained in:
Stefan Hardegger
2026-07-13 09:26:45 +02:00
parent e03031ea05
commit 9161ec6baa
10 changed files with 461 additions and 3 deletions

View File

@@ -4,7 +4,7 @@ import { useState, useEffect } from 'react';
import { useParams, useRouter } from 'next/navigation';
import Link from 'next/link';
import Image from 'next/image';
import { storyApi, seriesApi, getImageUrl } from '../../../../lib/api';
import { storyApi, seriesApi, audioCoveApi, getImageUrl } from '../../../../lib/api';
import { Story, Collection } from '../../../../types/api';
import AppLayout from '../../../../components/layout/AppLayout';
import Button from '../../../../components/ui/Button';
@@ -24,6 +24,8 @@ export default function StoryDetailPage() {
const [loading, setLoading] = useState(true);
const [updating, setUpdating] = useState(false);
const [isExporting, setIsExporting] = useState(false);
const [isSendingToAudioCove, setIsSendingToAudioCove] = useState(false);
const [audioCovedSuccess, setAudioCovedSuccess] = useState(false);
useEffect(() => {
const loadStoryData = async () => {
@@ -115,6 +117,22 @@ export default function StoryDetailPage() {
}
};
const handleSendToAudioCove = async () => {
if (!story || isSendingToAudioCove) return;
setIsSendingToAudioCove(true);
try {
await audioCoveApi.sendToAudioCove(story.id);
setAudioCovedSuccess(true);
setTimeout(() => setAudioCovedSuccess(false), 3000);
} catch (error: any) {
const message = error?.response?.data || 'Failed to send to AudioCove. Please try again.';
alert(message);
} finally {
setIsSendingToAudioCove(false);
}
};
const formatDate = (dateString: string) => {
return new Date(dateString).toLocaleDateString('en-US', {
year: 'numeric',
@@ -432,6 +450,14 @@ export default function StoryDetailPage() {
>
Edit Story
</Button>
<Button
onClick={handleSendToAudioCove}
variant="ghost"
size="lg"
disabled={isSendingToAudioCove || audioCovedSuccess}
>
{isSendingToAudioCove ? '🎧 Sending...' : audioCovedSuccess ? '✅ Sent!' : '🎧 Send to Audiocove'}
</Button>
</div>
</div>
</div>

View File

@@ -1164,6 +1164,13 @@ export const statisticsApi = {
},
};
export const audioCoveApi = {
sendToAudioCove: async (storyId: string): Promise<string> => {
const response = await api.post(`/stories/${storyId}/send-to-audiocove`);
return response.data;
},
};
// Image utility - now library-aware
export const getImageUrl = (path: string): string => {
if (!path) return '';