Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Saanvi51 committed Feb 4, 2025
1 parent ee95a9d commit a0fb94e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 39 deletions.
10 changes: 9 additions & 1 deletion fastapi/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
import requests
from pydantic import BaseModel
from bs4 import BeautifulSoup

from fastapi.middleware.cors import CORSMiddleware

app = FastAPI()

app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

class ArticleResponse(BaseModel):
article: str

Expand Down
41 changes: 3 additions & 38 deletions ui/src/components/TranslationSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ const TranslationSection = () => {
};
const [availableTranslationLanguages, setAvailableTranslationLanguages] = useState<SelectData<string>[]>([])
const [isLoading, setIsLoading] = useState(false)
const [articleContent, setArticleContent] = useState('');
const form = useForm<TranslationFormType>({
defaultValues: {
sourceArticleUrl: '',
Expand All @@ -147,10 +146,9 @@ const TranslationSection = () => {
setValue,
} = form

/*const onSubmit = useCallback(async (data: TranslationFormType) => {
const onSubmit = useCallback(async (data: TranslationFormType) => {
try {
setIsLoading(true)
const response = await fetchArticle({
translationTool,
deepLApiKey: APIKey,
Expand All @@ -162,32 +160,13 @@ const TranslationSection = () => {
Object.entries(response.data.articleLanguages).map(([key, value]) => ({
value,
label: key,
})))
})))
} catch (error) {
console.log(error)
} finally {
setIsLoading(false)
}
}, [setValue, translationTool, APIKey])*/

const onSubmit = useCallback(async (data: { sourceArticleUrl: string }) => {
try {
setIsLoading(true)

const mockResponse = {
title: 'Pizza',
content:
'Pizza is a popular Italian dish made of flattened bread dough topped with tomatoes, cheese, and other ingredients, baked in an oven.',
url: 'https://en.wikipedia.org/wiki/Pizza',
}
setArticleContent(mockResponse.content)
} catch (error) {
console.error('Error fetching article:', error)
} finally {
setIsLoading(false)
}
}, [])
}, [setValue, translationTool, APIKey])

const onLanguageChange = useCallback(async (translateArticleUrl: string) => {
try {
Expand Down Expand Up @@ -289,20 +268,6 @@ const TranslationSection = () => {
<TableCell>{text.editing}</TableCell>
</TableRow>
))}
{articleContent ? (
<TableRow>
<TableCell className="font-medium">{articleContent}</TableCell>
<TableCell className="font-medium">
Translation functionality is not implemented yet.
</TableCell>
</TableRow>
) : (
<TableRow>
<TableCell className="font-medium">No article content yet.</TableCell>
<TableCell className="font-medium">No translation available.</TableCell>
</TableRow>
)}

</TableBody>
</Table>

Expand Down

0 comments on commit a0fb94e

Please sign in to comment.