CFE-16 fixed pending notification and success notification

This commit is contained in:
2023-11-19 10:56:21 +03:30
parent 0d88145c74
commit bfdf586b20
2 changed files with 20 additions and 19 deletions

View File

@@ -21,7 +21,7 @@ function CallActions({tab}) {
description description
}, },
success: { success: {
notification: {show: false}, notification: {show: true},
}, },
}) })
.then(() => { .then(() => {

View File

@@ -1,5 +1,5 @@
import { createContext, useEffect, useReducer, useState } from "react"; import {createContext, useEffect, useReducer, useState} from "react";
import { GET_CATEGORY } from "@/core/data/apiRoutes"; import {GET_CATEGORY} from "@/core/data/apiRoutes";
import useRequest from "@/lib/app/hooks/useRequest"; import useRequest from "@/lib/app/hooks/useRequest";
const reducer = (state, action) => { const reducer = (state, action) => {
@@ -7,11 +7,11 @@ const reducer = (state, action) => {
case "CHANGE_ACTIVE_TAB": case "CHANGE_ACTIVE_TAB":
return state.map((answer, index) => return state.map((answer, index) =>
action.newValue === index action.newValue === index
? { ...answer, active: true } ? {...answer, active: true}
: { : {
...answer, ...answer,
active: false, active: false,
} }
); );
case "CHANGE_LIST": case "CHANGE_LIST":
return [...action.newList]; return [...action.newList];
@@ -19,10 +19,10 @@ const reducer = (state, action) => {
return state.map((answer, index) => return state.map((answer, index) =>
action.tab_id === answer.id action.tab_id === answer.id
? { ? {
...answer, ...answer,
active_category_id: action.category_id, active_category_id: action.category_id,
} }
: { ...answer } : {...answer}
); );
default: default:
return state; return state;
@@ -32,17 +32,17 @@ const reducer = (state, action) => {
const submission = (handleCategories, operation) => { const submission = (handleCategories, operation) => {
switch (operation.type) { switch (operation.type) {
case "SET_CATEGORIES": case "SET_CATEGORIES":
return { ...handleCategories, categoryLists: operation.categoriesByAPI }; return {...handleCategories, categoryLists: operation.categoriesByAPI};
case "SET_SUBCATEGORIES": case "SET_SUBCATEGORIES":
return { ...handleCategories, subCategoryLists: operation.subCategoriesByAPI }; return {...handleCategories, subCategoryLists: operation.subCategoriesByAPI};
default: default:
return handleCategories; return handleCategories;
} }
}; };
export const AnswersContext = createContext(); export const AnswersContext = createContext();
export const AnswersProvider = ({ children }) => { export const AnswersProvider = ({children}) => {
const requestServer = useRequest({ auth: true, notification: false }); const requestServer = useRequest({auth: true, notification: false});
const [openCallDialog, setOpenCallDialog] = useState(false); const [openCallDialog, setOpenCallDialog] = useState(false);
const [activeTab, setActiveTab] = useState(0); const [activeTab, setActiveTab] = useState(0);
const [handleCategories, operation] = useReducer(submission, { const [handleCategories, operation] = useReducer(submission, {
@@ -53,7 +53,7 @@ export const AnswersProvider = ({ children }) => {
useEffect(() => { useEffect(() => {
requestServer(GET_CATEGORY, "get") requestServer(GET_CATEGORY, "get")
.then(({ data }) => { .then(({data}) => {
const subCategoriesByAPI = data.data; const subCategoriesByAPI = data.data;
const categoriesByAPI = subCategoriesByAPI.reduce((accumulator, currentValue) => { const categoriesByAPI = subCategoriesByAPI.reduce((accumulator, currentValue) => {
if (!accumulator.find((item) => item.category_id === currentValue.category_id)) { if (!accumulator.find((item) => item.category_id === currentValue.category_id)) {
@@ -61,10 +61,11 @@ export const AnswersProvider = ({ children }) => {
} }
return accumulator; return accumulator;
}, []); }, []);
operation({ type: "SET_CATEGORIES", categoriesByAPI }); operation({type: "SET_CATEGORIES", categoriesByAPI});
operation({ type: "SET_SUBCATEGORIES", subCategoriesByAPI }); operation({type: "SET_SUBCATEGORIES", subCategoriesByAPI});
}) })
.catch(() => {}); .catch(() => {
});
}, []); }, []);
return ( return (