diff --git a/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/AbstractUpdate.js b/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/AbstractUpdate.js new file mode 100644 index 0000000..b732968 --- /dev/null +++ b/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/AbstractUpdate.js @@ -0,0 +1,12 @@ +export const validate = ( inputs ) => { + let object = {} + for (let i = 0; i < inputs.length; i++) { + if ( + inputs[i]['type'] === 'text' + && inputs[i]['ref'] !== undefined + && inputs[i]['ref'].current.value !== '' + ) + object[ inputs[i]['name'] ] = inputs[i]['ref'].current.value + } + return object +} \ No newline at end of file diff --git a/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/FormGenerator.js b/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/FormGenerator.js index 63a6cb8..efba6d5 100644 --- a/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/FormGenerator.js +++ b/src/components/index/indexConsole/commands/fetchCommands/Abstract Utils/FormGenerator.js @@ -14,23 +14,32 @@ export const FormGenerator = ({ const handler = async (event) => { event.preventDefault() for ( let i = 0; i < refList.length; i++ ) { - if ( refList[i].current.value === '' ) { + if ( + refList[i].current.value === '' + && inputList[0].action !== 'Update' + || i === 0 && refList.length !== 1 + ) { refList[i].current.focus() } else if ( i === refList.length - 1 ) { await action( refList ) } } } + + let info return (