From 4b9ea58f1b368bb813dae601a087d1557117de87 Mon Sep 17 00:00:00 2001 From: Juho Kettunen Date: Wed, 13 Nov 2024 13:15:36 +0200 Subject: [PATCH] Fix hiding the field from MaKe --- .../components/leaseSections/rent/ContractRentEdit.tsx | 8 ++++---- .../components/leaseSections/rent/ContractRents.tsx | 4 +++- .../components/leaseSections/rent/ContractRentsEdit.tsx | 9 +++------ src/leases/components/leaseSections/rent/RentItem.tsx | 4 +++- .../components/leaseSections/rent/RentItemEdit.tsx | 6 ++++-- src/leases/components/leaseSections/rent/Rents.tsx | 2 +- src/leases/components/leaseSections/rent/RentsEdit.tsx | 9 ++++++--- 7 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/leases/components/leaseSections/rent/ContractRentEdit.tsx b/src/leases/components/leaseSections/rent/ContractRentEdit.tsx index 3a10f111e..b3e8b4168 100644 --- a/src/leases/components/leaseSections/rent/ContractRentEdit.tsx +++ b/src/leases/components/leaseSections/rent/ContractRentEdit.tsx @@ -35,6 +35,7 @@ type Props = { receivableTypes: Array>; rentField: string; rentType: string; + serviceUnitId: number; showRemove: boolean; usersPermissions: UsersPermissionsType; change: (...args: Array) => any; @@ -73,6 +74,7 @@ class ContractRentEdit extends PureComponent { onRemove, receivableTypes, rentType, + serviceUnitId: leaseServiceUnitId, showRemove, usersPermissions } = this.props; @@ -223,11 +225,9 @@ class ContractRentEdit extends PureComponent { ; const endDateField = - {leaseAttributes.service_unit.id !== ServiceUnitIds.MAKE && - } ; const indexField = @@ -245,9 +245,9 @@ class ContractRentEdit extends PureComponent { {intendedUseField} - + { leaseServiceUnitId !== ServiceUnitIds.MAKE && {overrideReceivableTypeField} - + } {rentType === RentTypes.INDEX2022 && {indexField} } diff --git a/src/leases/components/leaseSections/rent/ContractRents.tsx b/src/leases/components/leaseSections/rent/ContractRents.tsx index bd565387d..5d43553a2 100644 --- a/src/leases/components/leaseSections/rent/ContractRents.tsx +++ b/src/leases/components/leaseSections/rent/ContractRents.tsx @@ -20,6 +20,7 @@ type Props = { largeScreen: boolean; leaseAttributes: Attributes; rentType: string; + serviceUnitId: number; }; type State = { amountPeriodOptions: Array>; @@ -61,6 +62,7 @@ class ContractRents extends PureComponent { largeScreen, leaseAttributes, rentType, + serviceUnitId, } = this.props; const { amountPeriodOptions, @@ -125,7 +127,7 @@ class ContractRents extends PureComponent { - {(leaseAttributes.service_unit.id !== ServiceUnitIds.MAKE) && + {(serviceUnitId !== ServiceUnitIds.MAKE) && <> diff --git a/src/leases/components/leaseSections/rent/ContractRentsEdit.tsx b/src/leases/components/leaseSections/rent/ContractRentsEdit.tsx index bd38dc92c..5f569771c 100644 --- a/src/leases/components/leaseSections/rent/ContractRentsEdit.tsx +++ b/src/leases/components/leaseSections/rent/ContractRentsEdit.tsx @@ -11,23 +11,21 @@ import { ConfirmationModalTexts } from "@/enums"; import { ButtonColors } from "@/components/enums"; import { UsersPermissions } from "@/usersPermissions/enums"; import { hasPermissions } from "@/util/helpers"; -import { getAttributes as getLeaseAttributes } from "@/leases/selectors"; import { getUsersPermissions } from "@/usersPermissions/selectors"; -import type { Attributes } from "types"; import type { UsersPermissions as UsersPermissionsType } from "@/usersPermissions/types"; type Props = { fields: any; - leaseAttributes: Attributes; rentField: string; rentType: string; + serviceUnitId: number; usersPermissions: UsersPermissionsType; }; const ContractRentsEdit = ({ fields, - leaseAttributes, rentField, rentType, + serviceUnitId, usersPermissions }: Props) => { const handleAdd = () => { @@ -60,7 +58,7 @@ const ContractRentsEdit = ({ }); }; - return 1} />; + return 1} serviceUnitId={serviceUnitId} />; })} } @@ -78,7 +76,6 @@ const ContractRentsEdit = ({ export default connect(state => { return { - leaseAttributes: getLeaseAttributes(state), usersPermissions: getUsersPermissions(state) }; })(ContractRentsEdit); diff --git a/src/leases/components/leaseSections/rent/RentItem.tsx b/src/leases/components/leaseSections/rent/RentItem.tsx index 915a29e10..97b71ab93 100644 --- a/src/leases/components/leaseSections/rent/RentItem.tsx +++ b/src/leases/components/leaseSections/rent/RentItem.tsx @@ -32,6 +32,7 @@ type Props = { rents: Array>; rentAdjustmentsCollapseState: boolean; rentCollapseState: boolean; + serviceUnitId: number; }; const RentItem = ({ @@ -46,6 +47,7 @@ const RentItem = ({ rents, rentAdjustmentsCollapseState, rentCollapseState, + serviceUnitId, }: Props) => { const handleCollapseToggle = (key: string, val: boolean) => { receiveCollapseStates({ @@ -118,7 +120,7 @@ const RentItem = ({ {(rentTypeIsIndex || rentTypeIsIndex2022 || rentTypeIsFixed || rentTypeIsManual) && - + } diff --git a/src/leases/components/leaseSections/rent/RentItemEdit.tsx b/src/leases/components/leaseSections/rent/RentItemEdit.tsx index e9f7edd71..4b491abf1 100644 --- a/src/leases/components/leaseSections/rent/RentItemEdit.tsx +++ b/src/leases/components/leaseSections/rent/RentItemEdit.tsx @@ -49,6 +49,7 @@ type Props = { rentId: number; rents: Array>; rentType: string | null | undefined; + serviceUnitId: number; usersPermissions: UsersPermissionsType; }; type State = { @@ -237,6 +238,7 @@ class RentItemEdit extends PureComponent { rentCollapseState, rentType, rents, + serviceUnitId, usersPermissions } = this.props; const { @@ -277,7 +279,7 @@ class RentItemEdit extends PureComponent { {(rentTypeIsIndex || rentTypeIsIndex2022 || rentTypeIsFixed || rentTypeIsManual) && - + } @@ -340,4 +342,4 @@ export default connect((state, props) => { }, { change, receiveCollapseStates -})(RentItemEdit); \ No newline at end of file +})(RentItemEdit); diff --git a/src/leases/components/leaseSections/rent/Rents.tsx b/src/leases/components/leaseSections/rent/Rents.tsx index 2a3932ecc..4c281098c 100644 --- a/src/leases/components/leaseSections/rent/Rents.tsx +++ b/src/leases/components/leaseSections/rent/Rents.tsx @@ -67,7 +67,7 @@ const Rents = ({ <> {!rents || !rents.length && Ei vuokria} {rents && !!rents.length && rents.map(rent => { - return ; + return ; })} {!!rentsArchived.length &&

>; + serviceUnitId: number; usersPermissions: UsersPermissionsType; }; @@ -65,6 +66,7 @@ const renderRents = ({ archived, fields, rents, + serviceUnitId, usersPermissions }: RentsProps): ReactElement => { const handleAdd = () => { @@ -99,7 +101,7 @@ const renderRents = ({ }); }; - return ; + return ; })} {!archived && @@ -219,6 +221,7 @@ class RentsEdit extends PureComponent { render() { const { + currentLease, editedActiveBasisOfRents, editedArchivedBasisOfRents, isRentInfoComplete, @@ -282,7 +285,7 @@ class RentsEdit extends PureComponent { - + { /* Archived rents */ @@ -344,4 +347,4 @@ export default flowRight(withRouter, connect(state => { destroyOnUnmount: false, validate: validateRentForm, warn: warnRentForm -}))(RentsEdit) as React.ComponentType; \ No newline at end of file +}))(RentsEdit) as React.ComponentType;