fix(tenders): clear documents scraped checkbox on filter reset
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
Control the checkbox through react-hook-form so Reset all updates the UI, and normalize documents_scraped to false when rebuilding filter state. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import { isDateRangeActive } from "@/utils/shared";
|
|||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import {
|
import {
|
||||||
Control,
|
Control,
|
||||||
|
Controller,
|
||||||
FieldValues,
|
FieldValues,
|
||||||
UseFormHandleSubmit,
|
UseFormHandleSubmit,
|
||||||
UseFormRegister,
|
UseFormRegister,
|
||||||
@@ -214,12 +215,22 @@ const TenderListFilters = ({
|
|||||||
subtitle="Restrict to tenders whose documents have been scraped."
|
subtitle="Restrict to tenders whose documents have been scraped."
|
||||||
>
|
>
|
||||||
<div className="max-w-fit rounded-xl border border-stroke/40 bg-white/60 p-4 dark:border-white/[0.06] dark:bg-dark-3/40">
|
<div className="max-w-fit rounded-xl border border-stroke/40 bg-white/60 p-4 dark:border-white/[0.06] dark:bg-dark-3/40">
|
||||||
<Checkbox
|
<Controller
|
||||||
label="Documents scraped"
|
name="documents_scraped"
|
||||||
minimal
|
control={control}
|
||||||
withBg
|
render={({ field: { value, onChange, name, onBlur, ref } }) => (
|
||||||
withIcon="check"
|
<Checkbox
|
||||||
{...filterRegister("documents_scraped")}
|
ref={ref}
|
||||||
|
name={name}
|
||||||
|
label="Documents scraped"
|
||||||
|
minimal
|
||||||
|
withBg
|
||||||
|
withIcon="check"
|
||||||
|
checked={value === true}
|
||||||
|
onBlur={onBlur}
|
||||||
|
onChange={(event) => onChange(event.target.checked)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</CollapsibleFilterSection>
|
</CollapsibleFilterSection>
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ const mergeTenderFilterFormState = (params: Record<string, any>) => {
|
|||||||
return {
|
return {
|
||||||
...TENDER_FILTER_FORM_DEFAULTS,
|
...TENDER_FILTER_FORM_DEFAULTS,
|
||||||
...built,
|
...built,
|
||||||
|
documents_scraped: built.documents_scraped === true,
|
||||||
created_at_range: built.created_at_range ?? [],
|
created_at_range: built.created_at_range ?? [],
|
||||||
tender_deadline_range: built.tender_deadline_range ?? [],
|
tender_deadline_range: built.tender_deadline_range ?? [],
|
||||||
publication_date_range: built.publication_date_range ?? [],
|
publication_date_range: built.publication_date_range ?? [],
|
||||||
|
|||||||
Reference in New Issue
Block a user