diff --git a/src/drawer/apis/deleteProduct.ts b/src/drawer/apis/deleteProduct.ts new file mode 100644 index 00000000..31f65241 --- /dev/null +++ b/src/drawer/apis/deleteProduct.ts @@ -0,0 +1,6 @@ +import { soomsilClient } from '@/apis'; + +export const deleteProduct = async (productId: number) => { + const { data } = await soomsilClient.delete(`/v2/drawer/${productId}`); + return data; +}; diff --git a/src/drawer/components/CardLayout/CardLayout.tsx b/src/drawer/components/CardLayout/CardLayout.tsx index 9c924147..6f159d37 100644 --- a/src/drawer/components/CardLayout/CardLayout.tsx +++ b/src/drawer/components/CardLayout/CardLayout.tsx @@ -24,6 +24,7 @@ export const CardLayout = ({ data, type }: CardLayoutProps) => { isBookmarked={product.isBookmarked} bigImgSrc={product.introductionImage[0]} smallImgSrc={product.mainImage} + productNo={product.productNo} /> ) : ( void; } -export const ServiceRemoveModal = ({ open, onOpenChange }: ServiceRemoveModalProps) => { +export const ServiceRemoveModal = ({ open, productNo, onOpenChange }: ServiceRemoveModalProps) => { const theme = useTheme(); + const queryClient = useQueryClient(); + + const deleteProductMutation = useMutation({ + mutationFn: deleteProduct, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['myRegistered', 'WEB'] }); + queryClient.invalidateQueries({ queryKey: ['bookmarked', 'WEB'] }); + }, + }); return ( @@ -30,7 +42,13 @@ export const ServiceRemoveModal = ({ open, onOpenChange }: ServiceRemoveModalPro
- + deleteProductMutation.mutate(productNo)} + > 확인
diff --git a/src/drawer/components/DrawerCard/UserDrawerCard/UserDrawerCard.tsx b/src/drawer/components/DrawerCard/UserDrawerCard/UserDrawerCard.tsx index ecf407f9..3b2360f3 100644 --- a/src/drawer/components/DrawerCard/UserDrawerCard/UserDrawerCard.tsx +++ b/src/drawer/components/DrawerCard/UserDrawerCard/UserDrawerCard.tsx @@ -8,6 +8,10 @@ import { DrawerCardProps } from '../DrawerCard.type'; import { StyledCardContainer } from './UserDrawerCard.style'; +interface UserDrawerCardProps extends DrawerCardProps { + productNo: number; +} + export const UserDrawerCard = ({ link, bigImgSrc, @@ -16,7 +20,8 @@ export const UserDrawerCard = ({ body, bookmarkCount, isBookmarked, -}: DrawerCardProps) => { + productNo, +}: UserDrawerCardProps) => { const [isCardSettingClicked, setIsCardSettingClicked] = useState(false); const [openRemoveModal, setOpenRemoveModal] = useState(false); @@ -52,7 +57,11 @@ export const UserDrawerCard = ({ - + ); }; diff --git a/src/drawer/components/ServiceDetailContents/ServiceAction/ServiceAction.tsx b/src/drawer/components/ServiceDetailContents/ServiceAction/ServiceAction.tsx index c71b67b5..b12dbfef 100644 --- a/src/drawer/components/ServiceDetailContents/ServiceAction/ServiceAction.tsx +++ b/src/drawer/components/ServiceDetailContents/ServiceAction/ServiceAction.tsx @@ -46,7 +46,7 @@ export const ServiceAction = ({ product }: { product: ProductDetailResult }) => const bookmarkMutation = useMutation({ mutationFn: product.isBookmarked ? deleteBookmarked : postBookmarked, - onSettled: () => { + onSuccess: () => { queryClient.invalidateQueries({ queryKey: ['productDetail', product.productNo] }); }, });