diff --git a/src/components/DataTableCells/SwitchFieldCell.js b/src/components/DataTableCells/SwitchFieldCell.js new file mode 100644 index 000000000..0e9635439 --- /dev/null +++ b/src/components/DataTableCells/SwitchFieldCell.js @@ -0,0 +1,43 @@ +import React from 'react'; +import classNames from 'classnames'; +import { get } from 'lodash'; +import { Classes, Switch, FormGroup, Intent } from '@blueprintjs/core'; + +const SwitchEditableCell = ({ + row: { index, original }, + column: { id, switchProps }, + cell: { value: initialValue }, + payload, +}) => { + const [value, setValue] = React.useState(initialValue); + + const onChange = (e) => { + const newValue = e.target.checked; + + setValue(newValue); + payload.updateData(index, id, newValue); + }; + + React.useEffect(() => { + setValue(initialValue); + }, [initialValue]); + + const error = payload.errors?.[index]?.[id]; + + return ( + + + + ); +}; +export default SwitchEditableCell; diff --git a/src/components/DataTableCells/TextAreaCell.js b/src/components/DataTableCells/TextAreaCell.js new file mode 100644 index 000000000..c8ff97a0c --- /dev/null +++ b/src/components/DataTableCells/TextAreaCell.js @@ -0,0 +1,42 @@ +import React, { useState, useEffect } from 'react'; +import classNames from 'classnames'; +import { Classes, TextArea, FormGroup, Intent } from '@blueprintjs/core'; + +const TextAreaEditableCell = ({ + row: { index }, + column: { id }, + cell: { value: initialValue }, + payload, +}) => { + const [value, setValue] = useState(initialValue); + + const onChange = (e) => { + setValue(e.target.value); + }; + const onBlur = () => { + payload.updateData(index, id, value); + }; + useEffect(() => { + setValue(initialValue); + }, [initialValue]); + + const error = payload.errors?.[index]?.[id]; + + return ( + +