File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
src/pages/EditShelterSupply Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ const EditShelterSupply = () => {
30
30
) ;
31
31
const [ , setSearchSupplies ] = useThrottle < string > (
32
32
{
33
- throttle : 400 ,
33
+ throttle : 200 ,
34
34
callback : ( value ) => {
35
35
if ( value ) {
36
36
const filteredSupplies = supplies . filter ( ( s ) =>
@@ -45,6 +45,7 @@ const EditShelterSupply = () => {
45
45
} ,
46
46
[ supplies ]
47
47
) ;
48
+
48
49
const [ , setSearch ] = useThrottle < string > (
49
50
{
50
51
throttle : 400 ,
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export const SupplySearch = ({
13
13
onAddNewItem
14
14
} : ISupplySearchProps ) => {
15
15
const [ searchValue , setSearchValue ] = useState < string > ( '' ) ;
16
+ const [ selectedItem , setSelectedItem ] = useState < IUseSuppliesData | null > ( null ) ;
16
17
17
18
function onChangeInputHandler ( event : React . ChangeEvent < HTMLInputElement > ) {
18
19
setSearchValue ( event . target . value ) ;
@@ -21,14 +22,17 @@ export const SupplySearch = ({
21
22
22
23
function onSelectItemHandler ( item : IUseSuppliesData ) {
23
24
setSearchValue ( item . name ) ;
25
+ setSelectedItem ( item ) ;
24
26
onSelectItem ( item ) ;
25
27
}
26
28
27
29
function onAddNewItemHandler ( ) {
30
+ setSelectedItem ( null ) ;
28
31
onAddNewItem ( ) ;
29
32
}
30
33
31
34
function onClearClickHandler ( ) {
35
+ setSelectedItem ( null ) ;
32
36
setSearchValue ( '' ) ;
33
37
onSearch ( '' ) ;
34
38
}
@@ -50,7 +54,7 @@ export const SupplySearch = ({
50
54
< X className = "h-4 w-4 ml-2 hover:cursor-pointer" onClick = { onClearClickHandler } />
51
55
</ div >
52
56
53
- { ! ! searchValue ? (
57
+ { ! ! searchValue && ! selectedItem ? (
54
58
< div className = "flex-col items-center rounded-md border border-input p-3 bg-slate-50 mt-1" >
55
59
{ supplyItems . slice ( 0 , limit ) . map ( ( item ) => (
56
60
< div
You can’t perform that action at this time.
0 commit comments