forked from vtex-apps/search-result
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NotFoundSearch.js
70 lines (65 loc) · 2.02 KB
/
NotFoundSearch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import PropTypes from 'prop-types'
import React, { Fragment } from 'react'
import { FormattedMessage } from 'react-intl'
import { ExtensionPoint } from 'vtex.render-runtime'
import { range } from 'ramda'
import searchResult from './searchResult.css'
const flexStyle = { flex: 1 }
/**
* Not found page component, rendered when the search doesn't return any
* products from the API.
*/
const NotFoundSearch = ({ term }) => {
return (
<Fragment>
<div
className={`${
searchResult.searchNotFound
} flex flex-column-s flex-row-ns justify-center-ns items-center h-auto-s h5-ns`}
>
<div
className="flex justify-end-ns justify-center-s ttu f1 ph4 pv4-s pv0-ns c-muted-3 ph9 b"
style={flexStyle}
>
ops!
</div>
<div className="ph9" style={flexStyle}>
{term ? (
<FormattedMessage
id="store/search.empty-products"
values={{
term: <span className="c-action-primary">{term}</span>,
}}
>
{(...textList) => (
<span className="c-muted-1 b">
{textList.map((text, index) => (
<Fragment key={index}>{text}</Fragment>
))}
</span>
)}
</FormattedMessage>
) : (
<FormattedMessage id="store/search.no-products" />
)}
<FormattedMessage id="store/search.what-do-i-do">
{text => <p className="c-muted-2">{text}</p>}
</FormattedMessage>
<ul className="c-muted-2">
{range(1, 5).map(id => (
<FormattedMessage id={`store/search.what-to-do.${id}`} key={id}>
{text => <li key={text}>{text}</li>}
</FormattedMessage>
))}
</ul>
</div>
</div>
<ExtensionPoint id="shelf" />
</Fragment>
)
}
NotFoundSearch.propTypes = {
/** Search term */
term: PropTypes.string,
}
export default NotFoundSearch