This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import InstantSearch from '~/features/instant-search' | |
import Feed from '~/features/instant-search/feed' | |
import Hit from '~/features/instant-search/hit' | |
export type FeedItemProps = { | |
title: number | |
} | |
const FeedItem: FC<FeedItemProps> = ({ index, total, title, ...rest }) => ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { ElementType, ComponentPropsWithoutRef } from 'react' | |
export type HitProps<Component extends ElementType> = HTMLElement & { | |
as?: Component | |
} | |
const Hit = <Component extends ElementType = 'article'>({ | |
as, | |
...rest | |
}: HitProps<Component> & Omit<ComponentPropsWithoutRef<Component>, keyof HitProps<Component>>) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import algoliasearch from 'algoliasearch/lite' | |
const client = algoliasearch( | |
process.env.ALGOLIA_APP_ID as string, | |
process.env.ALGOLIA_SEARCH_KEY as string | |
) | |
export default client |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { FC, useState } from 'react' | |
import { InstantSearch as InstantSearchAlgolia, InstantSearchProps } from 'react-instantsearch-dom' | |
import client from '~/features/instant-search/algolia-client' | |
type Props = Partial<InstantSearchProps> & { | |
initialSearchValue?: string | |
} | |
const DEFAULT_INDEX_NAME = process.env.ALGOLIA_DEFAULT_INDEX_NAME as string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { createRef, ElementType, ComponentPropsWithoutRef } from 'react' | |
import { connectInfiniteHits, connectStats } from 'react-instantsearch-dom' | |
import { FocusScope } from '@react-aria/focus' | |
import { InfiniteHitsProvided, StatsProvided } from 'react-instantsearch-core' | |
import { IHit, ReactChildrenFunction } from '~/@types/model' | |
import SearchResults from '~/features/instant-search/search-results' | |
type ChildrenArgs = { | |
hits: IHit[] | |
total: number |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { connectSearchBox, connectStats, connectStateResults } from 'react-instantsearch-dom' | |
import { SearchBoxProvided, StatsProvided, StateResultsProvided } from 'react-instantsearch-core' | |
import { SearchInput, Form, TotalItems } from '~/components/search-header/styled' | |
type Props = StatsProvided & StateResultsProvided & {} | |
const SearchHeader = ({ nbHits, searching }: Props) => { | |
return ( | |
<div role="search"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { connectSearchBox, connectStats } from 'react-instantsearch-dom' | |
import { SearchBoxProvided, StatsProvided } from 'react-instantsearch-core' | |
import SearchResults from '~/features/instant-search/search-results' | |
import { SearchInput, Form, TotalItems } from '~/components/search-header/styled' | |
type Props = StatsProvided & {} | |
const SearchHeader = ({ nbHits }: Props) => ( | |
<div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { StateResultsProvided } from 'react-instantsearch-core' | |
import React, { ReactElement } from 'react' | |
import { connectStateResults } from 'react-instantsearch-dom' | |
import { IHit } from '~/@types/model' | |
type ChildrenArgs = { searching: boolean } | |
interface Props extends StateResultsProvided<IHit> { | |
children: (args: ChildrenArgs) => ReactElement | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useCallback, InputHTMLAttributes } from 'react' | |
import { connectSearchBox } from 'react-instantsearch-dom' | |
import { SearchBoxProvided } from 'react-instantsearch-core' | |
import { InputEvent } from '~/@types/model' | |
type Props = SearchBoxProvided & InputHTMLAttributes<any> | |
const SearchBox = ({ currentRefinement, refine, ...rest }: Props) => { | |
const onChange = useCallback( | |
(e: InputEvent) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const router = express.Router(); | |
const bodyParser = require("body-parser"); | |
const stripe = require("stripe")(STRIPE_CLIENT_SECRET); | |
const app = express(); | |
app.use(bodyParser.json()); | |
const fetchProducts = async items => | |
stripe.skus.list({ |