Skip to content

Commit

Permalink
Fix/search group (#95)
Browse files Browse the repository at this point in the history
* fix: search group parameters

* fix: create group login redirect

* remove: unused file
  • Loading branch information
JohnsonMao authored Oct 10, 2024
1 parent c420a58 commit dcff94f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
2 changes: 1 addition & 1 deletion components/Group/Form/useGroupForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default function useGroupForm() {
};

useEffect(() => {
if (notLogin) openLoginWindow('/login');
if (notLogin) openLoginWindow();
}, [notLogin]);

return {
Expand Down
6 changes: 3 additions & 3 deletions components/Group/SearchField/SearchInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const SearchInput = () => {
const [getSearchParams, pushState] = useSearchParamsManager();
const [keyword, setKeyword] = useState('');
const [isSpeechMode, setIsSpeechMode] = useState(false);
const currentKeyword = getSearchParams('q').toString();
const currentKeyword = getSearchParams('search').toString();

useEffect(() => {
setKeyword(currentKeyword);
Expand All @@ -67,15 +67,15 @@ const SearchInput = () => {
/** @type {(event: SubmitEvent) => void} */
const handleSubmit = (event) => {
event.preventDefault();
pushState('q', keyword);
pushState('search', keyword);
};

return (
<SearchInputWrapper as="form" onSubmit={handleSubmit}>
<InputBaseWrapper
type="search"
inputProps={{ 'aria-label': 'search group' }}
name="q"
name="search"
value={keyword}
placeholder="想尋找甚麼類型的揪團呢?"
onChange={handleChange}
Expand Down
16 changes: 0 additions & 16 deletions functions/hello.js

This file was deleted.

13 changes: 8 additions & 5 deletions redux/sagas/groupSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function* getGroupItems() {
category: CATEGORIES,
partnerEducationStep: EDUCATION_STEP,
isGrouping: true,
q: true,
search: true,
};

Object.keys(searchParamsOptions).forEach((key) => {
Expand All @@ -33,10 +33,13 @@ function* getGroupItems() {
if (!searchParam || !option) return;

if (Array.isArray(option)) {
urlSearchParams.append(key, searchParam
.split(',')
.filter((item) => option.some((option) => option.label === item))
.join(','))
urlSearchParams.append(
key,
searchParam
.split(',')
.filter((item) => option.some((_option) => _option.label === item))
.join(','),
);
} else {
urlSearchParams.append(key, searchParam);
}
Expand Down

0 comments on commit dcff94f

Please sign in to comment.