// @flow import React from 'react'; import Button from 'component/button'; import CollectionItemsList from 'component/collectionItemsList'; import Card from 'component/common/card'; import * as MODALS from 'constants/modal_types'; import * as ICONS from 'constants/icons'; import * as COLLECTIONS_CONSTS from 'constants/collections'; import Tooltip from 'component/common/tooltip'; import { Tabs, TabList, Tab, TabPanels, TabPanel } from 'component/common/tabs'; import { useHistory } from 'react-router-dom'; import CollectionGeneralTab from 'component/collectionGeneralTab'; import ErrorText from 'component/common/error-text'; type Props = { collectionId: string, // -- redux - collection: Collection, collectionUrls: Array, collectionHasEdits: boolean, doCollectionEdit: (id: string, params: CollectionEditParams) => void, doClearEditsForCollectionid: (id: string) => void, doOpenModal: (id: string, params: {}) => void, }; function CollectionForm(props: Props) { const { collectionId, // -- redux - collection, collectionUrls, collectionHasEdits, doCollectionEdit, doClearEditsForCollectionid, doOpenModal, } = props; const { goBack } = useHistory(); const collectionResetPending = React.useRef(false); const isBuiltin = COLLECTIONS_CONSTS.BUILTIN_PLAYLISTS.includes(collectionId); const { name, description, thumbnail } = collection || {}; const initialParams = React.useRef({ uris: collectionUrls, name, description, thumbnail, }); const [thumbailError, setThumbnailError] = React.useState(''); const [params, setParams] = React.useState(initialParams.current); function updateParams(newParams) { // $FlowFixMe setParams({ ...params, ...newParams }); } function handleSubmit() { doCollectionEdit(collectionId, params); goBack(); } React.useEffect(() => { if (collection && collectionResetPending.current) { setParams({ uris: collectionUrls, name, description, thumbnail, }); collectionResetPending.current = false; } // eslint-disable-next-line react-hooks/exhaustive-deps }, [collection]); return (
{__('General')} {__('Items')}
{collectionHasEdits && (
); } export default CollectionForm;