Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/weather advisory #225

Merged
merged 3 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 63 additions & 62 deletions apps/amakrushi/lang/en.json
Original file line number Diff line number Diff line change
@@ -1,106 +1,107 @@
{
"label.title":"Ama Krushi AI Chatbot",
"label.welcome":"Welcome",
"label.chats":"Chats",
"label.farmer":"Farmer",
"label.extension_worker":"Extension Worker",
"label.continue":"Continue",
"label.search":"Search",
"label.back":"Back",
"label.send":"Send",
"label.profile":"Profile",
"label.faqs":"FAQs",
"label.dial":"Dial",
"label.feedback":"Feedback",
"label.title": "Ama Krushi AI Chatbot",
"label.welcome": "Welcome",
"label.chats": "Chats",
"label.farmer": "Farmer",
"label.extension_worker": "Extension Worker",
"label.continue": "Continue",
"label.search": "Search",
"label.back": "Back",
"label.send": "Send",
"label.profile": "Profile",
"label.faqs": "FAQs",
"label.dial": "Dial",
"label.feedback": "Feedback",
"label.share": "Share",
"label.download": "Download",
"label.comment":"Comment",
"label.logout":"Logout",
"label.more":"More",
"label.submit":"Submit",
"label.submit_review":"Submit Review",
"label.submit_feedback":"Submit Feedback",
"label.mobile_number":"Mobile Number",
"label.ask_me":"Ask me anything about farming",
"label.click":"Reload",
"label.new_chat":"New chat",
"label.confirm_delete":"Are you sure you want to delete this conversation?",
"label.no_history":"No Chats",
"label.call_amakrushi":"Call Ama Krushi",
"label.no_internet":"No Internet",
"label.comment": "Comment",
"label.logout": "Logout",
"label.more": "More",
"label.submit": "Submit",
"label.submit_review": "Submit Review",
"label.submit_feedback": "Submit Feedback",
"label.mobile_number": "Mobile Number",
"label.ask_me": "Ask me anything about farming",
"label.click": "Reload",
"label.new_chat": "New chat",
"label.confirm_delete": "Are you sure you want to delete this conversation?",
"label.no_history": "No Chats",
"label.call_amakrushi": "Call Ama Krushi",
"label.no_internet": "No Internet",
"label.helpful": "Helpful",
"label.not_helpful": "Not Helpful",
"label.refresh": "Refresh",
"label.type":"Type",
"label.speak":"Speak",
"label.type": "Type",
"label.speak": "Speak",
"label.tap_to_speak": "Tap to speak",
"label.manual":"User Manual - For VAWs",
"label.manual": "User Manual - For VAWs",
"table.header_date": "Date",
"table.header_temp_max":"Temp Max",
"table.header_temp_max": "Temp Max",
"table.header_temp_min": "Temp Min",
"table.header_temp": "Temp",
"table.header_humidity": "Humidity",
"table.header_precip": "Precip",
"table.header_precip_prob": "Precip Prob",
"table.header_precip_prob": "Precip Prob",
"table.header_windspeed": "Windspeed",
"table.header_cloudcover": "Cloudcover",
"table.header_conditions": "Conditions",
"message.speaker": "Click to hear",
"message.options":"To know the advisory for your crop, please click on the relevant button below:",
"message.no_signal":"No signal. \nPlease check your internet connection",
"message.options": "To know the advisory for your crop, please click on the relevant button below:",
"message.no_signal": "No signal. \nPlease check your internet connection",
"message.click_to_type": "Click here to type",
"message.downloading": "Downloading...",
"message.download_audio": "Loading Audio",
"message.no_link": "Something went wrong, please try later.",
"message.sharing": "Sharing...",
"message.no_history":"Your Chat History with AI will come here",
"message.no_history": "Your Chat History with AI will come here",
"message.socket_disconnect_msg": "to connect again.",
"message.enter_mobile":"Enter Mobile Number",
"message.register_message":"If you are already registered then use your mobile number to login.",
"message.not_register_yet":"Not registered yet ?",
"message.register_at_krushak":"Register at Krushak Odisha",
"message.otp_verification":" OTP Verification",
"message.ask_ur_question":"Ask Your Question",
"message.otp_message":"We will send you a one time password on this",
"message.invalid_mobile":"Enter a 10 digit number!",
"message.enter_mobile": "Enter Mobile Number",
"message.register_message": "If you are already registered then use your mobile number to login.",
"message.not_register_yet": "Not registered yet ?",
"message.register_at_krushak": "Register at Krushak Odisha",
"message.otp_verification": " OTP Verification",
"message.ask_ur_question": "Ask Your Question",
"message.otp_message": "We will send you a one time password on this",
"message.invalid_mobile": "Enter a 10 digit number!",
"message.cannot_answer_again": "Cannot answer again",
"message.invalid_otp":"Invalid Otp",
"message.otp_not_sent":"Otp not sent",
"message.invalid_otp": "Invalid Otp",
"message.otp_not_sent": "Otp not sent",
"message.otp_sent_again": "OTP sent again",
"message.wait_resending_otp": "Please wait before resending OTP",
"message.wait_before_choosing": "Please wait before choosing again",
"message.helpful": "Was this helpful?",
"message.retry":"Please retry.",
"message.down_time_title":"We're under maintenance",
"message.down_time_retry":"Try again",
"message.retry": "Please retry.",
"message.down_time_title": "We're under maintenance",
"message.down_time_retry": "Try again",
"message.down_time_view_prev_chats": "View previous chats",
"message.taking_longer":"Please wait, servers are taking longer than usual.",
"message.taking_longer": "Please wait, servers are taking longer than usual.",
"message.rating_submitted": "Rating Submitted!",
"message.review_submitted": "Review Submitted!",
"message.didnt_receive": "Didn't receive the OTP?",
"message.resend_again": "Resend again",
"message.shareUrl_android_error" : "Share feature coming soon, please download pdf to share",
"message.coming_soon" : "Coming Soon!",
"message.coming_soon_description" : "We are going to launch this feature very soon. Stay tuned!",
"message.dial_description" : "To connect with call centre",
"message.rating" : "Did you find this useful?",
"message.rating_description" : "Tap a star to rate",
"message.shareUrl_android_error": "Share feature coming soon, please download pdf to share",
"message.coming_soon": "Coming Soon!",
"message.coming_soon_description": "We are going to launch this feature very soon. Stay tuned!",
"message.dial_description": "To connect with call centre",
"message.rating": "Did you find this useful?",
"message.rating_description": "Tap a star to rate",
"message.review": "Write your review (optional)",
"message.review_description": "Give positive/negative feedback for advisory",
"message.comment_description": "Let us know your issue with the response",
"message.temporarily_down": "Have an urgent query?",
"message.temporarily_down_description": "We are experiencing high user volume at the moment, please try logging in after some time",
"message.recorder_wait": "Please wait while we process your request...",
"message.recorder_error": "Your question was not recognised. Pls try speaking more clearly.",
"message.dialer_popup":"You may speak to an Ama Krushi expert to get a satisfactory response",
"message.dialer_popup": "You may speak to an Ama Krushi expert to get a satisfactory response",
"message.cannot_share": "Your system doesn't support sharing this file.",
"error.fail_to_submit":"Failed to submit rating.",
"error.fail_to_submit": "Failed to submit rating.",
"error.fail_to_submit_review": "Failed to submit review.",
"error.sending_otp":"Error sending OTP",
"error.otp_not_sent":"OTP not sent",
"error.sending_otp": "Error sending OTP",
"error.otp_not_sent": "OTP not sent",
"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.",
"toast.reaction_like":"Successfully liked the response",
"toast.reaction_dislike":"Successfully disliked the response",
"toast.reaction_reset":"Successfully removed the response"
"toast.reaction_like": "Successfully liked the response",
"toast.reaction_dislike": "Successfully disliked the response",
"toast.reaction_reset": "Successfully removed the response"
}
1 change: 1 addition & 0 deletions apps/amakrushi/lang/or.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"message.otp_not_sent":"ୱାନ୍ ଟାଇମ଼ ପାସୱାର୍ଡ ପଠାଯାଇ ନାହିଁ",
"message.otp_sent_again": "OTP ପୁନର୍ବାର ପଠାଗଲା |",
"message.wait_resending_otp": "OTP ପଠାଇବା ପୂର୍ବରୁ ଦୟାକରି ଅପେକ୍ଷା କରନ୍ତୁ |",
"message.wait_before_choosing": "ପୁନର୍ବାର ବାଛିବା ପୂର୍ବରୁ ଦୟାକରି ଅପେକ୍ଷା କରନ୍ତୁ |",
"message.helpful": "ଏହା ସାହାଯ୍ୟକାରୀ ଥିଲା କି?",
"message.retry":"ପୁନର୍ବାର ଚେଷ୍ଟା କରନ୍ତୁ",
"message.down_time_title":"ଆମେ ରକ୍ଷଣାବେକ୍ଷଣ ଅଧୀନରେ ଅଛୁ",
Expand Down
66 changes: 36 additions & 30 deletions apps/amakrushi/src/components/chat-message-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({ message, onSend }) => {
message?.content?.data?.optionClicked || false
);
const getLists = useCallback(
({ choices }: { choices: any }) => {
({ choices, isWeather = false }: { choices: any, isWeather: Boolean }) => {
console.log('qwer12:', { choices, optionDisabled });
return (
<List className={`${styles.list}`}>
Expand All @@ -145,23 +145,27 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({ message, onSend }) => {
style={
optionDisabled
? {
background: 'var(--lightgrey)',
color: 'var(--font)',
boxShadow: 'none',
}
background: 'var(--lightgrey)',
color: 'var(--font)',
boxShadow: 'none',
}
: null
}
onClick={(e: any): void => {
e.preventDefault();
if (optionDisabled) {
toast.error(`${t('message.cannot_answer_again')}`);
toast.error(`${isWeather ? t('message.wait_before_choosing') : t('message.cannot_answer_again')}`);
} else {
if (context?.messages?.[0]?.exampleOptions) {
console.log('clearing chat');
context?.setMessages([]);
}
context?.sendMessage(choice);
// setOptionDisabled(true);
setOptionDisabled(true);
if (isWeather)
setTimeout(() => {
setOptionDisabled(false);
}, 7000)
}
}}>
<div
Expand All @@ -173,8 +177,8 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({ message, onSend }) => {
content?.data?.position === 'right'
? 'white'
: optionDisabled
? 'var(--font)'
: 'var(--secondarygreen)',
? 'var(--font)'
: 'var(--secondarygreen)',
}}>
<div>{choice}</div>
<div style={{ marginLeft: 'auto' }}>
Expand Down Expand Up @@ -364,7 +368,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({ message, onSend }) => {
}}>
{getFormatedTime(
content?.data?.sentTimestamp ||
content?.data?.repliedTimestamp
content?.data?.repliedTimestamp
)}
</span>
</div>
Expand Down Expand Up @@ -392,19 +396,19 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({ message, onSend }) => {
<div style={{ display: 'flex' }}>
<div
className={styles.msgSpeaker}
onClick={!ttsLoader ? downloadAudio : () => {}}
onClick={!ttsLoader ? downloadAudio : () => { }}
style={
!content?.data?.isEnd
? {
pointerEvents: 'none',
filter: 'grayscale(100%)',
opacity: '0.5',
}
pointerEvents: 'none',
filter: 'grayscale(100%)',
opacity: '0.5',
}
: {
pointerEvents: 'auto',
opacity: '1',
filter: 'grayscale(0%)',
}
pointerEvents: 'auto',
opacity: '1',
filter: 'grayscale(0%)',
}
}>
{context?.clickedAudioUrl === content?.data?.audio_url ? (
<Image
Expand Down Expand Up @@ -524,7 +528,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({ message, onSend }) => {
<span style={{ color: 'var(--font)', fontSize: '10px' }}>
{getFormatedTime(
content?.data?.sentTimestamp ||
content?.data?.repliedTimestamp
content?.data?.repliedTimestamp
)}
</span>
</div>
Expand Down Expand Up @@ -558,7 +562,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({ message, onSend }) => {
<span style={{ color: 'var(--font)', fontSize: '10px' }}>
{getFormatedTime(
content?.data?.sentTimestamp ||
content?.data?.repliedTimestamp
content?.data?.repliedTimestamp
)}
</span>
</div>
Expand All @@ -575,8 +579,8 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({ message, onSend }) => {
<>
<Bubble type="image">
<div style={{ padding: '7px' }}>
<iframe width="100%" height="fit-content"
src={`https://www.youtube.com/embed/`+videoId}
<iframe width="100%" height="fit-content"
src={`https://www.youtube.com/embed/` + videoId}
frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowFullScreen></iframe>
<div
style={{
Expand All @@ -587,7 +591,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({ message, onSend }) => {
<span style={{ color: 'var(--font)', fontSize: '10px' }}>
{getFormatedTime(
content?.data?.sentTimestamp ||
content?.data?.repliedTimestamp
content?.data?.repliedTimestamp
)}
</span>
</div>
Expand All @@ -612,6 +616,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({ message, onSend }) => {
{getLists({
choices:
content?.data?.payload?.buttonChoices ?? content?.data?.choices,
isWeather: true
})}
</Bubble>
</>
Expand Down Expand Up @@ -670,12 +675,12 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({ message, onSend }) => {
{' '}
{intl.locale == 'or'
? oriaWeatherTranslates[
el?.conditions
?.trim()
?.split(' ')
?.join('')
?.toLowerCase()
]
el?.conditions
?.trim()
?.split(' ')
?.join('')
?.toLowerCase()
]
: el.conditions}
</div>
</div>
Expand All @@ -697,6 +702,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({ message, onSend }) => {
t('message.options')}
{getLists({
choices: JSON.parse(content?.text)?.crops,
isWeather: true
})}
</span>
</Bubble>
Expand Down
Loading