From 28245d1ad632ff6d9920351a327e763da60d00b1 Mon Sep 17 00:00:00 2001 From: Murat Merdoglu Date: Fri, 19 Apr 2024 11:40:45 +0200 Subject: [PATCH] chore: change failure actions' dispaching --- .../data/board/boardActions/socketApi.ts | 63 +++++++------------ 1 file changed, 21 insertions(+), 42 deletions(-) diff --git a/src/modules/data/board/boardActions/socketApi.ts b/src/modules/data/board/boardActions/socketApi.ts index ab5e89ebac..24da731fef 100644 --- a/src/modules/data/board/boardActions/socketApi.ts +++ b/src/modules/data/board/boardActions/socketApi.ts @@ -39,16 +39,13 @@ export const useSocketApi = () => { const createColumnFailure = ( action: ReturnType ) => { - const { error } = action.payload; + console.log("createColumnFailure", action.payload); + const failureActionPayload = { - error, errorType: "notUpdatedViaSocket" as ErrorType, - httpStatus: Number(HttpStatusCode.NotFound), BoardObjectType: "boardColumn", }; - boardStore.dispatch( - BoardActions.notifyWithTemplateAndReload(failureActionPayload) - ); + boardStore.dispatch(BoardActions.notifyError(failureActionPayload)); }; const deleteCardRequest = async ( @@ -60,16 +57,13 @@ export const useSocketApi = () => { const deleteCardFailure = ( action: ReturnType ) => { - const { error } = action.payload; + console.log("deleteCardFailure", action.payload); + const failureActionPayload = { - error, errorType: "notUpdatedViaSocket" as ErrorType, - httpStatus: Number(HttpStatusCode.NotFound), BoardObjectType: "boardCard", }; - boardStore.dispatch( - BoardActions.notifyWithTemplateAndReload(failureActionPayload) - ); + boardStore.dispatch(BoardActions.notifyError(failureActionPayload)); }; const deleteColumnRequest = async ( @@ -82,16 +76,13 @@ export const useSocketApi = () => { const deleteColumnFailure = ( action: ReturnType ) => { - const { error } = action.payload; + console.log("deleteColumnFailure", action.payload); + const failureActionPayload = { - error, errorType: "notUpdatedViaSocket" as ErrorType, - httpStatus: Number(HttpStatusCode.NotFound), BoardObjectType: "boardColumn", }; - boardStore.dispatch( - BoardActions.notifyWithTemplateAndReload(failureActionPayload) - ); + boardStore.dispatch(BoardActions.notifyError(failureActionPayload)); }; const moveCardRequest = async ( @@ -104,16 +95,13 @@ export const useSocketApi = () => { const moveCardFailure = ( action: ReturnType ) => { - const { error } = action.payload; + console.log("moveCardFailure", action.payload); + const failureActionPayload = { - error, errorType: "notUpdatedViaSocket" as ErrorType, - httpStatus: Number(HttpStatusCode.NotFound), BoardObjectType: "boardCard", }; - boardStore.dispatch( - BoardActions.notifyWithTemplateAndReload(failureActionPayload) - ); + boardStore.dispatch(BoardActions.notifyError(failureActionPayload)); }; const moveColumnRequest = async ( @@ -126,16 +114,13 @@ export const useSocketApi = () => { const moveColumnFailure = ( action: ReturnType ) => { - const { error } = action.payload; + console.log("moveColumnFailure", action.payload); + const failureActionPayload = { - error, errorType: "notUpdatedViaSocket" as ErrorType, - httpStatus: Number(HttpStatusCode.NotFound), BoardObjectType: "boardColumn", }; - boardStore.dispatch( - BoardActions.notifyWithTemplateAndReload(failureActionPayload) - ); + boardStore.dispatch(BoardActions.notifyError(failureActionPayload)); }; const updateColumnTitleRequest = async ( @@ -148,16 +133,13 @@ export const useSocketApi = () => { const updateBoardTitleFailure = ( action: ReturnType ) => { - const { error } = action.payload; + console.log("updateBoardTitleFailure", action.payload); + const failureActionPayload = { - error, errorType: "notUpdatedViaSocket" as ErrorType, - httpStatus: Number(HttpStatusCode.NotFound), BoardObjectType: "board", }; - boardStore.dispatch( - BoardActions.notifyWithTemplateAndReload(failureActionPayload) - ); + boardStore.dispatch(BoardActions.notifyError(failureActionPayload)); }; const updateBoardTitleRequest = ( @@ -170,16 +152,13 @@ export const useSocketApi = () => { const updateColumnTitleFailure = ( action: ReturnType ) => { - const { error } = action.payload; + console.log("updateColumnTitleFailure", action.payload); + const failureActionPayload = { - error, errorType: "notUpdatedViaSocket" as ErrorType, - httpStatus: Number(HttpStatusCode.NotFound), BoardObjectType: "boardColumn", }; - boardStore.dispatch( - BoardActions.notifyWithTemplateAndReload(failureActionPayload) - ); + boardStore.dispatch(BoardActions.notifyError(failureActionPayload)); }; const updateBoardVisibilityRequest = (