From cd99465984dd80b08e505b6fa5e4858cf687ce69 Mon Sep 17 00:00:00 2001 From: arch-spatula Date: Mon, 9 Jan 2023 19:59:58 +0900 Subject: [PATCH] feat: useDeletePillData #1 #2 #4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 약을 삭제하는 함수를 추가합니다. --- src/Hooks/usePill.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Hooks/usePill.js b/src/Hooks/usePill.js index 3387c9f..530b3be 100644 --- a/src/Hooks/usePill.js +++ b/src/Hooks/usePill.js @@ -1,6 +1,6 @@ import { useMutation } from 'react-query'; import { dbService } from '../shared/firebase'; -import { addDoc, collection } from 'firebase/firestore'; +import { addDoc, deleteDoc, collection, query, doc } from 'firebase/firestore'; // 약 추가 함수 / firestore에 약 새로운 약 정보 추가 const addPill = (pill) => { @@ -11,3 +11,20 @@ const addPill = (pill) => { export const useAddPillData = () => { return useMutation(addPill); }; + +// 약 삭제 함수 / firestore에 새로운 약 정보 삭제 +const deletePill = (pill) => { + return deleteDoc(doc(dbService, 'pill', pill)); +}; + +// 약 삭제 함수 +export const useDeletePillData = () => { + return useMutation(deletePill, { + onError: () => { + console.log('ㅗ'); + }, + onSuccess: () => { + console.log('ㅇㅇ'); + }, + }); +};