import { baseUrl } from "@/api/baseUrl"; import ExportCard from "@/components/card/ExportCard"; import { AlertDialog, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@/components/ui/alert-dialog"; import { Button } from "@/components/ui/button"; import axios from "axios"; import { useCallback, useState } from "react"; import useSWR from "swr"; type ExportItem = { name: string; }; function Export() { const { data: exports, mutate } = useSWR( "exports/", (url: string) => axios({ baseURL: baseUrl, url }).then((res) => res.data), ); const [deleteClip, setDeleteClip] = useState(); const onHandleRename = useCallback( (original: string, update: string) => { axios.patch(`export/${original}/${update}`).then((response) => { if (response.status == 200) { setDeleteClip(undefined); mutate(); } }); }, [mutate], ); const onHandleDelete = useCallback(() => { if (!deleteClip) { return; } axios.delete(`export/${deleteClip}`).then((response) => { if (response.status == 200) { setDeleteClip(undefined); mutate(); } }); }, [deleteClip, mutate]); return (
setDeleteClip(undefined)} > Delete Export Confirm deletion of {deleteClip}. Cancel
{exports && (
{Object.values(exports).map((item) => ( setDeleteClip(file)} /> ))}
)}
); } export default Export;