import React, {useState} from "react"; import {addToast, Button, Checkbox, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader} from "@heroui/react"; import {Form, Formik} from "formik"; import LibraryDto from "Frontend/generated/org/gameyfin/app/libraries/dto/LibraryDto"; import {LibraryEndpoint} from "Frontend/generated/endpoints"; import Input from "Frontend/components/general/input/Input"; import * as Yup from "yup"; import DirectoryMappingInput from "Frontend/components/general/input/DirectoryMappingInput"; interface LibraryCreationModalProps { libraries: LibraryDto[]; setLibraries: (libraries: LibraryDto[]) => void; isOpen: boolean; onOpenChange: () => void; } export default function LibraryCreationModal({ libraries, isOpen, onOpenChange }: LibraryCreationModalProps) { const [scanAfterCreation, setScanAfterCreation] = useState(true); async function createLibrary(library: LibraryDto) { try { await LibraryEndpoint.createLibrary(library as LibraryDto, scanAfterCreation); addToast({ title: "New library created", description: `Library ${library.name} created!`, color: "success" }); } catch (e) { addToast({ title: "Error creating library", description: `Library ${library.name} could not be created!`, color: "warning" }); throw "Error creating library: " + e; } } return ( <> {(onClose) => ( { await createLibrary(values); onClose(); }} > {(formik) =>
Add a new library
Scan after creation?
}
)}
); }