Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/views/campaign/CouponCreateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,10 @@ const resetForm = () => {
formRef.value && formRef.value.clearValidate();
};

// props.recommendId 변화 감지
watch(() => props.recommendId, async (newId) => {
if (newId) {
watch([() => props.recommendId, () => props.visible], async ([newId, isVisible]) => {
if (newId && isVisible) {
await fetchRecommendCoupon(newId)
} else {
} else if (!isVisible) {
resetForm()
}
}, { immediate: true })
Expand Down Expand Up @@ -338,7 +337,9 @@ const handleSubmit = () => {
maxNum: form.maxNum,
segmentName: form.segmentName,
});
await api.put(`/recommend/coupon/update/${props.recommendId}`);
if (props.recommendId) {
await api.put(`/recommend/coupon/update/${props.recommendId}`);
}
ElMessage.success('쿠폰이 등록되었습니다.');
emit('created');
emit('update:visible', false);
Expand Down
12 changes: 6 additions & 6 deletions src/views/campaign/PromotionCreateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,10 @@ const resetForm = () => {
formRef.value && formRef.value.clearValidate();
};

watch(() => props.recommendId, async (newId) => {
if (newId) {
watch([() => props.recommendId, () => props.visible], async ([newId, isVisible]) => {
if (newId && isVisible) {
await fetchRecommendPromotion(newId)
} else {
// 모달 닫힐 때 폼 초기화
} else if (!isVisible) {
resetForm()
}
}, { immediate: true })
Expand Down Expand Up @@ -276,8 +275,9 @@ const handleSubmit = () => {
content: form.content,
segmentName: form.segmentName,
});
await api.put(`/recommend/promotion/update/${props.recommendId}`);

if (props.recommendId) {
await api.put(`/recommend/promotion/update/${props.recommendId}`);
}
ElMessage.success('프로모션이 등록되었습니다.');
emit('created'); // 부모에서 목록 재조회
emit('update:visible', false);
Expand Down
Loading