From 2a1e46bd97b61cf1d6dc0b7da1bf7b8fe18e52e9 Mon Sep 17 00:00:00 2001 From: CessnaJ Date: Wed, 17 Jan 2024 19:38:06 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[FEAT]=20=EC=9E=AC=EC=9E=85=EA=B3=A0=20?= =?UTF-8?q?=EC=95=8C=EB=A6=BC=EB=93=B1=EB=A1=9D=20api=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/notification/notification.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/apis/notification/notification.ts b/src/apis/notification/notification.ts index 3970f4af..bad1838b 100644 --- a/src/apis/notification/notification.ts +++ b/src/apis/notification/notification.ts @@ -3,6 +3,7 @@ import { AxiosError } from 'axios' import { authAxiosInstance } from '@/apis/utils/index' import type { Notification } from '@/types/notification' import { NotificationType } from '@/types/notification' +import type { EnrollRestockRequest } from '@/apis/notification/NotificationDto' import { EventSourcePolyfill } from 'event-source-polyfill' const BASE_URL = import.meta.env.VITE_API_BASE_URL @@ -59,6 +60,18 @@ export const deleteAllNotifications = async (): Promise => { await authAxiosInstance.delete(`${NOTIFICATION_PREFIX_PATH}${NOTIFICATION_DOMAIN_PREFIX_PATH}`) } +// 재입고 알림 등록 +export const enrollRestockNotificaton = async ( + enrollRestockRequest: EnrollRestockRequest +): Promise => { + const response = await authAxiosInstance.post( + `${NOTIFICATION_PREFIX_PATH}${NOTIFICATION_DOMAIN_PREFIX_PATH}/restock/enroll`, + enrollRestockRequest + ) + // 응답으로 return mongoDB string type id + return response.data +} + // 알림 구독 export const subscribeToNotifications = ( onMessage: (notification: Notification) => void, From 73be52aa5e979a46b31ff839bf6507573a9eb73e Mon Sep 17 00:00:00 2001 From: CessnaJ Date: Wed, 17 Jan 2024 19:38:19 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[FEAT]=20=EC=9E=AC=EC=9E=85=EA=B3=A0=20?= =?UTF-8?q?=EC=95=8C=EB=A6=BC=EB=93=B1=EB=A1=9D=20request=20dto=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/notification/NotificationDto.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/apis/notification/NotificationDto.ts diff --git a/src/apis/notification/NotificationDto.ts b/src/apis/notification/NotificationDto.ts new file mode 100644 index 00000000..63e1c0e9 --- /dev/null +++ b/src/apis/notification/NotificationDto.ts @@ -0,0 +1,4 @@ +export interface EnrollRestockRequest { + productId: number + sizeId: number +} From d31380993869a90b35a98d2093d23e88386410b2 Mon Sep 17 00:00:00 2001 From: CessnaJ Date: Wed, 17 Jan 2024 19:38:35 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[FEAT]=20=EC=9E=AC=EC=9E=85=EA=B3=A0=20?= =?UTF-8?q?=EC=95=8C=EB=A6=BC=EB=93=B1=EB=A1=9D=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=EB=B6=80=20=ED=98=B8=EC=B6=9C=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/ProductDetailView.vue | 44 +++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/views/ProductDetailView.vue b/src/views/ProductDetailView.vue index 8b4c444f..73d3a108 100644 --- a/src/views/ProductDetailView.vue +++ b/src/views/ProductDetailView.vue @@ -15,10 +15,12 @@ import { readWishListFromProduct, toggleWishList } from '@/apis/wishcart/WishLis import type { AxiosResponse } from 'axios' import TOP4OOTDComponent from '@/components/ootd/TOP4OOTDComponent.vue' import { Image, Select, SelectOption } from 'ant-design-vue' -import { errorModal, infoModal, warningModal } from '@/utils/Modal' +import { errorModal, infoModal, warningModal, confirmModal } from '@/utils/Modal' import { LOGIN_NEED_MSG } from '@/utils/CommonMessage' import { SizeOrder } from '@/types/enums/SizeOrder' import type { ProductStock } from '@/types/product/Product' +import { enrollRestockNotificaton } from '@/apis/notification/notification' +import type { EnrollRestockRequest } from '@/apis/notification/NotificationDto' const productStore = useProductStore() @@ -233,7 +235,44 @@ const bestPromotionalPriceUpdatedHandler = (maxDiscount: number) => { } } +/** + * 재입고 알림신청 관련 + */ +const enrollRestockNotificationHandler = async () => { + if (!localStorage.getItem('accessToken')) { + infoModal('알림', LOGIN_NEED_MSG) + return + } + + if (selectedProductSize.value.productSizeId <= 0) { + warningModal('알림', '옵션을 지정해주세요.') + return + } + + const confirmed = await confirmModal( + '재입고 알림 신청', + `해당 상품 ${selectedProductSize.value.productSizeName}사이즈의 재입고 알림을 신청하시겠습니까?` + ) + + if (confirmed) { + await postEnrollRestockNotificaton() + } +} + +const postEnrollRestockNotificaton = async () => { + const enrollRestockRequest: EnrollRestockRequest = { + productId: productId.value, + sizeId: selectedProductSize.value.productSizeId + } + + const restockId = await enrollRestockNotificaton(enrollRestockRequest) + if (restockId) { + infoModal('알림', '상품 재입고시, 신속하게 알려드리겠습니다.') // 이미 재입고 신청 취소도 가능해야하는지? + } +} + const getOrder = (size: string): number => { + // 상품 option 순서 맞추기 const defaultOrder = 1000 const normalizedSize = size.charAt(0).toUpperCase() + size.slice(1).toLowerCase() @@ -255,6 +294,7 @@ const getOrder = (size: string): number => { } const sortedProductStocks = computed(() => { + // computed로 사이즈끼리의 순서 맞춘걸 가짐 return product.value.productStocks.slice().sort((a: ProductStock, b: ProductStock) => { const orderA = getOrder(a.productSizeName) const orderB = getOrder(b.productSizeName) @@ -441,7 +481,7 @@ watch(selectedProductSize, () => {
-
+
Date: Wed, 17 Jan 2024 19:42:08 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[FEAT]=20=EC=9E=AC=EC=9E=85=EA=B3=A0=20?= =?UTF-8?q?=EC=95=8C=EB=A6=BC=20=EC=9E=AC=EA=B3=A0=20filtering=20=EA=B2=80?= =?UTF-8?q?=EC=82=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/ProductDetailView.vue | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/views/ProductDetailView.vue b/src/views/ProductDetailView.vue index 73d3a108..ac568240 100644 --- a/src/views/ProductDetailView.vue +++ b/src/views/ProductDetailView.vue @@ -244,6 +244,14 @@ const enrollRestockNotificationHandler = async () => { return } + if (selectedProductSize.value.quantity) { + infoModal( + '알림', + '재고가 없는 사이즈의 알림 신청만 가능합니다. \n 재입고 알림을 받고싶은 사이즈 선택 후 눌러주세요.' + ) + return + } + if (selectedProductSize.value.productSizeId <= 0) { warningModal('알림', '옵션을 지정해주세요.') return