diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 21776ae..3224263 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -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": "عملیات های مربوط به تماس", diff --git a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/PreviousOperatorData/__tests__/index.test.js b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/PreviousOperatorData/__tests__/index.test.js index 4fd4519..c057146 100644 --- a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/PreviousOperatorData/__tests__/index.test.js +++ b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/PreviousOperatorData/__tests__/index.test.js @@ -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(); @@ -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(); - const operatorAnswerDate = screen.queryByText("test date"); + const operatorAnswerDate = screen.queryByText(dateTime); expect(operatorAnswerDate).toBeInTheDocument(); }); }); diff --git a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/PreviousOperatorData/index.jsx b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/PreviousOperatorData/index.jsx index afd2ad7..357c6e8 100644 --- a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/PreviousOperatorData/index.jsx +++ b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/PreviousOperatorData/index.jsx @@ -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 ( @@ -14,13 +17,13 @@ const PreviousOperatorData = ({historyItem}) => { - {historyItem.operator_name} + {historyItem.operator_full_name} ({t("CallHistory.operator")}) - } secondary={historyItem.answer_date}/> + } secondary={moment(historyItem.created_at).locale(languageApp).format("HH:mm:ss | YYYY/MM/DD")}/> ) } diff --git a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/Topics/index.jsx b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/Topics/index.jsx index 3b57744..c9be4c0 100644 --- a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/Topics/index.jsx +++ b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/Topics/index.jsx @@ -12,7 +12,7 @@ const Topics = ({historyItem}) => { {t("CallHistory.category_name")}: - {historyItem.category_name} + {historyItem.category_name || t("CallHistory.no_data_exist")} @@ -31,7 +31,7 @@ const Topics = ({historyItem}) => { textAlign: "end", color: "#837e7e" }}> - {historyItem.subcategory_name} + {historyItem.subcategory_name || t("CallHistory.no_data_exist")} diff --git a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/index.jsx b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/index.jsx index 9d61cce..1ac6e1e 100644 --- a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/index.jsx +++ b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/index.jsx @@ -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}) => { } onClick={() => setShowRestOfHistory(true)} - label={t("show_more")} + label={t("CallHistory.show_more")} disabled={showRestOfHistory} /> @@ -48,10 +48,10 @@ const CallHistory = ({tab}) => { {showRestOfHistory && ( <> {historyList.map((historyItem, index) => ( - <> + - + ))} ) } diff --git a/src/lib/callWidget/hooks/useCallerHistory.jsx b/src/lib/callWidget/hooks/useCallerHistory.jsx index 810209d..7fe1100 100644 --- a/src/lib/callWidget/hooks/useCallerHistory.jsx +++ b/src/lib/callWidget/hooks/useCallerHistory.jsx @@ -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