href removed from useSearch hook

This commit is contained in:
nklhrstv 2020-03-28 19:27:07 +02:00
parent d709e57f97
commit 22ec152cee
2 changed files with 6 additions and 9 deletions

View file

@ -46,6 +46,8 @@ const Search = ({ queryParams }) => {
</div>
:
search.catalog_resources.map((catalog_resource, index) => {
const queryString = new URLSearchParams([['search', query]]).toString();
const href = `#/discover/${encodeURIComponent(catalog_resource.request.base)}/${encodeURIComponent(catalog_resource.request.path.type_name)}/${encodeURIComponent(catalog_resource.request.path.id)}?${queryString}`;
const title = `${catalog_resource.origin} - ${catalog_resource.request.path.id} ${catalog_resource.request.path.type_name}`;
switch (catalog_resource.content.type) {
case 'Ready': {
@ -56,7 +58,7 @@ const Search = ({ queryParams }) => {
title={title}
items={catalog_resource.content.content}
itemComponent={MetaItem}
href={catalog_resource.href}
href={href}
/>
);
}
@ -68,7 +70,7 @@ const Search = ({ queryParams }) => {
className={styles['search-row']}
title={title}
message={message}
href={catalog_resource.href}
href={href}
/>
);
}
@ -78,7 +80,7 @@ const Search = ({ queryParams }) => {
key={index}
className={styles['search-row']}
title={title}
href={catalog_resource.href}
href={href}
/>
);
}

View file

@ -7,10 +7,6 @@ const initSearchState = () => ({
});
const mapSearchStateWithCtx = (search, ctx) => {
const queryString = search.selected !== null ?
new URLSearchParams(search.selected.extra).toString()
:
'';
const selected = search.selected;
const catalog_resources = search.catalog_resources.map((catalog_resource) => {
const request = catalog_resource.request;
@ -37,8 +33,7 @@ const mapSearchStateWithCtx = (search, ctx) => {
return origin;
}, catalog_resource.request.base);
const href = `#/discover/${encodeURIComponent(catalog_resource.request.base)}/${encodeURIComponent(catalog_resource.request.path.type_name)}/${encodeURIComponent(catalog_resource.request.path.id)}?${queryString}`;
return { request, content, origin, href };
return { request, content, origin };
});
return { selected, catalog_resources };
};