diff --git a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallActions/index.jsx b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallActions/index.jsx index f93ad56..837d354 100644 --- a/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallActions/index.jsx +++ b/src/components/layouts/Dashboard/CallWidget/CallWidgetDialog/CallTabs/CallTabPanel/CallActions/index.jsx @@ -2,24 +2,26 @@ import CallActionsCategories from "./CallActionCategories"; import CallActionsSubcategories from "./CallActionSubcategories"; import ActionHeader from "./ActionHeader"; import CallActionDescription from "./CallActionDescription"; -import {CALL_ACTION} from "@/core/data/apiRoutes"; import useRequest from "@/lib/app/hooks/useRequest"; import useAnswers from "@/lib/callWidget/hooks/useAnswers"; import {useState} from "react"; import {Stack} from "@mui/material"; +import {CALL_ACTION} from "@/core/data/apiRoutes"; function CallActions({tab}) { - const [description, setDescription] = useState() + const [description, setDescription] = useState("") const requestServer = useRequest({auth: true}); const {closeAnswerTab} = useAnswers(); const handleSubcategoryButton = (category_id, subcategory_id) => { + let data = {} + data['category_id'] = category_id + data['subcategory_id'] = subcategory_id + if (description !== "") + data["description"] = description + requestServer(`${CALL_ACTION}/${tab.id}`, "post", { - data: { - category_id, - subcategory_id, - description - }, + data }) .then(() => { closeAnswerTab(tab.id); diff --git a/src/lib/callWidget/contexts/answers.jsx b/src/lib/callWidget/contexts/answers.jsx index 139ba88..ac6d4cc 100644 --- a/src/lib/callWidget/contexts/answers.jsx +++ b/src/lib/callWidget/contexts/answers.jsx @@ -49,13 +49,7 @@ export const AnswersProvider = ({children}) => { categoryLists: [], subCategoryLists: [], }); - const [state, dispatch] = useReducer(reducer, [{ - id: 1, - phone_number: '09134849737', - date: new Date(), - active: true, - active_category_id: 1, - }]); + const [state, dispatch] = useReducer(reducer, []); useEffect(() => { requestServer(GET_CATEGORY, "get")