Skip to content

Commit

Permalink
refactor: 리턴 데이터 타입 제네릭 타입으로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jiyaaany committed Nov 28, 2021
1 parent 5448c46 commit c268cc3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/hooks/usePost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ interface Post {
onError?: () => void;
}

export const usePost = ({
export const usePost = <T extends ProductId>({
pathname,
errorMessage = GENERAL_ERROR,
onSuccess,
onError,
}: Post): UseMutationResult<ObjectResponse<ProductId> | void, unknown> => {
}: Post): UseMutationResult<ObjectResponse<T> | void, unknown> => {
const [postErrorMessage, setPostErrorMessage] = useState<string>();

useCommonSnackbar({
Expand Down
6 changes: 4 additions & 2 deletions src/libs/draftjs-utils/inline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,10 @@ export const changeOriginalStyleToNewStyle = ({
);
}

const editorStateWithNewStyleAndPreviousSelection =
EditorState.forceSelection(editorStateWithNewStyle, originalSelection);
const editorStateWithNewStyleAndPreviousSelection = EditorState.forceSelection(
editorStateWithNewStyle,
originalSelection,
);

return editorStateWithNewStyleAndPreviousSelection;
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { FAILED_TO_SAVE_PRODUCT } from 'constants/errors';

import { useCommonSnackbar } from 'components/CommonSnackbar/useCommonSnackbar';
import { usePost } from 'hooks/usePost';
import {
currentProductIdAtom,
Expand Down Expand Up @@ -62,11 +61,5 @@ export const useSaveProduct = (): SaveProduct => {
mutate(postProductData);
};

useCommonSnackbar({
message: FAILED_TO_SAVE_PRODUCT,
severity: 'error',
dependencies: [showError],
});

return { saveProduct };
};
30 changes: 15 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2220,15 +2220,15 @@
"@types/yargs" "^15.0.0"
chalk "^4.0.0"

"@material-ui/core@^4.11.3":
version "4.11.3"
resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.11.3.tgz#f22e41775b0bd075e36a7a093d43951bf7f63850"
integrity sha512-Adt40rGW6Uds+cAyk3pVgcErpzU/qxc7KBR94jFHBYretU4AtWZltYcNsbeMn9tXL86jjVL1kuGcIHsgLgFGRw==
"@material-ui/core@^4.12.3":
version "4.12.3"
resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.12.3.tgz#80d665caf0f1f034e52355c5450c0e38b099d3ca"
integrity sha512-sdpgI/PL56QVsEJldwEe4FFaFTLUqN+rd7sSZiRCdx2E/C7z5yK0y/khAWVBH24tXwto7I1hCzNWfJGZIYJKnw==
dependencies:
"@babel/runtime" "^7.4.4"
"@material-ui/styles" "^4.11.3"
"@material-ui/system" "^4.11.3"
"@material-ui/types" "^5.1.0"
"@material-ui/styles" "^4.11.4"
"@material-ui/system" "^4.12.1"
"@material-ui/types" "5.1.0"
"@material-ui/utils" "^4.11.2"
"@types/react-transition-group" "^4.2.0"
clsx "^1.0.4"
Expand All @@ -2245,10 +2245,10 @@
dependencies:
"@babel/runtime" "^7.4.4"

"@material-ui/lab@^4.0.0-alpha.58":
version "4.0.0-alpha.58"
resolved "https://registry.yarnpkg.com/@material-ui/lab/-/lab-4.0.0-alpha.58.tgz#c7ebb66f49863c5acbb20817163737caa299fafc"
integrity sha512-GKHlJqLxUeHH3L3dGQ48ZavYrqGOTXkFkiEiuYMAnAvXAZP4rhMIqeHOPXSUQan4Bd8QnafDcpovOSLnadDmKw==
"@material-ui/lab@^4.0.0-alpha.60":
version "4.0.0-alpha.60"
resolved "https://registry.yarnpkg.com/@material-ui/lab/-/lab-4.0.0-alpha.60.tgz#5ad203aed5a8569b0f1753945a21a05efa2234d2"
integrity sha512-fadlYsPJF+0fx2lRuyqAuJj7hAS1tLDdIEEdov5jlrpb5pp4b+mRDUqQTUxi4inRZHS1bEXpU8QWUhO6xX88aA==
dependencies:
"@babel/runtime" "^7.4.4"
"@material-ui/utils" "^4.11.2"
Expand Down Expand Up @@ -2290,10 +2290,10 @@
jss-plugin-vendor-prefixer "^10.5.1"
prop-types "^15.7.2"

"@material-ui/system@^4.11.3":
version "4.11.3"
resolved "https://registry.yarnpkg.com/@material-ui/system/-/system-4.11.3.tgz#466bc14c9986798fd325665927c963eb47cc4143"
integrity sha512-SY7otguNGol41Mu2Sg6KbBP1ZRFIbFLHGK81y4KYbsV2yIcaEPOmsCK6zwWlp+2yTV3J/VwT6oSBARtGIVdXPw==
"@material-ui/system@^4.12.1":
version "4.12.1"
resolved "https://registry.yarnpkg.com/@material-ui/system/-/system-4.12.1.tgz#2dd96c243f8c0a331b2bb6d46efd7771a399707c"
integrity sha512-lUdzs4q9kEXZGhbN7BptyiS1rLNHe6kG9o8Y307HCvF4sQxbCgpL2qi+gUk+yI8a2DNk48gISEQxoxpgph0xIw==
dependencies:
"@babel/runtime" "^7.4.4"
"@material-ui/utils" "^4.11.2"
Expand Down

0 comments on commit c268cc3

Please sign in to comment.