CFE-17 Merge branch 'bugfix/CFE-17_fixed_show_history' into 'develop'

This commit is contained in:
AmirHossein Mahmoodi
2023-11-20 07:45:37 +00:00
6 changed files with 19 additions and 13 deletions

View File

@@ -261,7 +261,8 @@
"call_history_of": "تاریخچه تماس های",
"call_history_not_found": "تاریخچه ای برای تماس دریافتی یافت نشد",
"call_history_error_fetching": "خطا در دریافت تاریخچه تماس دریافتی",
"show_more": "نمایش موارد بیشتر"
"show_more": "نمایش موارد بیشتر",
"no_data_exist": "اطلاعاتی موجود نیست"
},
"CallAction": {
"call_history_of": "عملیات های مربوط به تماس",

View File

@@ -1,12 +1,13 @@
import {render, screen} from "@testing-library/react";
import MockAppWithProviders from "../../../../../../../../../../../../mocks/AppWithProvider";
import PreviousOperatorData from "../../PreviousOperatorData";
import moment from "jalali-moment";
describe("PreviousOperatorData Component From call history", () => {
describe("Rendering", () => {
const historyItem = {
operator_name: "test name",
answer_date: "test date"
operator_full_name: "test name",
created_at: "2023-11-19T10:32:48"
}
it("operator name rendered", () => {
render(<MockAppWithProviders><PreviousOperatorData historyItem={historyItem}/></MockAppWithProviders>);
@@ -14,8 +15,9 @@ describe("PreviousOperatorData Component From call history", () => {
expect(operatorName).toBeInTheDocument();
});
it("operator answer date rendered", () => {
const dateTime = moment(historyItem.created_at).locale('fa').format("HH:mm:ss | YYYY/MM/DD")
render(<MockAppWithProviders><PreviousOperatorData historyItem={historyItem}/></MockAppWithProviders>);
const operatorAnswerDate = screen.queryByText("test date");
const operatorAnswerDate = screen.queryByText(dateTime);
expect(operatorAnswerDate).toBeInTheDocument();
});
});

View File

@@ -1,8 +1,11 @@
import {useTranslations} from "next-intl";
import {Avatar, Box, ListItem, ListItemAvatar, ListItemText, Typography} from "@mui/material";
import HeadsetMicIcon from '@mui/icons-material/HeadsetMic';
import useLanguage from "@/lib/app/hooks/useLanguage";
import moment from "jalali-moment";
const PreviousOperatorData = ({historyItem}) => {
const {languageApp} = useLanguage()
const t = useTranslations();
return (
<ListItem>
@@ -14,13 +17,13 @@ const PreviousOperatorData = ({historyItem}) => {
<ListItemText primary={
<Box sx={{display: "flex", alignItems: "end"}}>
<Typography sx={{marginRight: 1, color: "#545151"}}>
{historyItem.operator_name}
{historyItem.operator_full_name}
</Typography>
<Typography variant="caption" sx={{color: "secondary.main"}}>
({t("CallHistory.operator")})
</Typography>
</Box>
} secondary={historyItem.answer_date}/>
} secondary={moment(historyItem.created_at).locale(languageApp).format("HH:mm:ss | YYYY/MM/DD")}/>
</ListItem>
)
}

View File

@@ -12,7 +12,7 @@ const Topics = ({historyItem}) => {
{t("CallHistory.category_name")}:
</Typography>
<Typography variant="subtitle2" sx={{color: "#837e7e"}}>
{historyItem.category_name}
{historyItem.category_name || t("CallHistory.no_data_exist")}
</Typography>
</Box>
</ListItem>
@@ -31,7 +31,7 @@ const Topics = ({historyItem}) => {
textAlign: "end",
color: "#837e7e"
}}>
{historyItem.subcategory_name}
{historyItem.subcategory_name || t("CallHistory.no_data_exist")}
</Typography>
</Box>
</ListItem>

View File

@@ -6,7 +6,7 @@ import HistoryHeader from "./HistoryHeader";
import ErrorOrEmpty from "./ErrorOrEmpty";
import useCallerHistory from "@/lib/callWidget/hooks/useCallerHistory";
import ListItemOfCalls from "./ListItemOfCalls";
import {useState} from "react";
import {Fragment, useState} from "react";
const max_size = 10;
const CallHistory = ({tab}) => {
@@ -40,7 +40,7 @@ const CallHistory = ({tab}) => {
<Chip
icon={<HeadphonesIcon/>}
onClick={() => setShowRestOfHistory(true)}
label={t("show_more")}
label={t("CallHistory.show_more")}
disabled={showRestOfHistory}
/>
</Divider>
@@ -48,10 +48,10 @@ const CallHistory = ({tab}) => {
{showRestOfHistory && (
<>
{historyList.map((historyItem, index) => (
<>
<Fragment key={historyItem.id}>
<ListItemOfCalls key={historyItem.id} historyItem={historyItem}/>
<Divider/>
</>
</Fragment>
))}
</>)
}

View File

@@ -16,7 +16,7 @@ const useCallerHistory = (call_id, phone_number, max_size) => {
};
const {data, isLoading} = useSWR(`${GET_CALLER_HISTORY}?phone_number=${phone_number}&size=${max_size}`, fetcher, {
revalidateIfStale: false,
revalidateIfStale: true,
revalidateOnFocus: false,
revalidateOnReconnect: false,
keepPreviousData: true