Revize a7ae217f
Přidáno uživatelem Václav Honzík před více než 2 roky(ů)
frontend/src/features/TrackingTool/trackingToolThunks.ts | ||
---|---|---|
1 | 1 |
import { createAsyncThunk } from '@reduxjs/toolkit' |
2 | 2 |
import axiosInstance from '../../api/api' |
3 |
import { RootState } from '../redux/store' |
|
4 |
import { MapPoint, PathVariant } from './pathUtils' |
|
3 | 5 |
|
4 | 6 |
export const sendTextForProcessing = createAsyncThunk( |
5 | 7 |
'trackingTool/sendTextForProcessing', |
... | ... | |
17 | 19 |
} |
18 | 20 |
} |
19 | 21 |
) |
22 |
|
|
23 |
// export const mergeWithImportedPath = createAsyncThunk('trackingTool/mergeWithImportedPath', async (jsonPath: PathVariant, { getState }) => { |
|
24 |
// if (!jsonPath) { |
|
25 |
// return undefined |
|
26 |
// } |
|
27 |
|
|
28 |
// // Get current state |
|
29 |
// const state = getState() as RootState |
|
30 |
// const { primaryPathIdx, pathVariants } = state.trackingTool |
|
31 |
|
|
32 |
// // Return undefined if there is no pathVariants or index is out of range |
|
33 |
// if (!pathVariants || pathVariants.length === 0 || primaryPathIdx >= pathVariants.length) { |
|
34 |
// return undefined |
|
35 |
// } |
|
36 |
|
|
37 |
// // Get the path and create a map to check whether some point with the same id already exists |
|
38 |
// const path = pathVariants[primaryPathIdx] |
|
39 |
// const pathMap = new Map(path.map((item) => [item.catalogItem.id as string, item])) |
|
40 |
|
|
41 |
// // Create an array of items to be replaced and items to be added to the end |
|
42 |
// const itemsToReplace: MapPoint[] = [] |
|
43 |
// const itemsToAdd: MapPoint[] = [] |
|
44 |
|
|
45 |
// jsonPath.forEach((item) => { |
|
46 |
// if (pathMap.has(item.catalogItem.id as string)) { |
|
47 |
// // @ts-ignore - we know that the id is a string and typescript refuses to acknowledge that |
|
48 |
// item.idx = pathMap[item.catalogItem.id as string].idx |
|
49 |
// itemsToReplace.push(item) |
|
50 |
// } else { |
|
51 |
// itemsToAdd.push(item) |
|
52 |
// } |
|
53 |
// }) |
|
54 |
|
|
55 |
// // Iterate over items to replace and replace them |
|
56 |
// const newPath = [...path] |
|
57 |
// itemsToReplace.forEach((item) => { |
|
58 |
// newPath[item.idx] = item |
|
59 |
// }) |
|
60 |
|
|
61 |
// // Add items to the end |
|
62 |
// itemsToAdd.forEach((item) => { |
|
63 |
// item.active = false |
|
64 |
// item.idx = newPath.length |
|
65 |
// newPath.push(item) |
|
66 |
// }) |
|
67 |
|
|
68 |
// // Return the new path |
|
69 |
// return newPath |
|
70 |
// }) |
Také k dispozici: Unified diff
import export part 1
re #9741