Refactor the rqbit-web file by breaking it down into components and helper functions. Improve code organization and maintainability
This commit is contained in:
parent
a5e7a5a5f5
commit
f978ad02fe
25 changed files with 1722 additions and 926 deletions
35
crates/librqbit/webui/src/components/MagnetInput.tsx
Normal file
35
crates/librqbit/webui/src/components/MagnetInput.tsx
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { useState } from "react";
|
||||
import { UploadButton } from "./UploadButton";
|
||||
import { UrlPromptModal } from "./UrlPromptModal";
|
||||
|
||||
export const MagnetInput = () => {
|
||||
let [magnet, setMagnet] = useState<string | null>(null);
|
||||
|
||||
let [showModal, setShowModal] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<UploadButton
|
||||
variant="primary"
|
||||
buttonText="Add Torrent from Magnet / URL"
|
||||
onClick={() => {
|
||||
setShowModal(true);
|
||||
}}
|
||||
data={magnet}
|
||||
resetData={() => setMagnet(null)}
|
||||
/>
|
||||
|
||||
<UrlPromptModal
|
||||
show={showModal}
|
||||
setUrl={(url) => {
|
||||
setShowModal(false);
|
||||
setMagnet(url);
|
||||
}}
|
||||
cancel={() => {
|
||||
setShowModal(false);
|
||||
setMagnet(null);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue