diff --git a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/PreviusOperatorData/index.jsx b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/PreviusOperatorData/index.jsx index 9610180..a907a33 100644 --- a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/PreviusOperatorData/index.jsx +++ b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallHistory/ListItemOfCalls/PreviusOperatorData/index.jsx @@ -3,7 +3,6 @@ import {Avatar, Box, ListItem, ListItemAvatar, ListItemText, Typography} from "@ import HeadsetMicIcon from '@mui/icons-material/HeadsetMic'; const PreviusOperatorData = ({historyItem}) => { - console.log(historyItem) const t = useTranslations(); return ( 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 0f2e832..93a246c 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 @@ -4,7 +4,7 @@ import {Box, List, ListItem, Typography} from "@mui/material"; const Topics = ({historyItem}) => { const t = useTranslations(); return ( - + 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 7537d12..ac20c3a 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 @@ -1,19 +1,17 @@ import {useTranslations} from "next-intl"; -import {Divider, List} from "@mui/material"; +import {Grow, List} from "@mui/material"; import PreviusOperatorData from "./PreviusOperatorData"; import Topics from "./Topics"; -const ListItemOfCalls = ({lastItem, historyItem}) => { +const ListItemOfCalls = ({historyItem}) => { const t = useTranslations(); - console.log("historyItem", historyItem) return ( - <> + - {!lastItem && } - + ) } 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 f8ccb28..bd10415 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 @@ -10,11 +10,15 @@ import {useState} from "react"; const CallHistory = ({tab}) => { const t = useTranslations(); - const {historyList, isLoadingHistoryList, errorHistoryList} = useCallerHistory(tab.id); + const max_size = 10; + const { + firstItemOfHistory, + historyList, + isLoadingHistoryList, + errorHistoryList + } = useCallerHistory(tab.phone_number, max_size); const [showRestOfHistory, setShowRestOfHistory] = useState(false); - const handleClick = () => { - console.info('You clicked the Chip.'); - }; + return ( { ) : ( - + } @@ -41,10 +45,9 @@ const CallHistory = ({tab}) => { {showRestOfHistory && ( <> - {historyList.slice(2).map((historyItem, index) => ( + {historyList.map((historyItem, index) => ( <> - + ))} diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index 32bedb0..127d1df 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -17,7 +17,7 @@ export const GET_PROVINCE_LIST = BASE_URL + "/api/provinces"; // province list // province list -export const GET_CALLER_HISTORY = BASE_URL + "..."; +export const GET_CALLER_HISTORY = BASE_URL + "/api/calls/list"; // province list //change password diff --git a/src/lib/callWidget/contexts/answers.jsx b/src/lib/callWidget/contexts/answers.jsx index adb622a..a9f7ae2 100644 --- a/src/lib/callWidget/contexts/answers.jsx +++ b/src/lib/callWidget/contexts/answers.jsx @@ -17,11 +17,7 @@ export const AnswersContext = createContext() export const AnswersProvider = ({children}) => { const [openCallDialog, setOpenCallDialog] = useState(false) const [activeTab, setActiveTab] = useState(0) - const [state, dispatch] = useReducer(reducer, [{ - id: 2, - phone_number: "09036949387", - active: true - }]); + const [state, dispatch] = useReducer(reducer, []); return { +const useCallerHistory = (phone_number, max_size) => { const requestServer = useRequest({auth: true, notification: false}) //swr config const fetcher = (...args) => { return requestServer(args, 'get').then(({data}) => { - return data.data; + return data.data.slice(2); }).catch(() => { }) }; - const {data, isLoading} = useSWR(`${GET_CALLER_HISTORY}/${id}`, fetcher, { + const {data, isLoading} = useSWR(`${GET_CALLER_HISTORY}?phone_number=${phone_number}&size=${max_size}`, fetcher, { revalidateIfStale: false, revalidateOnFocus: false, revalidateOnReconnect: false, @@ -21,38 +21,16 @@ const useCallerHistory = (id) => { }); return { - historyList: [ - { - id: 1, - operator_name: "اشکان خطیبی", - answer_date: "1379/02/03 13:50", - topic: "موضوع تست", - sub_topic: "زیر موضوع تست با متن طولانی تر از موضوع" - }, - { - id: 2, - operator_name: "مصیب خطیبی", - answer_date: "1385/01/23 23:10", - topic: "موضوع تست2", - sub_topic: "زیر موضوع تست با متن طولانی تر از موضوع2" - }, - { - id: 2, - operator_name: "علی جلالی", - answer_date: "1385/01/01 12:12", - topic: "موضوع تست23", - sub_topic: "زیر 22موضوع تست با متن طولانی تر از موضوع32" - }, - { - id: 2, - operator_name: "حسن محمودی", - answer_date: "1385/01/01 11:22", - topic: "موضوع اول", - sub_topic: "زیر دوم تست با متن طولانی تر از موضوع32" - } - ], - isLoadingHistoryList: false, - errorHistoryList: false + firstItemOfHistory: { + id: 1, + operator_name: "اشکان خطیبی", + answer_date: "1379/02/03 13:50", + topic: "موضوع تست", + sub_topic: "زیر موضوع تست با متن طولانی تر از موضوع" + }, + historyList: data, + isLoadingHistoryList: isLoading, + errorHistoryList: !data } };