-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ricerca in testata applica filtri sezione #401
Changes from all commits
3fa9f55
bed0176
8113631
cda1178
afb473f
ad09ea1
5235b2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,26 @@ const messages = defineMessages({ | |
|
||
const SearchSectionForm = ({ content }) => { | ||
const intl = useIntl(); | ||
const path = content['@id']; | ||
const searchFilters = useSelector( | ||
(state) => state?.searchFilters?.result?.sections, | ||
); | ||
|
||
const customPath = []; | ||
|
||
const sections = searchFilters?.[0]?.items ?? []; | ||
|
||
sections.forEach((section) => { | ||
if (!section.items) { | ||
return; | ||
} else { | ||
if (path === section['@id']) { | ||
customPath.push( | ||
section.items.map((item) => flattenToAppURL(item['@id'])), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aggiunto flattenToAppURL |
||
); | ||
} | ||
} | ||
}); | ||
|
||
const subsite = useSelector((state) => state.subsite?.data); | ||
const [searchableText, setSearchableText] = useState(''); | ||
|
@@ -44,13 +64,14 @@ const SearchSectionForm = ({ content }) => { | |
{}, | ||
null, | ||
null, | ||
null, | ||
customPath.length > 0 ? customPath : null, | ||
subsite, | ||
intl.locale, | ||
false, | ||
) + | ||
'&custom_path=' + | ||
flattenToAppURL(content['@id']); | ||
(customPath.length === 0 | ||
? `&custom_path=${flattenToAppURL(path)}` | ||
: ''); | ||
Comment on lines
+72
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sabrina-bongiovanni ho lasciato anche la vecchia implementazione per permettere l'utilizzo della ricerca in testata anche nelle pagine che non sono tra le quattro sezioni di ricerca, che è una cosa che prima era possibile quindi non dobbiamo togliere |
||
} | ||
}; | ||
return ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ho rimosso il dispatch perché quella query per search-filters viene già fatta a prescindere ogni volta che si visita il sito, era duplicata. Ho lasciato anche useIntl in cima, la convenzione vuole che gli hook stiano il più possibile in alto nel componente e quelli semplici tipo useIntl cerchiamo di tenerli sempre in cima.