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{
name: string;
category: string;
characteristics: {
id:number,
score:number,
characteristic: {
name: string;
value: string;
}[];

View File

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

View File

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

View File

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