Skip to content

Commit

Permalink
Remove CIRCULARS_FILTER_BY_DATE feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
lpsinger committed Jan 29, 2024
1 parent 2f476e6 commit 7d38205
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 80 deletions.
145 changes: 74 additions & 71 deletions app/routes/_gcn.circulars._archive._index/DateSelectorMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
Icon,
Radio,
} from '@trussworks/react-uswds'
import classNames from 'classnames'
import { type ChangeEvent, useRef, useState } from 'react'

import DetailsDropdownContent from '~/components/DetailsDropdownContent'
Expand Down Expand Up @@ -126,87 +127,89 @@ export function DateSelector({
}}
expanded={showContent}
/>
{showContent && (
<DetailsDropdownContent className="maxw-card-xlg">
<CardBody>
<Grid row>
<Grid col={4} key="radio-alltime">
<DetailsDropdownContent
className={classNames('maxw-card-xlg', {
'display-none': !showContent,
})}
>
<CardBody>
<Grid row>
<Grid col={4} key="radio-alltime">
<Radio
form=""
id="radio-alltime"
name="radio-date"
value=""
label="All Time"
defaultChecked={!defaultStartDate && !defaultEndDate}
onChange={radioOnChange}
/>
</Grid>
{Object.entries(dateSelectorLabels).map(([value, label]) => (
<Grid col={4} key={`radio-${value}`}>
<Radio
form=""
id="radio-alltime"
id={`radio-${value}`}
name="radio-date"
value=""
label="All Time"
defaultChecked={!defaultStartDate && !defaultEndDate}
value={value}
label={label}
defaultChecked={value === defaultStartDate}
onChange={radioOnChange}
/>
</Grid>
{Object.entries(dateSelectorLabels).map(([value, label]) => (
<Grid col={4} key={`radio-${value}`}>
<Radio
form=""
id={`radio-${value}`}
name="radio-date"
value={value}
label={label}
defaultChecked={value === defaultStartDate}
onChange={radioOnChange}
/>
</Grid>
))}
<Grid col={4}>
<Radio
form=""
id="radio-custom"
name="radio-date"
value="custom"
label="Custom Range..."
defaultChecked={defaultShowDateRange}
onChange={({ target: { checked } }) => {
setShowDateRange(checked)
}}
/>
</Grid>
</Grid>
{showDateRange && (
<DateRangePicker
startDateHint="YYYY-MM-DD"
startDateLabel="Start Date"
className="margin-bottom-2"
startDatePickerProps={{
form: '',
id: 'event-date-start',
name: 'event-date-start',
dateFormat: 'YYYY-MM-DD',
defaultValue: defaultStartDate,
onChange: (value) => {
setStartDate(value ?? '')
},
}}
endDateHint="YYYY-MM-DD"
endDateLabel="End Date"
endDatePickerProps={{
form: '',
id: 'event-date-end',
name: 'event-date-end',
dateFormat: 'YYYY-MM-DD',
defaultValue: defaultEndDate,
onChange: (value) => {
setEndDate(value ?? '')
},
))}
<Grid col={4}>
<Radio
form=""
id="radio-custom"
name="radio-date"
value="custom"
label="Custom Range..."
defaultChecked={defaultShowDateRange}
onChange={({ target: { checked } }) => {
setShowDateRange(checked)
}}
/>
)}
</CardBody>
</Grid>
</Grid>
{showDateRange && (
<CardFooter>
<Button type="submit" form={form}>
Submit
</Button>
</CardFooter>
<DateRangePicker
startDateHint="YYYY-MM-DD"
startDateLabel="Start Date"
className="margin-bottom-2"
startDatePickerProps={{
form: '',
id: 'event-date-start',
name: 'event-date-start',
dateFormat: 'YYYY-MM-DD',
defaultValue: defaultStartDate,
onChange: (value) => {
setStartDate(value ?? '')
},
}}
endDateHint="YYYY-MM-DD"
endDateLabel="End Date"
endDatePickerProps={{
form: '',
id: 'event-date-end',
name: 'event-date-end',
dateFormat: 'YYYY-MM-DD',
defaultValue: defaultEndDate,
onChange: (value) => {
setEndDate(value ?? '')
},
}}
/>
)}
</DetailsDropdownContent>
)}
</CardBody>
{showDateRange && (
<CardFooter>
<Button type="submit" form={form}>
Submit
</Button>
</CardFooter>
)}
</DetailsDropdownContent>
</>
)
}
14 changes: 5 additions & 9 deletions app/routes/_gcn.circulars._archive._index/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import CircularsIndex from './CircularsIndex'
import { DateSelector } from './DateSelectorMenu'
import Hint from '~/components/Hint'
import { getFormDataString } from '~/lib/utils'
import { useFeature } from '~/root'

import searchImg from 'nasawds/src/img/usa-icons-bg/search--white.svg'

Expand Down Expand Up @@ -92,7 +91,6 @@ export async function action({ request }: ActionFunctionArgs) {
export default function () {
const newItem = useActionData<typeof action>()
const { items, page, totalPages, totalItems } = useLoaderData<typeof loader>()
const featureCircularsFilterByDate = useFeature('CIRCULARS_FILTER_BY_DATE')

// Concatenate items from the action and loader functions
const allItems = [...(newItem ? [newItem] : []), ...(items || [])]
Expand Down Expand Up @@ -150,13 +148,11 @@ export default function () {
/>
</Button>
</Form>
{featureCircularsFilterByDate && (
<DateSelector
form={formId}
defaultStartDate={startDate}
defaultEndDate={endDate}
/>
)}
<DateSelector
form={formId}
defaultStartDate={startDate}
defaultEndDate={endDate}
/>
<Link to={`/circulars/new${searchString}`}>
<Button
type="button"
Expand Down

0 comments on commit 7d38205

Please sign in to comment.