upgrade CRUD console

develop
TBS093A 2020-08-07 14:17:36 +02:00
parent 5f3e045a7b
commit a17fbfa937
3 changed files with 31 additions and 26 deletions

View File

@ -101,19 +101,19 @@ const AlbumCreate = ({
id='titleAlbumInput'
autoComplete='off'
ref={ titleInput }
/>
/> <br />
description:
<input
id='descriptionAlbumInput'
autoComplete='off'
ref={ descriptionInput }
/>
/> <br />
image:
<input
id='imageAlbumInput'
autoComplete='off'
ref={ imageInput }
/>
/> <br />
<button type='submit' />
</form>
</div>

View File

@ -19,9 +19,9 @@ const AlbumGetAll = ({
let list = '.albums\n'
for (let i = 0; i < albums.length; i++) {
list += '├── ' + albums[i].title + '\n'
+ '│ ├── id: ' + albums[i].id + '\n'
+ '│ ├── user id: ' + albums[i].user_id + '\n'
+ '│ └── url: ' + albums[i].url_code + '\n'
+ '│ ├── id: ' + albums[i].id + '\n'
+ '│ ├── user id: ' + albums[i].user_id + '\n'
+ '│ └── url: ' + albums[i].url_code + '\n'
}
return list
}

View File

@ -13,11 +13,8 @@ import AlbumDelete from './commands/fetchCommands/Album/Delete'
import '../../../styles/general.scss'
import { deleteAuth } from '../../../stores/user/duck/operations'
const IndexConsole = ({
user,
deleteAuth
user
}) => {
const [consoleHistory, setConsoleHistory] = useState('')
@ -60,27 +57,17 @@ const IndexConsole = ({
let inputValue = consoleInput.current.value
consoleUser += inputValue + '\n'
let splitCommand = inputValue.split(' ')
let choiceCRUD = splitCommand[ splitCommand.length - 1 ]
if ( user.username !== '' ) {
if ( inputValue === 'help' ){
setConsoleHistory( consoleHistory + consoleUser + commands.helpUser() )
} else if ( inputValue === 'logout' ) {
setConsoleHistory( consoleHistory + consoleUser )
setLogout( !logout )
} else if ( inputValue === 'get all album') {
setConsoleHistory( consoleHistory + consoleUser )
setAlbumGetAll( !albumGetAll )
} else if ( inputValue === 'get one album' ) {
setConsoleHistory( consoleHistory + consoleUser )
setAlbumGetOne( !albumGetOne )
} else if ( inputValue === 'create album' ) {
setConsoleHistory( consoleHistory + consoleUser )
setAlbumCreate( !albumCreate )
} else if ( inputValue === 'update album' ) {
setConsoleHistory( consoleHistory + consoleUser )
setAlbumUpdate( !albumUpdate )
} else if ( inputValue === 'delete album' ) {
setConsoleHistory( consoleHistory + consoleUser )
setAlbumDelete( !albumDelete )
} else if ( choiceCRUD === 'album' ) {
albumCRUD( inputValue )
} else if ( inputValue === 'clean' ){
setConsoleHistory( '' )
} else {
@ -104,6 +91,25 @@ const IndexConsole = ({
activateInput()
}
const albumCRUD = ( inputValue ) => {
if ( inputValue === 'get all album') {
setConsoleHistory( consoleHistory + consoleUser )
setAlbumGetAll( !albumGetAll )
} else if ( inputValue === 'get one album' ) {
setConsoleHistory( consoleHistory + consoleUser )
setAlbumGetOne( !albumGetOne )
} else if ( inputValue === 'create album' ) {
setConsoleHistory( consoleHistory + consoleUser )
setAlbumCreate( !albumCreate )
} else if ( inputValue === 'update album' ) {
setConsoleHistory( consoleHistory + consoleUser )
setAlbumUpdate( !albumUpdate )
} else if ( inputValue === 'delete album' ) {
setConsoleHistory( consoleHistory + consoleUser )
setAlbumDelete( !albumDelete )
}
}
const activateInput = () => {
document.getElementById('consoleInput').focus()
}
@ -214,7 +220,6 @@ const mapStateToProps = state => ({
})
const mapDispatchToProps = dispatch => ({
deleteAuth: (token) => dispatch( deleteAuth(token) )
})
export default connect(mapStateToProps, mapDispatchToProps)(IndexConsole)