Skip to content

Commit

Permalink
temp: loader for receivable type field to prevent crash
Browse files Browse the repository at this point in the history
  • Loading branch information
NC-jsAhonen committed Apr 17, 2024
1 parent a244916 commit b9907c5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {getAttributes as getInvoiceAttributes} from '$src/invoices/selectors';
import {getReceivableTypes} from '$src/leaseCreateCharge/selectors';
import type {Attributes} from '$src/types';
import {receivableTypesFromAttributes, receivableTypeFromRows} from '$src/leaseCreateCharge/helpers';

import Loader from '$components/loader/Loader';

type Props = {
fields: any,
Expand Down Expand Up @@ -93,15 +93,18 @@ const InvoiceRowsEdit = ({fields, invoiceAttributes, isEditClicked, relativeTo,
</Column>
<Column small={4}>
<Authorization allow={isFieldAllowedToRead(invoiceAttributes, InvoiceRowsFieldPaths.RECEIVABLE_TYPE)}>
<FormField
disableTouched={isEditClicked}
fieldAttributes={
receivableType === 2 ?
getFieldAttributes(invoiceAttributes, InvoiceRowsFieldPaths.RECEIVABLE_TYPE):
receivableTypesFromAttributes(getFieldAttributes(invoiceAttributes, InvoiceRowsFieldPaths.RECEIVABLE_TYPE), receivableTypes)}
name={`${row}.receivable_type`}
overrideValues={{label: InvoiceRowsFieldTitles.RECEIVABLE_TYPE}}
/>
{receivableTypes ?
<FormField
disableTouched={isEditClicked}
fieldAttributes={
receivableType === 2 ?
getFieldAttributes(invoiceAttributes, InvoiceRowsFieldPaths.RECEIVABLE_TYPE):
receivableTypesFromAttributes(getFieldAttributes(invoiceAttributes, InvoiceRowsFieldPaths.RECEIVABLE_TYPE), receivableTypes)}
name={`${row}.receivable_type`}
overrideValues={{label: InvoiceRowsFieldTitles.RECEIVABLE_TYPE}}
/>
: <Loader isLoading={true} />
}
</Authorization>
</Column>
<Column small={4}>
Expand Down
26 changes: 16 additions & 10 deletions src/leases/components/leaseSections/invoice/forms/NewInvoiceForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ import {getUsersPermissions} from '$src/usersPermissions/selectors';
import type {Attributes} from '$src/types';
import type {Lease} from '$src/leases/types';
import type {UsersPermissions as UsersPermissionsType} from '$src/usersPermissions/types';
import Loader from '$components/loader/Loader';


type InvoiceRowsProps = {
fields: any,
Expand Down Expand Up @@ -139,16 +141,20 @@ const InvoiceRows = ({
? isFieldAllowedToEdit(leaseCreateChargeAttributes, LeaseCreateChargeRowsFieldPaths.RECEIVABLE_TYPE)
: isFieldAllowedToEdit(invoiceAttributes, InvoiceRowsFieldPaths.RECEIVABLE_TYPE)}
>
<FormField
disableTouched={isCreateClicked}
fieldAttributes={useLeaseCreateChargeEndpoint
? receivableTypesFromAttributes(getFieldAttributes(leaseCreateChargeAttributes, LeaseCreateChargeRowsFieldPaths.RECEIVABLE_TYPE), receivableTypes)
: receivableTypesFromAttributes(getFieldAttributes(invoiceAttributes, InvoiceRowsFieldPaths.RECEIVABLE_TYPE), receivableTypes)
}
invisibleLabel
name={`${row}.receivable_type`}
overrideValues={{label: InvoiceRowsFieldTitles.RECEIVABLE_TYPE}}
/>
{receivableTypes ?
<FormField
disableTouched={isCreateClicked}
fieldAttributes={useLeaseCreateChargeEndpoint
? receivableTypesFromAttributes(getFieldAttributes(leaseCreateChargeAttributes, LeaseCreateChargeRowsFieldPaths.RECEIVABLE_TYPE), receivableTypes)
: receivableTypesFromAttributes(getFieldAttributes(invoiceAttributes, InvoiceRowsFieldPaths.RECEIVABLE_TYPE), receivableTypes)
}
invisibleLabel
name={`${row}.receivable_type`}
overrideValues={{label: InvoiceRowsFieldTitles.RECEIVABLE_TYPE}}
/>
: <Loader isLoading={true} />
}

</Authorization>
</Column>
<Column small={2} large={2}>
Expand Down

0 comments on commit b9907c5

Please sign in to comment.