Skip to content

Commit

Permalink
fix: Use correct service function when deleting text and test blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroChaparro committed Feb 8, 2024
1 parent 5415164 commit 25d943a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/screens/edit-laboratory/dialogs/DeleteBlockDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from "@/components/ui/alert-dialog";
import { EditLaboratoryContext } from "@/context/laboratories/EditLaboratoryContext";
import { EditLaboratoryActionType } from "@/hooks/laboratories/editLaboratoryTypes";
import { deleteMarkdownBlockService } from "@/services/blocks/delete-markdown-block.service";
import { deleteTestBlockService } from "@/services/blocks/delete-test-block.service";
import { BlockType, Laboratory } from "@/types/entities/laboratory-entities";
import { useMutation, useQueryClient } from "@tanstack/react-query";
Expand Down Expand Up @@ -42,6 +43,8 @@ export const DeleteBlockDialog = ({
blockUUID,
blockType
}: DeleteBlockDialogProps) => {
console.log({ blockUUID });

// Global laboratory state
const { laboratoryStateDispatcher, laboratoryState } = useContext(
EditLaboratoryContext
Expand All @@ -51,7 +54,10 @@ export const DeleteBlockDialog = ({
// Delete block mutation
const queryClient = useQueryClient();
const { mutate: deleteTestBlockMutation } = useMutation({
mutationFn: deleteTestBlockService,
mutationFn:
blockType === "test"
? deleteTestBlockService
: deleteMarkdownBlockService,
onError: (error) => {
toast.error(error.message);
},
Expand Down

0 comments on commit 25d943a

Please sign in to comment.