shevadesuyash commited on
Commit
803d869
·
verified ·
1 Parent(s): 50ef454

Upload 55 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +7 -0
  2. src/App.jsx +49 -0
  3. src/api.js +64 -0
  4. src/assets/css/style.css +0 -0
  5. src/assets/img/11.jpeg +0 -0
  6. src/assets/img/4.jpeg +0 -0
  7. src/assets/img/5.jpeg +0 -0
  8. src/assets/img/6.jpeg +0 -0
  9. src/assets/img/7.png +3 -0
  10. src/assets/img/8.jpg +3 -0
  11. src/assets/img/8.png +0 -0
  12. src/assets/img/about-img.jpeg +0 -0
  13. src/assets/img/intro-carousel/1.jpg +3 -0
  14. src/assets/img/intro-carousel/2.jpeg +0 -0
  15. src/assets/img/intro-carousel/3.1.jpeg +0 -0
  16. src/assets/img/intro-carousel/3.jpeg +0 -0
  17. src/assets/img/intro-carousel/bg1.jpg +3 -0
  18. src/assets/img/team-1.jpeg +0 -0
  19. src/assets/img/team-2.jpeg +3 -0
  20. src/assets/img/team-3.jpeg +3 -0
  21. src/assets/img/team-4.jpeg +3 -0
  22. src/components/Layout/Footer.jsx +19 -0
  23. src/components/Layout/Header.jsx +65 -0
  24. src/components/Layout/Layout.jsx +17 -0
  25. src/components/Layout/TopBar.jsx +37 -0
  26. src/components/Sections/AboutSection.jsx +42 -0
  27. src/components/Sections/ChatbotSection.jsx +365 -0
  28. src/components/Sections/ContactSection.jsx +41 -0
  29. src/components/Sections/ErrorPopup.jsx +57 -0
  30. src/components/Sections/IntroSection.jsx +34 -0
  31. src/components/Sections/LoginSection.jsx +211 -0
  32. src/components/Sections/ModelSection.jsx +85 -0
  33. src/components/Sections/ParagraphChecker.jsx +156 -0
  34. src/components/Sections/ReviewSection.jsx +120 -0
  35. src/components/Sections/ServicesSection.jsx +99 -0
  36. src/components/Sections/Summariser.jsx +203 -0
  37. src/components/Sections/TeamSection.jsx +216 -0
  38. src/components/Sections/TranslationModule.jsx +320 -0
  39. src/components/Sections/VoiceInput.jsx +116 -0
  40. src/components/Sections/voiceUtils.js +29 -0
  41. src/components/Shared/ErrorBoundary.jsx +26 -0
  42. src/components/Shared/ProtectedRoute.jsx +19 -0
  43. src/components/Shared/PublicRoute.jsx +16 -0
  44. src/context/AuthContext.js +99 -0
  45. src/index.html +12 -0
  46. src/index.js +16 -0
  47. src/pages/ChatbotPage.jsx +9 -0
  48. src/pages/HomePage.jsx +20 -0
  49. src/pages/LoginPage.jsx +71 -0
  50. src/pages/ModelPage.jsx +9 -0
.gitattributes CHANGED
@@ -33,3 +33,10 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ src/assets/img/7.png filter=lfs diff=lfs merge=lfs -text
37
+ src/assets/img/8.jpg filter=lfs diff=lfs merge=lfs -text
38
+ src/assets/img/intro-carousel/1.jpg filter=lfs diff=lfs merge=lfs -text
39
+ src/assets/img/intro-carousel/bg1.jpg filter=lfs diff=lfs merge=lfs -text
40
+ src/assets/img/team-2.jpeg filter=lfs diff=lfs merge=lfs -text
41
+ src/assets/img/team-3.jpeg filter=lfs diff=lfs merge=lfs -text
42
+ src/assets/img/team-4.jpeg filter=lfs diff=lfs merge=lfs -text
src/App.jsx ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { lazy, Suspense } from "react";
2
+ import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
3
+ import Layout from "./components/Layout/Layout";
4
+ import HomePage from "./pages/HomePage";
5
+ import NotFoundPage from "./pages/NotFoundPage";
6
+ import ProtectedRoute from "./components/Shared/ProtectedRoute";
7
+ import { AuthProvider } from "./context/AuthContext";
8
+ import PublicRoute from "./components/Shared/PublicRoute";
9
+ import ErrorBoundary from "./components/Shared/ErrorBoundary";
10
+
11
+ const ModelPage = lazy(() => import("./pages/ModelPage"));
12
+ const TeamPage = lazy(() => import("./pages/TeamPage"));
13
+ const LoginPage = lazy(() => import("./pages/LoginPage"));
14
+ const RegisterPage = lazy(() => import("./pages/RegisterPage"));
15
+ const TranslationModulePage = lazy(
16
+ () => import("./pages/TranslationModulePage"),
17
+ );
18
+ const ParagraphCheckerPage = lazy(() => import("./pages/ParagraphCheckerPage"));
19
+ const ChatbotPage = lazy(() => import("./pages/ChatbotPage"));
20
+ const SummariserPage = lazy(() => import("./pages/SummariserPage"));
21
+
22
+ const App = () => {
23
+ return (
24
+ <AuthProvider>
25
+ <Router>
26
+ <ErrorBoundary>
27
+ <Layout>
28
+ <Suspense fallback={<div>Loading...</div>}>
29
+ <Routes>
30
+ <Route path="/" element={<HomePage />} />
31
+ <Route path="/model" element={<ModelPage />} />
32
+ <Route path="/team" element={<TeamPage />} />
33
+ <Route path="/login" element={<PublicRoute><LoginPage /></PublicRoute>} />
34
+ <Route path="/register" element={<PublicRoute><RegisterPage /></PublicRoute>} />
35
+ <Route path="/model/translator" element={<ProtectedRoute><TranslationModulePage /></ProtectedRoute>} />
36
+ <Route path="/model/grammar-check" element={<ProtectedRoute><ParagraphCheckerPage /></ProtectedRoute>} />
37
+ <Route path="/model/Chat-bot" element={<ProtectedRoute><ChatbotPage /></ProtectedRoute>} />
38
+ <Route path="/model/Summariser" element={<ProtectedRoute><SummariserPage/></ProtectedRoute>} />
39
+ <Route path="*" element={<NotFoundPage />} />
40
+ </Routes>
41
+ </Suspense>
42
+ </Layout>
43
+ </ErrorBoundary>
44
+ </Router>
45
+ </AuthProvider>
46
+ );
47
+ };
48
+
49
+ export default App;
src/api.js ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const BASE_URL = process.env.REACT_APP_BACKEND_URL || "http://localhost:8080";
2
+
3
+ const apiCall = async (
4
+ endpoint,
5
+ method = "GET",
6
+ data = null,
7
+ params = null,
8
+ ) => {
9
+ const token = localStorage.getItem("token");
10
+ const headers = {
11
+ "Content-Type": "application/json",
12
+ ...(token && { Authorization: `Bearer ${token}` }),
13
+ };
14
+
15
+ // For GET requests, we should use params, not body
16
+ let url = `${BASE_URL}${endpoint}`;
17
+ if (params || (method === "GET" && data)) {
18
+ const queryParams = new URLSearchParams(params || data).toString();
19
+ url += `?${queryParams}`;
20
+ }
21
+
22
+ const options = {
23
+ method,
24
+ headers,
25
+ ...(method !== "GET" && data && { body: JSON.stringify(data) }),
26
+ };
27
+ try {
28
+ const response = await fetch(url, options);
29
+
30
+ if (!response.ok) {
31
+ if (response.status === 401) {
32
+ localStorage.removeItem("token");
33
+ window.location.href = "/login";
34
+ }
35
+ const errorText = await response.text();
36
+ throw new Error(
37
+ errorText || `Request failed with status ${response.status}`,
38
+ );
39
+ }
40
+
41
+ return response.json();
42
+ } catch (error) {
43
+ console.error(`API Call Error: ${endpoint}`, error);
44
+ throw error;
45
+ }
46
+ };
47
+
48
+ export default {
49
+ register: (userData) => apiCall("/user/register", "POST", userData),
50
+ generateOtp: (email) => apiCall("/user/generateOtp", "POST", { email }),
51
+ login: (email, otp) => apiCall("/user/login", "POST", { email, otp }),
52
+ logout: () => apiCall("/user/logout", "POST"),
53
+ getUserProfile: (username) => apiCall(`/user/profile`, "GET", null, { username }),
54
+ submitReview: (reviewData) => apiCall("/user/review/submit", "POST", reviewData),
55
+ getAllReviews: () => apiCall("/user/review/all", "GET"),
56
+ createModel: () => apiCall("/model/create", "GET"),
57
+ sendMail: (emailData) => apiCall("/model/sendMail", "POST", emailData),
58
+ test: () => apiCall("/model/test", "GET"),
59
+ translate: (data) => apiCall("/model/translate", "POST", data),
60
+ grammarCheck: (data) => apiCall("/model/correct_text", "POST", data),
61
+ summarizeText: (data) => apiCall("/model/summarize", "POST", data),
62
+ startChat: (params) => apiCall("/model/start", "GET", null, params),
63
+ chatWithBot: (data) => apiCall("/model/chat", "POST", data),
64
+ };
src/assets/css/style.css ADDED
The diff for this file is too large to render. See raw diff
 
src/assets/img/11.jpeg ADDED
src/assets/img/4.jpeg ADDED
src/assets/img/5.jpeg ADDED
src/assets/img/6.jpeg ADDED
src/assets/img/7.png ADDED

Git LFS Details

  • SHA256: 552f4d354eeedb1f5adb002abf11dc78bd56bc3ee95315c5f9d4fb3bd3a859b9
  • Pointer size: 131 Bytes
  • Size of remote file: 144 kB
src/assets/img/8.jpg ADDED

Git LFS Details

  • SHA256: cfb76b1da2ade62dd4cc4f60f17d2ff19ef1ac4f87bb55b1c6a1b007dbba5e8e
  • Pointer size: 131 Bytes
  • Size of remote file: 100 kB
src/assets/img/8.png ADDED
src/assets/img/about-img.jpeg ADDED
src/assets/img/intro-carousel/1.jpg ADDED

Git LFS Details

  • SHA256: cfb76b1da2ade62dd4cc4f60f17d2ff19ef1ac4f87bb55b1c6a1b007dbba5e8e
  • Pointer size: 131 Bytes
  • Size of remote file: 100 kB
src/assets/img/intro-carousel/2.jpeg ADDED
src/assets/img/intro-carousel/3.1.jpeg ADDED
src/assets/img/intro-carousel/3.jpeg ADDED
src/assets/img/intro-carousel/bg1.jpg ADDED

Git LFS Details

  • SHA256: 2728fcd5ec0340ef8560c83cee698e04e9e96e2496fdd85fb4a4fb7ca05795f1
  • Pointer size: 131 Bytes
  • Size of remote file: 298 kB
src/assets/img/team-1.jpeg ADDED
src/assets/img/team-2.jpeg ADDED

Git LFS Details

  • SHA256: 3fc33b4cf46e4f0525e67cd80b4230552a83084176afbd85ade8405e060f284a
  • Pointer size: 131 Bytes
  • Size of remote file: 195 kB
src/assets/img/team-3.jpeg ADDED

Git LFS Details

  • SHA256: 14706d912164489abf19efb54437e80d2e2f4e720166dea47c2f47ee6ddc5f81
  • Pointer size: 131 Bytes
  • Size of remote file: 165 kB
src/assets/img/team-4.jpeg ADDED

Git LFS Details

  • SHA256: d413a156c7cb1bff024c67d824237b6120779779eb678c3903ca7db76c02525d
  • Pointer size: 131 Bytes
  • Size of remote file: 222 kB
