diff --git a/src/components/elements/FileManager.tsx b/src/components/elements/FileManager.tsx index 234257f..dd6dbcb 100644 --- a/src/components/elements/FileManager.tsx +++ b/src/components/elements/FileManager.tsx @@ -4,6 +4,7 @@ import UploadToIPFS from "./UploadToIPFS"; import { useSignMessage } from "wagmi"; import { Polybase } from "@polybase/client"; import { Icon } from "@iconify/react"; +import Modal from "./Modal"; interface Props { publicKey: `0x${string}`; @@ -29,6 +30,10 @@ const FileManager = ({ publicKey }: Props) => { const sign = useSignMessage(); const [songs, setSongs] = useState([]); + const [modalIsOpen, setModalIsOpen] = useState(false); + const [playlistName, setPlaylistName] = useState( + "My Amazing Playlist" + ); const songsCollection = db.collection("Song"); @@ -58,7 +63,8 @@ const FileManager = ({ publicKey }: Props) => { setSongs(newSongs); }; - const handleAddToPlaylist = async () => { + const handleCreatePlaylist = async () => { + setModalIsOpen(false); db.signer(async (data) => { return { h: "eth-personal-sign", @@ -74,92 +80,105 @@ const FileManager = ({ publicKey }: Props) => { await db .collection("Playlist") - .record("My Amazing Playlist") + .record(playlistName) .call("setSongs", [songIds]); + + setPlaylistName(""); }; return ( -
-
-

Files

- -
- -
-
-
-
- {songs.length > 0 && ( - <> - - - - )} -
+ <> + { + setModalIsOpen(false); + }} + /> +
+
+

Files

+
-
-
- - -
- {songs.length === 0 && ( -
- -

- Ops, it looks like you don’t have any files yet. Upload files to - get started. -

-
- )} -
-
    - {songs.map((song) => ( -
  • + +
    +
    +
    +
    + {songs.length > 0 && ( + <> -
  • - ))} -
+ + )} +
+
+
+
+ + +
+ {songs.length === 0 && ( +
+ +

+ Ops, it looks like you don’t have any files yet. Upload files + to get started. +

+
+ )} +
+
    + {songs.map((song) => ( +
  • + + +
  • + ))} +
+
-
+ ); }; diff --git a/src/components/elements/Modal.tsx b/src/components/elements/Modal.tsx new file mode 100644 index 0000000..aca97e2 --- /dev/null +++ b/src/components/elements/Modal.tsx @@ -0,0 +1,68 @@ +import React from "react"; +import Button from "./Button"; + +interface Props { + modalIsOpen: boolean; + setPlaylistName: (name: string) => void; + commitPlaylist: () => void; + closeModal: () => void; +} + +const Modal = ({ + modalIsOpen, + setPlaylistName, + commitPlaylist, + closeModal, +}: Props) => { + if (modalIsOpen) { + return ( + + ); + } +}; + +export default Modal;