Skip to content

Commit

Permalink
remove dueDates sorting from BasicInfoEdit
Browse files Browse the repository at this point in the history
It caused annoying in-place sorting when editing the values.
Fixing that and the change actions from redux-form is not worthwhile effort right now.
  • Loading branch information
henrinie-nc committed Oct 28, 2024
1 parent 495c797 commit 953a2a8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/leases/components/leaseSections/rent/BasicInfoEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { rentCustomDateOptions } from "@/leases/constants";
import { FieldTypes, FormNames } from "@/enums";
import { DueDatesPositions, FixedDueDates, LeaseRentDueDatesFieldPaths, LeaseRentDueDatesFieldTitles, LeaseRentsFieldPaths, LeaseRentsFieldTitles, RentCycles, RentTypes, RentDueDateTypes } from "@/leases/enums";
import { UsersPermissions } from "@/usersPermissions/enums";
import { formatDueDates, formatSeasonalDate, sortDueDates } from "@/leases/helpers";
import { formatDueDates, formatSeasonalDate } from "@/leases/helpers";
import { getUiDataLeaseKey } from "@/uiData/helpers";
import { getFieldAttributes, hasPermissions, isFieldAllowedToEdit, isFieldAllowedToRead, isFieldRequired } from "@/util/helpers";
import { getAttributes as getLeaseAttributes, getCurrentLease } from "@/leases/selectors";
Expand Down Expand Up @@ -133,7 +133,7 @@ const renderDueDates = ({
</FormTextTitle>
</Column>
</Row>
<Authorization allow={isFieldAllowedToEdit(leaseAttributes, LeaseRentDueDatesFieldPaths.DAY) || isFieldAllowedToEdit(leaseAttributes, LeaseRentDueDatesFieldPaths.MONTH)} errorComponent={<FormText>{formatDueDates(sortDueDates(dueDates)) || '-'}</FormText>}>
<Authorization allow={isFieldAllowedToEdit(leaseAttributes, LeaseRentDueDatesFieldPaths.DAY) || isFieldAllowedToEdit(leaseAttributes, LeaseRentDueDatesFieldPaths.MONTH)} errorComponent={<FormText>{formatDueDates(dueDates) || '-'}</FormText>}>
{fields && !!fields.length && fields.map((due_date, index) => {
const handleRemove = () => {
fields.remove(index);
Expand Down Expand Up @@ -269,7 +269,7 @@ const BasicInfoIndexOrManual = ({
{
/* Authorization is done on renderDueDates component */
}
<FieldArray component={renderDueDates} dueDates={sortDueDates(dueDates)} isSaveClicked={isSaveClicked} leaseAttributes={leaseAttributes} name="due_dates" usersPermissions={usersPermissions} />
<FieldArray component={renderDueDates} dueDates={dueDates} isSaveClicked={isSaveClicked} leaseAttributes={leaseAttributes} name="due_dates" usersPermissions={usersPermissions} />
</Column>}
{dueDatesType === RentDueDateTypes.FIXED && <Column small={6} medium={4} large={1}>
<Authorization allow={isFieldAllowedToRead(leaseAttributes, LeaseRentsFieldPaths.DUE_DATES_PER_YEAR)}>
Expand Down Expand Up @@ -436,7 +436,7 @@ const BasicInfoFixed = ({
{
/* Authorization is done on renderDueDates component */
}
<FieldArray component={renderDueDates} dueDates={sortDueDates(dueDates)} isSaveClicked={isSaveClicked} leaseAttributes={leaseAttributes} name="due_dates" usersPermissions={usersPermissions} />
<FieldArray component={renderDueDates} dueDates={dueDates} isSaveClicked={isSaveClicked} leaseAttributes={leaseAttributes} name="due_dates" usersPermissions={usersPermissions} />
</Column>}
{dueDatesType === RentDueDateTypes.FIXED && <Column small={6} medium={4} large={1}>
<Authorization allow={isFieldAllowedToRead(leaseAttributes, LeaseRentsFieldPaths.DUE_DATES_PER_YEAR)}>
Expand Down

0 comments on commit 953a2a8

Please sign in to comment.