MediaLibraryButton.jsx 591 B

12345678910111213141516171819202122232425
  1. import React from "react";
  2. import { useTranslation } from "react-i18next";
  3. import MediaLibraryModal from "./MediaLibraryModal";
  4. const MediaLibraryButton = ({ onSelect, label }) => {
  5. const { t } = useTranslation();
  6. const [showLibrary, setShowLibrary] = React.useState(false);
  7. return (
  8. <>
  9. <button onClick={() => setShowLibrary((prev) => !prev)}>
  10. {label || t("Select media")}
  11. </button>
  12. <MediaLibraryModal
  13. show={showLibrary}
  14. setShow={setShowLibrary}
  15. onSelect={onSelect}
  16. />
  17. </>
  18. );
  19. };
  20. export default MediaLibraryButton;