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 a9bd76a commit 9a80b3b
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 29 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 };
};
67 changes: 49 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,13 @@
dependencies:
regenerator-runtime "^0.13.4"

"@babel/runtime@^7.6.0":
version "7.16.3"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.16.3.tgz#b86f0db02a04187a3c17caa77de69840165d42d5"
integrity sha512-WBwekcqacdY2e9AF/Q7WLFUWmdJGJTkbjqTjoMDgXkVZ3ZRUvOPsLb5KdwISoQVsbP+DQzVZW4Zhci0DvpbNTQ==
dependencies:
regenerator-runtime "^0.13.4"

"@babel/runtime@^7.6.2":
version "7.15.4"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.15.4.tgz#fd17d16bfdf878e6dd02d19753a39fa8a8d9c84a"
Expand Down Expand Up @@ -2213,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 @@ -2238,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 All @@ -2268,7 +2275,7 @@
dependencies:
"@babel/runtime" "^7.4.4"
"@emotion/hash" "^0.8.0"
"@material-ui/types" "^5.1.0"
"@material-ui/types" "5.1.0"
"@material-ui/utils" "^4.11.2"
clsx "^1.0.4"
csstype "^2.5.2"
Expand All @@ -2283,17 +2290,17 @@
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"
csstype "^2.5.2"
prop-types "^15.7.2"

"@material-ui/types@^5.1.0":
"@material-ui/types@5.1.0", "@material-ui/types@^5.1.0":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@material-ui/types/-/types-5.1.0.tgz#efa1c7a0b0eaa4c7c87ac0390445f0f88b0d88f2"
integrity sha512-7cqRjrY50b8QzRSYyhSpx4WRw2YuO0KKIGQEVk5J8uoz2BanawykgZGoWEqKm7pVIbzFDN0SpPcVV4IhOFkl8A==
Expand Down Expand Up @@ -3521,6 +3528,13 @@
"@types/react" "*"
csstype "^3.0.2"

"@types/styled-jsx@^2.2.8":
version "2.2.9"
resolved "https://registry.yarnpkg.com/@types/styled-jsx/-/styled-jsx-2.2.9.tgz#e50b3f868c055bcbf9bc353eca6c10fdad32a53f"
integrity sha512-W/iTlIkGEyTBGTEvZCey8EgQlQ5l0DwMqi3iOXlLs2kyBwYTXHKEiU6IZ5EwoRwngL8/dGYuzezSup89ttVHLw==
dependencies:
"@types/react" "*"

"@types/tapable@*", "@types/tapable@^1.0.5":
version "1.0.6"
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.6.tgz#a9ca4b70a18b270ccb2bc0aaafefd1d486b7ea74"
Expand Down Expand Up @@ -5541,7 +5555,7 @@ cliui@^7.0.2:
strip-ansi "^6.0.0"
wrap-ansi "^7.0.0"

clsx@^1.0.4:
clsx@^1.0.2, clsx@^1.0.4:
version "1.1.1"
resolved "https://registry.yarnpkg.com/clsx/-/clsx-1.1.1.tgz#98b3134f9abbdf23b2663491ace13c5c03a73188"
integrity sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA==
Expand Down Expand Up @@ -13212,6 +13226,16 @@ react-textarea-autosize@^8.1.1:
use-composed-ref "^1.0.0"
use-latest "^1.0.0"

react-transition-group@^4.0.0:
version "4.4.2"
resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-4.4.2.tgz#8b59a56f09ced7b55cbd53c36768b922890d5470"
integrity sha512-/RNYfRAMlZwDSr6z4zNKV6xu53/e2BuaBbGhbyYIXTrmgu/bGHzmqOs7mJSJBHy9Ud+ApHx3QjrkKSp1pxvlFg==
dependencies:
"@babel/runtime" "^7.5.5"
dom-helpers "^5.0.1"
loose-envify "^1.4.0"
prop-types "^15.6.2"

react-transition-group@^4.3.0, react-transition-group@^4.4.0:
version "4.4.1"
resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-4.4.1.tgz#63868f9325a38ea5ee9535d828327f85773345c9"
Expand Down Expand Up @@ -13722,6 +13746,13 @@ rgba-regex@^1.0.0:
resolved "https://registry.yarnpkg.com/rgba-regex/-/rgba-regex-1.0.0.tgz#43374e2e2ca0968b0ef1523460b7d730ff22eeb3"
integrity sha1-QzdOLiyglosO8VI0YLfXMP8i7rM=

rifm@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/rifm/-/rifm-0.7.0.tgz#debe951a9c83549ca6b33e5919f716044c2230be"
integrity sha512-DSOJTWHD67860I5ojetXdEQRIBvF6YcpNe53j0vn1vp9EUb9N80EiZTxgP+FkDKorWC8PZw052kTF4C1GOivCQ==
dependencies:
"@babel/runtime" "^7.3.1"

rimraf@2.6.3:
version "2.6.3"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab"
Expand Down

0 comments on commit 9a80b3b

Please sign in to comment.