From e3954d7bed415d94837e5025b59bec5084929d69 Mon Sep 17 00:00:00 2001 From: Ebube Chuba Date: Wed, 6 Nov 2024 21:44:27 -0800 Subject: [PATCH 1/3] refactor: remove As type and replace with string union --- src/pages/components/UseCases/UseCaseCard.tsx | 4 ++-- src/pages/shared/useCases.ts | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/pages/components/UseCases/UseCaseCard.tsx b/src/pages/components/UseCases/UseCaseCard.tsx index 27b5b6ea..08c37aa4 100644 --- a/src/pages/components/UseCases/UseCaseCard.tsx +++ b/src/pages/components/UseCases/UseCaseCard.tsx @@ -1,4 +1,4 @@ -import { As, Box, Heading, HStack, Text, VStack } from '@chakra-ui/react'; +import { Box, Heading, HStack, Text, VStack } from '@chakra-ui/react'; const UseCaseCard = ({ label, @@ -8,7 +8,7 @@ const UseCaseCard = ({ flexDirection, }: { label: string, - as: As, + as: 'h1' | 'h2' | 'h3', description: string, image: string, flexDirection: 'row' | 'row-reverse', diff --git a/src/pages/shared/useCases.ts b/src/pages/shared/useCases.ts index d53aa1f8..db080a89 100644 --- a/src/pages/shared/useCases.ts +++ b/src/pages/shared/useCases.ts @@ -1,9 +1,7 @@ -import { As } from '@chakra-ui/react'; - const useCases = [ { label: 'Generate Subtitles', - as: 'h1' as As, + as: 'h1', description: 'Generate Igbo subtitles to reach more native speakers across the world. Perfect for content-producing teams.', image: @@ -11,7 +9,7 @@ const useCases = [ }, { label: 'Transcribe Conversations', - as: 'h1' as As, + as: 'h1', description: 'Convert Igbo speech into text, in real-time. Perfect for team capturing customer conversations like telehealth or insurance companies.', image: @@ -19,12 +17,12 @@ const useCases = [ }, { label: 'Build Language Learning Services', - as: 'h1' as As, + as: 'h1', description: 'Rely on the +25,000 Igbo words and +100,000 Igbo sentences to build experiences for language learners. Perfect for e-learning teams.', image: 'https://images.pexels.com/photos/27541898/pexels-photo-27541898/free-photo-of-drummers.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2', }, -]; +] as const; export default useCases; From 969def77bea27d17980ef1247a437e134f105ee1 Mon Sep 17 00:00:00 2001 From: Ebube Chuba Date: Wed, 6 Nov 2024 21:45:03 -0800 Subject: [PATCH 2/3] chore: share ts type --- src/pages/APIs/PredictionAPI.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pages/APIs/PredictionAPI.ts b/src/pages/APIs/PredictionAPI.ts index 12dbe537..5b9f5b77 100644 --- a/src/pages/APIs/PredictionAPI.ts +++ b/src/pages/APIs/PredictionAPI.ts @@ -2,15 +2,12 @@ import { useCallable } from '../../pages/hooks/useCallable'; import DemoOption from '../../shared/constants/DemoOption'; import LanguageEnum from '../../shared/constants/LanguageEnum'; import { OutgoingWord } from '../../types'; +import { Translation } from '../../controllers/translation'; export interface Prediction { transcription: string; } -export interface Translation { - translation: string; -} - export interface Dictionary { words: OutgoingWord[]; } From 3c27ebefb938f3aada92269714810420f7f106b2 Mon Sep 17 00:00:00 2001 From: Ebube Chuba Date: Wed, 6 Nov 2024 21:45:45 -0800 Subject: [PATCH 3/3] fix: correct translation response --- src/controllers/translation.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/translation.ts b/src/controllers/translation.ts index 2db9a14f..105104fe 100644 --- a/src/controllers/translation.ts +++ b/src/controllers/translation.ts @@ -17,7 +17,7 @@ const TranslationRequestBody = z }) .strict(); -interface Translation { +export interface Translation { translation: string; } @@ -73,7 +73,7 @@ export const getTranslation: MiddleWare = async (req, res, next) => { data: payload, }); - return res.send({ transcription: response.translation }); + return res.send({ translation: response.translation }); } catch (err) { return next(err); }