Skip to content

Commit 6b75fcc

Browse files
committed
fix: make date range parameters optional in useStacSearch hook
- Changed dateRangeFrom and dateRangeTo from required to optional in return type - Updated state initialization to use undefined instead of empty strings - Updated setters to accept optional string parameters - Updated reset function to set undefined instead of empty strings This resolves type inconsistencies where the return type claimed required strings but the implementation initialized with empty strings. Conceptually, users should be able to clear/unset date filters by passing undefined.
1 parent cc60b1d commit 6b75fcc

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/hooks/useStacSearch.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ type StacSearchHook = {
2323
setBbox: (bbox?: Bbox) => void;
2424
collections?: CollectionIdList;
2525
setCollections: (collections?: CollectionIdList) => void;
26-
dateRangeFrom: string;
27-
setDateRangeFrom: (date: string) => void;
28-
dateRangeTo: string;
29-
setDateRangeTo: (date: string) => void;
26+
dateRangeFrom?: string;
27+
setDateRangeFrom: (date?: string) => void;
28+
dateRangeTo?: string;
29+
setDateRangeTo: (date?: string) => void;
3030
sortby?: Sortby[];
3131
setSortby: (sortby?: Sortby[]) => void;
3232
limit: number;
@@ -48,8 +48,8 @@ function useStacSearch(): StacSearchHook {
4848
const [ids, setIds] = useState<string[]>();
4949
const [bbox, setBbox] = useState<Bbox>();
5050
const [collections, setCollections] = useState<CollectionIdList>();
51-
const [dateRangeFrom, setDateRangeFrom] = useState<string>('');
52-
const [dateRangeTo, setDateRangeTo] = useState<string>('');
51+
const [dateRangeFrom, setDateRangeFrom] = useState<string>();
52+
const [dateRangeTo, setDateRangeTo] = useState<string>();
5353
const [limit, setLimit] = useState<number>(25);
5454
const [sortby, setSortby] = useState<Sortby[]>();
5555

@@ -63,8 +63,8 @@ function useStacSearch(): StacSearchHook {
6363
setBbox(undefined);
6464
setCollections(undefined);
6565
setIds(undefined);
66-
setDateRangeFrom('');
67-
setDateRangeTo('');
66+
setDateRangeFrom(undefined);
67+
setDateRangeTo(undefined);
6868
setSortby(undefined);
6969
setLimit(25);
7070
setCurrentRequest(null);

0 commit comments

Comments
 (0)