diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json
index c78574c..4ae635f 100644
--- a/public/locales/fa/app.json
+++ b/public/locales/fa/app.json
@@ -252,8 +252,8 @@
"update_expert": "ویرایش کارشناس"
},
"CallHistory": {
- "topic": "موضوع",
- "sub_topic": "زیر موضوع",
+ "category_name": "موضوع",
+ "subcategory_name": "زیر موضوع",
"operator": "اپراتور",
"date": "تاریخ",
"call_history_of": "تاریخچه تماس های",
diff --git a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ErrorOrEmpty/__tests__/index.test.js b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ErrorOrEmpty/__tests__/index.test.js
index e69de29..91d5651 100644
--- a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ErrorOrEmpty/__tests__/index.test.js
+++ b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ErrorOrEmpty/__tests__/index.test.js
@@ -0,0 +1,19 @@
+import {render, screen} from "@testing-library/react";
+import ErrorOrEmpty from "../../ErrorOrEmpty";
+import MockAppWithProviders from "../../../../../../../../../../../mocks/AppWithProvider";
+
+describe("ErrorOrEmpty Component From call history", () => {
+ describe("Rendering", () => {
+ it("error fetching history of call text rendered", () => {
+ render();
+ const errorText = screen.queryByText('خطا در دریافت تاریخچه تماس دریافتی');
+ expect(errorText).toBeInTheDocument();
+ });
+ it("empty fetching history of call text rendered", () => {
+ render();
+ const emptyText = screen.queryByText('تاریخچه ای برای تماس دریافتی یافت نشد');
+ expect(emptyText).toBeInTheDocument();
+
+ });
+ });
+});
\ No newline at end of file
diff --git a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/HistoryHeader/__tests__/index.test.js b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/HistoryHeader/__tests__/index.test.js
index e69de29..13e05cf 100644
--- a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/HistoryHeader/__tests__/index.test.js
+++ b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/HistoryHeader/__tests__/index.test.js
@@ -0,0 +1,21 @@
+import {render, screen} from "@testing-library/react";
+import HistoryHeader from "../../HistoryHeader";
+import MockAppWithProviders from "../../../../../../../../../../../mocks/AppWithProvider";
+
+describe("HistoryHeader Component From call history", () => {
+ describe("Rendering", () => {
+ const tab = {
+ phone_number: "09111111111"
+ }
+ it("text of header rendered", () => {
+ render();
+ const textHeader = screen.queryByText(/تاریخچه تماس های/i);
+ expect(textHeader).toBeInTheDocument();
+ });
+ it("number of caller in header rendered", () => {
+ render();
+ const callerNumber = screen.queryByText(/09111111111/i);
+ expect(callerNumber).toBeInTheDocument();
+ });
+ });
+});
\ No newline at end of file
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 93a246c..3b57744 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
@@ -9,10 +9,10 @@ const Topics = ({historyItem}) => {
- {t("CallHistory.topic")}:
+ {t("CallHistory.category_name")}:
- {historyItem.topic}
+ {historyItem.category_name}
@@ -21,7 +21,7 @@ const Topics = ({historyItem}) => {
- {t("CallHistory.sub_topic")}:
+ {t("CallHistory.subcategory_name")}:
{
textAlign: "end",
color: "#837e7e"
}}>
- {historyItem.sub_topic}
+ {historyItem.subcategory_name}
diff --git a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/index.jsx b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/index.jsx
index ac20c3a..d697da8 100644
--- a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/index.jsx
+++ b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/index.jsx
@@ -5,6 +5,9 @@ import Topics from "./Topics";
const ListItemOfCalls = ({historyItem}) => {
const t = useTranslations();
+
+ // console.log(historyItem)
+
return (
diff --git a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/LoadingHistory/__tests__/intex.test.js b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/LoadingHistory/__tests__/intex.test.js
index e69de29..1592a02 100644
--- a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/LoadingHistory/__tests__/intex.test.js
+++ b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/LoadingHistory/__tests__/intex.test.js
@@ -0,0 +1,68 @@
+import {render, screen} from "@testing-library/react";
+import LoadingHistory from "../../LoadingHistory";
+import MockAppWithProviders from "../../../../../../../../../../../mocks/AppWithProvider";
+
+describe("LoadingHistory Component From call history", () => {
+ describe("Rendering", () => {
+ it("loading list rendered", () => {
+ render();
+ const loadingList = screen.queryByTestId("loading-list");
+ expect(loadingList).toBeInTheDocument();
+ });
+ it("loading list item avatar rendered", () => {
+ render();
+ const loadingListItemAvatar = screen.queryByTestId("loading-listItemAvatar");
+ expect(loadingListItemAvatar).toBeInTheDocument();
+ });
+ it("loading list item text rendered", () => {
+ render();
+ const loadingListItemText = screen.queryByTestId("loading-listItemText");
+ expect(loadingListItemText).toBeInTheDocument();
+ });
+ it("loading list item category rendered", () => {
+ render();
+ const loadingListItemCat = screen.queryByTestId("loading-listItem-cat");
+ expect(loadingListItemCat).toBeInTheDocument();
+ });
+ it("loading list item sub category rendered", () => {
+ render();
+ const loadingListItemSubCat = screen.queryByTestId("loading-listItem-subCat");
+ expect(loadingListItemSubCat).toBeInTheDocument();
+ });
+ it("operator avatar skeleton rendered", () => {
+ render();
+ const operatorAvatarSkeleton = screen.queryByTestId("operator-avatar-skeleton");
+ expect(operatorAvatarSkeleton).toBeInTheDocument();
+ });
+ it("operator name skeleton rendered", () => {
+ render();
+ const operatorNameSkeleton = screen.queryByTestId("operator-name-skeleton");
+ expect(operatorNameSkeleton).toBeInTheDocument();
+ });
+ it("operator answer date skeleton rendered", () => {
+ render();
+ const operatorAnswerDateSkeleton = screen.queryByTestId("operator-answer-date-skeleton");
+ expect(operatorAnswerDateSkeleton).toBeInTheDocument();
+ });
+ it("operator category header skeleton rendered", () => {
+ render();
+ const operatorCategoryHeaderSkeleton = screen.queryByTestId("operator-category-header-skeleton");
+ expect(operatorCategoryHeaderSkeleton).toBeInTheDocument();
+ });
+ it("operator category value skeleton rendered", () => {
+ render();
+ const operatorCategoryValueSkeleton = screen.queryByTestId("operator-category-value-skeleton");
+ expect(operatorCategoryValueSkeleton).toBeInTheDocument();
+ });
+ it("operator subCategory header skeleton rendered", () => {
+ render();
+ const operatorSubCategoryHeaderSkeleton = screen.queryByTestId("operator-subCategory-header-skeleton");
+ expect(operatorSubCategoryHeaderSkeleton).toBeInTheDocument();
+ });
+ it("operator subCategory value skeleton rendered", () => {
+ render();
+ const operatorSubCategoryValueSkeleton = screen.queryByTestId("operator-subCategory-value-skeleton");
+ expect(operatorSubCategoryValueSkeleton).toBeInTheDocument();
+ });
+ });
+});
\ No newline at end of file
diff --git a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/LoadingHistory/index.jsx b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/LoadingHistory/index.jsx
index c6cd59e..79093cb 100644
--- a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/LoadingHistory/index.jsx
+++ b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/LoadingHistory/index.jsx
@@ -5,7 +5,7 @@ const LoadingHistory = () => {
const t = useTranslations();
return (
<>
-
@@ -14,12 +14,15 @@ const LoadingHistory = () => {
alignItems: "center",
px: 2
}}>
-
-
+
+
-
{
} secondary={
{
-
+
{
-
+
{
+ describe("Rendering", () => {
+
+ });
+ describe("Behavioral", () => {
+
+ });
+});
\ No newline at end of file
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 bd10415..dd9f44a 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
@@ -8,15 +8,15 @@ import useCallerHistory from "@/lib/callWidget/hooks/useCallerHistory";
import ListItemOfCalls from "./ListItemOfCalls";
import {useState} from "react";
+const max_size = 10;
const CallHistory = ({tab}) => {
const t = useTranslations();
- const max_size = 10;
const {
firstItemOfHistory,
historyList,
isLoadingHistoryList,
errorHistoryList
- } = useCallerHistory(tab.phone_number, max_size);
+ } = useCallerHistory(tab.id, tab.phone_number, max_size);
const [showRestOfHistory, setShowRestOfHistory] = useState(false);
return (
@@ -30,19 +30,21 @@ const CallHistory = ({tab}) => {
) : isLoadingHistoryList ? (
- ) : historyList.length === 0 ? (
+ ) : !firstItemOfHistory ? (
) : (
-
- }
- onClick={() => setShowRestOfHistory(true)}
- label="نمایش موارد بیشتر"
- disabled={showRestOfHistory}>
-
-
+ {historyList && (
+
+ }
+ onClick={() => setShowRestOfHistory(true)}
+ label="نمایش موارد بیشتر"
+ disabled={showRestOfHistory}
+ />
+
+ )}
{showRestOfHistory && (
<>
{historyList.map((historyItem, index) => (
diff --git a/src/lib/callWidget/hooks/useCallerHistory.jsx b/src/lib/callWidget/hooks/useCallerHistory.jsx
index 93fd7b5..68ee6d0 100644
--- a/src/lib/callWidget/hooks/useCallerHistory.jsx
+++ b/src/lib/callWidget/hooks/useCallerHistory.jsx
@@ -1,14 +1,16 @@
-import {GET_CALLER_HISTORY} from "@/core/data/apiRoutes";
import useRequest from "@/lib/app/hooks/useRequest";
+import {useEffect, useState} from "react";
import useSWR from "swr";
+import {GET_CALLER_HISTORY} from "@/core/data/apiRoutes";
-const useCallerHistory = (phone_number, max_size) => {
- const requestServer = useRequest({auth: true, notification: false})
+const useCallerHistory = (call_id, phone_number, max_size) => {
+ const requestServer = useRequest({auth: true, notification: false});
+ const [validData, setValidData] = useState([]);
//swr config
const fetcher = (...args) => {
return requestServer(args, 'get').then(({data}) => {
- return data.data.slice(2);
+ return data.data;
}).catch(() => {
})
};
@@ -20,17 +22,15 @@ const useCallerHistory = (phone_number, max_size) => {
keepPreviousData: true
});
+ useEffect(() => {
+ data && setValidData(data.filter((item) => item.id != call_id));
+ }, [data, call_id]);
+
return {
- firstItemOfHistory: {
- id: 1,
- operator_name: "اشکان خطیبی",
- answer_date: "1379/02/03 13:50",
- topic: "موضوع تست",
- sub_topic: "زیر موضوع تست با متن طولانی تر از موضوع"
- },
- historyList: data,
- isLoadingHistoryList: isLoading,
- errorHistoryList: !data
+ firstItemOfHistory: validData.length === 0 ? false : validData[0],
+ historyList: validData.length < 2 ? false : validData.slice(1),
+ isLoadingHistoryList: true,
+ errorHistoryList: false
}
};