77 <template #header > 정보가 수정되었습니다 </template >
88 </ModalView >
99
10+ <ModalView
11+ :isOpen =" isWarnningModalVisible"
12+ :type =" 'warningType'"
13+ @click =" changePw"
14+ @close =" warningModalToggle" >
15+ <template #header > 정보가 저장되지 않았습니다 </template >
16+ <template #body > 수정 사항을 삭제하고 이동하시겠습니까? </template >
17+ </ModalView >
18+
1019 <div class =" profile" >
1120 <p class =" text-body text-xs font-bold" >프로필 사진</p >
1221 <img
3342 <input
3443 class =" input-box h-11 mt-2 text-black"
3544 placeholder =" 이름을 입력해주세요"
36- v-model =" info. name" />
45+ v-model =" name" />
3746 </div >
3847 <div class =" flex flex-col" >
3948 <p class =" text-body text-xs font-bold" >아이디</p >
5564 <p class =" text-body text-xs font-bold" >알림 수신 여부</p >
5665 <div class =" flex flex-col mt-2 gap-2" >
5766 <FormCheckbox
58- v-model =" info.notificationSettingInfo.agit "
67+ v-model =" agitCheck "
5968 :checkButtonName =" '아지트'"
60- :isChecked =" info.notificationSettingInfo.agit " />
69+ :isChecked =" agitCheck " />
6170 <FormCheckbox
62- v-model =" info.notificationSettingInfo.kakaoWork "
71+ v-model =" kakaoWorkCheck "
6372 :checkButtonName =" '카카오워크'"
64- :isChecked =" info.notificationSettingInfo.kakaoWork " />
73+ :isChecked =" kakaoWorkCheck " />
6574 <FormCheckbox
66- v-model =" info.notificationSettingInfo.email "
75+ v-model =" emailCheck "
6776 :checkButtonName =" '이메일'"
68- :isChecked =" info.notificationSettingInfo.email " />
77+ :isChecked =" emailCheck " />
6978 </div >
7079 </div >
7180 <div >
8695</template >
8796
8897<script lang="ts" setup>
89- import { ref } from ' vue'
98+ import { ref , watchEffect } from ' vue'
9099import { useRouter } from ' vue-router'
91100import ModalView from ' ./ModalView.vue'
92101import FormButtonContainer from ' ./common/FormButtonContainer.vue'
@@ -99,37 +108,68 @@ import { patchEditInfo } from '@/api/common'
99108const memberStore = useMemberStore ()
100109const { info } = storeToRefs (memberStore )
101110
111+ const name = ref (info .value .name )
112+ const agitCheck = ref (info .value .notificationSettingInfo .agit )
113+ const emailCheck = ref (info .value .notificationSettingInfo .email )
114+ const kakaoWorkCheck = ref (info .value .notificationSettingInfo .kakaoWork )
115+
102116const selectedFile = ref <File | null >(null )
103117const previewUrl = ref <string | null >(null )
104118
105119const isModalVisible = ref (false )
120+ const isWarnningModalVisible = ref (false )
121+
122+ watchEffect (() => {
123+ if (info .value ) {
124+ name .value = info .value .name
125+ agitCheck .value = info .value .notificationSettingInfo .agit
126+ emailCheck .value = info .value .notificationSettingInfo .email
127+ kakaoWorkCheck .value = info .value .notificationSettingInfo .kakaoWork
128+ }
129+ })
106130
107131const handleCancel = () => {
108132 router .back ()
109133}
110134
111135const handlePwChange = () => {
136+ if (
137+ selectedFile .value ||
138+ info .value .name != name .value ||
139+ info .value .notificationSettingInfo .agit != agitCheck .value ||
140+ info .value .notificationSettingInfo .kakaoWork != kakaoWorkCheck .value ||
141+ info .value .notificationSettingInfo .email != emailCheck .value
142+ ) {
143+ warningModalToggle ()
144+ } else {
145+ changePw ()
146+ }
147+ }
148+
149+ const changePw = () => {
112150 router .push (' /pw-check' )
113151}
114152
153+ const warningModalToggle = () => {
154+ isWarnningModalVisible .value = ! isWarnningModalVisible .value
155+ }
156+
115157const handleFileUpload = (event : Event ) => {
116158 const target = event .target as HTMLInputElement
117159 if (target .files && target .files [0 ]) {
118160 selectedFile .value = target .files [0 ]
119-
120161 previewUrl .value = URL .createObjectURL (selectedFile .value )
121162 }
122163}
123164
124165const handleSubmit = async () => {
125166 const formData = new FormData ()
126167 const memberInfo = {
127- name: info .value . name ,
128- agitNotification: info .value . notificationSettingInfo . agit ,
129- emailNotification: info .value . notificationSettingInfo . email ,
130- kakaoWorkNotification: info .value . notificationSettingInfo . kakaoWork
168+ name: name .value ,
169+ agitNotification: agitCheck .value ,
170+ emailNotification: emailCheck .value ,
171+ kakaoWorkNotification: kakaoWorkCheck .value
131172 }
132-
133173 const jsonMemberInfo = JSON .stringify (memberInfo )
134174 const newBlob = new Blob ([jsonMemberInfo ], { type: ' application/json' })
135175
0 commit comments