From 994d17a62220906c6206977ec43bd6f11d3408a0 Mon Sep 17 00:00:00 2001 From: Jukka Ahonen Date: Fri, 13 Dec 2024 17:24:09 +0200 Subject: [PATCH] get tasotarkistus from the api through a reducer --- src/leases/components/LeaseListPage.tsx | 19 ++++ ...dDwellingsInHousingCompaniesPriceIndex.tsx | 6 +- ...llingsInHousingCompaniesPriceIndexEdit.tsx | 6 +- .../leaseSections/rent/RentItemEdit.tsx | 62 +++---------- src/leases/types.ts | 17 +--- .../actions.ts | 19 ++++ .../constants.ts | 6 ++ ...llingsInHousingCompaniesPriceIndex.spec.ts | 87 +++++++++++++++++++ .../reducer.ts | 36 ++++++++ .../requests.ts | 10 +++ .../saga.ts | 36 ++++++++ .../selectors.ts | 12 +++ .../types.ts | 29 +++++++ src/root/createRootReducer.ts | 2 + 14 files changed, 278 insertions(+), 69 deletions(-) create mode 100644 src/oldDwellingsInHousingCompaniesPriceIndex/actions.ts create mode 100644 src/oldDwellingsInHousingCompaniesPriceIndex/constants.ts create mode 100644 src/oldDwellingsInHousingCompaniesPriceIndex/oldDwellingsInHousingCompaniesPriceIndex.spec.ts create mode 100644 src/oldDwellingsInHousingCompaniesPriceIndex/reducer.ts create mode 100644 src/oldDwellingsInHousingCompaniesPriceIndex/requests.ts create mode 100644 src/oldDwellingsInHousingCompaniesPriceIndex/saga.ts create mode 100644 src/oldDwellingsInHousingCompaniesPriceIndex/selectors.ts create mode 100644 src/oldDwellingsInHousingCompaniesPriceIndex/types.ts diff --git a/src/leases/components/LeaseListPage.tsx b/src/leases/components/LeaseListPage.tsx index 8da0c0179..baa4e0a9f 100644 --- a/src/leases/components/LeaseListPage.tsx +++ b/src/leases/components/LeaseListPage.tsx @@ -55,6 +55,13 @@ import type { LeaseList } from "@/leases/types"; import type { LessorList } from "@/lessor/types"; import type { ServiceUnits } from "@/serviceUnits/types"; import type { UsersPermissions as UsersPermissionsType, UserServiceUnit } from "@/usersPermissions/types"; +import { + getOldDwellingsInHousingCompaniesPriceIndex, + getIsFetching as getIsFetchingOldDwellingsInHousingCompaniesPriceIndex +} from "@/oldDwellingsInHousingCompaniesPriceIndex/selectors"; +import { OldDwellingsInHousingCompaniesPriceIndex } from "@/oldDwellingsInHousingCompaniesPriceIndex/types"; +import { fetchOldDwellingsInHousingCompaniesPriceIndex } from "@/oldDwellingsInHousingCompaniesPriceIndex/actions"; + const VisualizationTypes = { MAP: 'map', TABLE: 'table' @@ -76,6 +83,7 @@ type Props = { fetchLeasesByBBox: (...args: Array) => any; fetchLessors: (...args: Array) => any; fetchServiceUnits: (...args: Array) => any; + fetchOldDwellingsInHousingCompaniesPriceIndex: (...args: Array) => any; history: Record; initialize: (...args: Array) => any; isFetching: boolean; @@ -87,6 +95,7 @@ type Props = { leases: LeaseList; lessors: LessorList; location: Record; + oldDwellingsInHousingCompaniesPriceIndex: OldDwellingsInHousingCompaniesPriceIndex | null; receiveTopNavigationSettings: (...args: Array) => any; serviceUnits: ServiceUnits; userActiveServiceUnit: UserServiceUnit; @@ -130,8 +139,11 @@ class LeaseListPage extends PureComponent { fetchAreaNoteList, fetchLessors, fetchServiceUnits, + fetchOldDwellingsInHousingCompaniesPriceIndex, isFetchingServiceUnits, + isFetchingOldDwellingsInHousingCompaniesPriceIndex, lessors, + oldDwellingsInHousingCompaniesPriceIndex, receiveTopNavigationSettings, serviceUnits, leaseAttributes @@ -157,6 +169,10 @@ class LeaseListPage extends PureComponent { }); } + if (!isFetchingOldDwellingsInHousingCompaniesPriceIndex && !oldDwellingsInHousingCompaniesPriceIndex) { + fetchOldDwellingsInHousingCompaniesPriceIndex(); + } + window.addEventListener('popstate', this.handlePopState); this._isMounted = true; this.setState({ @@ -723,10 +739,12 @@ export default flowRight(withLeaseAttributes, withUiDataList, connect(state => { isFetching: getIsFetching(state), isFetchingByBBox: getIsFetchingByBBox(state), isFetchingServiceUnits: getIsFetchingServiceUnits(state), + isFetchingOldDwellingsInHousingCompaniesPriceIndex: getIsFetchingOldDwellingsInHousingCompaniesPriceIndex(state), leases: getLeasesList(state), lessors: getLessorList(state), serviceUnits: getServiceUnits(state), userActiveServiceUnit: getUserActiveServiceUnit(state), + oldDwellingsInHousingCompaniesPriceIndex: getOldDwellingsInHousingCompaniesPriceIndex(state), usersPermissions: getUsersPermissions(state) }; }, { @@ -736,6 +754,7 @@ export default flowRight(withLeaseAttributes, withUiDataList, connect(state => { fetchLeasesByBBox, fetchLessors, fetchServiceUnits, + fetchOldDwellingsInHousingCompaniesPriceIndex, initialize, receiveTopNavigationSettings }))(LeaseListPage); \ No newline at end of file diff --git a/src/leases/components/leaseSections/rent/OldDwellingsInHousingCompaniesPriceIndex.tsx b/src/leases/components/leaseSections/rent/OldDwellingsInHousingCompaniesPriceIndex.tsx index 94979747f..b7a208f85 100644 --- a/src/leases/components/leaseSections/rent/OldDwellingsInHousingCompaniesPriceIndex.tsx +++ b/src/leases/components/leaseSections/rent/OldDwellingsInHousingCompaniesPriceIndex.tsx @@ -4,10 +4,12 @@ import { getCurrentLeaseStartDate, getAttributes as getLeaseAttributes } from '@ import { flowRight } from 'lodash'; import { connect } from 'react-redux'; import type { - OldDwellingsInHousingCompaniesPriceIndex as OldDwellingsInHousingCompaniesPriceIndexProps, - IndexPointFigureYearly as IndexPointFigureYearlyProps, OldDwellingsInHousingCompaniesPriceIndexType, } from '@/leases/types'; +import type { + OldDwellingsInHousingCompaniesPriceIndex as OldDwellingsInHousingCompaniesPriceIndexProps, + IndexPointFigureYearly as IndexPointFigureYearlyProps, +} from '@/oldDwellingsInHousingCompaniesPriceIndex/types'; import BoxItemContainer from '@/components/content/BoxItemContainer'; import { withWindowResize } from '@/components/resize/WindowResizeHandler'; import FormText from "@/components/form/FormText"; diff --git a/src/leases/components/leaseSections/rent/OldDwellingsInHousingCompaniesPriceIndexEdit.tsx b/src/leases/components/leaseSections/rent/OldDwellingsInHousingCompaniesPriceIndexEdit.tsx index 8feb634b1..dc041f482 100644 --- a/src/leases/components/leaseSections/rent/OldDwellingsInHousingCompaniesPriceIndexEdit.tsx +++ b/src/leases/components/leaseSections/rent/OldDwellingsInHousingCompaniesPriceIndexEdit.tsx @@ -7,10 +7,12 @@ import { import { flowRight } from "lodash"; import { connect } from "react-redux"; import type { - OldDwellingsInHousingCompaniesPriceIndex as OldDwellingsInHousingCompaniesPriceIndexProps, - IndexPointFigureYearly as IndexPointFigureYearlyProps, OldDwellingsInHousingCompaniesPriceIndexType, } from "@/leases/types"; +import type { + OldDwellingsInHousingCompaniesPriceIndex as OldDwellingsInHousingCompaniesPriceIndexProps, + IndexPointFigureYearly as IndexPointFigureYearlyProps, +} from "@/oldDwellingsInHousingCompaniesPriceIndex/types"; import BoxItemContainer from "@/components/content/BoxItemContainer"; import { withWindowResize } from "@/components/resize/WindowResizeHandler"; import FormText from "@/components/form/FormText"; diff --git a/src/leases/components/leaseSections/rent/RentItemEdit.tsx b/src/leases/components/leaseSections/rent/RentItemEdit.tsx index c95cf35fe..35fd97053 100644 --- a/src/leases/components/leaseSections/rent/RentItemEdit.tsx +++ b/src/leases/components/leaseSections/rent/RentItemEdit.tsx @@ -26,7 +26,9 @@ import { getUsersPermissions } from "@/usersPermissions/selectors"; import type { Attributes } from "types"; import type { UsersPermissions as UsersPermissionsType } from "@/usersPermissions/types"; import OldDwellingsInHousingCompaniesPriceIndexEdit from "./OldDwellingsInHousingCompaniesPriceIndexEdit"; -import { OldDwellingsInHousingCompaniesPriceIndex as OldDwellingsInHousingCompaniesPriceIndexProps } from "@/leases/types"; +import { OldDwellingsInHousingCompaniesPriceIndex as OldDwellingsInHousingCompaniesPriceIndexProps } from "@/oldDwellingsInHousingCompaniesPriceIndex/types"; +import { getOldDwellingsInHousingCompaniesPriceIndex } from "@/oldDwellingsInHousingCompaniesPriceIndex/selectors"; + type Props = { change: (...args: Array) => any; contractRentsCollapseState: boolean; @@ -36,7 +38,8 @@ type Props = { equalizedRentsCollapseState: boolean; errors: Record | null | undefined; field: string; - oldDwellingsInHousingCompaniesPriceIndex: OldDwellingsInHousingCompaniesPriceIndexProps; + oldDwellingsInHousingCompaniesPriceIndex: OldDwellingsInHousingCompaniesPriceIndexProps | null; + rentOldDwellingsInHousingCompaniesPriceIndex: OldDwellingsInHousingCompaniesPriceIndexProps | null | undefined; oldDwellingsInHousingCompaniesPriceIndexCollapseState: boolean; fixedInitialYearRents: Array>; fixedInitialYearRentsCollapseState: boolean; @@ -182,55 +185,15 @@ class RentItemEdit extends PureComponent { addOldDwellingsInHousingCompaniesPriceIndex = () => { const { change, - field + field, + oldDwellingsInHousingCompaniesPriceIndex, } = this.props; change( formName, `${field}.old_dwellings_in_housing_companies_price_index`, - { - id: 1, - point_figures: [ - { - id: 4, - value: "97.4", - year: 2023, - region: "pks", - comment: "" - }, - { - id: 3, - value: "105.7", - year: 2022, - region: "pks", - comment: "" - }, - { - id: 2, - value: "105.6", - year: 2021, - region: "pks", - comment: "" - }, - { - id: 1, - value: "100.0", - year: 2020, - region: "pks", - comment: "" - } - ], - created_at: "2024-11-14T15:12:50.310543+02:00", - modified_at: "2024-12-08T18:05:37.983780+02:00", - code: "ketj_P_QA_T", - name: "Indeksi (2020=100)", - comment: "Indeksi on suhdeluku, joka kuvaa jonkin muuttujan (esimerkiksi hinnan, määrän tai arvon) suhteellista muutosta perusjakson (esimerkiksi vuoden) suhteen. Kunkin ajankohdan indeksipisteluku ilmoittaa, kuinka monta prosenttia kyseisen ajankohdan tarkasteltava muuttuja on perusjakson arvosta tai määrästä. Perusjakson indeksipistelukujen keskiarvo on 100. Tilastossa julkaistavat hintaindeksit ovat laatuvakioituja ja niiden kehitys voi poiketa neliöhintojen kehityksestä.\r\n", - source: "Tilastokeskus, osakeasuntojen hinnat", - source_table_updated: "2024-05-03T08:00:00+03:00", - source_table_label: "Vanhojen osakeasuntojen hintaindeksi (2020=100) ja kauppojen lukumäärät, vuositasolla muuttujina Vuosi, Alue ja Tiedot", - url: "https://pxdata.stat.fi:443/PxWeb/api/v1/fi/StatFin/ashi/statfin_ashi_pxt_13mq.px" - }, -); + oldDwellingsInHousingCompaniesPriceIndex + ); } handleCollapseToggle = (key: string, val: boolean) => { const { @@ -287,7 +250,7 @@ class RentItemEdit extends PureComponent { equalizedRentsCollapseState, field, fixedInitialYearRents, - oldDwellingsInHousingCompaniesPriceIndex, + rentOldDwellingsInHousingCompaniesPriceIndex, oldDwellingsInHousingCompaniesPriceIndexCollapseState, fixedInitialYearRentsCollapseState, indexAdjustedRentsCollapseState, @@ -335,7 +298,7 @@ class RentItemEdit extends PureComponent { { fixedInitialYearRents: selector(state, `${props.field}.fixed_initial_year_rents`), isSaveClicked: getIsSaveClicked(state), leaseAttributes: getLeaseAttributes(state), - oldDwellingsInHousingCompaniesPriceIndex: selector(state, `${props.field}.old_dwellings_in_housing_companies_price_index`), + oldDwellingsInHousingCompaniesPriceIndex: getOldDwellingsInHousingCompaniesPriceIndex(state), + rentOldDwellingsInHousingCompaniesPriceIndex: selector(state, `${props.field}.old_dwellings_in_housing_companies_price_index`), rentAdjustments: selector(state, `${props.field}.rent_adjustments`), rentId: id, rentType: selector(state, `${props.field}.type`), diff --git a/src/leases/types.ts b/src/leases/types.ts index 52c5be76d..6e07af6e3 100644 --- a/src/leases/types.ts +++ b/src/leases/types.ts @@ -50,22 +50,7 @@ export type IntendedUse = { name: string; service_unit: ServiceUnit["id"]; }; -export type IndexPointFigureYearly = { - value: number; - year: number; - region: string; - comment: string; -} -export type OldDwellingsInHousingCompaniesPriceIndex = { - code: string; - name: string; - comment: string; - source: string; - source_table_updated?: string; - source_table_label: string; - url: string; - point_figures: IndexPointFigureYearly[]; -} + export type OldDwellingsInHousingCompaniesPriceIndexType = "TASOTARKISTUS_20_20" | "TASOTARKISTUS_20_10"; export type FetchAttributesAction = Action; diff --git a/src/oldDwellingsInHousingCompaniesPriceIndex/actions.ts b/src/oldDwellingsInHousingCompaniesPriceIndex/actions.ts new file mode 100644 index 000000000..3e4951a33 --- /dev/null +++ b/src/oldDwellingsInHousingCompaniesPriceIndex/actions.ts @@ -0,0 +1,19 @@ +import { createAction } from "redux-actions"; +import { FETCH_ACTION_STRING, NOT_FOUND_ACTION_STRING, RECEIVE_ACTION_STRING } from "./constants"; +import { + FetchOldDwellingsInHousingCompaniesPriceIndexAction, + OldDwellingsInHousingCompaniesPriceIndex, + OldDwellingsInHousingCompaniesPriceIndexNotFoundAction, + ReceiveOldDwellingsInHousingCompaniesPriceIndexAction, +} from "./types"; + +export const fetchOldDwellingsInHousingCompaniesPriceIndex = + (): FetchOldDwellingsInHousingCompaniesPriceIndexAction => createAction(FETCH_ACTION_STRING)(); + +export const receiveOldDwellingsInHousingCompaniesPriceIndex = ( + payload: OldDwellingsInHousingCompaniesPriceIndex, +): ReceiveOldDwellingsInHousingCompaniesPriceIndexAction => + createAction(RECEIVE_ACTION_STRING)(payload); + +export const notFound = (): OldDwellingsInHousingCompaniesPriceIndexNotFoundAction => + createAction(NOT_FOUND_ACTION_STRING)(); diff --git a/src/oldDwellingsInHousingCompaniesPriceIndex/constants.ts b/src/oldDwellingsInHousingCompaniesPriceIndex/constants.ts new file mode 100644 index 000000000..ccf3bfc7d --- /dev/null +++ b/src/oldDwellingsInHousingCompaniesPriceIndex/constants.ts @@ -0,0 +1,6 @@ +export const DEFAULT_OLD_DWELLINGS_IN_HOUSING_COMPANIES_PRICE_INDEX_ID = 1; + +// Action type strings +export const FETCH_ACTION_STRING = "mvj/oldDwellingsInHousingCompaniesPriceIndex/FETCH"; +export const RECEIVE_ACTION_STRING = "mvj/oldDwellingsInHousingCompaniesPriceIndex/RECEIVE"; +export const NOT_FOUND_ACTION_STRING = "mvj/oldDwellingsInHousingCompaniesPriceIndex/NOT_FOUND"; diff --git a/src/oldDwellingsInHousingCompaniesPriceIndex/oldDwellingsInHousingCompaniesPriceIndex.spec.ts b/src/oldDwellingsInHousingCompaniesPriceIndex/oldDwellingsInHousingCompaniesPriceIndex.spec.ts new file mode 100644 index 000000000..86081a6b3 --- /dev/null +++ b/src/oldDwellingsInHousingCompaniesPriceIndex/oldDwellingsInHousingCompaniesPriceIndex.spec.ts @@ -0,0 +1,87 @@ +import { describe, expect, it } from "vitest"; +import { + receiveOldDwellingsInHousingCompaniesPriceIndex, + fetchOldDwellingsInHousingCompaniesPriceIndex, + notFound, +} from "./actions"; +import oldDwellingsInHousingCompaniesPriceIndexReducer from "./reducer"; +import type { + OldDwellingsInHousingCompaniesPriceIndex, + OldDwellingsInHousingCompaniesPriceIndexState, +} from "./types"; +const defaultState: OldDwellingsInHousingCompaniesPriceIndexState = { + isFetching: false, + latest: null, +}; + +describe("oldDwellingsInHousingCompaniesPriceIndex", () => { + describe("Reducer", () => { + describe("oldDwellingsInHousingCompaniesPriceIndexReducer", () => { + it("should update oldDwellingsInHousingCompaniesPriceIndex", () => { + const dummy: OldDwellingsInHousingCompaniesPriceIndex = { + point_figures: [ + { + value: 97.4, + year: 2023, + region: "pks", + comment: "", + }, + { + value: 105.7, + year: 2022, + region: "pks", + comment: "", + }, + { + value: 105.6, + year: 2021, + region: "pks", + comment: "", + }, + { + value: 100.0, + year: 2020, + region: "pks", + comment: "", + }, + ], + created_at: "2024-11-14T15:12:50.310543+02:00", + modified_at: "2024-12-08T18:05:37.983780+02:00", + code: "ketj_P_QA_T", + name: "Indeksi (2020=100)", + comment: + "Indeksi on suhdeluku, joka kuvaa jonkin muuttujan (esimerkiksi hinnan, määrän tai arvon) suhteellista muutosta perusjakson (esimerkiksi vuoden) suhteen. Kunkin ajankohdan indeksipisteluku ilmoittaa, kuinka monta prosenttia kyseisen ajankohdan tarkasteltava muuttuja on perusjakson arvosta tai määrästä. Perusjakson indeksipistelukujen keskiarvo on 100. Tilastossa julkaistavat hintaindeksit ovat laatuvakioituja ja niiden kehitys voi poiketa neliöhintojen kehityksestä.\r\n", + source: "Tilastokeskus, osakeasuntojen hinnat", + source_table_updated: "2024-05-03T08:00:00+03:00", + source_table_label: + "Vanhojen osakeasuntojen hintaindeksi (2020=100) ja kauppojen lukumäärät, vuositasolla muuttujina Vuosi, Alue ja Tiedot", + url: "https://pxdata.stat.fi:443/PxWeb/api/v1/fi/StatFin/ashi/statfin_ashi_pxt_13mq.px", + }; + + const newState = { ...defaultState, latest: dummy }; + const state = oldDwellingsInHousingCompaniesPriceIndexReducer( + {}, + receiveOldDwellingsInHousingCompaniesPriceIndex(dummy), + ); + expect(state).to.deep.equal(newState); + }); + it("should update isFetching flag to true when fetching vats", () => { + const newState = { ...defaultState, isFetching: true }; + const state = oldDwellingsInHousingCompaniesPriceIndexReducer( + {}, + fetchOldDwellingsInHousingCompaniesPriceIndex(), + ); + expect(state).to.deep.equal(newState); + }); + it("should update isFetching flag to false by notFound", () => { + const newState = { ...defaultState }; + let state = oldDwellingsInHousingCompaniesPriceIndexReducer( + {}, + fetchOldDwellingsInHousingCompaniesPriceIndex(), + ); + state = oldDwellingsInHousingCompaniesPriceIndexReducer(state, notFound()); + expect(state).to.deep.equal(newState); + }); + }); + }); +}); diff --git a/src/oldDwellingsInHousingCompaniesPriceIndex/reducer.ts b/src/oldDwellingsInHousingCompaniesPriceIndex/reducer.ts new file mode 100644 index 000000000..00a3484f4 --- /dev/null +++ b/src/oldDwellingsInHousingCompaniesPriceIndex/reducer.ts @@ -0,0 +1,36 @@ +import { combineReducers } from "redux"; +import { handleActions } from "redux-actions"; +import type { Reducer } from "@/types"; +import { + FETCH_ACTION_STRING, + NOT_FOUND_ACTION_STRING, + RECEIVE_ACTION_STRING, +} from "./constants"; +import { + OldDwellingsInHousingCompaniesPriceIndex, + ReceiveOldDwellingsInHousingCompaniesPriceIndexAction, +} from "./types"; + +const isFetchingReducer: Reducer = handleActions( + { + [FETCH_ACTION_STRING]: () => true, + [NOT_FOUND_ACTION_STRING]: () => false, + [RECEIVE_ACTION_STRING]: () => false, + }, + false, +); +const latestReducer: Reducer = handleActions( + { + [RECEIVE_ACTION_STRING]: ( + state: OldDwellingsInHousingCompaniesPriceIndex, + { payload }: ReceiveOldDwellingsInHousingCompaniesPriceIndexAction, + ) => { + return payload; + }, + }, + null, +); +export default combineReducers, any>({ + isFetching: isFetchingReducer, + latest: latestReducer, +}); diff --git a/src/oldDwellingsInHousingCompaniesPriceIndex/requests.ts b/src/oldDwellingsInHousingCompaniesPriceIndex/requests.ts new file mode 100644 index 000000000..63e29dcbb --- /dev/null +++ b/src/oldDwellingsInHousingCompaniesPriceIndex/requests.ts @@ -0,0 +1,10 @@ +import callApi from "@/api/callApi"; +import createUrl from "@/api/createUrl"; +import { DEFAULT_OLD_DWELLINGS_IN_HOUSING_COMPANIES_PRICE_INDEX_ID } from "./constants"; + +export const fetchOldDwellingsInHousingCompaniesPriceIndex = (): Generator => { + // As of the beginning of 2025, there is only one index. + const id = DEFAULT_OLD_DWELLINGS_IN_HOUSING_COMPANIES_PRICE_INDEX_ID; + + return callApi(new Request(createUrl(`old_dwellings_in_housing_companies_price_index/${id}`))); +}; diff --git a/src/oldDwellingsInHousingCompaniesPriceIndex/saga.ts b/src/oldDwellingsInHousingCompaniesPriceIndex/saga.ts new file mode 100644 index 000000000..161b53f32 --- /dev/null +++ b/src/oldDwellingsInHousingCompaniesPriceIndex/saga.ts @@ -0,0 +1,36 @@ +import { all, call, fork, put, takeLatest } from "redux-saga/effects"; +import { notFound, receiveOldDwellingsInHousingCompaniesPriceIndex } from "./actions"; +import { fetchOldDwellingsInHousingCompaniesPriceIndex } from "./requests"; +import { receiveError } from "@/api/actions"; +import { FETCH_ACTION_STRING } from "./constants"; + +function* fetchOldDwellingsInHousingCompaniesPriceIndexSaga(): Generator { + try { + const { + response: { + status: statusCode + }, + bodyAsJson + } = yield call(fetchOldDwellingsInHousingCompaniesPriceIndex); + + switch (statusCode) { + case 200: + yield put(receiveOldDwellingsInHousingCompaniesPriceIndex(bodyAsJson.results)); + break; + + default: + yield put(notFound()); + break; + } + } catch (error) { + console.error('Failed to fetch fetch old dwellings in housing companies price index with error "%s"', error); + yield put(notFound()); + yield put(receiveError(error)); + } +} + +export default function* (): Generator { + yield all([fork(function* (): Generator { + yield takeLatest(FETCH_ACTION_STRING, fetchOldDwellingsInHousingCompaniesPriceIndexSaga); + })]); +} \ No newline at end of file diff --git a/src/oldDwellingsInHousingCompaniesPriceIndex/selectors.ts b/src/oldDwellingsInHousingCompaniesPriceIndex/selectors.ts new file mode 100644 index 000000000..01ea2c014 --- /dev/null +++ b/src/oldDwellingsInHousingCompaniesPriceIndex/selectors.ts @@ -0,0 +1,12 @@ +import type { Selector } from "@/types"; +import type { RootState } from "@/root/types"; +import type { OldDwellingsInHousingCompaniesPriceIndex } from "./types"; + +export const getIsFetching: Selector = (state: RootState): boolean => + state.oldDwellingsInHousingCompaniesPriceIndex.isFetching; +export const getOldDwellingsInHousingCompaniesPriceIndex: Selector< + OldDwellingsInHousingCompaniesPriceIndex, + void +> = (state: RootState): OldDwellingsInHousingCompaniesPriceIndex => { + return state.oldDwellingsInHousingCompaniesPriceIndex.latest; +}; diff --git a/src/oldDwellingsInHousingCompaniesPriceIndex/types.ts b/src/oldDwellingsInHousingCompaniesPriceIndex/types.ts new file mode 100644 index 000000000..02614d949 --- /dev/null +++ b/src/oldDwellingsInHousingCompaniesPriceIndex/types.ts @@ -0,0 +1,29 @@ +import type { Action } from "@/types"; + +export type IndexPointFigureYearly = { + value: number; + year: number; + region: string; + comment: string; +} + +export type OldDwellingsInHousingCompaniesPriceIndex = { + code: string; + name: string; + comment: string; + source: string; + source_table_updated?: string; + source_table_label: string; + url: string; + point_figures: IndexPointFigureYearly[]; +} +export type OldDwellingsInHousingCompaniesPriceIndexId = number; + +export type OldDwellingsInHousingCompaniesPriceIndexState = { + isFetching: boolean; + latest: OldDwellingsInHousingCompaniesPriceIndex; +}; + +export type FetchOldDwellingsInHousingCompaniesPriceIndexAction = Action; +export type ReceiveOldDwellingsInHousingCompaniesPriceIndexAction = Action; +export type OldDwellingsInHousingCompaniesPriceIndexNotFoundAction = Action; \ No newline at end of file diff --git a/src/root/createRootReducer.ts b/src/root/createRootReducer.ts index bed40f8f0..11961aca9 100644 --- a/src/root/createRootReducer.ts +++ b/src/root/createRootReducer.ts @@ -29,6 +29,7 @@ import landUseInvoiceReducer from "@/landUseInvoices/reducer"; import landUseContractReducer from "@/landUseContract/reducer"; import landUseAgreementAttachmentReducer from "@/landUseAgreementAttachment/reducer"; import leaseReducer from "@/leases/reducer"; +import oldDwellingsInHousingCompaniesPriceIndexReducer from "@/oldDwellingsInHousingCompaniesPriceIndex/reducer"; import plotSearchReducer from "@/plotSearch/reducer"; import plotApplicationsReducer from "@/plotApplications/reducer"; import applicationReducer from "@/application/reducer"; @@ -86,6 +87,7 @@ export default ((history: Record): Reducer => combineRed leaseStatisticReport: leaseStatisticReportReducer, leaseType: leaseTypeReducer, lessor: lessorReducer, + oldDwellingsInHousingCompaniesPriceIndex: oldDwellingsInHousingCompaniesPriceIndexReducer, penaltyInterest: penaltyInterestReducer, previewInvoices: previewInvoicesReducer, rentBasis: rentBasisReducer,