diff --git a/src/client/Containers/Calculation/Results/resultsList.ts b/src/client/Containers/Calculation/Results/resultsList.ts index 11441e3..40ab5a7 100644 --- a/src/client/Containers/Calculation/Results/resultsList.ts +++ b/src/client/Containers/Calculation/Results/resultsList.ts @@ -15,7 +15,7 @@ const resultsList: IGroup[] = [ Component: Label, props: { name: 'lblLead', - computedValue: 'leadName', + computedValueName: 'leadName', }, }, { @@ -23,7 +23,7 @@ const resultsList: IGroup[] = [ Component: Label, props: { name: 'lblOpportunity', - computedValue: 'opportunityName', + computedValueName: 'opportunityName', }, }, { diff --git a/src/client/Containers/Calculation/Sections/sectionsList.ts b/src/client/Containers/Calculation/Sections/sectionsList.ts index 0992197..77d2b71 100644 --- a/src/client/Containers/Calculation/Sections/sectionsList.ts +++ b/src/client/Containers/Calculation/Sections/sectionsList.ts @@ -599,6 +599,33 @@ const sections: ISections[] = [ }, ], }, + // { + // elements: [ + // { + // type: ElementType.Table, + // Component: Table, + // props: { + // name: 'tablePayments', + // features: { + // canDeleteRow: false, + // numerize: { + // columnTitle: 'Номер платежа', + // }, + // }, + // columns: [ + // { + // name: 'paymentRelation', + // title: 'Соотношение платежа', + // Component: Label, + // }, + // ], + // }, + // }, + // ], + // layout: { + // newLine: true, + // }, + // }, ], }, { @@ -673,7 +700,7 @@ const sections: ISections[] = [ Component: Label, props: { name: 'labelLeaseObjectRisk', - computedValue: 'leaseObjectRiskName', + computedValueName: 'leaseObjectRiskName', }, }, @@ -1339,7 +1366,7 @@ const sections: ISections[] = [ Component: InputNumber, props: { name: 'tbxInsKaskoPriceLeasePeriod', - computedValue: 'insKaskoPriceLeasePeriod', + computedValueName: 'insKaskoPriceLeasePeriod', }, }, ], @@ -1351,9 +1378,6 @@ const sections: ISections[] = [ Component: Table, props: { name: 'tableInsurance', - features: { - // canDeleteRow: true, - }, columns: [ { name: 'policyType', diff --git a/src/client/Containers/Calculation/index.jsx b/src/client/Containers/Calculation/index.jsx index 3039813..710e962 100644 --- a/src/client/Containers/Calculation/index.jsx +++ b/src/client/Containers/Calculation/index.jsx @@ -48,16 +48,9 @@ const Calculation = () => { calculationStore.setStaticData(staticEntities); calculationStore.applyOptions({ selectLead: leadOptions }); calculationStore.applyOptions({ selectOpportunity: opportunities }); - calculationStore.setTableColumn( - { - tableName: 'tableInsurance', - }, - { - options: { - insuranceCompany: insuranceCompanies, - }, - }, - ); + calculationStore.setTableColumns('tableInsurance')({ + options: { insuranceCompany: insuranceCompanies }, + }); setReady(true); }, ) diff --git a/src/client/Elements/Table.jsx b/src/client/Elements/Table.jsx index cc67863..93387d2 100644 --- a/src/client/Elements/Table.jsx +++ b/src/client/Elements/Table.jsx @@ -53,42 +53,44 @@ const TableWrapper = styled(Box)` } `; -const DeleteRowButton = ({ onClick }) => ( - - - Удалить - - -); +// const DeleteRowButton = ({ onClick }) => ( +// +// +// Удалить +// +// +// ); -const Table = ({ name: tableName, columns, values, features, actions }) => { - const { canDeleteRow } = features; - if (!values) { - values = []; - } +const Table = ({ name: tableName, columns, rows, features, actions }) => { return ( - +
- {columns.map(({ name, title }, ci) => { + {features && features.numerize && ( + + )} + {columns.map(({ title }, ci) => { return ; })} - {canDeleteRow && - {values.map((row, ri) => { - const keys = Object.keys(row); + {rows.map((row, ri) => { + const rowProps = Object.keys(row); return ( - {keys.map((key, ki) => { - const columnIndex = columns.findIndex(c => c.name === key); - const Component = columns[columnIndex].Component; + {features && features.numerize && } + {rowProps.map((rowPropName, ki) => { + const columnIndex = columns.findIndex( + c => c.name === rowPropName, + ); + const { Component } = columns[columnIndex]; const Element = withTableValue(Component)({ tableName, rowIndex: ri, - propName: key, + propName: rowPropName, ...columns[columnIndex].props, }); return ( @@ -97,7 +99,7 @@ const Table = ({ name: tableName, columns, values, features, actions }) => { ); })} - {canDeleteRow && ( + {/* {features && features.canDeleteRow && ( - )} + )} */} ); })} diff --git a/src/client/hocs/withStore.js b/src/client/hocs/withStore.js index 32631d6..cad96aa 100644 --- a/src/client/hocs/withStore.js +++ b/src/client/hocs/withStore.js @@ -1,28 +1,33 @@ -import { useOptions } from 'client/hooks/useOptions'; -import { useStatus, useTableStatus } from 'client/hooks/useStatus'; -import { useStoreValue, useTableValue } from 'client/hooks/useValue'; -import { useValidation } from 'client/hooks/useValidation'; -import { observer, useObserver } from 'mobx-react-lite'; -import React from 'react'; +import { useAction } from 'client/hooks/Calculation/useAction'; +import { useModal } from 'client/hooks/Calculation/useModal'; +import { + useOptions, + useTableOptions, +} from 'client/hooks/Calculation/useOptions'; +import { useStatus, useTableStatus } from 'client/hooks/Calculation/useStatus'; +import { useValidation } from 'client/hooks/Calculation/useValidation'; +import { + useStoreValue, + useTableValue, +} from 'client/hooks/Calculation/useValue'; import { useStores } from 'client/hooks/useStores'; -import { useTableOptions } from 'client/hooks/useOptions'; -import { useModal } from 'client/hooks/useModal'; -import { useAction } from 'client/hooks/useAction'; +import { observer } from 'mobx-react-lite'; +import React from 'react'; export const withStoreValue = Component => ({ name, valueName, - computedValue, + computedValueName, validation, ...params -}) => { - const ComponentWithStore = () => { +}) => + observer(() => { const { value, setCurrentValue, debouncedValue } = useStoreValue({ - computedValue, + computedValueName, valueName, }); const { status } = useStatus(name); - const { isValid, validateStatus, message } = useValidation({ + const { validateStatus, message } = useValidation({ elementName: name, value: debouncedValue, validation, @@ -40,38 +45,24 @@ export const withStoreValue = Component => ({ {...params} /> ); - }; - return observer(ComponentWithStore); -}; + }); export const withTableData = Table => props => { const { name: tableName } = props; const ObservedTable = observer(Table); - const TableWithStore = useObserver(() => { - const { calculationStore } = useStores(); - const tableData = calculationStore.tables[tableName]; - return ( - { - calculationStore.deleteTableRow(tableName, rowIndex); - }, - }} - /> - ); - }); - return () => TableWithStore; + const { calculationStore } = useStores(); + const tableData = calculationStore.tables[tableName]; + return () => ; }; export const withTableValue = Component => ({ tableName, rowIndex, propName, + validation, ...params -}) => { - const ComponentWithStore = () => { +}) => + observer(() => { const { value, setCurrentValue } = useTableValue({ tableName, rowIndex, @@ -94,12 +85,10 @@ export const withTableValue = Component => ({ filter={filter} /> ); - }; - return observer(ComponentWithStore); -}; + }); -export const withStoreModal = Modal => { - const ModalWithStore = () => { +export const withStoreModal = Modal => + observer(() => { const { isModalVisible, modalText, closeModal } = useModal(); return ( { closeModal={closeModal} /> ); - }; - return observer(ModalWithStore); -}; + }); -export const withStoreButton = Button => ({ name, actionName, ...params }) => { - const ButtonWithStore = () => { +export const withStoreButton = Button => ({ name, actionName, ...params }) => + observer(() => { const { status } = useStatus(name); const { action } = useAction({ actionName }); return
{features.numerize.columnTitle || '#'}{title}} + {/* {features && features.canDeleteRow && } */}
{ri + 1} { @@ -105,7 +107,7 @@ const Table = ({ name: tableName, columns, values, features, actions }) => { }} />