@@ -14,7 +14,6 @@ import extractFilename from "@/utils/helper";
1414import { getHintList } from "@/queries/getHintList" ;
1515
1616import { DrawerType } from "../types/themeDrawerTypes" ;
17- // import cloneDeep from "lodash/cloneDeep";
1817
1918const useEditHint = ( {
2019 onCloseDrawer,
@@ -34,6 +33,15 @@ const useEditHint = ({
3433
3534 const drawerRef = useRef < HTMLFormElement > ( null ) ;
3635
36+ useEffect ( ( ) => {
37+ setCreateHint ( ( prev ) => ( {
38+ ...prev ,
39+ hintImageUrlList : selectedHint . hintImageUrlList ,
40+ answerImageUrlList : selectedHint . answerImageUrlList ,
41+ } ) ) ;
42+ // eslint-disable-next-line react-hooks/exhaustive-deps
43+ } , [ ] ) ;
44+
3745 const isImcomplete = ! (
3846 createHint . hintCode &&
3947 createHint . progress &&
@@ -46,14 +54,13 @@ const useEditHint = ({
4654 Number ( createHint . progress ) === Number ( selectedHint . progress ) &&
4755 String ( createHint . contents ) === String ( selectedHint . contents ) &&
4856 String ( createHint . answer ) === String ( selectedHint . answer ) &&
49- // TODO: 이거 왜 계속 같이 업데이트 되는지 모르겠음... 딥카피 왜안됨 ...????? 몰카냐..
5057 // 서버에 올라간 사진 삭제 여부를 비교
51- // prevHintImages === selectedHint.hintImageUrlList &&
52- // prevAnswerImages === selectedHint.answerImageUrlList &&
53- // 로컬에서 새로 업로드 한 사진 있는지 비교
58+ createHint . hintImageUrlList === selectedHint . hintImageUrlList &&
59+ createHint . answerImageUrlList === selectedHint . answerImageUrlList &&
60+ // 로컬 업로드 사진 하나라도 있으면 변경된 것
5461 Boolean ( ! hintImages . length ) &&
5562 Boolean ( ! answerImages . length ) ;
56- // console.log(createHint, selectedHint, isSameHint);
63+
5764 useEffect ( ( ) => {
5865 if ( hintType === "Add" ) {
5966 return ;
@@ -116,10 +123,7 @@ const useEditHint = ({
116123 if ( hintElement . length !== 1 ) {
117124 throw Error ( "hintElement is not unique" ) ;
118125 }
119- // TODO: 이건 동작 안하는데 .. 애니메이션 빼는 방법 모르겠음
120- // if (hintType === "Add" && drawerRef.current) {
121- // drawerRef.current.classList.remove("animate");
122- // }
126+
123127 setSelectedHint ( hintElement [ 0 ] ) ;
124128 handleHintCreate ( "Edit" ) ;
125129 } catch ( error ) {
0 commit comments