Skip to content

Commit

Permalink
set currentHelpQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayadav09 committed Dec 13, 2024
1 parent 058ec50 commit f11fe06
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/SearchInput.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { LocalStorageUtils } from '../utils';
import { ReactComponent as GoSearchIcon } from '../icons/paper-airplane.svg';
import { ReactComponent as PhoneIcon } from '../icons/phone.svg';
import { ReactComponent as ChatIcon } from '../icons/chat-bubble.svg';
Expand All @@ -15,7 +16,7 @@ const SearchInput = ( {
const [ error, setError ] = useState( '' );

const validateInput = () => {
if ( ! searchInput.trim() ) {
if ( ! searchInput || ! searchInput.trim() ) {
setError(
__(
'Please enter a specific search term to get results.',
Expand All @@ -24,6 +25,7 @@ const SearchInput = ( {
);
return false;
}
LocalStorageUtils.setCurrentHelpQuery( searchInput );
setError( '' );
return true;
};
Expand Down
3 changes: 3 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ export const LocalStorageUtils = {
JSON.stringify( updatedResults )
);
},
setCurrentHelpQuery: ( helpQuery ) => {
localStorage.setItem( 'nfdHelpCurrentQuery', helpQuery );
},
};

export const Analytics = {
Expand Down

0 comments on commit f11fe06

Please sign in to comment.