From 810e32dac0ab93d8b6f3236c0dbeb073d1473ff2 Mon Sep 17 00:00:00 2001 From: Prateek Jakhar Date: Mon, 26 Jun 2023 19:33:09 +0530 Subject: [PATCH 01/34] ui changes --- apps/agri-mitra/lang/bn.json | 4 + apps/agri-mitra/lang/en.json | 4 + apps/agri-mitra/lang/hi.json | 148 +++++----- apps/agri-mitra/lang/ta.json | 4 + apps/agri-mitra/lang/te.json | 4 + .../agri-mitra/src/assets/icons/startIcon.svg | 4 +- apps/agri-mitra/src/assets/icons/stop.gif | Bin 360309 -> 962585 bytes .../src/components/HomePage/index.module.css | 8 +- .../src/components/HomePage/index.tsx | 36 ++- .../src/components/MorePage/FAQPage/index.tsx | 6 +- .../src/components/MorePage/index.tsx | 8 +- .../src/components/NavBar/index.tsx | 2 +- .../PhoneView/ChatWindow/ChatUiWindow.tsx | 74 ++--- .../agri-mitra/src/components/Popup/index.tsx | 261 +++++++++++++++--- .../src/components/Popup/styles.module.css | 32 +++ apps/agri-mitra/src/components/menu/index.tsx | 8 +- .../recorder/RenderVoiceRecorder.jsx | 5 +- .../src/components/recorder/styles.module.css | 8 +- .../src/context/ContextProvider.tsx | 10 +- apps/agri-mitra/src/hooks/useLogin.ts | 2 +- apps/agri-mitra/src/pages/_app.tsx | 58 ++-- apps/agri-mitra/src/pages/index.tsx | 4 +- apps/agri-mitra/src/utils/serviceWorker.ts | 16 +- apps/agri-mitra/src/utils/textToSpeech.ts | 3 +- package-lock.json | 19 ++ package.json | 5 +- yarn.lock | 9 +- 27 files changed, 515 insertions(+), 227 deletions(-) diff --git a/apps/agri-mitra/lang/bn.json b/apps/agri-mitra/lang/bn.json index 54e724b..fc84629 100644 --- a/apps/agri-mitra/lang/bn.json +++ b/apps/agri-mitra/lang/bn.json @@ -8,6 +8,7 @@ "label.search": "অনুসন্ধান", "label.back": "পিছনে", "label.send": "পাঠান", + "label.close": "বন্ধ", "label.profile": "প্রোফাইল", "label.faqs": "প্রায়শ্চিত্ত্যসম্পর্কিত প্রশ্নগুলি", "label.dial": "ডায়াল করুন", @@ -22,6 +23,9 @@ "label.new_chat": "নতুন চ্যাট", "label.confirm_delete": "আপনি কি নিশ্চিত যে আপনি এই চ্যাটটি মুছতে চান?", "label.no_history": "কোনও চ্যাট নেই", + "label.popUpTitle": "আপনার আধার নম্বর / সুবিধাভোগী আইডি / ফোন নম্বর লিখুন।", + "label.popUpTitle2": "আপনার আধারের শেষ 4টি সংখ্যা লিখুন", + "label.popUpTitle3": "OTP লিখুন", "message.example_ques_one": "আমার টাকা কোথায়?", "message.example_ques_two": "আমার আবেদনের অবস্থা কী?", "message.example_ques_three": "আমি আমার টাকা পেতে কার সাথে কথা বলতে হবে?", diff --git a/apps/agri-mitra/lang/en.json b/apps/agri-mitra/lang/en.json index 63b2c36..ac4b0c5 100644 --- a/apps/agri-mitra/lang/en.json +++ b/apps/agri-mitra/lang/en.json @@ -8,6 +8,7 @@ "label.search": "Search", "label.back": "Back", "label.send": "Send", + "label.close": "Close", "label.profile": "Profile", "label.faqs": "FAQs", "label.dial": "Dial", @@ -22,6 +23,9 @@ "label.new_chat": "New chat", "label.confirm_delete": "Are you sure you want to delete this conversation?", "label.no_history": "No Chats", + "label.popUpTitle": "Enter your Aadhaar Number / Beneficiary ID / Phone no.", + "label.popUpTitle2": "Enter your last 4 digits of Aadhaar", + "label.popUpTitle3": "Enter OTP", "message.example_ques_one": "Where is my money?", "message.example_ques_two": "What is the status of my application?", "message.example_ques_three": "Whom do I need to speak to in order to get my money?", diff --git a/apps/agri-mitra/lang/hi.json b/apps/agri-mitra/lang/hi.json index abe1a7c..219cd40 100644 --- a/apps/agri-mitra/lang/hi.json +++ b/apps/agri-mitra/lang/hi.json @@ -1,73 +1,77 @@ { - "label.title":"AgrI-Mitra", - "label.welcome":"स्वागत", - "label.chats":"चैट", - "label.farmer":"किसान", - "label.extension_worker":"एक्सटेंशन कार्यकर्ता", - "label.continue":"जारी रखें", - "label.search":"खोजें", - "label.back":"वापस", - "label.send":"भेजें", - "label.profile":"प्रोफ़ाइल", - "label.faqs":"सामान्य प्रश्न", - "label.dial":"डायल करें", - "label.feedback":"प्रतिक्रिया", - "label.logout":"लॉग आउट", - "label.more":"अधिक", - "label.submit":"प्रस्तुत करें", - "label.submit_review":"समीक्षा प्रस्तुत करें", - "label.mobile_number":"मोबाइल नंबर", - "label.examples":"उदाहरण प्रश्न", - "label.click":"रीलोड करें", - "label.new_chat":"नई चैट", - "label.confirm_delete":"क्या आप वाकई इस बातचीत को हटाना चाहते हैं?", - "label.no_history":"कोई चैट नहीं", - "message.example_ques_one": "मेरा पैसा कहाँ है?", - "message.example_ques_two": "मेरे आवेदन की स्थिति क्या है?", - "message.example_ques_three": "अपना पैसा पाने के लिए मुझे किससे बात करने की आवश्यकता है?", - "message.no_history":"यहां एआई के साथ आपकी चैट इतिहास होगा", - "message.socket_disconnect_msg": "फिर से कनेक्ट करने के लिए।", - "message.enter_mobile":"मोबाइल नंबर दर्ज करें", - "message.register_message":"यदि आप पहले से पंजीकृत हैं तो अपना मोबाइल नंबर उपयोग करके लॉगिन करें।", - "message.not_register_yet":"अभी तक पंजीकृत नहीं हैं?", - "message.register_at_krushak":"कृषक ओडिशा पर पंजीकरण करें", - "message.otp_verification":"वन टाइम पासवर्ड सत्यापन", - "message.ask_ur_question":"अपना प्रश्न पूछें", - "message.otp_message":"हम आपको इस पर एक वन टाइम पासवर्ड भेजेंगे", - "message.invalid_mobile":"10 अंकों की संख्या दर्ज करें!", - "message.cannot_answer_again": "फिर से जवाब नहीं दे सकते", - "message.invalid_otp":"अमान्य ओटीपी", - "message.otp_not_sent":"ओटीपी नहीं भेजी गई", - "message.otp_sent_again": "ओटीपी फिर से भेजी गई", - "message.wait_resending_otp": "ओटीपी फिर से भेजने से पहले कृपया प्रतीक्षा करें", - "message.helpful": "क्या यह मददगार था?", - "message.retry":"कृपया पुनः प्रयास करें।", - "message.down_time_retry":"पुनः प्रयास करें", - "message.taking_longer":"कृपया प्रतीक्षा करें, सर्वरों में सामान्य से अधिक समय लग रहा है।", - "message.rating_submitted": "रेटिंग सबमिट की गई!", - "message.review_submitted": "समीक्षा सबमिट की गई!", - "message.didnt_receive": "ओटीपी प्राप्त नहीं हुआ?", - "message.resend_again": "पुनः भेजें", - "message.coming_soon" : "जल्द आ रहा है!", - "message.coming_soon_description" : "हम इस सुविधा को बहुत जल्द लॉन्च करने जा रहे हैं। बने रहें!", - "message.dial_description" : "कॉल सेंटर से संपर्क करने के लिए", - "message.rating" : "क्या आपको यह उपयोगी लगा?", - "message.rating_description" : "रेट करने के लिए एक स्टार टैप करें", - "message.review": "अपनी समीक्षा लिखें (वैकल्पिक)", - "message.review_description": "कृपया अपने अनुभव की प्रतिक्रिया लिखें।", - "message.temporarily_down": "हम अस्थायी रूप से निचे हैं", - "message.temporarily_down_description": "वर्तमान में हमें उच्च उपयोगकर्ता मात्रा का सामना हो रहा है, कृपया कुछ समय बाद लॉग इन करने का प्रयास करें", - "message.recorder_wait": "कृपया प्रतीक्षा करें जब तक हम आपकी अनुरोध को प्रोसेस कर रहे हैं...", - "message.recorder_error": "माफ़ करें, वर्तमान में आपका अनुरोध प्रोसेस करने में समस्या हो रही है। कृपया कुछ समय बाद प्रयास करें।", - "message.dialer_popup":"आप एक अमा कृषि विशेषज्ञ से बात कर सकते हैं ताकि आपको संतोषजनक जवाब मिल सके", - "error.fail_to_submit":"रेटिंग सबमिट करने में विफल।", - "error.fail_to_submit_review": "समीक्षा सबमिट करने में विफल।", - "error.sending_otp":"ओटीपी भेजने में त्रुटि", - "error.otp_not_sent":"ओटीपी नहीं भेजी गई", - "error.empty_msg": "कृपया भेजने के लिए एक संदेश टाइप या चुनें।", - "error.wait_new_chat": "कृपया जवाब की प्रतीक्षा करें।", - "error.disconnected": "आप डिस्कनेक्ट कर दिए गए हैं। कृपया रीफ्रेश करें या फिर से लॉगिन करें।", - "toast.reaction_like":"सफलतापूर्वक प्रतिक्रिया पसंद की गई", - "toast.reaction_dislike":"सफलतापूर्वक प्रतिक्रिया नापसंद की गई", - "toast.reaction_reset":"सफलतापूर्वक प्रतिक्रिया हटा दी गई" - } \ No newline at end of file + "label.title": "AgrI-Mitra", + "label.welcome": "स्वागत", + "label.chats": "चैट", + "label.farmer": "किसान", + "label.extension_worker": "एक्सटेंशन कार्यकर्ता", + "label.continue": "जारी रखें", + "label.search": "खोजें", + "label.back": "वापस", + "label.send": "भेजें", + "label.close": "बंद करें", + "label.profile": "प्रोफ़ाइल", + "label.faqs": "सामान्य प्रश्न", + "label.dial": "डायल करें", + "label.feedback": "प्रतिक्रिया", + "label.logout": "लॉग आउट", + "label.more": "अधिक", + "label.submit": "प्रस्तुत करें", + "label.submit_review": "समीक्षा प्रस्तुत करें", + "label.mobile_number": "मोबाइल नंबर", + "label.examples": "उदाहरण प्रश्न", + "label.click": "रीलोड करें", + "label.new_chat": "नई चैट", + "label.confirm_delete": "क्या आप वाकई इस बातचीत को हटाना चाहते हैं?", + "label.no_history": "कोई चैट नहीं", + "label.popUpTitle": "अपना आधार नंबर / लाभार्थी आईडी / फोन नंबर दर्ज करें।", + "label.popUpTitle2": "अपने आधार के अंतिम 4 अंक दर्ज करें", + "label.popUpTitle3": "ओटीपी दर्ज करें", + "message.example_ques_one": "मेरा पैसा कहाँ है?", + "message.example_ques_two": "मेरे आवेदन की स्थिति क्या है?", + "message.example_ques_three": "अपना पैसा पाने के लिए मुझे किससे बात करने की आवश्यकता है?", + "message.no_history": "यहां एआई के साथ आपकी चैट इतिहास होगा", + "message.socket_disconnect_msg": "फिर से कनेक्ट करने के लिए।", + "message.enter_mobile": "मोबाइल नंबर दर्ज करें", + "message.register_message": "यदि आप पहले से पंजीकृत हैं तो अपना मोबाइल नंबर उपयोग करके लॉगिन करें।", + "message.not_register_yet": "अभी तक पंजीकृत नहीं हैं?", + "message.register_at_krushak": "कृषक ओडिशा पर पंजीकरण करें", + "message.otp_verification": "वन टाइम पासवर्ड सत्यापन", + "message.ask_ur_question": "अपना प्रश्न पूछें", + "message.otp_message": "हम आपको इस पर एक वन टाइम पासवर्ड भेजेंगे", + "message.invalid_mobile": "10 अंकों की संख्या दर्ज करें!", + "message.cannot_answer_again": "फिर से जवाब नहीं दे सकते", + "message.invalid_otp": "अमान्य ओटीपी", + "message.otp_not_sent": "ओटीपी नहीं भेजी गई", + "message.otp_sent_again": "ओटीपी फिर से भेजी गई", + "message.wait_resending_otp": "ओटीपी फिर से भेजने से पहले कृपया प्रतीक्षा करें", + "message.helpful": "क्या यह मददगार था?", + "message.retry": "कृपया पुनः प्रयास करें।", + "message.down_time_retry": "पुनः प्रयास करें", + "message.taking_longer": "कृपया प्रतीक्षा करें, सर्वरों में सामान्य से अधिक समय लग रहा है।", + "message.rating_submitted": "रेटिंग सबमिट की गई!", + "message.review_submitted": "समीक्षा सबमिट की गई!", + "message.didnt_receive": "ओटीपी प्राप्त नहीं हुआ?", + "message.resend_again": "पुनः भेजें", + "message.coming_soon": "जल्द आ रहा है!", + "message.coming_soon_description": "हम इस सुविधा को बहुत जल्द लॉन्च करने जा रहे हैं। बने रहें!", + "message.dial_description": "कॉल सेंटर से संपर्क करने के लिए", + "message.rating": "क्या आपको यह उपयोगी लगा?", + "message.rating_description": "रेट करने के लिए एक स्टार टैप करें", + "message.review": "अपनी समीक्षा लिखें (वैकल्पिक)", + "message.review_description": "कृपया अपने अनुभव की प्रतिक्रिया लिखें।", + "message.temporarily_down": "हम अस्थायी रूप से निचे हैं", + "message.temporarily_down_description": "वर्तमान में हमें उच्च उपयोगकर्ता मात्रा का सामना हो रहा है, कृपया कुछ समय बाद लॉग इन करने का प्रयास करें", + "message.recorder_wait": "कृपया प्रतीक्षा करें जब तक हम आपकी अनुरोध को प्रोसेस कर रहे हैं...", + "message.recorder_error": "माफ़ करें, वर्तमान में आपका अनुरोध प्रोसेस करने में समस्या हो रही है। कृपया कुछ समय बाद प्रयास करें।", + "message.dialer_popup": "आप एक अमा कृषि विशेषज्ञ से बात कर सकते हैं ताकि आपको संतोषजनक जवाब मिल सके", + "error.fail_to_submit": "रेटिंग सबमिट करने में विफल।", + "error.fail_to_submit_review": "समीक्षा सबमिट करने में विफल।", + "error.sending_otp": "ओटीपी भेजने में त्रुटि", + "error.otp_not_sent": "ओटीपी नहीं भेजी गई", + "error.empty_msg": "कृपया भेजने के लिए एक संदेश टाइप या चुनें।", + "error.wait_new_chat": "कृपया जवाब की प्रतीक्षा करें।", + "error.disconnected": "आप डिस्कनेक्ट कर दिए गए हैं। कृपया रीफ्रेश करें या फिर से लॉगिन करें।", + "toast.reaction_like": "सफलतापूर्वक प्रतिक्रिया पसंद की गई", + "toast.reaction_dislike": "सफलतापूर्वक प्रतिक्रिया नापसंद की गई", + "toast.reaction_reset": "सफलतापूर्वक प्रतिक्रिया हटा दी गई" +} diff --git a/apps/agri-mitra/lang/ta.json b/apps/agri-mitra/lang/ta.json index 3adb26f..7e19ead 100644 --- a/apps/agri-mitra/lang/ta.json +++ b/apps/agri-mitra/lang/ta.json @@ -8,6 +8,7 @@ "label.search": "தேடு", "label.back": "பின் செல்ல", "label.send": "அனுப்பு", + "label.close": "நெருக்கமான", "label.profile": "சுயவிபரம்", "label.faqs": "கேள்விகள்", "label.dial": "டயல்", @@ -22,6 +23,9 @@ "label.new_chat": "புதிய உரை", "label.confirm_delete": "இந்த உரையாடலை நீக்க விரும்புகிறீர்களா?", "label.no_history": "உரைகள் இல்லை", + "label.popUpTitle": "உங்கள் ஆதார் எண் / பயனாளி ஐடி / தொலைபேசி எண்ணை உள்ளிடவும்.", + "label.popUpTitle2": "ஆதாரின் கடைசி 4 இலக்கங்களை உள்ளிடவும்", + "label.popUpTitle3": "OTP ஐ உள்ளிடவும்", "message.example_ques_one": "என் பணம் எங்கே?", "message.example_ques_two": "எனது விண்ணப்பத்தின் நிலை என்ன?", "message.example_ques_three": "எனது பணத்தைப் பெற எவருடன் பேச வேண்டும்?", diff --git a/apps/agri-mitra/lang/te.json b/apps/agri-mitra/lang/te.json index a8f9b37..8ae2e49 100644 --- a/apps/agri-mitra/lang/te.json +++ b/apps/agri-mitra/lang/te.json @@ -8,6 +8,7 @@ "label.search": "శోధన", "label.back": "తిరిగి", "label.send": "పంపండి", + "label.close": "దగ్గరగా", "label.profile": "ప్రొఫైల్", "label.faqs": "అకౌంటింటే", "label.dial": "డైల్", @@ -22,6 +23,9 @@ "label.new_chat": "కొత్త చాట్", "label.confirm_delete": "ఈ సంభాషణను తొలగించాలని నిర్ధిష్టంగా ఉన్నారా?", "label.no_history": "చాట్లు లేవు", + "label.popUpTitle": "మీ ఆధార్ నంబర్ / బెనిఫిషియరీ ID / ఫోన్ నంబర్‌ను నమోదు చేయండి.", + "label.popUpTitle2": "మీ ఆధార్‌లోని చివరి 4 అంకెలను నమోదు చేయండి", + "label.popUpTitle3": "OTPని నమోదు చేయండి", "message.example_ques_one": "నా డబ్బు ఎక్కడ ఉంది?", "message.example_ques_two": "నా అప్లికేషన్ స్థితి ఏమిటి?", "message.example_ques_three": "నా డబ్బు పొందడానికి నాకు ఎవరితో మాట్లాడాలి?", diff --git a/apps/agri-mitra/src/assets/icons/startIcon.svg b/apps/agri-mitra/src/assets/icons/startIcon.svg index 23da3a0..6e36946 100644 --- a/apps/agri-mitra/src/assets/icons/startIcon.svg +++ b/apps/agri-mitra/src/assets/icons/startIcon.svg @@ -3,7 +3,7 @@ + + + + + + \ No newline at end of file diff --git a/apps/agri-mitra/examples/workflow/index.html b/apps/agri-mitra/examples/workflow/index.html new file mode 100644 index 0000000..cc9c7b8 --- /dev/null +++ b/apps/agri-mitra/examples/workflow/index.html @@ -0,0 +1,44 @@ + + + + AgrI Mitra + + + + + + +
+
+
+ + + +
+
+ + + + + diff --git a/apps/agri-mitra/examples/workflow/index.js b/apps/agri-mitra/examples/workflow/index.js new file mode 100644 index 0000000..6ca6ce9 --- /dev/null +++ b/apps/agri-mitra/examples/workflow/index.js @@ -0,0 +1,127 @@ +document.addEventListener("DOMContentLoaded", () => { + + const dropdown = document.querySelector(".dropdown"); + const dropdownContent = document.querySelector(".dropdown-content"); + + dropdown.addEventListener("click", (event) => { + event.stopPropagation(); + dropdownContent.classList.toggle("show"); + }); + + dropdownContent.addEventListener("click", (event) => { + event.preventDefault(); + const target = event.target; + if (target.tagName === "A") { + const lang = target.getAttribute("data-lang"); + setLanguage(lang); + dropdownContent.classList.remove("show"); + } + }); + + function setLanguage(lang) { + localStorage.setItem("locale", lang); + } + + const messageContainer = document.getElementById("message-container"); + const messageInput = document.getElementById("message-input"); + const sendButton = document.getElementById("send-button"); + const recordButton = document.getElementById("record-button"); + + let isRecording = false; + let audioChunks = []; + + messageInput.addEventListener('keydown', function(event) { + if (event.key === 'Enter') { + sendButton.click(); + } + }); + + sendButton.addEventListener("click", () => { + const messageText = messageInput.value.trim(); + if (messageText !== "") { + appendMessage(messageText); + messageInput.value = ""; + } + }); + + recordButton.addEventListener("click", () => { + if (!isRecording) { + startRecording(); + } else { + stopRecording(); + } + }); + + function startRecording() { + isRecording = true; + audioChunks = []; + recordButton.classList.add("recording"); + navigator.mediaDevices.getUserMedia({ audio: true }) + .then(stream => { + const mediaRecorder = new MediaRecorder(stream); + mediaRecorder.addEventListener("dataavailable", event => { + audioChunks.push(event.data); + }); + mediaRecorder.addEventListener("stop", () => { + const audioBlob = new Blob(audioChunks); + const reader = new FileReader(); + reader.onloadend = function() { + const base64Audio = reader.result.split(",")[1]; + convertAudioToText(base64Audio); + }; + reader.readAsDataURL(audioBlob); + }); + mediaRecorder.start(); + }) + .catch(error => { + console.error("Error accessing microphone:", error); + }); + } + + function stopRecording() { + isRecording = false; + recordButton.classList.remove("recording"); + navigator.mediaDevices.getUserMedia({ audio: true }) + .then(stream => { + const mediaRecorder = new MediaRecorder(stream); + mediaRecorder.addEventListener("stop", () => { + mediaRecorder.stream.getTracks().forEach(track => track.stop()); + }); + mediaRecorder.stop(); + }) + .catch(error => { + console.error("Error accessing microphone:", error); + }); + } + + function convertAudioToText(base64Audio) { + // const aiToolsSDK = new AiToolsSDK(); + AITools.stt(base64Audio) + .then(response => { + console.log(response) + const transcribedText = response.text; + if (transcribedText) { + appendMessage(transcribedText); + } + }) + .catch(error => { + console.error("Error converting audio to text:", error); + }); + } + + function appendMessage(message) { + const messageElement = document.createElement("div"); + messageElement.classList.add("message"); + messageElement.textContent = message; + messageContainer.appendChild(messageElement); + } + document.querySelector("body").onload = + async function fetchAiToolsSdk() { + try { + const response = await fetch('https://cdn.jsdelivr.net/npm/ai-tools-sdk@0.1.2/src/index.ts'); + } catch (error) { + console.error(error); + } + } + +}); diff --git a/apps/agri-mitra/examples/workflow/mic.svg b/apps/agri-mitra/examples/workflow/mic.svg new file mode 100644 index 0000000..9def6cd --- /dev/null +++ b/apps/agri-mitra/examples/workflow/mic.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/apps/agri-mitra/examples/workflow/styles.css b/apps/agri-mitra/examples/workflow/styles.css new file mode 100644 index 0000000..c32360e --- /dev/null +++ b/apps/agri-mitra/examples/workflow/styles.css @@ -0,0 +1,125 @@ +body { + font-family: Arial, sans-serif; + margin: 0; + padding: 0; + overflow: hidden; +} + +nav{ + padding: 1vh; + height: 4vh; + display: flex; + justify-content: space-between; +} + +.dropbtn{ + padding: 10px 20px; +} + +#heading{ + font-weight: 700; + color: #4CAF50; + font-size: 5vw; +} + +#logos{ + display: flex; +} + +/* Dropdown Styles */ +.dropdown { + position: relative; + display: inline-block; +} + +.dropdown-content { + display: none; + position: absolute; + z-index: 1; + background-color: #f9f9f9; + min-width: 160px; + box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); + padding: 12px 16px; +} + +.dropdown-content a { + color: #000; + text-decoration: none; + display: block; + padding: 6px 0; +} + +.dropdown:hover .dropdown-content { + display: block; +} + +.dropdown-content a:hover { + background-color: #ddd; +} + +.show { + display: block; +} + + +#chat-container { + display: flex; + flex-direction: column; + height: 94vh; + padding: 20px; + box-sizing: border-box; +} + +#message-container { + flex: 1; + overflow-y: auto; +} + +.message { + background-color: #f1f1f1; + padding: 14px; + margin-bottom: 12px; + border-radius: 5px; + font-size: 28px; +} + +#input-container { + display: flex; + align-items: center; + margin-top: 10px; +} + +#record-button{ + margin-right: 8px; + width: 75px; + height: 75px; +} + +#message-input { + flex: 0.85; + padding: 10px; + height: 110px; + font-size: 28px; + border: 1px solid #ccc; + border-radius: 5px; + outline: none; + width: 100%; + box-sizing: border-box; +} + +#send-button { + height: 110px; + font-size: 28px; + flex: 0.15; + margin-left: 10px; + padding: 5px 10px; + border: none; + background-color: #4CAF50; + color: white; + border-radius: 50px; + cursor: pointer; +} + +#send-button:hover { + background-color: #45a049; +} From f06759055a7f0012c8e1e4073bfb36b8be423d83 Mon Sep 17 00:00:00 2001 From: Amruth-Vamshi Date: Fri, 7 Jul 2023 13:57:10 +0530 Subject: [PATCH 15/34] Updated the hindi STT model Id. --- apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx b/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx index 3dc620b..60d58d3 100644 --- a/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx +++ b/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx @@ -217,7 +217,7 @@ const RenderVoiceRecorder = ( props ) => { const lang = localStorage.getItem('locale') || 'en'; switch (lang) { case 'hi': - return '620fb9fc7c69fa1fc5bba7be'; + return '64117455b1463435d2fbaec4'; case 'bn': return '6411746956e9de23f65b5426'; case 'ta': From a86d88939ea5037225cfc25916fec480b9f661d5 Mon Sep 17 00:00:00 2001 From: Prateek Jakhar Date: Tue, 11 Jul 2023 10:19:40 +0530 Subject: [PATCH 16/34] Updated verify otp req --- apps/agri-mitra/src/components/Popup/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/agri-mitra/src/components/Popup/index.tsx b/apps/agri-mitra/src/components/Popup/index.tsx index cbbafd5..4461dfe 100644 --- a/apps/agri-mitra/src/components/Popup/index.tsx +++ b/apps/agri-mitra/src/components/Popup/index.tsx @@ -190,7 +190,7 @@ const Popup = (props: PopupProps) => { fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/user/verifyotp`, { method: 'POST', body: JSON.stringify({ - identifier: input, + identifier: input+(aadhaar.length>0?aadhaar:''), otp: otp, }), headers: { From 2dcea3d78f12c6219490be4eeb13a2edc6c3cae0 Mon Sep 17 00:00:00 2001 From: Prateek Jakhar Date: Tue, 11 Jul 2023 10:35:58 +0530 Subject: [PATCH 17/34] Updated identifier --- apps/agri-mitra/src/components/Popup/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/agri-mitra/src/components/Popup/index.tsx b/apps/agri-mitra/src/components/Popup/index.tsx index 4461dfe..53fd067 100644 --- a/apps/agri-mitra/src/components/Popup/index.tsx +++ b/apps/agri-mitra/src/components/Popup/index.tsx @@ -71,7 +71,7 @@ const Popup = (props: PopupProps) => { const handleSend = async () => { try { - sessionStorage.setItem('identifier', input); + sessionStorage.setItem('identifier', input+(aadhaar.length>0?aadhaar:'')); // const response = await fetch( // `${process.env.NEXT_PUBLIC_BASE_URL}/user/linkedBeneficiaryIdsCount/${input}`, // { @@ -151,6 +151,7 @@ const Popup = (props: PopupProps) => { const handleAadhaarSubmit = () => { // checking if aadhaar is a 4 digit number only if (aadhaar.length === 4 && /^\d{4}$/.test(aadhaar)) { + sessionStorage.setItem('identifier', input+(aadhaar.length>0?aadhaar:'')); // fetch( // `${process.env.NEXT_PUBLIC_BASE_URL}/user/checkMapping?phoneNo=${input}&maskedAadhaar=${aadhaar}`, // { method: 'GET' } From 541b27a71e3a33fb7b431442575ba899276e295a Mon Sep 17 00:00:00 2001 From: prtkjakhar Date: Tue, 11 Jul 2023 11:43:33 +0530 Subject: [PATCH 18/34] changed send to submit for otp --- apps/agri-mitra/src/components/Popup/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/agri-mitra/src/components/Popup/index.tsx b/apps/agri-mitra/src/components/Popup/index.tsx index 53fd067..3997dd6 100644 --- a/apps/agri-mitra/src/components/Popup/index.tsx +++ b/apps/agri-mitra/src/components/Popup/index.tsx @@ -324,7 +324,7 @@ const Popup = (props: PopupProps) => { {showInput ? ( ) : showOtp ? ( - + ) : ( )} From 60badec3d5499ee170ef61f9650cf21060a04b2a Mon Sep 17 00:00:00 2001 From: root Date: Thu, 13 Jul 2023 08:28:00 +0000 Subject: [PATCH 19/34] Updated langauge data and ContextProvider.tsx --- apps/agri-mitra/lang/en.json | 6 +++--- apps/agri-mitra/src/context/ContextProvider.tsx | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/agri-mitra/lang/en.json b/apps/agri-mitra/lang/en.json index ac4b0c5..774f914 100644 --- a/apps/agri-mitra/lang/en.json +++ b/apps/agri-mitra/lang/en.json @@ -1,5 +1,5 @@ { - "label.title": "AgrI-Mitra", + "label.title": "Kisan e-Mitra", "label.welcome": "Welcome", "label.chats": "Chats", "label.farmer": "Farmer", @@ -23,9 +23,9 @@ "label.new_chat": "New chat", "label.confirm_delete": "Are you sure you want to delete this conversation?", "label.no_history": "No Chats", - "label.popUpTitle": "Enter your Aadhaar Number / Beneficiary ID / Phone no.", + "label.popUpTitle": "Dear Beneficiery, Thank for reaching out to us with your query. In order to provide you with the correct resolution, we kindly request you to provide us with your Aadhaar Number / Beneficiary ID / Phone no.", "label.popUpTitle2": "Enter your last 4 digits of Aadhaar", - "label.popUpTitle3": "Enter OTP", + "label.popUpTitle3": "Enter Beneficiery, request you to kindly enter the OTP that has been received by you", "message.example_ques_one": "Where is my money?", "message.example_ques_two": "What is the status of my application?", "message.example_ques_three": "Whom do I need to speak to in order to get my money?", diff --git a/apps/agri-mitra/src/context/ContextProvider.tsx b/apps/agri-mitra/src/context/ContextProvider.tsx index 488ed7d..8378eaf 100644 --- a/apps/agri-mitra/src/context/ContextProvider.tsx +++ b/apps/agri-mitra/src/context/ContextProvider.tsx @@ -78,6 +78,7 @@ const ContextProvider: FC<{ ) { setNewSocket( io(URL, { + path: '/websocket/socket.io', transportOptions: { polling: { extraHeaders: { From c4c5704f9ab2e6f70d55e92c2740de77fcc054b8 Mon Sep 17 00:00:00 2001 From: prtkjakhar Date: Thu, 13 Jul 2023 14:17:13 +0530 Subject: [PATCH 20/34] hindi models updated --- .../src/components/recorder/RenderVoiceRecorder.jsx | 8 ++++---- apps/agri-mitra/src/context/ContextProvider.tsx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx b/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx index 60d58d3..81fc4ee 100644 --- a/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx +++ b/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx @@ -232,7 +232,7 @@ const RenderVoiceRecorder = ( props ) => { const lang = localStorage.getItem('locale') || 'en'; switch (lang) { case 'hi': - return '6110f8b7014fa35d5e767c48'; + return '63b286b286369150cb004369'; case 'bn': return '6110f7bc014fa35d5e767c3b'; case 'ta': @@ -272,8 +272,8 @@ const RenderVoiceRecorder = ( props ) => { .then(async (resp) => { let rsp_data = await resp.json(); if (resp.ok && rsp_data !== null) { - console.log("hi", rsp_data.data.source); - console.log("hi", props.wordToNumber); + // console.log("hi", rsp_data.data.source); + // console.log("hi", props.wordToNumber); if (props.wordToNumber) { // translating other language words to english words if (localStorage.getItem('locale') && localStorage.getItem('locale') !== 'en') { @@ -292,7 +292,7 @@ const RenderVoiceRecorder = ( props ) => { headers: obj.getHeaders().headers, }).then(async (translationResp) => { let rsp_data = await translationResp.json(); - console.log("hi", wordToNumber(rsp_data.output[0].target)) + // console.log("hi", wordToNumber(rsp_data.output[0].target)) if (translationResp.ok) { // setOutput((prev) => ({ // ...prev, diff --git a/apps/agri-mitra/src/context/ContextProvider.tsx b/apps/agri-mitra/src/context/ContextProvider.tsx index 8378eaf..31f96d2 100644 --- a/apps/agri-mitra/src/context/ContextProvider.tsx +++ b/apps/agri-mitra/src/context/ContextProvider.tsx @@ -180,7 +180,7 @@ const ContextProvider: FC<{ const lang = localStorage.getItem('locale') || 'en'; switch (lang) { case 'hi': - return '6110f7f7014fa35d5e767c3f'; + return '63b286b286369150cb004369'; case 'bn': return '6110f7da014fa35d5e767c3d'; case 'ta': From 5e3552eaaa0be9c2dd265543ad25c47d59381486 Mon Sep 17 00:00:00 2001 From: prtkjakhar Date: Thu, 13 Jul 2023 15:50:27 +0530 Subject: [PATCH 21/34] bug fixes --- .../agri-mitra/src/components/Popup/index.tsx | 9 +++++++++ .../recorder/RenderVoiceRecorder.jsx | 6 +++--- .../src/context/ContextProvider.tsx | 19 ++++++++++++------- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/apps/agri-mitra/src/components/Popup/index.tsx b/apps/agri-mitra/src/components/Popup/index.tsx index 3997dd6..faf747f 100644 --- a/apps/agri-mitra/src/components/Popup/index.tsx +++ b/apps/agri-mitra/src/components/Popup/index.tsx @@ -188,6 +188,13 @@ const Popup = (props: PopupProps) => { const handleOTPSubmit = () => { if (otp.length === 4) { + // Check if the function is already running + if (context?.isSubmitting) { + return; + } + + context.setIsSubmitting(true); + fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/user/verifyotp`, { method: 'POST', body: JSON.stringify({ @@ -219,10 +226,12 @@ const Popup = (props: PopupProps) => { router.push('/chat'); } else { toast.error(`${t('message.invalid_otp')}`); + context?.setIsSubmitting(false); } }) .catch((err) => { console.log(err); + context?.setIsSubmitting(false); }); } }; diff --git a/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx b/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx index 81fc4ee..b958d7e 100644 --- a/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx +++ b/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx @@ -303,10 +303,10 @@ const RenderVoiceRecorder = ( props ) => { // translation: rsp_data.output[0].target, // })); } - props.setInputMsg(wordToNumber(rsp_data.output[0].target)); + props.setInputMsg(wordToNumber(rsp_data?.output?.[0]?.target)); }); - } else props.setInputMsg(wordToNumber(rsp_data.data.source)); - } else props.setInputMsg(rsp_data.data.source); + } else props.setInputMsg(wordToNumber(rsp_data?.data?.source)); + } else props.setInputMsg(rsp_data?.data?.source); // setSuggestEditValues((prev) => ({ // ...prev, // asr: rsp_data.data.source, diff --git a/apps/agri-mitra/src/context/ContextProvider.tsx b/apps/agri-mitra/src/context/ContextProvider.tsx index 31f96d2..138d077 100644 --- a/apps/agri-mitra/src/context/ContextProvider.tsx +++ b/apps/agri-mitra/src/context/ContextProvider.tsx @@ -67,6 +67,7 @@ const ContextProvider: FC<{ const [showPopUp, setShowPopUp] = useState(false); const [cookie, setCookie, removeCookie] = useCookies(); const [isAudioPlaying, setIsAudioPlaying] = useState(false); + const [OTPSubmitting, setOTPSubmitting] = useState(false); const audioRef = useRef(null); console.log(messages); @@ -78,7 +79,7 @@ const ContextProvider: FC<{ ) { setNewSocket( io(URL, { - path: '/websocket/socket.io', + path: '/websocket/socket.io', transportOptions: { polling: { extraHeaders: { @@ -171,7 +172,7 @@ const ContextProvider: FC<{ }); } else if (msg.content.msg_type.toUpperCase() === 'TEXT') { try { - if(localStorage.getItem('locale') === 'en'){ + if (localStorage.getItem('locale') === 'en') { setLoading(false); updateMsgState({ user, msg, media: {} }); return; @@ -192,9 +193,9 @@ const ContextProvider: FC<{ } }; - if(msg.content.split){ + if (msg.content.split) { let titles = msg.content.title.split(`\n`); - for(let i=0; i Date: Thu, 13 Jul 2023 16:10:51 +0530 Subject: [PATCH 22/34] Update index.tsx --- apps/agri-mitra/src/components/Popup/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/agri-mitra/src/components/Popup/index.tsx b/apps/agri-mitra/src/components/Popup/index.tsx index faf747f..a6d3e6c 100644 --- a/apps/agri-mitra/src/components/Popup/index.tsx +++ b/apps/agri-mitra/src/components/Popup/index.tsx @@ -224,6 +224,7 @@ const Popup = (props: PopupProps) => { context?.sendMessage(props.msg.trim()); context?.setShowPopUp(false); router.push('/chat'); + context?.setIsSubmitting(false); } else { toast.error(`${t('message.invalid_otp')}`); context?.setIsSubmitting(false); From 31d6d616b95ab6a68fbcd1a60218e993e3ed1bcd Mon Sep 17 00:00:00 2001 From: Karun Agarwal <113603846+singhalkarun@users.noreply.github.com> Date: Thu, 13 Jul 2023 16:39:28 +0530 Subject: [PATCH 23/34] Update build-and-push.yml --- .github/workflows/build-and-push.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 83dd7c0..dff90b1 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -38,9 +38,11 @@ jobs: with: build-args: | "SERVER_RELEASE_VERSION=${{ github.sha }}" + "NEXT_PUBLIC_BASE_URL=${{ secrets.NEXT_PUBLIC_BASE_URL }}" + "NEXT_PUBLIC_SOCKET_URL=${{ secrets.NEXT_PUBLIC_SOCKET_URL }}" context: . push: true cache-from: type=gha cache-to: type=gha,mode=max tags: ${{ env.DOCKER_REGISTRY }}/${{ steps.lower-repo.outputs.repository }}:${{env.DOCKER_IMAGE_TAG}} - labels: org.opencontainers.image.source=https://github.com/${{steps.lower-repo.outputs.repository}} \ No newline at end of file + labels: org.opencontainers.image.source=https://github.com/${{steps.lower-repo.outputs.repository}} From 73c197d685befcc98089d737d8b64f179d03da9e Mon Sep 17 00:00:00 2001 From: Karun Agarwal <113603846+singhalkarun@users.noreply.github.com> Date: Thu, 13 Jul 2023 16:41:52 +0530 Subject: [PATCH 24/34] Update Dockerfile --- Dockerfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Dockerfile b/Dockerfile index 4886d2d..4ee2f5b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,15 @@ WORKDIR /app COPY . . RUN npm install WORKDIR /app/apps/agri-mitra + +ARG NEXT_PUBLIC_BASE_URL +ENV NEXT_PUBLIC_BASE_URL ${NEXT_PUBLIC_BASE_URL} + +ARG NEXT_PUBLIC_SOCKET_URL +ENV NEXT_PUBLIC_SOCKET_URL ${NEXT_PUBLIC_SOCKET_URL} + RUN npm run build ENV NODE_ENV production + EXPOSE 3000 CMD ["npm", "start"] From d552c2664c56d2cb5cc1be1eef5ad41a82b629bf Mon Sep 17 00:00:00 2001 From: prtkjakhar Date: Thu, 13 Jul 2023 16:54:41 +0530 Subject: [PATCH 25/34] removed isSubmitting --- apps/agri-mitra/src/components/Popup/index.tsx | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/apps/agri-mitra/src/components/Popup/index.tsx b/apps/agri-mitra/src/components/Popup/index.tsx index a6d3e6c..3997dd6 100644 --- a/apps/agri-mitra/src/components/Popup/index.tsx +++ b/apps/agri-mitra/src/components/Popup/index.tsx @@ -188,13 +188,6 @@ const Popup = (props: PopupProps) => { const handleOTPSubmit = () => { if (otp.length === 4) { - // Check if the function is already running - if (context?.isSubmitting) { - return; - } - - context.setIsSubmitting(true); - fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/user/verifyotp`, { method: 'POST', body: JSON.stringify({ @@ -224,15 +217,12 @@ const Popup = (props: PopupProps) => { context?.sendMessage(props.msg.trim()); context?.setShowPopUp(false); router.push('/chat'); - context?.setIsSubmitting(false); } else { toast.error(`${t('message.invalid_otp')}`); - context?.setIsSubmitting(false); } }) .catch((err) => { console.log(err); - context?.setIsSubmitting(false); }); } }; From 1369bd1850f23398a97580eedce49dfeacb6a41f Mon Sep 17 00:00:00 2001 From: prtkjakhar Date: Thu, 13 Jul 2023 16:58:07 +0530 Subject: [PATCH 26/34] added otpsubmitting --- apps/agri-mitra/src/components/Popup/index.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/agri-mitra/src/components/Popup/index.tsx b/apps/agri-mitra/src/components/Popup/index.tsx index 3997dd6..63e8b4e 100644 --- a/apps/agri-mitra/src/components/Popup/index.tsx +++ b/apps/agri-mitra/src/components/Popup/index.tsx @@ -188,6 +188,13 @@ const Popup = (props: PopupProps) => { const handleOTPSubmit = () => { if (otp.length === 4) { + // Check if the function is already running + if (context?.OTPSubmitting) { + return; + } + + context.setOTPSubmitting(true); + fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/user/verifyotp`, { method: 'POST', body: JSON.stringify({ @@ -217,12 +224,15 @@ const Popup = (props: PopupProps) => { context?.sendMessage(props.msg.trim()); context?.setShowPopUp(false); router.push('/chat'); + context?.setOTPSubmitting(false); } else { toast.error(`${t('message.invalid_otp')}`); + context?.setOTPSubmitting(false); } }) .catch((err) => { console.log(err); + context?.setOTPSubmitting(false); }); } }; From 6a8a2e0a32c8597a5ff380455724b20da1fb0654 Mon Sep 17 00:00:00 2001 From: prtkjakhar Date: Thu, 13 Jul 2023 17:48:31 +0530 Subject: [PATCH 27/34] fix: minor ui changes --- apps/agri-mitra/lang/bn.json | 1 + apps/agri-mitra/lang/en.json | 1 + apps/agri-mitra/lang/hi.json | 1 + apps/agri-mitra/lang/ta.json | 1 + apps/agri-mitra/lang/te.json | 9 +++++---- apps/agri-mitra/src/components/Popup/index.tsx | 12 ++++++------ .../src/components/recorder/RenderVoiceRecorder.jsx | 8 ++++---- apps/agri-mitra/src/context/ContextProvider.tsx | 8 ++++---- 8 files changed, 23 insertions(+), 18 deletions(-) diff --git a/apps/agri-mitra/lang/bn.json b/apps/agri-mitra/lang/bn.json index fc84629..983a2e4 100644 --- a/apps/agri-mitra/lang/bn.json +++ b/apps/agri-mitra/lang/bn.json @@ -71,6 +71,7 @@ "error.empty_msg": "পাঠানোর জন্য দয়া করে একটি বার্তা টাইপ করুন বা নির্বাচন করুন।", "error.wait_new_chat": "উত্তরের জন্য অপেক্ষা করুন।", "error.disconnected": "আপনি সংযুক্ত হয়নি। দয়া করে রিফ্রেশ করুন বা আবার লগইন করুন।", + "error.userid_not_registered": "ব্যবহারকারী নিবন্ধিত নয়", "toast.reaction_like": "সাফল্যের সাথে প্রতিক্রিয়াটি পছন্দ হয়েছে", "toast.reaction_dislike": "সাফল্যের সাথে প্রতিক্রিয়াটি অপছন্দ হয়েছে", "toast.reaction_reset": "প্রতিক্রিয়াটি সাফল্যের সাথে পুনরায় সেট করা হয়েছে" diff --git a/apps/agri-mitra/lang/en.json b/apps/agri-mitra/lang/en.json index 774f914..ca45963 100644 --- a/apps/agri-mitra/lang/en.json +++ b/apps/agri-mitra/lang/en.json @@ -71,6 +71,7 @@ "error.empty_msg": "Please type or select a message to send.", "error.wait_new_chat": "Please wait for reply.", "error.disconnected": "You are disconnected. Please refresh or login again.", + "error.userid_not_registered": "UserID not registered.", "toast.reaction_like": "Successfully liked the response", "toast.reaction_dislike": "Successfully disliked the response", "toast.reaction_reset": "Successfully removed the response" diff --git a/apps/agri-mitra/lang/hi.json b/apps/agri-mitra/lang/hi.json index 219cd40..bfa278e 100644 --- a/apps/agri-mitra/lang/hi.json +++ b/apps/agri-mitra/lang/hi.json @@ -71,6 +71,7 @@ "error.empty_msg": "कृपया भेजने के लिए एक संदेश टाइप या चुनें।", "error.wait_new_chat": "कृपया जवाब की प्रतीक्षा करें।", "error.disconnected": "आप डिस्कनेक्ट कर दिए गए हैं। कृपया रीफ्रेश करें या फिर से लॉगिन करें।", + "error.userid_not_registered": "उपयोगकर्ता पंजीकृत नहीं है।", "toast.reaction_like": "सफलतापूर्वक प्रतिक्रिया पसंद की गई", "toast.reaction_dislike": "सफलतापूर्वक प्रतिक्रिया नापसंद की गई", "toast.reaction_reset": "सफलतापूर्वक प्रतिक्रिया हटा दी गई" diff --git a/apps/agri-mitra/lang/ta.json b/apps/agri-mitra/lang/ta.json index 7e19ead..7759b20 100644 --- a/apps/agri-mitra/lang/ta.json +++ b/apps/agri-mitra/lang/ta.json @@ -71,6 +71,7 @@ "error.empty_msg": "அனுப்ப ஒரு செய்தியை அல்லது தேர்ந்தெடுத்த செய்தியை தட்டவும்.", "error.wait_new_chat": "பதிலைக் காத்திருக்க தயவுசெய்து காத்திருங்கள்.", "error.disconnected": "இணைக்கப்படவில்லை. மீண்டும் சேமிக்கவும் அல்லது முதன்முதலில் உள்நுழைக.", + "error.userid_not_registered": "பயனர் பதிவு செய்யப்படவில்லை", "toast.reaction_like": "பதிலை விரும்புகின்றீர்கள் என்பதை வெற்றிகரமாக அமைத்துக் கொண்டீர்கள்", "toast.reaction_dislike": "பதிலை விருப்பத்தை அகற்றுகின்றீர்கள் என்பதை வெற்றிகரமாக அமைத்துக் கொண்டீர்கள்", "toast.reaction_reset": "பதிலை நீக்கி வைத்துக் கொண்டீர்கள்" diff --git a/apps/agri-mitra/lang/te.json b/apps/agri-mitra/lang/te.json index 8ae2e49..c6fd692 100644 --- a/apps/agri-mitra/lang/te.json +++ b/apps/agri-mitra/lang/te.json @@ -65,12 +65,13 @@ "message.recorder_error": "క్షమించండి, ప్రస్తుతం మీ అభ్యర్థనను ప్రాసెస్ చేయడంలో సమస్య ఉంది. దయచేసి తరువాత మరీ ప్రయత్నించండి.", "message.dialer_popup": "తృప్తికరమైన సమాధానం కోసం ఒక అమా కృషి నిపుణునితో మాటలు చేయగలరు", "error.fail_to_submit": "రేటింగ్ సమర్పించలేదు.", - "error.fail_to_submit_review": "సమీక్షను సమర్పించలేదు.", + "error.fail_to_submit_review": "సమీక్షను సమర్పించలేదు", "error.sending_otp": "OTP పంపడంలో లోపం ఉంది", "error.otp_not_sent": "OTP పంపబడలేదు", - "error.empty_msg": "దయచేసి పంపుటకు ఒక సందేశాన్ని టైప్ లేదా ఎంచుకోండి.", - "error.wait_new_chat": "దయచేసి జవాబుకు వేచి ఉండండి.", - "error.disconnected": "మీరు డిస్కనెక్ట్ అయ్యారు. దయచేసి రీఫ్రెష్ చేయండి లేదా మళ్ళీ లాగిన్ చేయండి.", + "error.empty_msg": "దయచేసి పంపుటకు ఒక సందేశాన్ని టైప్ లేదా ఎంచుకోండి", + "error.wait_new_chat": "దయచేసి జవాబుకు వేచి ఉండండి", + "error.disconnected": "మీరు డిస్కనెక్ట్ అయ్యారు. దయచేసి రీఫ్రెష్ చేయండి లేదా మళ్ళీ లాగిన్ చేయండి", + "error.userid_not_registered": "వినియోగదారు నమోదు చేయబడలేదు", "toast.reaction_like": "సమాధానంని సరిగా ఇష్టపడండి", "toast.reaction_dislike": "సమాధానంని సరిగా ఇష్టపడండి", "toast.reaction_reset": "సమాధానంని తీసివేయబడింది" diff --git a/apps/agri-mitra/src/components/Popup/index.tsx b/apps/agri-mitra/src/components/Popup/index.tsx index 63e8b4e..ba4ed1c 100644 --- a/apps/agri-mitra/src/components/Popup/index.tsx +++ b/apps/agri-mitra/src/components/Popup/index.tsx @@ -7,7 +7,6 @@ import axios from 'axios'; import RenderVoiceRecorder from '../recorder/RenderVoiceRecorder'; import { useLocalization } from '../../hooks/useLocalization'; import { FormattedMessage } from 'react-intl'; -import { useCookies } from 'react-cookie'; import Image from 'next/image'; import crossIcon from '../../assets/icons/crossIcon.svg'; @@ -27,7 +26,6 @@ const Popup = (props: PopupProps) => { const [isResendingOTP, setIsResendingOTP] = useState(false); const [countdown, setCountdown] = useState(0); const [countdownIntervalId, setCountdownIntervalId] = useState(null); - const [cookies, setCookie, removeCookie] = useCookies(['access_token']); const resendOTP = useCallback(async () => { if (isResendingOTP) { @@ -38,7 +36,7 @@ const Popup = (props: PopupProps) => { setIsResendingOTP(true); try { const response = await axios.get( - `${process.env.NEXT_PUBLIC_BASE_URL}/user/sendotp/${input}` + `${process.env.NEXT_PUBLIC_BASE_URL}/user/sendotp/${input+(aadhaar.length>0?aadhaar:'')}` ); if (response.status === 200) { toast.success(`${t('message.otp_sent_again')}`); @@ -67,7 +65,7 @@ const Popup = (props: PopupProps) => { clearInterval(countdownIntervalId); } }; - }, [isResendingOTP, t, input, countdownIntervalId]); + }, [isResendingOTP, t, input, countdownIntervalId, aadhaar]); const handleSend = async () => { try { @@ -116,13 +114,15 @@ const Popup = (props: PopupProps) => { console.log(otpRes); if (otpRes.status === 'NOT_OK') { const errorMsg = otpRes?.d?.output?.Message || otpRes?.error; - toast.error(errorMsg); if ( - otpRes.d.output.Message === + errorMsg === 'This mobile number taged with multiple records.' ) { + toast.error(errorMsg); setShowInput(false); setShowAadhaar(true); + }else{ + toast.error(`${t('error.userid_not_registered')}`); } } else { toast.success('OTP sent'); diff --git a/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx b/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx index b958d7e..b4f9c38 100644 --- a/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx +++ b/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx @@ -232,13 +232,13 @@ const RenderVoiceRecorder = ( props ) => { const lang = localStorage.getItem('locale') || 'en'; switch (lang) { case 'hi': - return '63b286b286369150cb004369'; + return '63b28348ff7cd87a3f7e1029'; case 'bn': - return '6110f7bc014fa35d5e767c3b'; + return '641d1d818ecee6735a1b37c7'; case 'ta': - return '6110f917014fa35d5e767c4e'; + return '641d1caa92a6a31751ff1eb6'; case 'te': - return '6110f924014fa35d5e767c4f'; + return '641d1cab8ecee6735a1b370b'; default: return '63ee09c3b95268521c70cd7c'; } diff --git a/apps/agri-mitra/src/context/ContextProvider.tsx b/apps/agri-mitra/src/context/ContextProvider.tsx index 5888051..6a867a3 100644 --- a/apps/agri-mitra/src/context/ContextProvider.tsx +++ b/apps/agri-mitra/src/context/ContextProvider.tsx @@ -181,13 +181,13 @@ const ContextProvider: FC<{ const lang = localStorage.getItem('locale') || 'en'; switch (lang) { case 'hi': - return '63b286b286369150cb004369'; + return '63b28348ff7cd87a3f7e1029'; case 'bn': - return '6110f7da014fa35d5e767c3d'; + return '641d1d818ecee6735a1b37c7'; case 'ta': - return '610cfe8b014fa35d5e767c35'; + return '641d1caa92a6a31751ff1eb6'; case 'te': - return '6110f89b014fa35d5e767c46'; + return '641d1cab8ecee6735a1b370b'; default: return '63ee09c3b95268521c70cd7c'; } From a59ba875ad4c0fc7ab5c897ce6b61554d1acbd70 Mon Sep 17 00:00:00 2001 From: prtkjakhar Date: Thu, 13 Jul 2023 18:10:59 +0530 Subject: [PATCH 28/34] changed models --- .../src/components/recorder/RenderVoiceRecorder.jsx | 9 +++++---- apps/agri-mitra/src/context/ContextProvider.tsx | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx b/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx index b4f9c38..8819491 100644 --- a/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx +++ b/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx @@ -228,17 +228,18 @@ const RenderVoiceRecorder = ( props ) => { return '6387b54086369150cb004351'; } }; + // converts other languages to english const modelId_TRANSLATION = () => { const lang = localStorage.getItem('locale') || 'en'; switch (lang) { case 'hi': - return '63b28348ff7cd87a3f7e1029'; + return '641d1cd18ecee6735a1b372a'; case 'bn': - return '641d1d818ecee6735a1b37c7'; + return '641d1d3e8ecee6735a1b3793'; case 'ta': - return '641d1caa92a6a31751ff1eb6'; + return '641d1d2d92a6a31751ff1f1d'; case 'te': - return '641d1cab8ecee6735a1b370b'; + return '641d1ca98ecee6735a1b3707'; default: return '63ee09c3b95268521c70cd7c'; } diff --git a/apps/agri-mitra/src/context/ContextProvider.tsx b/apps/agri-mitra/src/context/ContextProvider.tsx index 6a867a3..ee99006 100644 --- a/apps/agri-mitra/src/context/ContextProvider.tsx +++ b/apps/agri-mitra/src/context/ContextProvider.tsx @@ -177,6 +177,7 @@ const ContextProvider: FC<{ updateMsgState({ user, msg, media: {} }); return; } + // converts english messages from socket to other languages const modelId_TRANSLATION = () => { const lang = localStorage.getItem('locale') || 'en'; switch (lang) { From 108172393d20513b65a789c7739a4f9a5cd4ae5f Mon Sep 17 00:00:00 2001 From: prtkjakhar Date: Thu, 13 Jul 2023 18:34:07 +0530 Subject: [PATCH 29/34] updated hindi asr model --- apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx b/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx index 8819491..80675c6 100644 --- a/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx +++ b/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx @@ -217,7 +217,7 @@ const RenderVoiceRecorder = ( props ) => { const lang = localStorage.getItem('locale') || 'en'; switch (lang) { case 'hi': - return '64117455b1463435d2fbaec4'; + return '648025f27cdd753e77f461a9'; case 'bn': return '6411746956e9de23f65b5426'; case 'ta': From f2f15601e6593f1d7c619e5277968801fb6b2a4c Mon Sep 17 00:00:00 2001 From: prtkjakhar Date: Fri, 14 Jul 2023 10:03:27 +0530 Subject: [PATCH 30/34] fix: updated translation hindi model id --- apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx b/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx index 80675c6..deb5f44 100644 --- a/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx +++ b/apps/agri-mitra/src/components/recorder/RenderVoiceRecorder.jsx @@ -233,7 +233,7 @@ const RenderVoiceRecorder = ( props ) => { const lang = localStorage.getItem('locale') || 'en'; switch (lang) { case 'hi': - return '641d1cd18ecee6735a1b372a'; + return '63b286b286369150cb004369'; case 'bn': return '641d1d3e8ecee6735a1b3793'; case 'ta': From b89c87075efb25baa70bfa26832cd1b41752f363 Mon Sep 17 00:00:00 2001 From: prtkjakhar Date: Fri, 14 Jul 2023 11:20:24 +0530 Subject: [PATCH 31/34] updated title in launch page --- apps/agri-mitra/lang/bn.json | 2 +- apps/agri-mitra/lang/hi.json | 2 +- apps/agri-mitra/lang/ta.json | 2 +- apps/agri-mitra/lang/te.json | 2 +- apps/agri-mitra/src/components/LaunchPage/index.tsx | 4 +++- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/agri-mitra/lang/bn.json b/apps/agri-mitra/lang/bn.json index 983a2e4..4e42368 100644 --- a/apps/agri-mitra/lang/bn.json +++ b/apps/agri-mitra/lang/bn.json @@ -1,5 +1,5 @@ { - "label.title": "AgrI-Mitra", + "label.title": "Kisan e-Mitra", "label.welcome": "স্বাগতম", "label.chats": "চ্যাটগুলি", "label.farmer": "কৃষক", diff --git a/apps/agri-mitra/lang/hi.json b/apps/agri-mitra/lang/hi.json index bfa278e..6c473a5 100644 --- a/apps/agri-mitra/lang/hi.json +++ b/apps/agri-mitra/lang/hi.json @@ -1,5 +1,5 @@ { - "label.title": "AgrI-Mitra", + "label.title": "Kisan e-Mitra", "label.welcome": "स्वागत", "label.chats": "चैट", "label.farmer": "किसान", diff --git a/apps/agri-mitra/lang/ta.json b/apps/agri-mitra/lang/ta.json index 7759b20..8d84bbf 100644 --- a/apps/agri-mitra/lang/ta.json +++ b/apps/agri-mitra/lang/ta.json @@ -1,5 +1,5 @@ { - "label.title": "AgrI-Mitra", + "label.title": "Kisan e-Mitra", "label.welcome": "வரவேற்பு", "label.chats": "உரைகள்", "label.farmer": "விவசாயி", diff --git a/apps/agri-mitra/lang/te.json b/apps/agri-mitra/lang/te.json index c6fd692..f1523e5 100644 --- a/apps/agri-mitra/lang/te.json +++ b/apps/agri-mitra/lang/te.json @@ -1,5 +1,5 @@ { - "label.title": "AgrI-Mitra", + "label.title": "Kisan e-Mitra", "label.welcome": "స్వాగతం", "label.chats": "చాట్లు", "label.farmer": "రైతు", diff --git a/apps/agri-mitra/src/components/LaunchPage/index.tsx b/apps/agri-mitra/src/components/LaunchPage/index.tsx index 3e0e1e0..78cd067 100644 --- a/apps/agri-mitra/src/components/LaunchPage/index.tsx +++ b/apps/agri-mitra/src/components/LaunchPage/index.tsx @@ -1,8 +1,10 @@ import styles from './index.module.css'; import Logo from "../../assets/images/MOA_logo.png"; import Image from "next/image"; +import { useLocalization } from '../../hooks'; function LaunchPage() { + const t = useLocalization(); return (
- AgrI-Mitra + {t('label.title')}
) } From cbc01ca9599b936959230979259fce1f04c158df Mon Sep 17 00:00:00 2001 From: prtkjakhar Date: Fri, 14 Jul 2023 11:22:48 +0530 Subject: [PATCH 32/34] added splash title var in json --- apps/agri-mitra/lang/bn.json | 1 + apps/agri-mitra/lang/en.json | 1 + apps/agri-mitra/lang/hi.json | 1 + apps/agri-mitra/lang/ta.json | 1 + apps/agri-mitra/lang/te.json | 1 + apps/agri-mitra/src/components/LaunchPage/index.tsx | 2 +- 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/agri-mitra/lang/bn.json b/apps/agri-mitra/lang/bn.json index 4e42368..cdb10dd 100644 --- a/apps/agri-mitra/lang/bn.json +++ b/apps/agri-mitra/lang/bn.json @@ -1,5 +1,6 @@ { "label.title": "Kisan e-Mitra", + "label.splash_title": "Kisan e-Mitra", "label.welcome": "স্বাগতম", "label.chats": "চ্যাটগুলি", "label.farmer": "কৃষক", diff --git a/apps/agri-mitra/lang/en.json b/apps/agri-mitra/lang/en.json index ca45963..0e8883b 100644 --- a/apps/agri-mitra/lang/en.json +++ b/apps/agri-mitra/lang/en.json @@ -1,5 +1,6 @@ { "label.title": "Kisan e-Mitra", + "label.splash_title": "Kisan e-Mitra", "label.welcome": "Welcome", "label.chats": "Chats", "label.farmer": "Farmer", diff --git a/apps/agri-mitra/lang/hi.json b/apps/agri-mitra/lang/hi.json index 6c473a5..9fd2f2d 100644 --- a/apps/agri-mitra/lang/hi.json +++ b/apps/agri-mitra/lang/hi.json @@ -1,5 +1,6 @@ { "label.title": "Kisan e-Mitra", + "label.splash_title": "Kisan e-Mitra", "label.welcome": "स्वागत", "label.chats": "चैट", "label.farmer": "किसान", diff --git a/apps/agri-mitra/lang/ta.json b/apps/agri-mitra/lang/ta.json index 8d84bbf..f9496b1 100644 --- a/apps/agri-mitra/lang/ta.json +++ b/apps/agri-mitra/lang/ta.json @@ -1,5 +1,6 @@ { "label.title": "Kisan e-Mitra", + "label.splash_title": "Kisan e-Mitra", "label.welcome": "வரவேற்பு", "label.chats": "உரைகள்", "label.farmer": "விவசாயி", diff --git a/apps/agri-mitra/lang/te.json b/apps/agri-mitra/lang/te.json index f1523e5..822f1e8 100644 --- a/apps/agri-mitra/lang/te.json +++ b/apps/agri-mitra/lang/te.json @@ -1,5 +1,6 @@ { "label.title": "Kisan e-Mitra", + "label.splash_title": "Kisan e-Mitra", "label.welcome": "స్వాగతం", "label.chats": "చాట్లు", "label.farmer": "రైతు", diff --git a/apps/agri-mitra/src/components/LaunchPage/index.tsx b/apps/agri-mitra/src/components/LaunchPage/index.tsx index 78cd067..d96d4e8 100644 --- a/apps/agri-mitra/src/components/LaunchPage/index.tsx +++ b/apps/agri-mitra/src/components/LaunchPage/index.tsx @@ -14,7 +14,7 @@ function LaunchPage() { width={235} height={235} /> - {t('label.title')} + {t('label.splash_title')} ) } From 6c750d5127d40285a7493b0bcf0e98551b8a60cb Mon Sep 17 00:00:00 2001 From: prtkjakhar Date: Fri, 14 Jul 2023 11:52:21 +0530 Subject: [PATCH 33/34] removed splash title --- apps/agri-mitra/src/components/LaunchPage/index.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/agri-mitra/src/components/LaunchPage/index.tsx b/apps/agri-mitra/src/components/LaunchPage/index.tsx index d96d4e8..d741dcc 100644 --- a/apps/agri-mitra/src/components/LaunchPage/index.tsx +++ b/apps/agri-mitra/src/components/LaunchPage/index.tsx @@ -1,10 +1,8 @@ import styles from './index.module.css'; import Logo from "../../assets/images/MOA_logo.png"; import Image from "next/image"; -import { useLocalization } from '../../hooks'; function LaunchPage() { - const t = useLocalization(); return (
- {t('label.splash_title')} + Kisan e-Mitra
) } From b16b2920ed57f82ba8837fe1d517b11d8815fa2c Mon Sep 17 00:00:00 2001 From: prtkjakhar Date: Fri, 14 Jul 2023 12:13:26 +0530 Subject: [PATCH 34/34] added splash title --- .../src/components/LaunchPage/index.tsx | 4 +- apps/agri-mitra/src/pages/_app.tsx | 95 +++++++++++-------- 2 files changed, 56 insertions(+), 43 deletions(-) diff --git a/apps/agri-mitra/src/components/LaunchPage/index.tsx b/apps/agri-mitra/src/components/LaunchPage/index.tsx index d741dcc..e0e302d 100644 --- a/apps/agri-mitra/src/components/LaunchPage/index.tsx +++ b/apps/agri-mitra/src/components/LaunchPage/index.tsx @@ -1,8 +1,10 @@ import styles from './index.module.css'; import Logo from "../../assets/images/MOA_logo.png"; import Image from "next/image"; +import { useLocalization } from '../../hooks/useLocalization'; function LaunchPage() { + const t = useLocalization(); return (
- Kisan e-Mitra + {t('label.splash_title')}
) } diff --git a/apps/agri-mitra/src/pages/_app.tsx b/apps/agri-mitra/src/pages/_app.tsx index ba0c04d..373ac22 100644 --- a/apps/agri-mitra/src/pages/_app.tsx +++ b/apps/agri-mitra/src/pages/_app.tsx @@ -5,11 +5,9 @@ import ContextProvider from '../context/ContextProvider'; import { ReactElement, useCallback, useEffect, useState } from 'react'; import 'chatui/dist/index.css'; import { Toaster } from 'react-hot-toast'; -import { useCookies } from 'react-cookie'; -import { useRouter } from 'next/router'; import dynamic from 'next/dynamic'; -import { useLogin } from '../hooks'; import FingerprintJS from '@fingerprintjs/fingerprintjs'; +import { IntlProvider } from 'react-intl'; const LaunchPage = dynamic(() => import('../components/LaunchPage'), { ssr: false, @@ -26,10 +24,44 @@ function SafeHydrate({ children }: { children: ReactElement }) { } const App = ({ Component, pageProps }: AppProps) => { - const router = useRouter(); - const { isAuthenticated, login } = useLogin(); const [launch, setLaunch] = useState(true); - const [cookie, setCookie, removeCookie] = useCookies(); + const [locale, setLocale] = useState('en'); + const [localeMsgs, setLocaleMsgs] = useState | null>( + null + ); + + function loadMessages(locale: string) { + switch (locale) { + case 'en': + return import('../../lang/en.json'); + case 'hi': + return import('../../lang/hi.json'); + case 'bn': + return import('../../lang/bn.json'); + case 'ta': + return import('../../lang/ta.json'); + case 'te': + return import('../../lang/te.json'); + default: + return import('../../lang/en.json'); + } + } + + useEffect(() => { + if (typeof window !== 'undefined') { + const savedLocale = localStorage.getItem('locale'); + if (savedLocale) { + setLocale(savedLocale); + } + } + }, []); + + useEffect(() => { + if (locale) { + //@ts-ignore + loadMessages(locale).then((res) => setLocaleMsgs(res)); + } + }, [locale]); useEffect(() => { setTimeout(() => { @@ -57,50 +89,29 @@ const App = ({ Component, pageProps }: AppProps) => { }, []); - // const handleLoginRedirect = useCallback(() => { - // if (router.pathname === '/login' || router.pathname.startsWith('/otp')) { - // // already logged in then send to home - // if (cookie['access_token'] && localStorage.getItem('userID')) { - // router.push('/'); - // } - // } else { - // // not logged in then send to login page - // if (!cookie['access_token'] || !localStorage.getItem('userID')) { - // localStorage.clear(); - // sessionStorage.clear(); - // router.push('/login'); - // } - // } - // }, [cookie, router]); - - // useEffect(() => { - // handleLoginRedirect(); - // }, [handleLoginRedirect]); - - // useEffect(() => { - // if (!isAuthenticated) { - // login(); - // } - // }, [isAuthenticated, login]); - if (process.env.NODE_ENV === 'production') { globalThis.console.log = () => {}; } if (launch) { - return ; + return ( + //@ts-ignore + + + + ); } else { return ( - -
- - - - - -
-
+ +
+ + + + + +
+
); }