mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 07:26:59 +00:00
fix: Search text result
This commit is contained in:
parent
d1ea2354ee
commit
90fbe59c7e
@ -1,6 +1,7 @@
|
||||
import { SWRHook } from '@commerce/utils/types'
|
||||
import useSearch, { UseSearch } from '@commerce/product/use-search'
|
||||
import data from '../data.json'
|
||||
import useCallback from 'react'
|
||||
export default useSearch as UseSearch<typeof handler>
|
||||
|
||||
const productsFinder = (s: string) => {
|
||||
@ -16,17 +17,21 @@ export const handler: SWRHook<any> = {
|
||||
fetchOptions: {
|
||||
query: '',
|
||||
},
|
||||
async fetcher({ input, options, fetch }) {},
|
||||
async fetcher({ input, options, fetch }) {
|
||||
debugger
|
||||
},
|
||||
useHook:
|
||||
({ useData }) =>
|
||||
({ search }) => {
|
||||
const { mutate } = useData()
|
||||
const products = productsFinder(search)
|
||||
mutate()
|
||||
return {
|
||||
data: {
|
||||
products,
|
||||
},
|
||||
data:
|
||||
products.length > 0
|
||||
? {
|
||||
products,
|
||||
found: true,
|
||||
}
|
||||
: null,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user