diff --git a/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/AbstractCRUD/AbstractCreate.js b/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/AbstractCRUD/AbstractCreate.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/AbstractCRUD/AbstractDelete.js b/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/AbstractCRUD/AbstractDelete.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/AbstractCRUD/AbstractGetAll.js b/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/AbstractCRUD/AbstractGetAll.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/AbstractCRUD/AbstractGetOne.js b/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/AbstractCRUD/AbstractGetOne.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/AbstractCRUD/AbstractUpdate.js b/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/AbstractCRUD/AbstractUpdate.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/UploadGenerator.js b/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/UploadGenerator.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/components/index/indexConsole/commands/fetchCommands/Album/Create.js b/src/components/index/indexConsole/commands/fetchCommands/Album/Create.js deleted file mode 100644 index 0582329..0000000 --- a/src/components/index/indexConsole/commands/fetchCommands/Album/Create.js +++ /dev/null @@ -1,197 +0,0 @@ -import React, { useState, useEffect } from 'react' -import { connect } from 'react-redux' - -import { createAlbum } from '../../../../../../stores/album/duck/operations' -import FormGenerator from '../Abstract Utils/FormGenerator' - - -const AlbumCreate = ({ - user, - createAlbum, - consoleHistory, setConsoleHistory, - componentVisible, setComponentVisible, - activateConsoleInput -}) => { - - const [message, setMessage] = useState('') - const [image, setImage] = useState('') - const [imageInfo, setImageInfo] = useState('Drop/Click\nfor upload album image...') - - const titleInput = React.createRef() - const descriptionInput = React.createRef() - - let inputList = [ - { - type: 'text', - name: 'titleAlbum', - ref: titleInput - }, - { - type: 'text', - name: 'descriptionAlbum', - ref: descriptionInput - }, - { - type: 'file', - name: 'imageAlbum', - fileType: 'image', - dropInfo: imageInfo, - setDropInfo: setImageInfo, - file: image, - setFile: setImage - } - ] - - const create = async (event) => { - event.preventDefault() - let title = titleInput.current.value - let description = descriptionInput.current.value - if ( title !== '' && description !== '' ) { - await createFetch(title, description) - } if ( description === '') { - document.getElementById('descriptionAlbumInput').focus() - } - } - - const createFetch = async (title, description) => { - let album = { - user_id: user.id, - title: title, - description: description, - image: image, - url_code: generateUrlCode(), - } - await createAlbum( - album, - user.token - ).then( response => { - setMessage( response['info'] + '\n' ) - }) - } - - const generateUrlCode = () => { - let code = 'op?album=' - let hash = [ - '!', '@', '#', '$', '%', '^', '&', '*', - 'Q', 'W', 'X', 'S', 'q', 'w', 'x', 's' - ] - code += - + hash[ randomInt(7, 14) ] - + hash[ randomInt(7, 14) ] - + hash[ randomInt(7, 14) ] - + hash[ randomInt(0, 7) ] - + hash[ randomInt(0, 7) ] - + hash[ randomInt(0, 7) ] - + randomInt(0, 9) - + randomInt(0, 9) - + randomInt(0, 9) - return code - } - - const randomInt = (min, max) => { - return min + Math.floor((max - min) * Math.random()) - } - - useEffect( - () => { - if ( componentVisible ) { - document.getElementById('titleAlbumInput').focus() - } else { - activateConsoleInput() - } - if ( message !== '' ) { - - titleInput.current.value = '' - descriptionInput.current.value = '' - - setConsoleHistory( consoleHistory + message ) - setComponentVisible( false ) - setImage('') - setImageInfo('Drop/Click\nfor upload album image...') - setMessage('') - } - } - ) - - return ( - - ) - - // const toBase64 = ( file ) => new Promise( (resolve, reject) => { - // let fileReader = new FileReader() - // fileReader.readAsDataURL( file ) - // fileReader.onload = () => resolve( fileReader.result ) - // fileReader.onerror = error => reject( error ) - // }) - - // const onLoadFile = async ( event ) => { - // event.preventDefault() - // let data = event.target.files[0] - // setImage( await toBase64( data ) ) - // setImageInfos(data.name, data.size) - // } - - // const onLoadFileDrop = async ( event ) => { - // event.preventDefault() - // event.persist() - // let data = event.dataTransfer.files[0] - // setImage( await toBase64( data ) ) - // setImageInfos(data.name, data.size) - // } - - // const setImageInfos = (name, size) => { - // setImageInfo( - // 'name: "' - // + name - // + '"\nsize: ' - // + (Math.round(size / 100 + 'e-2') / 100 ) - // + ' MB' - // ) - // } - - // return ( - //
onLoadFileDrop(event) } - // > - //
create(event) }> - // title: - //
- // description: - //
- //
-    //                 { imageInfo }
-    //             
- // onLoadFile(event) } - // />
- //
- // ) -} - -const mapStateToProps = state => ({ - user: state.user -}) - -const mapDispatchToProps = dispatch => ({ - createAlbum: (album, token) => createAlbum(album, token) -}) - -export default connect(mapStateToProps, mapDispatchToProps)(AlbumCreate) \ No newline at end of file