diff --git a/src/leases/components/leaseSections/rent/OldDwellingsInHousingCompaniesPriceIndexEdit.tsx b/src/leases/components/leaseSections/rent/OldDwellingsInHousingCompaniesPriceIndexEdit.tsx index dd88a847..2b7e6c78 100644 --- a/src/leases/components/leaseSections/rent/OldDwellingsInHousingCompaniesPriceIndexEdit.tsx +++ b/src/leases/components/leaseSections/rent/OldDwellingsInHousingCompaniesPriceIndexEdit.tsx @@ -18,22 +18,27 @@ import { LeaseFieldTitles, LeaseRentOldDwellingsInHousingCompaniesPriceIndexFieldPaths, LeaseRentOldDwellingsInHousingCompaniesPriceIndexFieldTitles, + LeaseRentsFieldPaths, } from "@/leases/enums"; import { getUiDataLeaseKey } from "@/uiData/helpers"; -import { formatDate } from "@/util/helpers"; +import { formatDate, getFieldAttributes } from "@/util/helpers"; +import FormField from "@/components/form/FormField"; +import { Attributes } from "@/types"; type Props = { oldDwellingsInHousingCompaniesPriceIndex: OldDwellingsInHousingCompaniesPriceIndexProps; + leaseAttributes: Attributes; leaseStartDate: string; + isSaveClicked: boolean; }; const getLastYearsIndexPointNumber = ( - pointFigures: IndexPointFigureYearlyProps[] + pointFigures: IndexPointFigureYearlyProps[], ): string => { const lastYear = new Date().getFullYear() - 1; const lastYearIndex = pointFigures?.find( - (x: IndexPointFigureYearlyProps) => x.year == lastYear + (x: IndexPointFigureYearlyProps) => x.year == lastYear, ) || null; return lastYearIndex ? `${lastYearIndex.year} * ${lastYearIndex.value}` @@ -41,49 +46,55 @@ const getLastYearsIndexPointNumber = ( }; const getReviewDaysSorted = ( - pointFigures: IndexPointFigureYearlyProps[] + pointFigures: IndexPointFigureYearlyProps[], ): IndexPointFigureYearlyProps[] => { // deep copy const sortedNumbers = JSON.parse(JSON.stringify(pointFigures)); sortedNumbers.sort( (a: IndexPointFigureYearlyProps, b: IndexPointFigureYearlyProps) => - a.year - b.year + a.year - b.year, ); return sortedNumbers; }; class OldDwellingsInHousingCompaniesPriceIndexViewEdit extends PureComponent { render() { - const { oldDwellingsInHousingCompaniesPriceIndex, leaseStartDate } = - this.props; - - console.log("oldDwellingsInHousingCompaniesPriceIndex", oldDwellingsInHousingCompaniesPriceIndex); + const { + oldDwellingsInHousingCompaniesPriceIndex, + leaseAttributes, + leaseStartDate, + isSaveClicked, + } = this.props; if (!oldDwellingsInHousingCompaniesPriceIndex) { - return

Lisää tasotarkistus

; + return

Lisää tasotarkistus

; } const { - name, point_figures: pointFigures, source_table_label: sourceTableLabel, } = oldDwellingsInHousingCompaniesPriceIndex || {}; + console.log("leaseAttributes", leaseAttributes); return ( - - { - LeaseRentOldDwellingsInHousingCompaniesPriceIndexFieldTitles.NAME - } - - {name} + name="old_dwellings_in_housing_companies_price_index_type" + overrideValues={{ + label: LeaseRentOldDwellingsInHousingCompaniesPriceIndexFieldTitles.TYPE, + type: "choice", + }} + // enableUiDataEdit + // uiDataKey={getUiDataLeaseKey(LeaseRentOldDwellingsInHousingCompaniesPriceIndexFieldPaths.OLD_DWELLINGS_IN_HOUSING_COMPANIES_PRICE_INDEX_TYPE)} + /> {LeaseFieldTitles.START_DATE} @@ -92,7 +103,7 @@ class OldDwellingsInHousingCompaniesPriceIndexViewEdit extends PureComponent { @@ -105,7 +116,7 @@ class OldDwellingsInHousingCompaniesPriceIndexViewEdit extends PureComponent { @@ -126,7 +137,7 @@ class OldDwellingsInHousingCompaniesPriceIndexViewEdit extends PureComponent ); - } + }, ) : ""} @@ -145,5 +156,5 @@ export default flowRight( leaseAttributes: getLeaseAttributes(state), leaseStartDate: getCurrentLeaseStartDate(state), }; - }) + }), )(OldDwellingsInHousingCompaniesPriceIndexViewEdit); diff --git a/src/leases/enums.ts b/src/leases/enums.ts index d5efd753..c3b90634 100644 --- a/src/leases/enums.ts +++ b/src/leases/enums.ts @@ -869,6 +869,7 @@ export const LeaseRentsFieldPaths = { Y_VALUE_START: 'rents.child.children.y_value_start', OVERRIDE_RECEIVABLE_TYPE: 'rents.child.children.override_receivable_type', OLD_DWELLINGS_IN_HOUSING_COMPANIES_PRICE_INDEX: 'rents.child.children.old_dwellings_in_housing_companies_price_index', + OLD_DWELLINGS_IN_HOUSING_COMPANIES_PRICE_INDEX_TYPE: 'rents.child.children.old_dwellings_in_housing_companies_price_index_type', }; /** @@ -931,6 +932,7 @@ export const LeaseRentDueDatesFieldTitles = { */ export const LeaseRentOldDwellingsInHousingCompaniesPriceIndexFieldPaths = { OLD_DWELLINGS_IN_HOUSING_COMPANIES_PRICE_INDEX: 'rents.child.children.old_dwellings_in_housing_companies_price_index', + OLD_DWELLINGS_IN_HOUSING_COMPANIES_PRICE_INDEX_TYPE: 'rents.child.children.old_dwellings_in_housing_companies_price_index_type', NAME: 'rents.child.children.old_dwellings_in_housing_companies_price_index.name', NUMBERS: 'rents.child.children.old_dwellings_in_housing_companies_price_index.numbers', }; @@ -942,7 +944,7 @@ export const LeaseRentOldDwellingsInHousingCompaniesPriceIndexFieldPaths = { */ export const LeaseRentOldDwellingsInHousingCompaniesPriceIndexFieldTitles = { OLD_DWELLINGS_IN_HOUSING_COMPANIES_PRICE_INDEX: 'Tasotarkistus', - NAME: 'Tyyppi', + TYPE: 'Tyyppi', NUMBERS: 'Indeksipisteluku', REVIEW_DAYS: 'Tarkistuspäivät', };