From a85ac53ba1b479365d3d948ec6a2aa2b5273331b Mon Sep 17 00:00:00 2001 From: Stephanie Gredell Date: Thu, 11 Dec 2025 15:36:09 -0800 Subject: [PATCH] add clear sounds button --- frontend/src/pages/SpeechSoundsAdminPage.tsx | 42 ++++++++++++++++++++ frontend/src/services/apiClient.ts | 5 +++ 2 files changed, 47 insertions(+) diff --git a/frontend/src/pages/SpeechSoundsAdminPage.tsx b/frontend/src/pages/SpeechSoundsAdminPage.tsx index 2938a78..134aabd 100644 --- a/frontend/src/pages/SpeechSoundsAdminPage.tsx +++ b/frontend/src/pages/SpeechSoundsAdminPage.tsx @@ -1,7 +1,31 @@ +import { useState } from 'react'; import { WordGroupManager } from '../components/WordGroupManager/WordGroupManager'; import { Link } from 'react-router-dom'; +import { speechSoundsApi } from '../services/apiClient'; export function SpeechSoundsAdminPage() { + const [clearingCache, setClearingCache] = useState(false); + const [cacheMessage, setCacheMessage] = useState(null); + + const handleClearCache = async () => { + if (!confirm('Are you sure you want to clear all cached pronunciations? Words will regenerate with new settings on next play.')) { + return; + } + + try { + setClearingCache(true); + setCacheMessage(null); + await speechSoundsApi.clearPronunciationsCache(); + setCacheMessage('Pronunciation cache cleared successfully!'); + setTimeout(() => setCacheMessage(null), 3000); + } catch (err: any) { + setCacheMessage(err.error?.message || 'Failed to clear cache'); + setTimeout(() => setCacheMessage(null), 5000); + } finally { + setClearingCache(false); + } + }; + return (
@@ -15,6 +39,24 @@ export function SpeechSoundsAdminPage() {

Manage word groups for speech sound practice

+
+ +
+ {cacheMessage && ( +
+ {cacheMessage} +
+ )}
diff --git a/frontend/src/services/apiClient.ts b/frontend/src/services/apiClient.ts index e2b2e6a..276c8e9 100644 --- a/frontend/src/services/apiClient.ts +++ b/frontend/src/services/apiClient.ts @@ -196,3 +196,8 @@ export const magicCodeApi = { getSettingsByCode: (code: string) => api.get(`/magic-code/${code}`) }; +// Speech Sounds API (admin only) +export const speechSoundsApi = { + clearPronunciationsCache: () => api.delete('/speech-sounds/cache') +}; +