This commit is contained in:
Firesieht 2022-10-22 21:01:16 +03:00
parent d7c4e9ad12
commit 8a98ea23a8
5 changed files with 16 additions and 7 deletions

View File

@ -1 +1 @@
export const host = "https://0c9e-5-227-22-1.eu.ngrok.io/api/" export const host = "https://7ee1-5-227-22-5.eu.ngrok.io/api/"

View File

@ -15,7 +15,9 @@ export interface IHint{
export interface IProduct{ export interface IProduct{
name: string; name: string;
category: string; category: string;
characteristics: { id:number,
score:number,
characteristic: {
name: string; name: string;
value: string; value: string;
}[]; }[];

View File

@ -1,23 +1,25 @@
import { Card } from "antd"; import { Card } from "antd";
import React from "react"; import React from "react";
import { useAppSelector } from "../../hooks"; import { useAppSelector } from "../../hooks";
import { fetcher } from "../../pages/api/fetch";
import { products } from "../../store/reducers/nodesInputReducer"; import { products } from "../../store/reducers/nodesInputReducer";
export const ProductsView:React.FC = () =>{ export const ProductsView:React.FC = () =>{
const getProducts = useAppSelector(products) const getProducts = useAppSelector(products)
console.log(getProducts) console.log("Продукты", getProducts)
return( return(
<div> <div>
{ {
getProducts.map(el=> <Card title={el.name} bordered={true}> getProducts.map(el=> <Card title={el.name} bordered={true}>
<div> <div>
{el.category} {el.score}
</div> </div>
<div> <div>
{ {
el.characteristics == undefined? "":el.characteristics.toString() el.characteristic == undefined? "":el.characteristic.map(e=><div><div>{e.name}</div><div>{e.value}</div></div>)
} }
</div> </div>
<div onClick={()=>fetcher.post("/score/"+el.id)}>Посмотреть</div>
</Card>) </Card>)
} }

View File

@ -4,6 +4,8 @@ import { fetcher } from "../../pages/api/fetch";
import { useAppDispatch, useAppSelector } from "../../hooks"; import { useAppDispatch, useAppSelector } from "../../hooks";
import { hints, INode, products } from "../../store/reducers/nodesInputReducer"; import { hints, INode, products } from "../../store/reducers/nodesInputReducer";
import { createHints, search } from "../../store/reducers/asyncActions"; import { createHints, search } from "../../store/reducers/asyncActions";
import styles from "./search.module.css"
export const Search: React.FC<{onData:(data:any)=>void}> = (props) =>{ export const Search: React.FC<{onData:(data:any)=>void}> = (props) =>{
const [data, setData] = useState("") const [data, setData] = useState("")
@ -12,9 +14,9 @@ export const Search: React.FC<{onData:(data:any)=>void}> = (props) =>{
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const getHints = useAppSelector(hints); const getHints = useAppSelector(hints);
const [autoCompleteValue, setAutoCompleteValue] = useState("") const [autoCompleteValue, setAutoCompleteValue] = useState("")
const onChange = (text:string) =>{ const onChange = (text:string) =>{
if (text.length >= 3 && text.length%3 == 0){ if (text.length >= 3 && text.length%3 == 0){
dispatch( dispatch(
createHints({word:text, hints:getHints.length == 0? []: getHints.map((el)=>el.value)}) createHints({word:text, hints:getHints.length == 0? []: getHints.map((el)=>el.value)})
) )
@ -61,9 +63,9 @@ export const Search: React.FC<{onData:(data:any)=>void}> = (props) =>{
onSelect={onSelect as any} onSelect={onSelect as any}
value={autoCompleteValue} value={autoCompleteValue}
onChange={(e)=>setAutoCompleteValue(e)} onChange={(e)=>setAutoCompleteValue(e)}
// onSearch={handleSearch}
> >
<Input.Search prefix={tags} <Input.Search prefix={tags}
className={styles.search}
onChange={(e)=>onChange(e.target.value)} onChange={(e)=>onChange(e.target.value)}
value={data} value={data}
onSearch={(e) => onEnter(e)} onSearch={(e) => onEnter(e)}

View File

@ -0,0 +1,3 @@
.search{
}