Skip to content

Commit

Permalink
chore: change failure actions' dispaching
Browse files Browse the repository at this point in the history
  • Loading branch information
muratmerdoglu-dp committed Apr 19, 2024
1 parent d5b1df5 commit 28245d1
Showing 1 changed file with 21 additions and 42 deletions.
63 changes: 21 additions & 42 deletions src/modules/data/board/boardActions/socketApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,13 @@ export const useSocketApi = () => {
const createColumnFailure = (
action: ReturnType<typeof BoardActions.createColumnFailure>
) => {
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 (
Expand All @@ -60,16 +57,13 @@ export const useSocketApi = () => {
const deleteCardFailure = (
action: ReturnType<typeof BoardActions.deleteCardFailure>
) => {
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 (
Expand All @@ -82,16 +76,13 @@ export const useSocketApi = () => {
const deleteColumnFailure = (
action: ReturnType<typeof BoardActions.deleteColumnFailure>
) => {
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 (
Expand All @@ -104,16 +95,13 @@ export const useSocketApi = () => {
const moveCardFailure = (
action: ReturnType<typeof BoardActions.moveCardFailure>
) => {
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 (
Expand All @@ -126,16 +114,13 @@ export const useSocketApi = () => {
const moveColumnFailure = (
action: ReturnType<typeof BoardActions.moveColumnFailure>
) => {
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 (
Expand All @@ -148,16 +133,13 @@ export const useSocketApi = () => {
const updateBoardTitleFailure = (
action: ReturnType<typeof BoardActions.updateBoardTitleFailure>
) => {
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 = (
Expand All @@ -170,16 +152,13 @@ export const useSocketApi = () => {
const updateColumnTitleFailure = (
action: ReturnType<typeof BoardActions.updateColumnTitleFailure>
) => {
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 = (
Expand Down

0 comments on commit 28245d1

Please sign in to comment.