import React, {useState} from 'react'; import { sendForm } from './SendForm'; import Modal from 'react-bootstrap/Modal'; import Button from 'react-bootstrap/Button'; import { actionUsersPlaylists } from '../store/promiseReducer'; import { store } from '../store/store'; import { history } from '../App'; import {Form} from "react-bootstrap"; export const CreatePlaylist = (props) => { const [name, setName] = useState(''); const [description, setDescription] = useState(''); const [privat, setPrivat] = useState(0); const [image, setImage] = useState(null); const PostCreatePlaylist = async(event) =>{ event.preventDefault(); const data = new FormData(); data.append("name", name); description && data.append("description", description); data.append("private", privat); image && data.append("photo", image, image.name); let result = await sendForm('playlists/create', data); console.log(result); store.dispatch(actionUsersPlaylists(store.getState().auth?.user?.id)); history.push(`/playlist/${result.playlist.id}`) } const PreViewImage = (image) => { if (image && typeof (image) !== "string") { return
} } return <> Create new Playlist
{PreViewImage(image)} Image { setImage(e.target.files[0]); }} multiple={false} /> Name setName(e.target.value)} /> Description setDescription(e.target.value)} /> setPrivat(e.target.checked? 1 : 0)} />
}