Skip to content

Commit

Permalink
Support for weather table in OR
Browse files Browse the repository at this point in the history
  • Loading branch information
amit-s19 committed Jan 12, 2024
1 parent 7a1694f commit 3702808
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 21 deletions.
10 changes: 10 additions & 0 deletions apps/amakrushi/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
"label.speak":"Speak",
"label.tap_to_speak": "Tap to speak",
"label.manual":"User Manual - For VAWs",
"table.header_date": "Date",
"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_windspeed": "Windspeed",
"table.header_cloudcover": "Cloudcover",
"table.header_conditions": "Conditions",
"message.no_signal":"No signal. \nPlease check your internet connection",
"message.click_to_type": "Click here to type",
"message.downloading": "Downloading...",
Expand Down
10 changes: 10 additions & 0 deletions apps/amakrushi/lang/or.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
"label.speak":"କଥା ହୁଅନ୍ତୁ",
"label.tap_to_speak": "କହିବାକୁ ଟ୍ୟାପ୍ କରନ୍ତୁ",
"label.manual":"ବ୍ୟବହାରକାରୀ ମାନୁଆଲ - VAWs ପାଇଁ",
"table.header_date": "ତାରିଖ",
"table.header_temp_max":"ସର୍ବାଧିକ ତାପମାତ୍ରା",
"table.header_temp_min": "ସାର୍ବନିମ୍ନ ତାପମାତ୍ରା ",
"table.header_temp": "ତାପମାତ୍ରା",
"table.header_humidity": "ଆର୍ଦ୍ରତା",
"table.header_precip": "ବୃଷ୍ଟିପାତ",
"table.header_precip_prob": "ବୃଷ୍ଟିପାତ ସମ୍ଭାବନା",
"table.header_windspeed": "ପବନର ବେଗ",
"table.header_cloudcover": "ମେଘ ଆବରଣ",
"table.header_conditions": "ସର୍ତ୍ତ",
"message.no_signal":"ସିଗ୍ନାଲ ନାହିଁ। \nଦୟାକରି ଆପଣଙ୍କ ଇଣ୍ଟରନେଟ ସଂଯୋଗ କୁ ଚେକ୍ କରନ୍ତ",
"message.click_to_type": "ଟାଇପ୍ କରିବାକୁ ଏଠାରେ କ୍ଲିକ୍ କରନ୍ତୁ",
"message.downloading": "ଡାଉନଲୋଡ୍ ହେଉଛି ....",
Expand Down
55 changes: 34 additions & 21 deletions apps/amakrushi/src/components/chat-message-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { Button } from '@chakra-ui/react';
import flagsmith from 'flagsmith/isomorphic';
import Loader from '../loader';
import { Paper, Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from '@material-ui/core';
import { useIntl } from 'react-intl';

const getToastMessage = (t: any, reaction: number): string => {
if (reaction === 1) return t('toast.reaction_like');
Expand All @@ -51,7 +52,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
onSend,
}) => {
const flags = useFlags(['show_msg_id', 'dialer_number']);

const intl = useIntl();
const t = useLocalization();
const context = useContext(AppContext);
const [reaction, setReaction] = useState(message?.content?.data?.reaction);
Expand Down Expand Up @@ -167,6 +168,18 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
context?.playAudio(url, content);
};

const getFormattedDate = (datestr: string) => {
const today = new Date(datestr);
const yyyy = today.getFullYear();
let mm: any = today.getMonth() + 1; // Months start at 0!
let dd: any = today.getDate();

if (dd < 10) dd = '0' + dd;
if (mm < 10) mm = '0' + mm;

return dd + '/' + mm + '/' + yyyy;
}

const { content, type } = message;
// console.log('#-debug:', content);
switch (type) {
Expand Down Expand Up @@ -446,29 +459,29 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
<>
<div className={styles.tableContainer}>
<div className={styles.tableHeader}>
<div><b>Date</b></div>
<div>Temp Max</div>
<div>Temp Min</div>
<div>Temp</div>
<div>Humidity</div>
<div>Precip</div>
<div>Precip Prob</div>
<div>Windspeed</div>
<div>Cloudcover</div>
<div>Conditions</div>
<div><b>{t('table.header_date')}</b></div>
<div>{t('table.header_temp_max')}</div>
<div>{t('table.header_temp_min')}</div>
<div>{t('table.header_temp')}</div>
<div>{t('table.header_humidity')}</div>
<div>{t('table.header_precip')}</div>
<div>{t('table.header_precip_prob')}</div>
<div>{t('table.header_windspeed')}</div>
<div>{t('table.header_cloudcover')}</div>
<div>{t('table.header_conditions')}</div>
</div>
<div className={styles.tableData}>
{JSON.parse(content?.text)?.map((el: any, idx: any) => <div key={el.datetime + idx} className={styles.tableDataCol}>
<div><b> {el.datetime}</b></div>
<div>{el.tempmax}</div>
<div>{el.tempmin}</div>
<div>{el.temp}</div>
<div>{el.humidity}</div>
<div>{el.precip}</div>
<div>{el.precipprob}</div>
<div>{el.windspeed}</div>
<div>{el.cloudcover}</div>
<div>{el.conditions}</div>
<div><b> {getFormattedDate(el.datetime)}</b></div>
<div>{el.tempmax} °C </div>
<div>{el.tempmin} °C </div>
<div>{el.temp} °C </div>
<div>{el.humidity} %</div>
<div>{el.precip} mm</div>
<div>{el.precipprob} % </div>
<div>{el.windspeed} m/s</div>
<div>{el.cloudcover} %</div>
<div> {intl.locale == 'or' ? 'ପାର୍ଟିଆଲ କ୍ଲାଉଡି' : el.conditions}</div>
</div>)}
</div>

Expand Down

0 comments on commit 3702808

Please sign in to comment.