work on caller history part of widget and making fake data and work on that
This commit is contained in:
@@ -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 <AnswersContext.Provider
|
||||
value={{
|
||||
|
||||
@@ -2,18 +2,18 @@ import {GET_CALLER_HISTORY} from "@/core/data/apiRoutes";
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
import useSWR from "swr";
|
||||
|
||||
const useCallerHistory = (id) => {
|
||||
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
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user