Skip to content

Commit

Permalink
feat: useDeletePillData #1 #2 #4
Browse files Browse the repository at this point in the history
약을 삭제하는 함수를 추가합니다.
  • Loading branch information
arch-spatula committed Jan 9, 2023
1 parent d045bfe commit cd99465
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Hooks/usePill.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand All @@ -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('ㅇㅇ');
},
});
};

0 comments on commit cd99465

Please sign in to comment.