diff --git a/.env b/.env new file mode 100644 index 0000000..f1d46f2 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +NEXT_PUBLIC_API_KEY='sk-proj-axckbga92Xzt6DpWIIMBT3BlbkFJkZNo1QegEYwwd45bUcNe' diff --git a/src/app/page.tsx b/src/app/page.tsx index 4346f99..4309b5f 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,67 +1,180 @@ "use client"; import "regenerator-runtime/runtime"; -import Image from "next/image"; -import { IconVolume,IconFileUpload } from '@tabler/icons-react'; +import React, { useState, ChangeEvent } from "react"; +import { + IconCopy, + IconStar, + IconThumbDown, + IconThumbUp, + IconVolume, +} from "@tabler/icons-react"; +import SpeechRecognitionComponent from "@/components/Speech Recognition/SpeechRecognition"; +import TextArea from "@/components/Inputs/TextArea"; +import FileUpload from "@/components/Inputs/FileUpload"; +import LinkPaste from "@/components/Inputs/LinkPaste"; +import LanguageSelector from "@/components/Inputs/LanguageSelector"; +import useTranslate from "@/hooks/useTranslate"; +import { rtfToText } from "@/utils/rtfToText"; +import SvgDecorations from "@/components/SvgDecorations"; +import CategoryLinks from "@/components/categoryLinks"; -import React, {useState,ChangeEvent} from "react"; -import TextArea from '@/components/Inputs/TextArea'; -import SpeechRecognitionComponent from '@/components/Speech Recognition/SpeechRecognition'; +const Home: React.FC = () => { + const [sourceText, setSourceText] = useState(""); + const [copied, setCopied] = useState(false); + const [favorite, setFavorite] = useState(false); + const [languages] = useState([ + "English", + "Spanish", + "French", + "German", + "Chinese", + ]); + const [selectedLanguage, setSelectedLanguage] = useState("Spanish"); -export default function Home() { + const targetText = useTranslate(sourceText, selectedLanguage); - const [sourceText,setSourceText]=useState(""); - const handleAudioPlayback = (text:string) =>{ - const utterance=new SpeechSynthesisUtterance(text); + const handleFileUpload = (e: ChangeEvent) => { + const file = e.target.files?.[0]; + if (file) { + const reader = new FileReader(); + reader.onload = () => { + const rtfContent = reader.result as string; + const text = rtfToText(rtfContent); + setSourceText(text); + }; + reader.readAsText(file); + } + }; + + const handleLinkPaste = async (e: ChangeEvent) => { + const link = e.target.value; + try { + const response = await fetch(link); + const data = await response.text(); + setSourceText(data); + } catch (error) { + console.error("Error fetching link content:", error); + } + }; + + const handleCopyToClipboard = () => { + navigator.clipboard.writeText(targetText); + setCopied(true); + setTimeout(() => setCopied(false), 2000); + }; + + const handleLike = () => { + // Implement like logic + }; + + const handleDislike = () => { + // Implement dislike logic + }; + + const handleFavorite = () => { + setFavorite(!favorite); + if (!favorite) { + localStorage.setItem("favoriteTranslation", targetText); + } else { + localStorage.removeItem("favoriteTranslation"); + } + }; + + const handleAudioPlayback = (text: string) => { + const utterance = new SpeechSynthesisUtterance(text); window.speechSynthesis.speak(utterance); }; - return
+ + return (
-
+
+
-
+
-

Chit - Chat

-

- ChitChat: Bridging voices , connecting worlds -

- -
-
-
+

+ ChitChat +

+ +

+ ChitChat: Bridging Voices, Connecting Worlds. +

+ +
+
+