Files
Brenda WallaceandDaniel O'Connor 75595350bc Easier recording of harvests from the front page (#5077)
* Implement AddSeedsPicker component and enhance planting selection UI; update styles and serializers for better seed management

* Enhance PlantingPicker component: add hints and titles for harvest and seed actions; update test to reflect changes in seed saving behavior

* Enhance harvest recording: allow harvesting from crops without plantings; update forms and modals for better user experience

* Refactor code structure for improved readability and maintainability

* Remove AddSeedsPicker component and its associated tests

* Add planting picker functionality for harvesting and seed saving

- Introduced PlantingPickersController to handle JSON responses for member's plantings.
- Updated HomeHelper to include crop ID in planting picker properties.
- Refactored PlantPicker and PlantSomethingModal components to support multiple gardens.
- Created PlantingFlow component to manage planting actions (harvest and save seeds).
- Implemented RecordDialog component to handle server-rendered links for harvesting and seed saving.
- Updated various views to include data attributes for triggering the record dialog.
- Added routes for planting picker and corresponding request specs for testing.
- Adjusted styles in _plantings.scss for better layout and spacing.

* Add job management features including job creation and wishlist functionality

* Remove WishlistJobsController and associated views and tests

* Add suggestion links rendering and fix routes formatting

* Refactor AddJobModal and JobPicker components to simplify props and enhance user experience

* Update seed addition test to check dialog presence and current path

* Apply suggestion from @CloCkWeRX

---------

Co-authored-by: Daniel O'Connor <daniel.oconnor@gmail.com>
2026-10-26 21:38:12 +10:30

53 lines
1.9 KiB
React

import React from 'react';
import {formatDate} from '../dates';
export const WHEN_CHOICES = [['today', 'Today'], ['yesterday', 'Yesterday'], ['other', 'Enter date']];
// Today, Yesterday or Enter date, as pills with a date box under Enter date.
// `when` is today, yesterday or other; `date` is the date typed under other.
// `choices` can leave out Yesterday; `min` is the earliest date the box takes.
// `hint` is the date the current choice means, shown under the pills; `hideLegend`
// keeps the legend for screen readers only.
export default function WhenPicker({id, legend, when, onWhen, date, onDate, choices = WHEN_CHOICES, min, max, hint, hideLegend = false}) {
return (
<fieldset>
<legend className={`crop-picker-label step-legend${hideLegend ? ' visually-hidden' : ''}`}>{legend}</legend>
<div className="pill-choices">
{choices.map(([choice, label]) => (
<React.Fragment key={choice}>
<input
type="radio"
className="visually-hidden"
name={`${id}-when`}
id={`${id}-when-${choice}`}
checked={when === choice}
onChange={() => onWhen(choice)}
autoFocus={choice === 'today'}
/>
<label className="pill-choice" htmlFor={`${id}-when-${choice}`}>{label}</label>
</React.Fragment>
))}
</div>
{when === 'other' ? (
<div className="mt-3">
<label className="form-label" htmlFor={`${id}-date`}>Date</label>
<input
id={`${id}-date`}
type="date"
className="form-control when-date"
value={date}
min={min}
max={max}
onChange={onDate}
required
autoFocus
/>
</div>
) : (
<p className="step-hint">{hint && formatDate(hint)}</p>
)}
</fieldset>
);
}