- added preview of application for beneficiary;
- added isRequestedAmount setting;
This commit is contained in:
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { flexRender, getCoreRowModel, useReactTable } from '@tanstack/react-table';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
|
||||
const RenderTable = ({ data, columns, setRowsFn }) => {
|
||||
const RenderTable = ({ data, columns, setRowsFn, disabled }) => {
|
||||
const table = useReactTable({
|
||||
data,
|
||||
columns,
|
||||
@@ -16,6 +16,7 @@ const RenderTable = ({ data, columns, setRowsFn }) => {
|
||||
|
||||
return (
|
||||
<input
|
||||
disabled={disabled}
|
||||
value={initialValue ? initialValue : ''}
|
||||
onChange={(e) => table.options.meta?.updateData(index, id, e.target.value)}
|
||||
onBlur={onBlur}
|
||||
|
||||
@@ -17,6 +17,7 @@ const Table = ({
|
||||
label,
|
||||
register,
|
||||
errors,
|
||||
disabled = false,
|
||||
config = {},
|
||||
defaultValue = [],
|
||||
tableColumns = []
|
||||
@@ -29,6 +30,9 @@ const Table = ({
|
||||
const [rowIndexToDelete, rowRowIndexToDelete] = useState(null);
|
||||
|
||||
const addNewRow = () => {
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
const obj = columnsCfg
|
||||
.reduce((acc, cur) => {
|
||||
acc[cur.name] = ''
|
||||
@@ -94,6 +98,7 @@ const Table = ({
|
||||
header: () => '',
|
||||
footer: (props) => props.column.id,
|
||||
cell: ({row: { index }}) => <Button
|
||||
disabled={disabled}
|
||||
type="button"
|
||||
icon="pi pi-times"
|
||||
className="p-button-danger"
|
||||
@@ -139,9 +144,11 @@ const Table = ({
|
||||
{label}{config.required || config.isRequired || (config.validate && config.validate.nonEmptyTables)
|
||||
? <span className="appForm__field--required">*</span> : null}
|
||||
</label>
|
||||
{rows ? <RenderTable columns={columns} data={rows} setRowsFn={updateRows}/> : null}
|
||||
{rows ? <RenderTable columns={columns} data={rows} setRowsFn={updateRows} disabled={disabled}/> : null}
|
||||
{!isEmpty(columns) && !shouldDisableNewRows
|
||||
? <div className="addNewTableRow" onClick={addNewRow}>{__('Aggiungi una riga', 'gepafin')}</div>
|
||||
? <div className="addNewTableRow" onClick={addNewRow}>
|
||||
{__('Aggiungi una riga', 'gepafin')}
|
||||
</div>
|
||||
: null}
|
||||
</>)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user