src/components/Layout/Footer.jsx ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // src/components/Layout/Footer.jsx
2
+ import React from "react";
3
+ import "../../assets/css/style.css";
4
+
5
+ const Footer = () => {
6
+ return (
7
+ <footer>
8
+ <div className="container">
9
+ <div className="row">
10
+ <div className="col-lg-12 text-center">
11
+ <p>&copy; 2025 ConvoMate. All Rights Reserved.</p>
12
+ </div>
13
+ </div>
14
+ </div>
15
+ </footer>
16
+ );
17
+ };
18
+
19
+ export default Footer;
src/components/Layout/Header.jsx ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+ import { Link } from "react-router-dom";
3
+ import { useAuth } from "../../context/AuthContext"; // Import useAuth
4
+
5
+ const Header = () => {
6
+ const { authenticated, logout, authKey } = useAuth(); // Use authentication state and logout function
7
+
8
+ return (
9
+ <header id="header" key={authKey}>
10
+ <div className="container">
11
+ <div className="pull-left" id="logo">
12
+ <h1>
13
+ <Link to="/" className="scrollto">
14
+ Convo<span>Mate</span>
15
+ </Link>
16
+ </h1>
17
+ </div>
18
+ <nav id="nav-menu-container">
19
+ <ul className="nav-menu">
20
+ <li className="menu-active">
21
+ <Link to="/">Home</Link>
22
+ </li>
23
+ {authenticated ? (
24
+ <li id="logoutLink">
25
+ <button onClick={logout}>Logout</button>
26
+ </li>
27
+ ) : (
28
+ <li id="loginLink">
29
+ <Link to="/login">Login</Link>
30
+ </li>
31
+ )}
32
+ <li>
33
+ <Link to="/">About Us</Link>
34
+ </li>
35
+ <li>
36
+ <Link to="/Team">Team</Link>
37
+ </li>
38
+ <li className="menu-has-children">
39
+ <Link to="/model">Models</Link>
40
+ <ul>
41
+ <li>
42
+ <Link to="/model/Chat-bot">Chat-bot</Link>
43
+ </li>
44
+ <li>
45
+ <Link to="/model/translator">Translator</Link>
46
+ </li>
47
+ <li>
48
+ <Link to="/model/grammar-check">Paragraph Checker</Link>
49
+ </li>
50
+ <li>
51
+ <Link to="/model/Summariser">Text Summarizer</Link>
52
+ </li>
53
+ </ul>
54
+ </li>
55
+ <li>
56
+ <Link to="/">Contact</Link>
57
+ </li>
58
+ </ul>
59
+ </nav>
60
+ </div>
61
+ </header>
62
+ );
63
+ };
64
+
65
+ export default Header;
src/components/Layout/Layout.jsx ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+ import Header from "./Header";
3
+ import Footer from "./Footer";
4
+ import TopBar from "./TopBar";
5
+
6
+ const Layout = ({ children }) => {
7
+ return (
8
+ <div>
9
+ <TopBar />
10
+ <Header />
11
+ <main>{children}</main>
12
+ <Footer />
13
+ </div>
14
+ );
15
+ };
16
+
17
+ export default Layout;
src/components/Layout/TopBar.jsx ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+ import "font-awesome/css/font-awesome.min.css";
3
+
4
+ const TopBar = () => {
5
+ return (
6
+ <section id="topbar">
7
+ <div className="container">
8
+ <div className="contact-info">
9
+ <i className="fa fa-envelope-o"></i>
10
+ <a href="mailto:convomate.contact@gmail.com">
11
+ convomate.contact@gmail.com
12
+ </a>
13
+ <i className="fa fa-phone"></i> 9359782454
14
+ </div>
15
+ <div className="social-links">
16
+ <a href="https://www.facebook.com/" className="facebook">
17
+ <i className="fa fa-facebook"></i>
18
+ </a>
19
+ <a
20
+ href="https://www.instagram.com/accounts/login/?hl=en"
21
+ className="instagram"
22
+ >
23
+ <i className="fa fa-instagram"></i>
24
+ </a>
25
+ <a href="https://g.co/kgs/KxRpUCz" className="google-plus">
26
+ <i className="fa fa-google-plus"></i>
27
+ </a>
28
+ <a href="https://in.linkedin.com/" className="linkedin">
29
+ <i className="fa fa-linkedin"></i>
30
+ </a>
31
+ </div>
32
+ </div>
33
+ </section>
34
+ );
35
+ };
36
+
37
+ export default TopBar;
src/components/Sections/AboutSection.jsx ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+ import "../../assets/css/style.css";
3
+ import aboutImg from "../../assets/img/about-img.jpeg"; // Correct import for Webpack
4
+
5
+ const AboutSection = () => {
6
+ return (
7
+ <section id="about" className="wow fadeInUp">
8
+ <div className="container">
9
+ <div className="row">
10
+ <div className="col-lg-6 about-img">
11
+ <img src={aboutImg} alt="About" /> {/* Use the imported image */}
12
+ </div>
13
+
14
+ <div className="col-lg-6 content">
15
+ <h2>
16
+ "Communication – the human connection – is the key to personal and
17
+ career success."
18
+ </h2>
19
+
20
+ <ul>
21
+ <li>
22
+ <i className="ion-android-checkmark-circle"></i>
23
+ At Convomate, we believe in the power of meaningful
24
+ conversations to uplift your skills and enrich your journey of
25
+ self-improvement.
26
+ </li>
27
+ <li>
28
+ <i className="ion-android-checkmark-circle"></i>
29
+ Convomate is not just a platform; it's your companion in skill
30
+ development, ensuring that every conversation adds value to your
31
+ personal and professional journey.
32
+ </li>
33
+ </ul>
34
+ </div>
35
+ <br />
36
+ </div>
37
+ </div>
38
+ </section>
39
+ );
40
+ };
41
+
42
+ export default AboutSection;
src/components/Sections/ChatbotSection.jsx ADDED
@@ -0,0 +1,365 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useEffect, useRef } from "react";
2
+ import "font-awesome/css/font-awesome.min.css";
3
+ import "../../assets/css/style.css";
4
+ import api from "../../api";
5
+ import VoiceInput from "./VoiceInput";
6
+ import { loadVoices, getDefaultVoice } from "./voiceUtils";
7
+ import ErrorPopup from "./ErrorPopup";
8
+
9
+ const ChatbotSection = () => {
10
+ const [messages, setMessages] = useState([]);
11
+ const [inputText, setInputText] = useState("");
12
+ const [voices, setVoices] = useState([]);
13
+ const [selectedVoice, setSelectedVoice] = useState(null);
14
+ const [conversationStarted, setConversationStarted] = useState(false);
15
+ const [isLoading, setIsLoading] = useState(false);
16
+ const [error, setError] = useState("");
17
+ const conversationRef = useRef(null);
18
+
19
+ useEffect(() => {
20
+ const initializeVoices = async () => {
21
+ const loadedVoices = await loadVoices();
22
+ setVoices(loadedVoices);
23
+ setSelectedVoice(getDefaultVoice(loadedVoices));
24
+ };
25
+ initializeVoices();
26
+ }, []);
27
+
28
+ useEffect(() => {
29
+ if (conversationRef.current) {
30
+ conversationRef.current.scrollTop = conversationRef.current.scrollHeight;
31
+ }
32
+ }, [messages]);
33
+
34
+ const handleVoiceResult = (transcript) => {
35
+ setInputText((prevText) => prevText + (prevText ? " " : "") + transcript);
36
+ };
37
+
38
+ const handleClearInput = () => {
39
+ setInputText("");
40
+ };
41
+
42
+ const startConversation = async () => {
43
+ setIsLoading(true);
44
+ try {
45
+ const response = await api.startChat(
46
+ {},
47
+ {
48
+ headers: {
49
+ Authorization: `Bearer ${localStorage.getItem("jwtToken")}`,
50
+ },
51
+ },
52
+ );
53
+
54
+ if (response && response.next_question) {
55
+ setMessages([{ text: response.next_question, sender: "bot" }]);
56
+ setConversationStarted(true);
57
+ }
58
+ } catch (error) {
59
+ console.error("Error starting conversation:", error);
60
+ setError("Failed to start conversation. Please try again.");
61
+ } finally {
62
+ setIsLoading(false);
63
+ }
64
+ };
65
+
66
+ const handleSubmit = async (e) => {
67
+ e.preventDefault();
68
+ if (!inputText.trim()) return;
69
+
70
+ const userMessage = { text: inputText, sender: "user" };
71
+ setMessages((prev) => [...prev, userMessage]);
72
+ setInputText("");
73
+ setIsLoading(true);
74
+
75
+ try {
76
+ const response = await api.chatWithBot(
77
+ { message: inputText },
78
+ {
79
+ headers: {
80
+ Authorization: `Bearer ${localStorage.getItem("jwtToken")}`,
81
+ },
82
+ },
83
+ );
84
+
85
+ if (response) {
86
+ if (response.is_corrected) {
87
+ setMessages((prev) => [
88
+ ...prev,
89
+ {
90
+ text: `Correction: ${response.corrected_text}`,
91
+ sender: "bot",
92
+ isCorrection: true,
93
+ },
94
+ ]);
95
+ }
96
+
97
+ if (response.compliment) {
98
+ setMessages((prev) => [
99
+ ...prev,
100
+ { text: response.compliment, sender: "bot", isCompliment: true },
101
+ ]);
102
+ }
103
+
104
+ if (response.next_question) {
105
+ setMessages((prev) => [
106
+ ...prev,
107
+ { text: response.next_question, sender: "bot" },
108
+ ]);
109
+ }
110
+ }
111
+ } catch (error) {
112
+ console.error("Error in chat:", error);
113
+ setMessages((prev) => [
114
+ ...prev,
115
+ {
116
+ text: "Sorry, there was an error processing your message.",
117
+ sender: "bot",
118
+ isError: true,
119
+ },
120
+ ]);
121
+ setError("An error occurred while sending your message.");
122
+ } finally {
123
+ setIsLoading(false);
124
+ }
125
+ };
126
+
127
+ const handleTextToSpeech = (text) => {
128
+ if (!selectedVoice) return;
129
+
130
+ const synth = window.speechSynthesis;
131
+ synth.cancel();
132
+
133
+ const utterance = new SpeechSynthesisUtterance(text);
134
+ utterance.voice = selectedVoice;
135
+ utterance.lang = "en-US";
136
+ synth.speak(utterance);
137
+ };
138
+
139
+ const handleClosePopup = () => {
140
+ setError("");
141
+ };
142
+
143
+ return (
144
+ <div
145
+ className="chatbot-container"
146
+ style={{ maxWidth: "800px", margin: "0 auto" }}
147
+ >
148
+ <h2 style={{ textAlign: "center", width: "75%" }}>Chat-bot Chat</h2>
149
+
150
+ {error && <ErrorPopup message={error} onClose={handleClosePopup} />}
151
+
152
+ <div
153
+ id="chatbot"
154
+ style={{
155
+ border: "1px solid #ccc",
156
+ borderRadius: "10px",
157
+ padding: "20px",
158
+ backgroundColor: "#fdfdfd",
159
+ }}
160
+ >
161
+ <div
162
+ id="conversation"
163
+ ref={conversationRef}
164
+ style={{
165
+ height: "400px",
166
+ overflowY: "auto",
167
+ padding: "10px",
168
+ border: "1px solid #ddd",
169
+ background: "#fff",
170
+ borderRadius: "8px",
171
+ marginBottom: "10px",
172
+ }}
173
+ >
174
+ {!conversationStarted && messages.length === 0 && (
175
+ <div
176
+ className="start-conversation-prompt"
177
+ style={{ textAlign: "center", padding: "20px", color: "#666" }}
178
+ >
179
+ <p>Click "Start Conversation" to begin chatting with the bot</p>
180
+ </div>
181
+ )}
182
+
183
+ {messages.map((message, index) => (
184
+ <div
185
+ key={index}
186
+ className={`chatbot-message ${message.sender}`}
187
+ style={{
188
+ display: "flex",
189
+ justifyContent:
190
+ message.sender === "user" ? "flex-end" : "flex-start",
191
+ marginBottom: "10px",
192
+ }}
193
+ >
194
+ <div
195
+ className={`message-bubble ${message.sender}
196
+ ${message.isCorrection ? "correction" : ""}
197
+ ${message.isCompliment ? "compliment" : ""}
198
+ ${message.isError ? "error" : ""}`}
199
+ >
200
+ <p
201
+ style={{
202
+ margin: 0,
203
+ whiteSpace: "pre-wrap",
204
+ wordBreak: "break-word",
205
+ display: "inline",
206
+ }}
207
+ >
208
+ {Array.isArray(message.text)
209
+ ? message.text.join("")
210
+ : String(message.text)}
211
+ </p>
212
+
213
+ {message.sender === "bot" && (
214
+ <button
215
+ className="speaker-button"
216
+ onClick={() => handleTextToSpeech(message.text)}
217
+ style={{
218
+ background: "transparent",
219
+ border: "none",
220
+ position: "absolute",
221
+ bottom: "5px",
222
+ right: "10px",
223
+ cursor: "pointer",
224
+ color: message.isCorrection
225
+ ? "#ffc107"
226
+ : message.isCompliment
227
+ ? "#28a745"
228
+ : message.isError
229
+ ? "#dc3545"
230
+ : "#000",
231
+ }}
232
+ >
233
+ <i className="fa fa-volume-up"></i>
234
+ </button>
235
+ )}
236
+ </div>
237
+ </div>
238
+ ))}
239
+
240
+ {isLoading && (
241
+ <div style={{ textAlign: "center", padding: "10px" }}>
242
+ <div className="spinner-border text-primary" role="status">
243
+ <span className="sr-only">Loading...</span>
244
+ </div>
245
+ </div>
246
+ )}
247
+ </div>
248
+
249
+ {!conversationStarted ? (
250
+ <div style={{ textAlign: "center" }}>
251
+ <button
252
+ onClick={startConversation}
253
+ disabled={isLoading}
254
+ style={{
255
+ backgroundColor: "#28a745",
256
+ border: "none",
257
+ color: "#fff",
258
+ padding: "10px 20px",
259
+ borderRadius: "20px",
260
+ cursor: "pointer",
261
+ fontSize: "16px",
262
+ }}
263
+ >
264
+ {isLoading ? "Starting..." : "Start Conversation"}
265
+ </button>
266
+ </div>
267
+ ) : (
268
+ <form
269
+ id="input-form"
270
+ onSubmit={handleSubmit}
271
+ style={{
272
+ display: "flex",
273
+ gap: "8px",
274
+ alignItems: "center",
275
+ flexWrap: "wrap",
276
+ }}
277
+ >
278
+ <input
279
+ id="input-field"
280
+ type="text"
281
+ placeholder="Type your message here"
282
+ value={inputText}
283
+ onChange={(e) => setInputText(e.target.value)}
284
+ style={{
285
+ flexGrow: 1,
286
+ padding: "10px",
287
+ borderRadius: "20px",
288
+ border: "1px solid #ccc",
289
+ outline: "none",
290
+ }}
291
+ />
292
+
293
+ <VoiceInput
294
+ onResult={handleVoiceResult}
295
+ disabled={isLoading}
296
+ buttonStyle={{ marginRight: "8px" }}
297
+ />
298
+
299
+ <button
300
+ type="button"
301
+ onClick={handleClearInput}
302
+ disabled={isLoading}
303
+ className="clear-button"
304
+ style={{
305
+ backgroundColor: "#6c757d",
306
+ border: "none",
307
+ color: "#fff",
308
+ padding: "10px 15px",
309
+ borderRadius: "5px",
310
+ cursor: "pointer",
311
+ marginRight: "8px",
312
+ }}
313
+ >
314
+ Clear
315
+ </button>
316
+
317
+ <button
318
+ id="submit-button"
319
+ type="submit"
320
+ disabled={isLoading}
321
+ style={{
322
+ backgroundColor: "#007bff",
323
+ border: "none",
324
+ color: "#fff",
325
+ padding: "10px 15px",
326
+ borderRadius: "50%",
327
+ cursor: "pointer",
328
+ }}
329
+ >
330
+ <i className="fa fa-paper-plane"></i>
331
+ </button>
332
+
333
+ <select
334
+ title="Select Voice"
335
+ value={selectedVoice ? selectedVoice.name : ""}
336
+ onChange={(e) => {
337
+ const voice = voices.find((v) => v.name === e.target.value);
338
+ setSelectedVoice(voice);
339
+ }}
340
+ disabled={isLoading}
341
+ style={{
342
+ padding: "6px 8px",
343
+ borderRadius: "10px",
344
+ fontSize: "0.85rem",
345
+ border: "1px solid #ccc",
346
+ maxWidth: "180px",
347
+ whiteSpace: "nowrap",
348
+ overflow: "hidden",
349
+ textOverflow: "ellipsis",
350
+ }}
351
+ >
352
+ {voices.map((voice) => (
353
+ <option key={voice.name} value={voice.name}>
354
+ {voice.name} ({voice.lang})
355
+ </option>
356
+ ))}
357
+ </select>
358
+ </form>
359
+ )}
360
+ </div>
361
+ </div>
362
+ );
363
+ };
364
+
365
+ export default ChatbotSection;
src/components/Sections/ContactSection.jsx ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+
3
+ import "../../assets/css/style.css";
4
+ const ContactSection = () => {
5
+ return (
6
+ <section id="contact">
7
+ <div className="container11">
8
+ <div className="section-header">
9
+ <h2>Contact Us</h2>
10
+ </div>
11
+ <div className="row contact-info">
12
+ <div className="col-md-4">
13
+ <div className="contact-address">
14
+ <i className="ion-ios-location-outline"></i>
15
+ <h3>Address</h3>
16
+ <address>
17
+ <b>NCER, Talegaon Dabhade</b>
18
+ </address>
19
+ </div>
20
+ </div>
21
+ <div className="col-md-4">
22
+ <div className="contact-phone">
23
+ <i className="ion-ios-telephone-outline"></i>
24
+ <h3>Phone Number</h3>
25
+ <a href="tel:+155895548855">9359782454</a>
26
+ </div>
27
+ </div>
28
+ <div className="col-md-4">
29
+ <div className="contact-email">
30
+ <i className="ion-ios-email-outline"></i>
31
+ <h3>Email</h3>
32
+ <a href="mailto:info@example.com">convomate@star.com</a>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ </div>
37
+ </section>
38
+ );
39
+ };
40
+
41
+ export default ContactSection;
src/components/Sections/ErrorPopup.jsx ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+
3
+ const ErrorPopup = ({ message, onClose }) => {
4
+ if (!message) return null;
5
+
6
+ return (
7
+ <>
8
+ <style>{`
9
+ .error-popup-overlay {
10
+ position: fixed;
11
+ top: 0;
12
+ left: 0;
13
+ width: 100%;
14
+ height: 100%;
15
+ background: rgba(0,0,0,0.4);
16
+ display: flex;
17
+ align-items: center;
18
+ justify-content: center;
19
+ z-index: 999;
20
+ }
21
+
22
+ .error-popup {
23
+ background: white;
24
+ padding: 20px 30px;
25
+ border-radius: 10px;
26
+ max-width: 400px;
27
+ text-align: center;
28
+ box-shadow: 0 0 20px rgba(0,0,0,0.3);
29
+ }
30
+
31
+ .error-popup button {
32
+ margin-top: 15px;
33
+ background-color: #dc3545;
34
+ color: white;
35
+ border: none;
36
+ padding: 8px 16px;
37
+ border-radius: 8px;
38
+ cursor: pointer;
39
+ }
40
+
41
+ .error-popup button:hover {
42
+ background-color: #c82333;
43
+ }
44
+ `}</style>
45
+
46
+ <div className="error-popup-overlay">
47
+ <div className="error-popup">
48
+ <h3>⚠️ Something went wrong</h3>
49
+ <p>{message}</p>
50
+ <button onClick={onClose}>Close</button>
51
+ </div>
52
+ </div>
53
+ </>
54
+ );
55
+ };
56
+
57
+ export default ErrorPopup;
src/components/Sections/IntroSection.jsx ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+ import { Link } from "react-router-dom";
3
+ import "../../assets/css/style.css";
4
+ import introImage from "../../assets/img/4.jpeg"; // Import the image
5
+
6
+ const IntroSection = () => {
7
+ return (
8
+ <section id="intro">
9
+ {/* Image Section (Moved to Left) */}
10
+ <div className="intro-image">
11
+ <img src={introImage} alt="AI Voice Bot" />
12
+ </div>
13
+
14
+ {/* Text Content (Moved to Right) */}
15
+ <div className="intro-content">
16
+ <h2>
17
+ An AI for,
18
+ <br />
19
+ <span>Better</span> Communication
20
+ </h2>
21
+ <div>
22
+ <Link to="/model" className="btn-get-started scrollto">
23
+ Get Started
24
+ </Link>
25
+ <Link to="/model" className="btn-projects scrollto">
26
+ Our Models
27
+ </Link>
28
+ </div>
29
+ </div>
30
+ </section>
31
+ );
32
+ };
33
+
34
+ export default IntroSection;
src/components/Sections/LoginSection.jsx ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+ import bgImage from "../../assets/img/intro-carousel/bg1.jpg";
3
+
4
+ const LoginSection = ({
5
+ email,
6
+ setEmail,
7
+ otp,
8
+ setOtp,
9
+ otpSent,
10
+ timer,
11
+ error,
12
+ loading,
13
+ handleGenerateOtp,
14
+ handleResendOtp,
15
+ handleSubmit,
16
+ }) => {
17
+ return (
18
+ <div style={styles.container}>
19
+ {/* Central Error Popup */}
20
+ {error && (
21
+ <div
22
+ style={{
23
+ ...styles.popup,
24
+ backgroundColor: error.includes("success") ? "#4CAF50" : "#f44336", // Green if success, Red if failure
25
+ }}
26
+ >
27
+ <p style={styles.popupText}>{error}</p>
28
+ </div>
29
+ )}
30
+
31
+ <div style={styles.formContainer}>
32
+ <div style={styles.headingContainer}>
33
+ <h2 style={styles.heading}>Login</h2>
34
+ </div>
35
+
36
+ <form onSubmit={handleSubmit} style={styles.form}>
37
+ {/* Email Input */}
38
+ <div style={styles.inputGroup}>
39
+ <label htmlFor="email" style={styles.label}>
40
+ Email
41
+ </label>
42
+ <input
43
+ type="email"
44
+ id="email"
45
+ name="email"
46
+ placeholder="Enter your email"
47
+ value={email}
48
+ onChange={(e) => setEmail(e.target.value)}
49
+ required
50
+ disabled={loading}
51
+ style={styles.input}
52
+ />
53
+ </div>
54
+
55
+ {/* Send OTP Button */}
56
+ {!otpSent && (
57
+ <button
58
+ type="button"
59
+ onClick={handleGenerateOtp}
60
+ disabled={loading}
61
+ style={styles.button}
62
+ >
63
+ {loading ? "Sending..." : "Send OTP"}
64
+ </button>
65
+ )}
66
+
67
+ {/* OTP Input and Buttons */}
68
+ {otpSent && (
69
+ <>
70
+ <div style={styles.inputGroup}>
71
+ <label htmlFor="otp" style={styles.label}>
72
+ OTP
73
+ </label>
74
+ <input
75
+ type="text"
76
+ id="otp"
77
+ name="otp"
78
+ placeholder="Enter OTP"
79
+ value={otp}
80
+ onChange={(e) => setOtp(e.target.value)}
81
+ required
82
+ disabled={loading}
83
+ style={styles.input}
84
+ />
85
+ </div>
86
+
87
+ <button
88
+ type="button"
89
+ onClick={handleResendOtp}
90
+ disabled={timer > 0 || loading}
91
+ style={{
92
+ ...styles.button,
93
+ backgroundColor: "#6c757d",
94
+ marginTop: "10px",
95
+ }}
96
+ >
97
+ Resend OTP {timer > 0 ? `(${timer}s)` : ""}
98
+ </button>
99
+
100
+ <button
101
+ type="submit"
102
+ disabled={loading}
103
+ style={{ ...styles.button, marginTop: "10px" }}
104
+ >
105
+ {loading ? "Submitting..." : "Submit OTP"}
106
+ </button>
107
+ </>
108
+ )}
109
+
110
+ <p style={styles.registerText}>
111
+ Not registered?{" "}
112
+ <a href="/register" style={styles.link}>
113
+ Register/Signup here
114
+ </a>
115
+ </p>
116
+ </form>
117
+ </div>
118
+ </div>
119
+ );
120
+ };
121
+
122
+ /* Styles */
123
+ const styles = {
124
+ container: {
125
+ display: "flex",
126
+ justifyContent: "center",
127
+ alignItems: "center",
128
+ height: "100vh",
129
+ backgroundImage: `url(${bgImage})`,
130
+ backgroundSize: "cover",
131
+ backgroundPosition: "center",
132
+ backgroundRepeat: "no-repeat",
133
+ position: "relative",
134
+ },
135
+ popup: {
136
+ position: "absolute",
137
+ top: "20px",
138
+ left: "50%",
139
+ transform: "translateX(-50%)",
140
+ backgroundColor: "#f44336", //Default red color, will be overridden by condition
141
+ color: "white",
142
+ padding: "10px 20px",
143
+ borderRadius: "8px",
144
+ zIndex: 1000,
145
+ boxShadow: "0px 4px 12px rgba(0, 0, 0, 0.2)",
146
+ fontWeight: "bold",
147
+ },
148
+ popupText: {
149
+ margin: 0,
150
+ },
151
+ formContainer: {
152
+ backgroundColor: "white",
153
+ padding: "30px",
154
+ borderRadius: "10px",
155
+ boxShadow: "0 4px 8px rgba(0, 0, 0, 0.1)",
156
+ width: "400px",
157
+ display: "flex",
158
+ flexDirection: "column",
159
+ },
160
+ headingContainer: {
161
+ display: "flex",
162
+ justifyContent: "flex-start",
163
+ marginBottom: "20px",
164
+ },
165
+ heading: {
166
+ fontSize: "24px",
167
+ fontWeight: "bold",
168
+ color: "#5DDAB4",
169
+ },
170
+ form: {
171
+ display: "flex",
172
+ flexDirection: "column",
173
+ },
174
+ inputGroup: {
175
+ marginBottom: "20px",
176
+ },
177
+ label: {
178
+ fontSize: "14px",
179
+ fontWeight: "bold",
180
+ marginBottom: "8px",
181
+ display: "block",
182
+ },
183
+ input: {
184
+ width: "100%",
185
+ padding: "12px",
186
+ fontSize: "16px",
187
+ border: "1px solid #ddd",
188
+ borderRadius: "5px",
189
+ marginTop: "5px",
190
+ },
191
+ button: {
192
+ padding: "12px",
193
+ backgroundColor: "#033452",
194
+ color: "white",
195
+ border: "none",
196
+ borderRadius: "5px",
197
+ cursor: "pointer",
198
+ marginTop: "15px",
199
+ },
200
+ registerText: {
201
+ textAlign: "center",
202
+ marginTop: "20px",
203
+ },
204
+ link: {
205
+ color: "#007bff",
206
+ textDecoration: "none",
207
+ fontWeight: "bold",
208
+ },
209
+ };
210
+
211
+ export default LoginSection;
src/components/Sections/ModelSection.jsx ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+ import { Link } from "react-router-dom";
3
+ import Image6 from "../../assets/img/6.jpeg";
4
+ import Image7 from "../../assets/img/7.png";
5
+ import Image8 from "../../assets/img/8.png";
6
+ import Image11 from "../../assets/img/11.jpeg";
7
+ import bgImage from "../../assets/img/intro-carousel/bg1.jpg"; // Adjust the path as per your folder structure
8
+
9
+ const ModelSection = () => {
10
+ return (
11
+ <section id="intro11">
12
+ <div className="intro-content">
13
+ <div className="container" style={{ textAlign: "center" }}>
14
+ <div className="row">
15
+ {/* First Image Column */}
16
+ <div className="col-lg-6">
17
+ <img
18
+ alt="Second Image"
19
+ src={Image7}
20
+ style={{ width: "50%", height: "70" }}
21
+ />
22
+ <br />
23
+ <br />
24
+ <button className="btn btn-primary">
25
+ <Link to="/model/grammar-check" style={{ color: "black" }}>
26
+ Grammar Checker{" "}
27
+ </Link>
28
+ </button>
29
+ </div>
30
+
31
+ {/* Second Image Column */}
32
+ <div className="col-lg-6">
33
+ <img
34
+ alt="First Image"
35
+ src={Image11}
36
+ style={{ width: "50%", height: "70%" }}
37
+ />
38
+ <br />
39
+ <br />
40
+ <button className="btn btn-primary">
41
+ <Link to="/model/Chat-bot" style={{ color: "black" }}>
42
+ ConvoMate Chatbot{" "}
43
+ </Link>
44
+ </button>
45
+ </div>
46
+
47
+ {/* Third Image Column */}
48
+ <div className="col-lg-6">
49
+ <img
50
+ alt="Third Image"
51
+ src={Image8}
52
+ style={{ width: "50%", height: "70%" }}
53
+ />
54
+ <br />
55
+ <br />
56
+ <button className="btn btn-primary">
57
+ <Link to="/model/translator" style={{ color: "black" }}>
58
+ Language translator
59
+ </Link>
60
+ </button>
61
+ </div>
62
+
63
+ {/* Fourth Image Column */}
64
+ <div className="col-lg-6">
65
+ <img
66
+ alt="Fourth Image"
67
+ src={Image6}
68
+ style={{ width: "50%", height: "70%" }}
69
+ />
70
+ <br />
71
+ <br />
72
+ <button className="btn btn-primary">
73
+ <Link to="/model/Summariser" style={{ color: "black" }}>
74
+ Text Summarizer{" "}
75
+ </Link>
76
+ </button>
77
+ </div>
78
+ </div>
79
+ </div>
80
+ </div>
81
+ </section>
82
+ );
83
+ };
84
+
85
+ export default ModelSection;
src/components/Sections/ParagraphChecker.jsx ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from "react";
2
+ import api from "../../api";
3
+ import { diffWords } from "diff";
4
+ import "../../assets/css/style.css";
5
+ import VoiceInput from "./VoiceInput";
6
+ import ErrorPopup from "./ErrorPopup";
7
+
8
+ const ParagraphChecker = () => {
9
+ const [inputText, setInputText] = useState("");
10
+ const [correctedText, setCorrectedText] = useState("");
11
+ const [loading, setLoading] = useState(false);
12
+ const [error, setError] = useState("");
13
+ const [highlightedOriginal, setHighlightedOriginal] = useState("");
14
+ const [highlightedCorrected, setHighlightedCorrected] = useState("");
15
+
16
+ const token = localStorage.getItem("jwtToken");
17
+
18
+ const handleGrammarCheck = async () => {
19
+ if (!inputText.trim()) {
20
+ setError("Please enter text to check.");
21
+ return;
22
+ }
23
+ setError("");
24
+ setLoading(true);
25
+ setCorrectedText("");
26
+ setHighlightedOriginal("");
27
+ setHighlightedCorrected("");
28
+
29
+ try {
30
+ const response = await api.grammarCheck(
31
+ { paragraph: inputText },
32
+ { headers: { Authorization: `Bearer ${token}` } },
33
+ );
34
+
35
+ if (response && response.grammar_corrected) {
36
+ setCorrectedText(response.grammar_corrected);
37
+ highlightDifferences(inputText, response.grammar_corrected);
38
+ } else {
39
+ setError("No corrected text found.");
40
+ }
41
+ } catch (err) {
42
+ setError(err.message || "Something went wrong.");
43
+ } finally {
44
+ setLoading(false);
45
+ }
46
+ };
47
+
48
+ const highlightDifferences = (original, corrected) => {
49
+ if (!original || !corrected) return;
50
+
51
+ const differences = diffWords(original, corrected);
52
+
53
+ const originalHighlighted = differences.map((part, index) => {
54
+ if (part.removed) {
55
+ return (
56
+ <span
57
+ key={index}
58
+ style={{ color: "red", textDecoration: "line-through" }}
59
+ >
60
+ {part.value}
61
+ </span>
62
+ );
63
+ }
64
+ return part.added ? null : (
65
+ <span key={index} style={{ color: "black" }}>
66
+ {part.value}
67
+ </span>
68
+ );
69
+ });
70
+
71
+ const correctedHighlighted = differences.map((part, index) => {
72
+ if (part.added) {
73
+ return (
74
+ <span key={index} style={{ color: "green" }}>
75
+ {part.value}
76
+ </span>
77
+ );
78
+ }
79
+ return part.removed ? null : (
80
+ <span key={index} style={{ color: "black" }}>
81
+ {part.value}
82
+ </span>
83
+ );
84
+ });
85
+
86
+ setHighlightedOriginal(originalHighlighted);
87
+ setHighlightedCorrected(correctedHighlighted);
88
+ };
89
+
90
+ const handleClearText = () => {
91
+ setInputText("");
92
+ setCorrectedText("");
93
+ setHighlightedOriginal("");
94
+ setHighlightedCorrected("");
95
+ setError("");
96
+ };
97
+
98
+ const handleVoiceResult = (transcript) => {
99
+ setInputText(transcript);
100
+ };
101
+
102
+ const handleClosePopup = () => {
103
+ setError("");
104
+ };
105
+
106
+ return (
107
+ <div className="grammar-checker-container">
108
+ <h2>Paragraph Grammar Checker</h2>
109
+ <div className="text-area-row">
110
+ <div className="input-section-3">
111
+ <h3 className="box-title1">Input Text</h3>
112
+ <textarea
113
+ className="input-textarea-3"
114
+ placeholder="Type your paragraph here..."
115
+ value={inputText}
116
+ onChange={(e) => setInputText(e.target.value)}
117
+ />
118
+ </div>
119
+
120
+ <div className="output-section-3">
121
+ <h3 className="box-title2">Corrected Text</h3>
122
+ <div className="output-display-3">
123
+ {highlightedCorrected.length > 0
124
+ ? highlightedCorrected
125
+ : correctedText || "Corrected text will appear here..."}
126
+ </div>
127
+ </div>
128
+ </div>
129
+
130
+ <div className="controls">
131
+ {error && <ErrorPopup message={error} onClose={handleClosePopup} />}
132
+
133
+ {/* 🎯 Buttons all in one row */}
134
+ <div className="checker-button-row">
135
+ <VoiceInput
136
+ onResult={handleVoiceResult}
137
+ language="en-US"
138
+ buttonStyle={{}}
139
+ />
140
+ <button
141
+ onClick={handleGrammarCheck}
142
+ disabled={loading}
143
+ className="checker-correct-button"
144
+ >
145
+ {loading ? "Checking..." : "Correct"}
146
+ </button>
147
+ <button onClick={handleClearText} className="checker-clear-button">
148
+ Clear
149
+ </button>
150
+ </div>
151
+ </div>
152
+ </div>
153
+ );
154
+ };
155
+
156
+ export default ParagraphChecker;
src/components/Sections/ReviewSection.jsx ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from "react";
2
+ import api from "../../api";
3
+
4
+ const ReviewSection = () => {
5
+ const [formData, setFormData] = useState({
6
+ name: "",
7
+ email: "",
8
+ subject: "",
9
+ message: "",
10
+ });
11
+ const [error, setError] = useState("");
12
+ const [loading, setLoading] = useState(false);
13
+
14
+ const handleSubmit = async (e) => {
15
+ e.preventDefault();
16
+ setLoading(true);
17
+ setError("");
18
+ try {
19
+ await api.submitReview(formData);
20
+ alert("Review submitted successfully!");
21
+ setFormData({ name: "", email: "", subject: "", message: "" }); // Reset form
22
+ } catch (err) {
23
+ setError(err.message || "Failed to submit review.");
24
+ } finally {
25
+ setLoading(false);
26
+ }
27
+ };
28
+
29
+ return (
30
+ <section id="contact1">
31
+ <div className="container11">
32
+ <div className="section-header">
33
+ <h2>Review</h2>
34
+ </div>
35
+ <div className="form">
36
+ {error && <div className="alert alert-danger">{error}</div>}
37
+ <form
38
+ onSubmit={handleSubmit}
39
+ className="contactForm"
40
+ method="post"
41
+ role="form"
42
+ >
43
+ <div className="form-row">
44
+ <div className="form-group col-md-6">
45
+ <input
46
+ className="form-control"
47
+ id="name"
48
+ name="name"
49
+ placeholder="Your Name"
50
+ type="text"
51
+ value={formData.name}
52
+ onChange={(e) =>
53
+ setFormData({ ...formData, name: e.target.value })
54
+ }
55
+ disabled={loading}
56
+ />
57
+ <div className="validation"></div>
58
+ </div>
59
+ <div className="form-group col-md-6">
60
+ <input
61
+ className="form-control"
62
+ id="email"
63
+ name="email"
64
+ placeholder="Your Email"
65
+ type="email"
66
+ value={formData.email}
67
+ onChange={(e) =>
68
+ setFormData({ ...formData, email: e.target.value })
69
+ }
70
+ disabled={loading}
71
+ />
72
+ <div className="validation"></div>
73
+ </div>
74
+ </div>
75
+ <div className="form-group">
76
+ <input
77
+ className="form-control"
78
+ id="subject"
79
+ name="subject"
80
+ placeholder="Subject"
81
+ type="text"
82
+ value={formData.subject}
83
+ onChange={(e) =>
84
+ setFormData({ ...formData, subject: e.target.value })
85
+ }
86
+ disabled={loading}
87
+ />
88
+ <div className="validation"></div>
89
+ </div>
90
+ <div className="form-group">
91
+ <textarea
92
+ className="form-control"
93
+ name="message"
94
+ placeholder="Message"
95
+ rows="5"
96
+ value={formData.message}
97
+ onChange={(e) =>
98
+ setFormData({ ...formData, message: e.target.value })
99
+ }
100
+ disabled={loading}
101
+ />
102
+ <div className="validation"></div>
103
+ </div>
104
+ <div className="text-center">
105
+ <button
106
+ type="submit"
107
+ disabled={loading}
108
+ className="submit-button"
109
+ >
110
+ {loading ? "Submitting..." : "Submit"}
111
+ </button>
112
+ </div>
113
+ </form>
114
+ </div>
115
+ </div>
116
+ </section>
117
+ );
118
+ };
119
+
120
+ export default ReviewSection;
src/components/Sections/ServicesSection.jsx ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+
3
+ const ServicesSection = () => {
4
+ return (
5
+ <section id="services">
6
+ <div className="container11">
7
+ <div className="section-header">
8
+ <h2>Services</h2>
9
+ <p>Following are the services provided by our Convomate!</p>
10
+ </div>
11
+
12
+ <div className="row">
13
+ <div className="col-lg-6 mb-4">
14
+ {" "}
15
+ {/* Added mb-4 for spacing */}
16
+ <div className="box wow fadeInLeft">
17
+ <div className="icon">
18
+ <i className="fa fa-check-square-o"></i>
19
+ </div>{" "}
20
+ {/* Changed icon */}
21
+ <h4 className="title">
22
+ <a href="#">Grammar Checker</a>
23
+ </h4>{" "}
24
+ {/* Updated title */}
25
+ <p className="description">
26
+ Ensure your writing is clear and error-free. This tool helps you
27
+ identify and correct grammatical mistakes, spelling errors, and
28
+ punctuation issues in your text.
29
+ </p>{" "}
30
+ {/* Updated description */}
31
+ </div>
32
+ </div>
33
+ <div className="col-lg-6 mb-4">
34
+ {" "}
35
+ {/* Added mb-4 for spacing */}
36
+ <div className="box wow fadeInRight">
37
+ <div className="icon">
38
+ <i className="fa fa-commenting-o"></i>
39
+ </div>{" "}
40
+ {/* Changed icon */}
41
+ <h4 className="title">
42
+ <a href="#">ConvoMate Chatbot</a>
43
+ </h4>{" "}
44
+ {/* Updated title */}
45
+ <p className="description">
46
+ Engage in natural and helpful conversations. This chatbot can
47
+ understand your queries, provide information, and assist you
48
+ with various tasks in a conversational manner.
49
+ </p>{" "}
50
+ {/* Updated description */}
51
+ </div>
52
+ </div>
53
+ <div className="col-lg-6 mb-4">
54
+ {" "}
55
+ {/* Added mb-4 for spacing */}
56
+ <div className="box wow fadeInRight" data-wow-delay="0.2s">
57
+ <div className="icon">
58
+ <i className="fa fa-language"></i>
59
+ </div>{" "}
60
+ {/* Changed icon */}
61
+ <h4 className="title">
62
+ <a href="#">Language Translator</a>
63
+ </h4>{" "}
64
+ {/* Updated title */}
65
+ <p className="description">
66
+ Break down language barriers. This tool allows you to translate
67
+ text from one language to another, facilitating communication
68
+ across different linguistic communities.
69
+ </p>{" "}
70
+ {/* Updated description */}
71
+ </div>
72
+ </div>
73
+ <div className="col-lg-6 mb-4">
74
+ {" "}
75
+ {/* Added mb-4 for spacing */}
76
+ <div className="box wow fadeInLeft" data-wow-delay="0.2s">
77
+ <div className="icon">
78
+ <i className="fa fa-file-text-o"></i>
79
+ </div>{" "}
80
+ {/* Changed icon */}
81
+ <h4 className="title">
82
+ <a href="#">Text Summarizer</a>
83
+ </h4>{" "}
84
+ {/* Updated title */}
85
+ <p className="description">
86
+ Get the key information quickly. This tool can condense long
87
+ pieces of text into concise summaries, saving you time and
88
+ effort in understanding the main points.
89
+ </p>{" "}
90
+ {/* Updated description */}
91
+ </div>
92
+ </div>
93
+ </div>
94
+ </div>
95
+ </section>
96
+ );
97
+ };
98
+
99
+ export default ServicesSection;
src/components/Sections/Summariser.jsx ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from "react";
2
+ import api from "../../api";
3
+ import "../../assets/css/style.css";
4
+ import ErrorPopup from "../Sections/ErrorPopup";
5
+ import VoiceInput from "../Sections/VoiceInput"; // 👈 Make sure you have this component
6
+
7
+ const Summariser = () => {
8
+ const [inputText, setInputText] = useState("");
9
+ const [summarizedText, setSummarizedText] = useState("");
10
+ const [loading, setLoading] = useState(false);
11
+ const [error, setError] = useState("");
12
+ const [summaryType, setSummaryType] = useState("paragraph");
13
+ const [originalText, setOriginalText] = useState("");
14
+ const [errorPopupMessage, setErrorPopupMessage] = useState("");
15
+
16
+ const token = localStorage.getItem("jwtToken");
17
+
18
+ const handleSummarize = async () => {
19
+ if (!inputText.trim()) {
20
+ setError("Please enter text to summarize.");
21
+ return;
22
+ }
23
+
24
+ setError("");
25
+ setLoading(true);
26
+ setSummarizedText("");
27
+ setOriginalText("");
28
+
29
+ try {
30
+ const response = await api.summarizeText(
31
+ {
32
+ text: inputText,
33
+ type: summaryType,
34
+ },
35
+ { headers: { Authorization: `Bearer ${token}` } },
36
+ );
37
+
38
+ if (response && response.summarized_text) {
39
+ const cleanedText = response.summarized_text
40
+ .replace(/\n\s*\n/g, "\n")
41
+ .replace(/^\s+|\s+$/g, "");
42
+
43
+ setSummarizedText(cleanedText);
44
+ setOriginalText(response.original_text || inputText);
45
+ } else {
46
+ const message = "No summarized text found.";
47
+ setError(message);
48
+ setErrorPopupMessage(message);
49
+ }
50
+ } catch (err) {
51
+ const message =
52
+ err.message || "Failed to summarize text. Please try again.";
53
+ setError(message);
54
+ setErrorPopupMessage(
55
+ message.includes("504")
56
+ ? "Server timeout. Please try again. (504 Gateway Timeout)"
57
+ : message,
58
+ );
59
+ } finally {
60
+ setLoading(false);
61
+ }
62
+ };
63
+
64
+ const handleClearText = () => {
65
+ setInputText("");
66
+ setSummarizedText("");
67
+ setOriginalText("");
68
+ setError("");
69
+ };
70
+
71
+ const handleVoiceResult = (transcript) => {
72
+ setInputText((prevText) => `${prevText} ${transcript}`.trim());
73
+ };
74
+
75
+ const formatSummaryText = (text) => {
76
+ if (!text) return null;
77
+
78
+ const normalizedText = text
79
+ .replace(/\n\s*\n/g, "\n")
80
+ .replace(/^\s+|\s+$/g, "");
81
+
82
+ const paragraphs = normalizedText
83
+ .split("\n")
84
+ .filter((p) => p.trim().length > 0);
85
+
86
+ return paragraphs.map((paragraph, index) => (
87
+ <React.Fragment key={index}>
88
+ {paragraph.startsWith("- ") ? (
89
+ <li className="bullet-point">{paragraph.substring(2)}</li>
90
+ ) : (
91
+ <p className="summary-paragraph">{paragraph}</p>
92
+ )}
93
+ {index < paragraphs.length - 1 && <br />}
94
+ </React.Fragment>
95
+ ));
96
+ };
97
+
98
+ return (
99
+ <div className="summariser-container">
100
+ <h2>Text Summarizer</h2>
101
+
102
+ <div className="controls">
103
+ <div className="summary-type-selector">
104
+ <label>
105
+ <input
106
+ type="radio"
107
+ value="paragraph"
108
+ checked={summaryType === "paragraph"}
109
+ onChange={() => setSummaryType("paragraph")}
110
+ />
111
+ Paragraph Summary
112
+ </label>
113
+ <label>
114
+ <input
115
+ type="radio"
116
+ value="points"
117
+ checked={summaryType === "points"}
118
+ onChange={() => setSummaryType("points")}
119
+ />
120
+ Bullet Points
121
+ </label>
122
+ </div>
123
+ </div>
124
+
125
+ <div className="text-area-row">
126
+ <div className="text-box">
127
+ <h3>Original Text:</h3>
128
+ <textarea
129
+ className="input-textarea-3 summariser-textarea"
130
+ placeholder="Type or paste your text here..."
131
+ value={inputText}
132
+ onChange={(e) => setInputText(e.target.value)}
133
+ rows={14}
134
+ />
135
+ </div>
136
+
137
+ <div className="text-box">
138
+ <h3>Summarized Text:</h3>
139
+ <div className="output-display-3 summariser-output">
140
+ {loading ? (
141
+ <div className="loading-spinner">Summarizing...</div>
142
+ ) : summarizedText ? (
143
+ <div className="summary-result">
144
+ {formatSummaryText(summarizedText)}
145
+ </div>
146
+ ) : (
147
+ <div className="placeholder">
148
+ Summarized text will appear here...
149
+ </div>
150
+ )}
151
+ </div>
152
+ </div>
153
+ </div>
154
+
155
+ {error && <div className="error-message">{error}</div>}
156
+
157
+ <div className="button-container">
158
+ <VoiceInput
159
+ onResult={handleVoiceResult}
160
+ language="en-US"
161
+ buttonStyle={{}}
162
+ />
163
+ <button
164
+ onClick={handleSummarize}
165
+ disabled={loading || !inputText.trim()}
166
+ className="summarize-button"
167
+ >
168
+ {loading ? "Processing..." : "Summarize"}
169
+ </button>
170
+ <button
171
+ onClick={handleClearText}
172
+ className="clear-button"
173
+ disabled={loading}
174
+ >
175
+ Clear
176
+ </button>
177
+ </div>
178
+
179
+ {originalText && summarizedText && (
180
+ <div className="summary-stats">
181
+ <p>
182
+ Original length: {originalText.split(" ").length} words | Summary
183
+ length: {summarizedText.split(" ").length} words | Reduction:{" "}
184
+ {Math.round(
185
+ 100 -
186
+ (summarizedText.split(" ").length /
187
+ originalText.split(" ").length) *
188
+ 100,
189
+ )}
190
+ %
191
+ </p>
192
+ </div>
193
+ )}
194
+
195
+ <ErrorPopup
196
+ message={errorPopupMessage}
197
+ onClose={() => setErrorPopupMessage("")}
198
+ />
199
+ </div>
200
+ );
201
+ };
202
+
203
+ export default Summariser;
src/components/Sections/TeamSection.jsx ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from 'react';
2
+ import '../../assets/css/style.css'; // Assuming your CSS is in this path
3
+ import Team1 from '../../assets/img/team-1.jpeg';
4
+ import Team2 from '../../assets/img/team-2.jpeg';
5
+ import Team3 from '../../assets/img/team-3.jpeg';
6
+ import Team4 from '../../assets/img/team-4.jpeg';
7
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
8
+ import { faTimes, faGraduationCap, faGlobe, faLightbulb, faHandsHelping, faBook, faHeart } from '@fortawesome/free-solid-svg-icons';
9
+ import { faLinkedinIn, faGithub } from '@fortawesome/free-brands-svg-icons';
10
+ import { faInstagram } from '@fortawesome/free-brands-svg-icons';
11
+
12
+
13
+ const TeamSection = () => {
14
+ const [selectedMember, setSelectedMember] = useState(null);
15
+
16
+ const teamMembers = [
17
+ // ... (your teamMembers array remains the same)
18
+ {
19
+ id: 1,
20
+ name: "Suyash Shevade",
21
+ role: "Backend Developer",
22
+ image: Team1,
23
+ bio: "Java backend developer skilled in Spring Boot, PostgreSQL, and AWS. Passionate about building scalable and efficient systems.",
24
+ education: "B.Tech in Computer Science Engineering (2025)",
25
+ skills: ["Java", "Spring Boot", "PostgreSQL", "Docker", "AWS", "Liquibase"],
26
+ social: {
27
+ linkedin: "https://www.linkedin.com/in/suyash-shevade-8b07a9236/",
28
+ github: "https://github.com/Shevadesuyash",
29
+ instagram: "https://www.instagram.com/shevadesuyash30/"
30
+ },
31
+ fullBio: "I am a backend developer with hands-on experience in Java and Spring Boot. I have worked on real-world projects during my internship at Brandspark Technologies, where I developed RESTful APIs, integrated AWS services, managed PostgreSQL databases, and used Docker for containerization. I am passionate about creating robust and scalable server-side applications and continuously improving my skills in backend technologies and DevOps tools."
32
+ },
33
+ {
34
+ id: 2,
35
+ name: "Taranjeet Kaur",
36
+ role: "Frontend Developer",
37
+ image: Team2,
38
+ bio: "Creative UI/UX enthusiast with expertise in React and modern CSS frameworks.",
39
+ education: "Web Development Certification",
40
+ skills: ["React", "JavaScript", "CSS3", "Responsive Design"],
41
+ social: {
42
+ linkedin: "#",
43
+ github: "#",
44
+ instagram: "#"
45
+ },
46
+ fullBio: "As a frontend developer, I bridge the gap between design and technology. I create beautiful, intuitive interfaces using React and modern CSS techniques. With a keen eye for design and user experience, I ensure our applications are not only functional but also delightful to use."
47
+ },
48
+ {
49
+ id: 3,
50
+ name: "Abhijeet Borkar",
51
+ role: "Frontend Developer",
52
+ image: Team3,
53
+ bio: "Focuses on creating interactive user experiences with clean, maintainable code.",
54
+ education: "Information Technology Graduate",
55
+ skills: ["React", "Redux", "TypeScript", "Bootstrap"],
56
+ social: {
57
+ linkedin: "#",
58
+ github: "#",
59
+ instagram: "#"
60
+ },
61
+ fullBio: "I specialize in building complex frontend applications with React and TypeScript. My focus is on creating maintainable, well-structured code that scales. I'm particularly interested in state management solutions and optimizing frontend performance for better user experiences."
62
+ },
63
+ {
64
+ id: 4,
65
+ name: "Roshan Anand",
66
+ role: "Machine Learning Engineer",
67
+ image: Team4,
68
+ bio: "Passionate about AI and data science. Enjoys implementing ML models to solve real-world problems.",
69
+ education: "AI & Machine Learning Specialization",
70
+ skills: ["Python", "TensorFlow", "Data Analysis", "NLP"],
71
+ social: {
72
+ linkedin: "#",
73
+ github: "#",
74
+ instagram: "#"
75
+ },
76
+ fullBio: "As our machine learning specialist, I develop and implement AI models to solve complex problems. My expertise includes natural language processing and predictive analytics. I'm passionate about making AI accessible and creating solutions that have real-world impact."
77
+ }
78
+ ];
79
+
80
+ const handleMemberClick = (member) => {
81
+ setSelectedMember(member);
82
+ };
83
+
84
+ const closeDetails = () => {
85
+ setSelectedMember(null);
86
+ };
87
+
88
+ return (
89
+ <section id="team" className="team-section">
90
+ <div>
91
+ <div className="section-header">
92
+ <h2>Meet Our Team</h2>
93
+ <p className="section-subtitle">A group of passionate freshers ready to make an impact</p>
94
+ </div>
95
+
96
+ <div className="team-intro">
97
+ <p>
98
+ We are a team of recent graduates and self-taught developers who believe in the power of
99
+ collaboration and continuous learning. Though we're new to the industry, we bring fresh
100
+ perspectives, up-to-date knowledge, and boundless enthusiasm to every project.
101
+ </p>
102
+ </div>
103
+
104
+ <div className="team-members-grid">
105
+ <div className="row"> {/* Added a 'row' here to contain the grid items */}
106
+ {teamMembers.map((member) => (
107
+ <div className="col-lg-3 col-md-6" key={member.id}>
108
+ <div
109
+ className={`team-member-card ${selectedMember?.id === member.id ? 'active' : ''}`}
110
+ onClick={() => handleMemberClick(member)}
111
+ >
112
+ <div className="member-image">
113
+ <img src={member.image} alt={member.name} />
114
+ <div className="image-overlay">
115
+ <div className="social-links">
116
+ <a href={member.social.linkedin} aria-label={`${member.name} LinkedIn`}>
117
+ <FontAwesomeIcon icon={faLinkedinIn} />
118
+ </a>
119
+ <a href={member.social.github} aria-label={`${member.name} GitHub`}>
120
+ <FontAwesomeIcon icon={faGithub} />
121
+ </a>
122
+ {member.social.instagram && (
123
+ <a href={member.social.instagram} aria-label={`${member.name} instagram`}>
124
+ <FontAwesomeIcon icon={faInstagram} />
125
+ </a>
126
+ )}
127
+ </div>
128
+ </div>
129
+ </div>
130
+ <div className="member-basic-info">
131
+ <h3>{member.name}</h3>
132
+ <span className="role">{member.role}</span>
133
+ <p className="bio">{member.bio}</p>
134
+ </div>
135
+ </div>
136
+ </div>
137
+ ))}
138
+ </div>
139
+ </div>
140
+
141
+ {selectedMember && (
142
+ <div className="team-member-details show">
143
+ <button className="close-details" onClick={closeDetails}>
144
+ <FontAwesomeIcon icon={faTimes} />
145
+ </button>
146
+ <div className="details-content">
147
+ <div className="details-left">
148
+ <img src={selectedMember.image} alt={selectedMember.name} />
149
+ <div className="social-links">
150
+ <a href={selectedMember.social.linkedin} target="_blank" rel="noopener noreferrer">
151
+ <FontAwesomeIcon icon={faLinkedinIn} />
152
+ </a>
153
+ <a href={selectedMember.social.github} target="_blank" rel="noopener noreferrer">
154
+ <FontAwesomeIcon icon={faGithub} />
155
+ </a>
156
+ {selectedMember.social.instagram && (
157
+ <a href={selectedMember.social.instagram} target="_blank" rel="noopener noreferrer">
158
+ <FontAwesomeIcon icon={faInstagram} />
159
+ </a>
160
+ )}
161
+ </div>
162
+ </div>
163
+ <div className="details-right">
164
+ <h2>{selectedMember.name}</h2>
165
+ <h3>{selectedMember.role}</h3>
166
+ <div className="education">
167
+ <FontAwesomeIcon icon={faGraduationCap} />
168
+ <span>{selectedMember.education}</span>
169
+ </div>
170
+ <div className="full-bio">
171
+ <p>{selectedMember.fullBio}</p>
172
+ </div>
173
+ <div className="skills-section">
174
+ <h4>Skills & Expertise</h4>
175
+ <div className="skill-tags">
176
+ {selectedMember.skills.map((skill, index) => (
177
+ <span key={index} className="skill-tag">{skill}</span>
178
+ ))}
179
+ </div>
180
+ </div>
181
+ </div>
182
+ </div>
183
+ </div>
184
+ )}
185
+
186
+ <div className="team-values">
187
+ <h3>Our Values</h3>
188
+ <div className="values-grid">
189
+ <div className="value-item">
190
+ <FontAwesomeIcon icon={faLightbulb} />
191
+ <h4>Innovation</h4>
192
+ <p>We embrace new ideas and creative problem-solving</p>
193
+ </div>
194
+ <div className="value-item">
195
+ <FontAwesomeIcon icon={faHandsHelping} />
196
+ <h4>Collaboration</h4>
197
+ <p>We believe the best solutions come from teamwork</p>
198
+ </div>
199
+ <div className="value-item">
200
+ <FontAwesomeIcon icon={faBook} />
201
+ <h4>Continuous Learning</h4>
202
+ <p>We're committed to constantly improving our skills</p>
203
+ </div>
204
+ <div className="value-item">
205
+ <FontAwesomeIcon icon={faHeart} />
206
+ <h4>Passion</h4>
207
+ <p>We love what we do and it shows in our work</p>
208
+ </div>
209
+ </div>
210
+ </div>
211
+ </div>
212
+ </section>
213
+ );
214
+ };
215
+
216
+ export default TeamSection;
src/components/Sections/TranslationModule.jsx ADDED
@@ -0,0 +1,320 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useEffect } from "react";
2
+ import api from "../../api";
3
+ import "../../assets/css/style.css";
4
+ import VoiceInput from "./VoiceInput";
5
+ import { loadVoices, getDefaultVoice } from "./voiceUtils";
6
+
7
+ const languages = [
8
+ { code: "auto", label: "Auto Detect" },
9
+ { code: "en", label: "English" },
10
+ { code: "hi", label: "Hindi" },
11
+ { code: "es", label: "Spanish" },
12
+ { code: "fr", label: "French" },
13
+ { code: "de", label: "German" },
14
+ { code: "zh-cn", label: "Chinese (Simplified)" },
15
+ { code: "zh-tw", label: "Chinese (Traditional)" },
16
+ { code: "ja", label: "Japanese" },
17
+ { code: "ko", label: "Korean" },
18
+ { code: "ru", label: "Russian" },
19
+ { code: "ar", label: "Arabic" },
20
+ { code: "pt", label: "Portuguese" },
21
+ { code: "it", label: "Italian" },
22
+ { code: "mr", label: "Marathi" },
23
+ { code: "bn", label: "Bengali" },
24
+ { code: "pa", label: "Punjabi" },
25
+ { code: "gu", label: "Gujarati" },
26
+ { code: "ur", label: "Urdu" },
27
+ { code: "tr", label: "Turkish" },
28
+ { code: "vi", label: "Vietnamese" },
29
+ { code: "id", label: "Indonesian" },
30
+ { code: "ms", label: "Malay" },
31
+ { code: "ta", label: "Tamil" },
32
+ { code: "te", label: "Telugu" },
33
+ { code: "th", label: "Thai" },
34
+ { code: "pl", label: "Polish" },
35
+ { code: "nl", label: "Dutch" },
36
+ { code: "sv", label: "Swedish" },
37
+ { code: "fa", label: "Persian" },
38
+ { code: "ro", label: "Romanian" },
39
+ { code: "uk", label: "Ukrainian" },
40
+ { code: "he", label: "Hebrew" },
41
+ { code: "fi", label: "Finnish" },
42
+ { code: "el", label: "Greek" },
43
+ { code: "cs", label: "Czech" },
44
+ { code: "hu", label: "Hungarian" },
45
+ { code: "sr", label: "Serbian" },
46
+ { code: "sk", label: "Slovak" },
47
+ { code: "bg", label: "Bulgarian" },
48
+ { code: "no", label: "Norwegian" },
49
+ { code: "da", label: "Danish" },
50
+ { code: "sw", label: "Swahili" },
51
+ { code: "fil", label: "Filipino" },
52
+ { code: "ne", label: "Nepali" },
53
+ { code: "si", label: "Sinhala" },
54
+ { code: "af", label: "Afrikaans" },
55
+ ];
56
+
57
+ const TranslationModule = () => {
58
+ const [fromLanguage, setFromLanguage] = useState("auto");
59
+ const [toLanguage, setToLanguage] = useState("");
60
+ const [textToTranslate, setTextToTranslate] = useState("");
61
+ const [translatedText, setTranslatedText] = useState("");
62
+ const [error, setError] = useState(null);
63
+ const [voices, setVoices] = useState([]);
64
+ const [selectedVoice, setSelectedVoice] = useState(null);
65
+
66
+ useEffect(() => {
67
+ const initializeVoices = async () => {
68
+ const loadedVoices = await loadVoices();
69
+ setVoices(loadedVoices);
70
+ setSelectedVoice(getDefaultVoice(loadedVoices));
71
+ };
72
+ initializeVoices();
73
+ }, []);
74
+
75
+ const handleVoiceResult = (transcript) => {
76
+ setTextToTranslate(
77
+ (prevText) => prevText + (prevText ? " " : "") + transcript,
78
+ );
79
+ };
80
+
81
+ const handleClearText = () => {
82
+ setTextToTranslate("");
83
+ };
84
+
85
+ const handleTextToSpeech = () => {
86
+ if (!translatedText || !selectedVoice) {
87
+ setError("No translated text or voice selected");
88
+ return;
89
+ }
90
+
91
+ const synth = window.speechSynthesis;
92
+ synth.cancel();
93
+
94
+ const utterance = new SpeechSynthesisUtterance(translatedText);
95
+ utterance.voice = selectedVoice;
96
+ utterance.lang = toLanguage || "en-US";
97
+ synth.speak(utterance);
98
+ };
99
+
100
+ const handleTranslate = async () => {
101
+ setError(null);
102
+ if (!toLanguage) {
103
+ setError('Please select the "To Language".');
104
+ return;
105
+ }
106
+ // Find the language code based on the selected/typed label
107
+ const fromLangCode =
108
+ languages.find((lang) => lang.label === fromLanguage)?.code || "auto";
109
+ const toLangCode = languages.find(
110
+ (lang) => lang.label === toLanguage,
111
+ )?.code;
112
+
113
+ if (!toLangCode && toLanguage !== "") {
114
+ setError('Invalid "To Language" selected.');
115
+ return;
116
+ }
117
+
118
+ try {
119
+ const data = {
120
+ from_language: fromLangCode,
121
+ to_language: toLangCode || toLanguage,
122
+ text_to_translate: textToTranslate,
123
+ };
124
+ const response = await api.translate(data);
125
+ if (response.error) {
126
+ setError(response.error);
127
+ } else if (response.translatedText) {
128
+ setTranslatedText(response.translatedText);
129
+ } else {
130
+ setError("No translated text received from API.");
131
+ }
132
+ } catch (err) {
133
+ setError("Translation failed. Please try again.");
134
+ console.error("Error during translation:", err);
135
+ }
136
+ };
137
+
138
+ return (
139
+ <div id="translator">
140
+ <h2>🌐 Language Translator</h2>
141
+
142
+ {/* Internal CSS for error popup */}
143
+ <style>{`
144
+ .error-popup-overlay {
145
+ position: fixed;
146
+ top: 0;
147
+ left: 0;
148
+ width: 100%;
149
+ height: 100%;
150
+ background: rgba(0,0,0,0.4);
151
+ display: flex;
152
+ align-items: center;
153
+ justify-content: center;
154
+ z-index: 999;
155
+ }
156
+
157
+ .error-popup {
158
+ background: white;
159
+ padding: 20px 30px;
160
+ border-radius: 10px;
161
+ max-width: 400px;
162
+ text-align: center;
163
+ box-shadow: 0 0 20px rgba(0,0,0,0.3);
164
+ }
165
+
166
+ .error-popup button {
167
+ margin-top: 15px;
168
+ background-color: #dc3545;
169
+ color: white;
170
+ border: none;
171
+ padding: 8px 16px;
172
+ border-radius: 8px;
173
+ cursor: pointer;
174
+ }
175
+
176
+ .error-popup button:hover {
177
+ background-color: #c82333;
178
+ }
179
+
180
+ .error-message {
181
+ color: red;
182
+ font-size: 14px;
183
+ margin-top: 10px;
184
+ }
185
+ textarea {
186
+ color: black !important;
187
+ background-color: white !important;
188
+ }
189
+
190
+
191
+ `}</style>
192
+
193
+ <form onSubmit={(e) => e.preventDefault()}>
194
+ {/* From Language */}
195
+ <label htmlFor="fromLanguage">From Language:</label>
196
+ <input
197
+ list="languages"
198
+ value={fromLanguage}
199
+ onChange={(e) => setFromLanguage(e.target.value)}
200
+ placeholder="Type or select a language"
201
+ />
202
+ <datalist id="languages">
203
+ {languages.map((lang) => (
204
+ <option key={lang.label} value={lang.label}>
205
+ {lang.label}
206
+ </option>
207
+ ))}
208
+ </datalist>
209
+
210
+ {/* To Language */}
211
+ <label htmlFor="toLanguage">To Language:</label>
212
+ <input
213
+ list="languages"
214
+ value={toLanguage}
215
+ onChange={(e) => setToLanguage(e.target.value)}
216
+ placeholder="Type or select a language"
217
+ />
218
+ <datalist id="languages">
219
+ {languages.map((lang) => (
220
+ <option key={lang.label} value={lang.label}>
221
+ {lang.label}
222
+ </option>
223
+ ))}
224
+ </datalist>
225
+
226
+ {/* Text to Translate */}
227
+ <div>
228
+ <label htmlFor="textToTranslate">Text to Translate:</label>
229
+ </div>
230
+ <div className="input-container">
231
+ <textarea
232
+ id="textToTranslate"
233
+ rows="5"
234
+ value={textToTranslate}
235
+ onChange={(e) => setTextToTranslate(e.target.value)}
236
+ placeholder="Enter text here..."
237
+ ></textarea>
238
+ </div>
239
+ <div>
240
+ <VoiceInput
241
+ onResult={handleVoiceResult}
242
+ language={
243
+ fromLanguage === "auto"
244
+ ? "en-US"
245
+ : languages.find((lang) => lang.label === fromLanguage)?.code ||
246
+ "en-US"
247
+ }
248
+ buttonStyle={{ marginLeft: "8px" }}
249
+ />
250
+ <button
251
+ type="button"
252
+ onClick={handleClearText}
253
+ className="clear-button"
254
+ >
255
+ Clear
256
+ </button>
257
+
258
+ <button type="button" onClick={handleTranslate}>
259
+ Translate
260
+ </button>
261
+ </div>
262
+ {/* Error Popup */}
263
+ {error && (
264
+ <div className="error-popup-overlay">
265
+ <div className="error-popup">
266
+ <h3>⚠️ Something went wrong</h3>
267
+ <p>{error}</p>
268
+ <button onClick={() => setError(null)}>Close</button>
269
+ </div>
270
+ </div>
271
+ )}
272
+
273
+ <label htmlFor="translatedText">Translated Text:</label>
274
+ <div className="input-container">
275
+ <textarea
276
+ id="translatedText"
277
+ rows="4"
278
+ value={translatedText}
279
+ readOnly
280
+ ></textarea>
281
+ </div>
282
+ <div>
283
+ <button
284
+ type="button"
285
+ onClick={handleTextToSpeech}
286
+ className="voice-button"
287
+ disabled={!translatedText || !selectedVoice}
288
+ >
289
+ <i className="fa fa-volume-up"></i>
290
+ </button>
291
+ </div>
292
+
293
+ <label htmlFor="voice-select">Select Voice:</label>
294
+ <select
295
+ id="voice-select"
296
+ value={selectedVoice ? selectedVoice.name : ""}
297
+ onChange={(e) => {
298
+ const voice = voices.find((v) => v.name === e.target.value);
299
+ setSelectedVoice(voice);
300
+ }}
301
+ style={{
302
+ padding: "8px",
303
+ borderRadius: "4px",
304
+ border: "1px solid #ddd",
305
+ width: "100%",
306
+ maxWidth: "300px",
307
+ }}
308
+ >
309
+ {voices.map((voice) => (
310
+ <option key={voice.name} value={voice.name}>
311
+ {voice.name} ({voice.lang})
312
+ </option>
313
+ ))}
314
+ </select>
315
+ </form>
316
+ </div>
317
+ );
318
+ };
319
+
320
+ export default TranslationModule;
src/components/Sections/VoiceInput.jsx ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // convomate/src/components/Sections/VoiceInput.jsx
2
+ import React, { useState, useEffect } from "react";
3
+ import "font-awesome/css/font-awesome.min.css";
4
+
5
+ const VoiceInput = ({
6
+ onResult,
7
+ language = "en-US",
8
+ buttonStyle = {},
9
+ disabled = false,
10
+ }) => {
11
+ const [isListening, setIsListening] = useState(false);
12
+ const [recognition, setRecognition] = useState(null);
13
+
14
+ useEffect(() => {
15
+ const SpeechRecognition =
16
+ window.SpeechRecognition || window.webkitSpeechRecognition;
17
+ if (SpeechRecognition) {
18
+ const recognizer = new SpeechRecognition();
19
+ recognizer.continuous = false;
20
+ recognizer.interimResults = false;
21
+ recognizer.lang = language;
22
+ setRecognition(recognizer);
23
+
24
+ recognizer.onresult = (event) => {
25
+ const transcript = event.results[0][0].transcript;
26
+ onResult(transcript);
27
+ setIsListening(false);
28
+ };
29
+
30
+ recognizer.onerror = (event) => {
31
+ console.error("Voice input error:", event.error);
32
+ setIsListening(false);
33
+ };
34
+
35
+ recognizer.onend = () => {
36
+ if (isListening) setIsListening(false);
37
+ };
38
+ }
39
+
40
+ return () => {
41
+ if (recognition) {
42
+ recognition.stop();
43
+ }
44
+ };
45
+ }, [language, onResult]);
46
+
47
+ const startListening = () => {
48
+ if (!recognition || disabled) return;
49
+ recognition.start();
50
+ setIsListening(true);
51
+ };
52
+
53
+ const stopListening = () => {
54
+ if (recognition && isListening) {
55
+ recognition.stop();
56
+ setIsListening(false);
57
+ }
58
+ };
59
+
60
+ return (
61
+ <div style={{ position: "relative", display: "inline-block" }}>
62
+ {!isListening ? (
63
+ <button
64
+ type="button"
65
+ onClick={startListening}
66
+ disabled={!recognition || disabled}
67
+ style={{
68
+ backgroundColor: "#007bff",
69
+ border: "none",
70
+ color: "#fff",
71
+ padding: "10px 15px",
72
+ borderRadius: "50%",
73
+ cursor: "pointer",
74
+ ...buttonStyle,
75
+ }}
76
+ title="Start voice input"
77
+ >
78
+ <i className="fa fa-microphone"></i>
79
+ </button>
80
+ ) : (
81
+ <button
82
+ type="button"
83
+ onClick={stopListening}
84
+ style={{
85
+ backgroundColor: "#dc3545",
86
+ border: "none",
87
+ color: "#fff",
88
+ padding: "10px 15px",
89
+ borderRadius: "50%",
90
+ cursor: "pointer",
91
+ ...buttonStyle,
92
+ }}
93
+ title="Stop listening"
94
+ >
95
+ <i className="fa fa-microphone-slash"></i>
96
+ </button>
97
+ )}
98
+ {isListening && (
99
+ <span
100
+ style={{
101
+ position: "absolute",
102
+ top: "-5px",
103
+ right: "-5px",
104
+ width: "10px",
105
+ height: "10px",
106
+ backgroundColor: "red",
107
+ borderRadius: "50%",
108
+ animation: "pulse 1.5s infinite",
109
+ }}
110
+ ></span>
111
+ )}
112
+ </div>
113
+ );
114
+ };
115
+
116
+ export default VoiceInput;
src/components/Sections/voiceUtils.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // convomate/src/components/Sections/voiceUtils.js
2
+ export const loadVoices = () => {
3
+ return new Promise((resolve) => {
4
+ const voices = window.speechSynthesis.getVoices();
5
+ if (voices.length > 0) {
6
+ resolve(voices);
7
+ } else {
8
+ window.speechSynthesis.onvoiceschanged = () => {
9
+ resolve(window.speechSynthesis.getVoices());
10
+ };
11
+ }
12
+ });
13
+ };
14
+
15
+ export const getDefaultVoice = (voices) => {
16
+ // Try to find Google US English first
17
+ const googleUS = voices.find(
18
+ (voice) =>
19
+ voice.name.includes("Google US English") ||
20
+ voice.name.includes("English United States"),
21
+ );
22
+
23
+ // Fallback to first English voice
24
+ const englishVoice = voices.find(
25
+ (voice) => voice.lang.includes("en-US") || voice.lang.includes("en_GB"),
26
+ );
27
+
28
+ return googleUS || englishVoice || voices[0];
29
+ };
src/components/Shared/ErrorBoundary.jsx ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { Component } from "react";
2
+
3
+ class ErrorBoundary extends Component {
4
+ constructor(props) {
5
+ super(props);
6
+ this.state = { hasError: false };
7
+ }
8
+
9
+ static getDerivedStateFromError(error) {
10
+ return { hasError: true };
11
+ }
12
+
13
+ componentDidCatch(error, errorInfo) {
14
+ console.error("Error caught by ErrorBoundary:", error, errorInfo);
15
+ }
16
+
17
+ render() {
18
+ if (this.state.hasError) {
19
+ return <h1>Something went wrong. Please try again later.</h1>;
20
+ }
21
+
22
+ return this.props.children;
23
+ }
24
+ }
25
+
26
+ export default ErrorBoundary;
src/components/Shared/ProtectedRoute.jsx ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+ import { Navigate } from "react-router-dom";
3
+ import { useAuth } from "../../context/AuthContext";
4
+
5
+ const ProtectedRoute = ({ children }) => {
6
+ const { authenticated, loading } = useAuth();
7
+
8
+ if (loading) {
9
+ return <div>Loading...</div>; // ✅ Wait until token check completes
10
+ }
11
+
12
+ if (!authenticated) {
13
+ return <Navigate to="/login" state={{ from: window.location.pathname }} />;
14
+ }
15
+
16
+ return children;
17
+ };
18
+
19
+ export default ProtectedRoute;
src/components/Shared/PublicRoute.jsx ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+ import { Navigate } from "react-router-dom";
3
+ import { useAuth } from "../../context/AuthContext";
4
+
5
+ const PublicRoute = ({ children }) => {
6
+ const { authenticated } = useAuth();
7
+
8
+ // Redirect authenticated users away from public routes
9
+ if (authenticated) {
10
+ return <Navigate to="/" />;
11
+ }
12
+
13
+ return children;
14
+ };
15
+
16
+ export default PublicRoute;
src/context/AuthContext.js ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { createContext, useState, useEffect, useContext } from "react";
2
+ import api from "../api";
3
+
4
+ const AuthContext = createContext();
5
+
6
+ const AuthProvider = ({ children }) => {
7
+ const [authenticated, setAuthenticated] = useState(false);
8
+ const [error, setError] = useState(null);
9
+ const [loading, setLoading] = useState(false);
10
+
11
+ // Keep user logged in on page refresh
12
+ useEffect(() => {
13
+ setLoading(true);
14
+ const token = localStorage.getItem("token");
15
+ if (token) setAuthenticated(true);
16
+ setLoading(false);
17
+ }, []);
18
+
19
+ const generateOtp = async (email) => {
20
+ try {
21
+ setLoading(true);
22
+ setError(null);
23
+ await api.generateOtp(email);
24
+ return true;
25
+ } catch (err) {
26
+ setError(err.message || "Failed to generate OTP");
27
+ throw err;
28
+ } finally {
29
+ setLoading(false);
30
+ }
31
+ };
32
+
33
+ const [authKey, setAuthKey] = useState(0);
34
+
35
+ const login = async (email, otp) => {
36
+ try {
37
+ setLoading(true);
38
+ setError(null);
39
+ const response = await api.login(email, otp);
40
+ const token = response.token;
41
+ if (!token) throw new Error("Token missing in response");
42
+
43
+ localStorage.setItem("token", token);
44
+ setAuthenticated(true);
45
+ window.location.reload();
46
+ } catch (err) {
47
+ setError(err.message || "Login failed");
48
+ throw err;
49
+ } finally {
50
+ setLoading(false);
51
+ }
52
+ };
53
+
54
+ const logout = () => {
55
+ localStorage.removeItem("token");
56
+ setAuthenticated(false);
57
+ window.location.reload();
58
+ };
59
+
60
+ const register = async (username, name, email) => {
61
+ try {
62
+ setLoading(true);
63
+ setError(null);
64
+ const response = await api.register({ username, name, email });
65
+
66
+ if (response.message?.includes("success")) {
67
+ // Registration succeeded, optionally show a toast or redirect
68
+ return;
69
+ }
70
+
71
+ throw new Error(response.message || "Registration failed");
72
+ } catch (err) {
73
+ setError(err.message || "Registration failed");
74
+ throw err;
75
+ } finally {
76
+ setLoading(false);
77
+ }
78
+ };
79
+
80
+ return (
81
+ <AuthContext.Provider
82
+ value={{
83
+ authenticated,
84
+ generateOtp,
85
+ login,
86
+ register,
87
+ logout,
88
+ error,
89
+ loading,
90
+ }}
91
+ >
92
+ {children}
93
+ </AuthContext.Provider>
94
+ );
95
+ };
96
+
97
+ const useAuth = () => useContext(AuthContext);
98
+
99
+ export { AuthProvider, useAuth };
src/index.html ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Convomate</title>
6
+ <link href="favicon.ico" rel="icon" />
7
+ <base href="/" />
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ </body>
12
+ </html>
src/index.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+ import { createRoot } from "react-dom/client";
3
+ import App from "./App";
4
+ import "./assets/css/style.css"; // Updated to use consolidated Main.css
5
+ import { AuthProvider } from "./context/AuthContext";
6
+
7
+ const container = document.getElementById("root");
8
+ const root = createRoot(container);
9
+
10
+ root.render(
11
+ <React.StrictMode>
12
+ <AuthProvider>
13
+ <App />
14
+ </AuthProvider>
15
+ </React.StrictMode>,
16
+ );
src/pages/ChatbotPage.jsx ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+ import Layout from "../components/Layout/Layout";
3
+ import ChatbotSection from "../components/Sections/ChatbotSection";
4
+
5
+ const ChatbotPage = () => {
6
+ return <ChatbotSection />;
7
+ };
8
+
9
+ export default ChatbotPage;
src/pages/HomePage.jsx ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+ import IntroSection from "../components/Sections/IntroSection";
3
+ import AboutSection from "../components/Sections/AboutSection";
4
+ import ServicesSection from "../components/Sections/ServicesSection";
5
+ import ContactSection from "../components/Sections/ContactSection";
6
+ import ReviewSection from "../components/Sections/ReviewSection";
7
+
8
+ const HomePage = () => {
9
+ return (
10
+ <div>
11
+ <IntroSection />
12
+ <AboutSection />
13
+ <ServicesSection />
14
+ <ContactSection />
15
+ <ReviewSection />
16
+ </div>
17
+ );
18
+ };
19
+
20
+ export default HomePage;
src/pages/LoginPage.jsx ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useEffect } from "react";
2
+ import { useNavigate } from "react-router-dom";
3
+ import { useAuth } from "../context/AuthContext";
4
+ import LoginSection from "../components/Sections/LoginSection";
5
+
6
+ const LoginPage = () => {
7
+ const [email, setEmail] = useState("");
8
+ const [otp, setOtp] = useState("");
9
+ const [otpSent, setOtpSent] = useState(false);
10
+ const [timer, setTimer] = useState(30);
11
+ const { generateOtp, login, error, loading } = useAuth();
12
+ const navigate = useNavigate();
13
+
14
+ const handleGenerateOtp = async (e) => {
15
+ e.preventDefault();
16
+ try {
17
+ const response = await generateOtp(email);
18
+ console.log("OTP generated:", response);
19
+ setOtpSent(true);
20
+ setTimer(30);
21
+ } catch (err) {
22
+ console.error("OTP generation failed:", err);
23
+ }
24
+ };
25
+
26
+ const handleSubmit = async (e) => {
27
+ e.preventDefault();
28
+ if (!otp) return;
29
+ try {
30
+ const response = await login(email, otp);
31
+ console.log("Login successful:", response);
32
+ navigate("/");
33
+ } catch (err) {
34
+ console.error("Login failed:", err);
35
+ }
36
+ };
37
+
38
+ const handleResendOtp = async () => {
39
+ try {
40
+ await generateOtp(email);
41
+ setTimer(30);
42
+ } catch (err) {
43
+ console.error("OTP resend failed:", err);
44
+ }
45
+ };
46
+
47
+ useEffect(() => {
48
+ if (otpSent && timer > 0) {
49
+ const interval = setInterval(() => setTimer((prev) => prev - 1), 1000);
50
+ return () => clearInterval(interval);
51
+ }
52
+ }, [otpSent, timer]);
53
+
54
+ return (
55
+ <LoginSection
56
+ email={email}
57
+ setEmail={setEmail}
58
+ otp={otp}
59
+ setOtp={setOtp}
60
+ otpSent={otpSent}
61
+ timer={timer}
62
+ error={error}
63
+ loading={loading}
64
+ handleGenerateOtp={handleGenerateOtp}
65
+ handleResendOtp={handleResendOtp}
66
+ handleSubmit={handleSubmit}
67
+ />
68
+ );
69
+ };
70
+
71
+ export default LoginPage;
src/pages/ModelPage.jsx ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+ import Layout from "../components/Layout/Layout";
3
+ import ModelSection from "../components/Sections/ModelSection";
4
+
5
+ const ModelPage = () => {
6
+ return <ModelSection />;
7
+ };
8
+
9
+ export default ModelPage;