Skip to content

Commit ab45c1f

Browse files
committed
Lease Dates field (controlled by calendar modal) is now able to be reset
1 parent abf2fe5 commit ab45c1f

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/components/CalendarModal/CalendarModal.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ const today = new Date()
7979
export function useCalendarState(startDateInit = today, endDateInit = today) {
8080
const [dateTimeStart, setStart] = useState(startDateInit)
8181
const [dateTimeEnd, setEnd] = useState(endDateInit)
82+
const resetDates = () => {
83+
setStart(startDateInit);
84+
setEnd(startDateInit);
85+
};
8286

83-
return { dateTimeStart, dateTimeEnd, setStart, setEnd }
87+
return { dateTimeStart, dateTimeEnd, setStart, setEnd, resetDates }
8488
}

src/views/AddTenant/addTenant.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const AddTenant = () => {
4343
const [propertyErrorText, setPropertyErrorText] = useState("");
4444

4545
const calendarState = useCalendarState();
46-
const { dateTimeStart, dateTimeEnd } = calendarState;
46+
const { dateTimeStart, dateTimeEnd, resetDates } = calendarState;
4747

4848
useMountEffect(() => getProperties());
4949

@@ -191,6 +191,7 @@ export const AddTenant = () => {
191191
setStaffSearchText("");
192192
setStaffSelections([]);
193193
setPropertyErrorText("");
194+
resetDates();
194195
setIsValidationActive(false);
195196
setSubmitting(false);
196197
}}
@@ -314,7 +315,7 @@ export const AddTenant = () => {
314315
Create New Property
315316
</button>
316317
</div>
317-
<h1 className="section-title">UNIT</h1>
318+
<h1 className="section-title">LEASE</h1>
318319
<div className="form-row form-first-row">
319320
<label
320321
className="column is-one-fifth"
@@ -329,7 +330,7 @@ export const AddTenant = () => {
329330
name="unitNum"
330331
onChange={handleChange}
331332
value={values.unitNum}
332-
placeholder="Unit Number"
333+
placeholder="Unit Number (Optional)"
333334
/>
334335
{errors.unitNum ? (
335336
<div className="error-message">{errors.unitNum}</div>
@@ -349,7 +350,7 @@ export const AddTenant = () => {
349350
name="occupants"
350351
onChange={handleChange}
351352
value={values.occupants}
352-
placeholder="Total number of unit tenants"
353+
placeholder="Total number of unit tenants (Optional)"
353354
/>
354355
{errors.occupants ? (
355356
<div className="error-message">{errors.occupants}</div>
@@ -372,7 +373,7 @@ export const AddTenant = () => {
372373
? `${dateTimeStart.toDateString()} - ${dateTimeEnd.toDateString()}`
373374
: ""
374375
}
375-
placeholder="Lease dates (Start and End)"
376+
placeholder="Lease dates (Optional)"
376377
/>
377378
<CalendarModal title="Lease Range" calendarState={calendarState} iconYPosition="0.8rem" />
378379
</div>

0 commit comments

Comments
 (0)