"use client"; import qs from "query-string"; import axios from "axios"; import { useState } from "react"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { useModal } from "@/hooks/use-modal-store"; import { Button } from "@/components/ui/button"; export const DeleteMessageModal = () => { const { isOpen, onClose, type, data } = useModal(); const isModalOpen = isOpen && type === "deleteMessage"; const { apiUrl, query } = data; const [isLoading, setIsLoading] = useState(false); const onClick = async () => { try { setIsLoading(true); const url = qs.stringifyUrl({ url: apiUrl || "", query, }) await axios.delete(url); onClose(); } catch (error) { console.log(error); } finally { setIsLoading(false); onClose(); } } return ( Delete Message Are you sure you want to do this?
The message will be permenantly deleted.
) }