From ab722bea95a26a794bcca113d8a63047cdf773b5 Mon Sep 17 00:00:00 2001 From: TBS093A Date: Thu, 20 Aug 2020 13:06:32 +0200 Subject: [PATCH] add delete track -> CRUD --- .../commands/fetchCommands/Track/Delete.js | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/src/components/index/indexConsole/commands/fetchCommands/Track/Delete.js b/src/components/index/indexConsole/commands/fetchCommands/Track/Delete.js index e69de29..509a86e 100644 --- a/src/components/index/indexConsole/commands/fetchCommands/Track/Delete.js +++ b/src/components/index/indexConsole/commands/fetchCommands/Track/Delete.js @@ -0,0 +1,82 @@ +import React, { useState, useEffect } from 'react' +import { connect } from 'react-redux' + +import { deleteTrack } from '../../../../../../stores/track/duck/operations' +import { AbstractDelete } from '../Abstract Utils/AbstractDelete' +import { FormGenerator } from '../Abstract Utils/FormGenerator' +import { ResetComponent } from '../Abstract Utils/ResetComponent' + +const TrackDelete = ({ + user, + deleteTrack, + consoleHistory, setConsoleHistory, + componentVisible, setComponentVisible, + activateConsoleInput +}) => { + + const [message, setMessage] = useState('') + + const idInput = React.createRef() + + let refList = [ + idInput + ] + + let inputList = [ + { + type: 'info', + action: 'Delete', + endpoint: 'Track' + }, + { + type: 'text', + name: 'id', + ref: idInput + } + ] + + const deleteFetch = (event) => { + AbstractDelete( + refList, + consoleHistory, + setConsoleHistory, + setMessage, + deleteTrack, + user.token + ) + } + + const resetState = () => { + setConsoleHistory( consoleHistory + message ) + setComponentVisible( false ) + setMessage('') + } + + return ( +
+ + +
+ ) +} + +const mapStateToProps = state => ({ + user: state.user +}) + +const mapDispatchToProps = dispatch => ({ + deleteTrack: (id, token) => deleteTrack(id, token) + +}) + +export default connect(mapStateToProps, mapDispatchToProps)(TrackDelete) \ No newline at end of file