From 15b88f1513d1fccef3dac1967618bd9b1a2b4e47 Mon Sep 17 00:00:00 2001 From: TBS093A Date: Thu, 20 Aug 2020 13:04:28 +0200 Subject: [PATCH] fix mapStatesToProps && create track GetAll --- .../commands/fetchCommands/Album/GetAll.js | 1 - .../commands/fetchCommands/Track/GetAll.js | 58 +++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/components/index/indexConsole/commands/fetchCommands/Album/GetAll.js b/src/components/index/indexConsole/commands/fetchCommands/Album/GetAll.js index ef54d37..d0f8721 100644 --- a/src/components/index/indexConsole/commands/fetchCommands/Album/GetAll.js +++ b/src/components/index/indexConsole/commands/fetchCommands/Album/GetAll.js @@ -6,7 +6,6 @@ import { ResetComponentWithoutInputs } from '../Abstract Utils/ResetComponent' import { mapAllRowsToString } from '../Abstract Utils/MapRowsToString' const AlbumGetAll = ({ - album, getAllAlbum, consoleHistory, setConsoleHistory, componentVisible, setComponentVisible, diff --git a/src/components/index/indexConsole/commands/fetchCommands/Track/GetAll.js b/src/components/index/indexConsole/commands/fetchCommands/Track/GetAll.js index e69de29..8cc45c9 100644 --- a/src/components/index/indexConsole/commands/fetchCommands/Track/GetAll.js +++ b/src/components/index/indexConsole/commands/fetchCommands/Track/GetAll.js @@ -0,0 +1,58 @@ +import React, { useState } from 'react' +import { connect } from 'react-redux' + +import { getAllTrack } from '../../../../../../stores/track/duck/operations' +import { ResetComponentWithoutInputs } from '../Abstract Utils/ResetComponent' +import { mapAllRowsToString } from '../Abstract Utils/MapRowsToString' + +const TrackGetAll = ({ + getAllTrack, + consoleHistory, setConsoleHistory, + componentVisible, setComponentVisible, + activateConsoleInput +}) => { + + const [message, setMessage] = useState('') + + const resetState = () => { + setConsoleHistory(consoleHistory + message) + setComponentVisible(false) + setMessage('') + } + + const mapTracksToString = (albums) => { + let mapFields = [ + 'title', + 'id', + 'album_id', + 'user_id', + 'url_code' + ] + return mapAllRowsToString( albums, 'albums', mapFields ) + } + + return ( +
+ +
+ ) +} + +const mapStateToProps = state => ({ + album: state.album +}) + +const mapDispatchToProps = dispatch => ({ + getAllTrack: () => dispatch(getAllTrack()) + +}) + +export default connect(mapStateToProps, mapDispatchToProps)(TrackGetAll) \ No newline at end of file