2022-10-22 10:37:05 +03:00
|
|
|
import {createAsyncThunk} from '@reduxjs/toolkit'
|
2022-10-22 19:11:56 +03:00
|
|
|
import {INode, IProduct, IHint, hints} from './nodesInputReducer';
|
2022-10-22 10:37:05 +03:00
|
|
|
import search_api from '../../pages/api/search';
|
|
|
|
import create_hints_api from '../../pages/api/create_hints';
|
|
|
|
|
|
|
|
export const createHints = createAsyncThunk(
|
|
|
|
'nodesInput/createHints',
|
2022-10-22 19:11:56 +03:00
|
|
|
async (data: {word: string, hints: INode[]}, thunkApi) => {
|
|
|
|
console.log("thunk")
|
|
|
|
const response: IHint[] = await create_hints_api(data.word,[]);
|
2022-10-22 10:37:05 +03:00
|
|
|
//TODO: добавить сеть
|
2022-10-22 19:11:56 +03:00
|
|
|
console.log(response, "RESP")
|
2022-10-22 10:37:05 +03:00
|
|
|
return response;
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
export const search = createAsyncThunk(
|
|
|
|
'nodesInput/search',
|
|
|
|
async (nodes: INode[], thunkApi) => {
|
2022-10-22 19:11:56 +03:00
|
|
|
|
2022-10-22 10:37:05 +03:00
|
|
|
const response: IProduct[] = await search_api(nodes) as IProduct[];
|
2022-10-22 19:11:56 +03:00
|
|
|
|
2022-10-22 10:37:05 +03:00
|
|
|
return response;
|
|
|
|
}
|
|
|
|
)
|