mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-29 18:28:28 -04:00
25 lines
763 B
React
25 lines
763 B
React
import React, {useState} from 'react';
|
|
|
|
import AddPhotoModal from './AddPhotoModal';
|
|
import PickerButton from './PickerButton';
|
|
|
|
// A button that opens the add-photo dialog for one garden, for pages that are
|
|
// not a list of garden cards. Once the photo is added the page reloads.
|
|
export default function PhotoPicker({label, sublabel, buttonClass, garden, newUrl}) {
|
|
const [open, setOpen] = useState(false);
|
|
|
|
return (
|
|
<>
|
|
<PickerButton label={label} sublabel={sublabel} className={buttonClass} onClick={() => setOpen(true)} />
|
|
{open && (
|
|
<AddPhotoModal
|
|
label={garden.name}
|
|
newUrl={newUrl}
|
|
onClose={() => setOpen(false)}
|
|
onAdded={() => window.location.reload()}
|
|
/>
|
|
)}
|
|
</>
|
|
);
|
|
}
|