removed react-instantsearch-dom

This commit is contained in:
shams mosowi
2019-09-26 16:52:16 +10:00
parent ae5042b291
commit 7809115e28
3 changed files with 28 additions and 66 deletions

View File

@@ -33,7 +33,6 @@
"react-data-grid-addons": "^6.1.0",
"react-dom": "^16.9.0",
"react-dropzone": "^10.1.8",
"react-instantsearch-dom": "^5.7.0",
"react-router-dom": "^5.0.1",
"react-scripts": "3.1.1",
"react-virtualized": "^9.21.1",

View File

@@ -1,28 +1,13 @@
import React, { useState } from "react";
import React, { useState, useEffect } from "react";
import SearchIcon from "@material-ui/icons/Search";
import IconButton from "@material-ui/core/IconButton";
import Typography from "@material-ui/core/Typography";
import Button from "@material-ui/core/Button";
import { createStyles, makeStyles, Theme } from "@material-ui/core/styles";
import Popper from "@material-ui/core/Popper";
import Fade from "@material-ui/core/Fade";
import Paper from "@material-ui/core/Paper";
import TextareaAutosize from "@material-ui/core/TextareaAutosize";
import ClickAwayListener from "@material-ui/core/ClickAwayListener";
import { onSubmit } from "components/Table/grid-fns";
import { TextField } from "@material-ui/core";
import algoliasearch from "algoliasearch/lite";
import { TextField } from "@material-ui/core";
import {
InstantSearch,
Hits,
SearchBox,
Pagination,
Highlight,
ClearRefinements,
RefinementList,
Configure,
} from "react-instantsearch-dom";
const searchClient = algoliasearch(
process.env.REACT_APP_ALGOLIA_APP_ID
? process.env.REACT_APP_ALGOLIA_APP_ID
@@ -60,6 +45,15 @@ interface Props {
const DocSelect = (props: Props) => {
const { value, row, onSubmit, collectionPath } = props;
const [query, setQuery] = useState(value ? value : "");
const [hits, setHits] = useState<{}>([]);
const algoliaIndex = searchClient.initIndex(collectionPath);
const search = async (query: string) => {
const resp = await algoliaIndex.search({ query });
setHits(resp.hits);
};
useEffect(() => {
search(query);
}, [query]);
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
const classes = useStyles();
@@ -88,16 +82,23 @@ const DocSelect = (props: Props) => {
{value}
<Popper id={id} open={open} anchorEl={anchorEl}>
<Paper>
{/* <TextField id={id} placeholder={`searching ${collectionPath}`} /> */}
<TextField
id={id}
placeholder={`searching ${collectionPath}`}
onChange={(e: any) => {
setQuery(e.target.value);
}}
/>
<div className="ais-InstantSearch">
<InstantSearch
<div>
{/* <InstantSearch
indexName={collectionPath}
searchClient={searchClient}
>
<SearchBox />
<Hits hitComponent={Hit} />
</InstantSearch>
<SearchBox /> */}
{/* </InstantSearch> */}
</div>
</Paper>
</Popper>
@@ -110,8 +111,7 @@ const DocSelect = (props: Props) => {
const Hit = (props: any) => {
return (
<div>
<Highlight attribute="firstName" hit={props.hit} />
<h3>{props.hit.firstName}</h3>
<p>{props.hit.email}</p>
</div>
);

View File

@@ -2133,16 +2133,7 @@ ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.5.5:
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"
algoliasearch-helper@^2.26.0:
version "2.28.0"
resolved "https://registry.yarnpkg.com/algoliasearch-helper/-/algoliasearch-helper-2.28.0.tgz#1cafa7fcd02c15e9411c4d1778e9a4e89581916d"
integrity sha512-ZWczpkns2tw9sAtFL+1Cn3XAGkaunYS+ckldBrHHHQZj1/vw9n8SOGUO7lwpjuKXG9+TWgzx6XP3ZsG3iM+6hw==
dependencies:
events "^1.1.1"
lodash "^4.17.5"
qs "^6.5.1"
algoliasearch@^3.27.1, algoliasearch@^3.34.0:
algoliasearch@^3.34.0:
version "3.34.0"
resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-3.34.0.tgz#02eb97bd6718e3a2c71121b9c3b655a35a4ba645"
integrity sha512-s8LDedkTWTAWR5uCWgJzGxDkCrqiej5iE4Tc2iCV+ONOO35i5qnVdieKg5gv2VDXBE7IP0YoqfAq/CC0V8PA+Q==
@@ -4876,7 +4867,7 @@ eventemitter3@^3.0.0:
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.2.tgz#2d3d48f9c346698fce83a85d7d664e98535df6e7"
integrity sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==
events@^1.1.0, events@^1.1.1:
events@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924"
integrity sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=
@@ -7571,7 +7562,7 @@ lodash.uniq@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=
"lodash@>=3.5 <5", lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1:
"lodash@>=3.5 <5", lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1:
version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
@@ -9809,11 +9800,6 @@ qs@6.7.0:
resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc"
integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==
qs@^6.5.1:
version "6.9.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.0.tgz#d1297e2a049c53119cb49cca366adbbacc80b409"
integrity sha512-27RP4UotQORTpmNQDX8BHPukOnBP3p1uUJY5UnDhaJB+rMt9iMsok724XL+UHU23bEFOHRMQ2ZhI99qOWUMGFA==
qs@~6.5.2:
version "6.5.2"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
@@ -10023,29 +10009,6 @@ react-input-autosize@^2.1.2:
dependencies:
prop-types "^15.5.8"
react-instantsearch-core@^5.7.0:
version "5.7.0"
resolved "https://registry.yarnpkg.com/react-instantsearch-core/-/react-instantsearch-core-5.7.0.tgz#6979ec419d2711033f6c83181de6cae9e1f064c2"
integrity sha512-fjexlv+hR8OyZraAmjwM+GmiVcJFzLUnufIKPMLO7/L4Mg5h0pETSXNBT22cCXTnda6XML//+GqQmWJFf+PBrA==
dependencies:
"@babel/runtime" "^7.1.2"
algoliasearch-helper "^2.26.0"
lodash "^4.17.4"
prop-types "^15.5.10"
react-instantsearch-dom@^5.7.0:
version "5.7.0"
resolved "https://registry.yarnpkg.com/react-instantsearch-dom/-/react-instantsearch-dom-5.7.0.tgz#5a9b0cfb461c08a349a5fdc5d1cff50b8f5fcf56"
integrity sha512-FwFZZXwgaYtLrXD9KJNlrPVkfw8JOqVgpDBvra547udF4zbacZUuX7/qTyMHjVW/Lz59t5T25vCGLzmQiO89YA==
dependencies:
"@babel/runtime" "^7.1.2"
algoliasearch "^3.27.1"
algoliasearch-helper "^2.26.0"
classnames "^2.2.5"
lodash "^4.17.4"
prop-types "^15.5.10"
react-instantsearch-core "^5.7.0"
react-is-deprecated@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/react-is-deprecated/-/react-is-deprecated-0.1.2.tgz#301148f86ea428fe8e673eca7a372160b7579dbd"