Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 04fdedc6

Přidáno uživatelem Václav Honzík před asi 2 roky(ů)

Adjustments

re #9629

Zobrazit rozdíly:

frontend/src/features/TrackingTool/trackingToolSlice.ts
1 1
import { createSlice } from '@reduxjs/toolkit'
2 2
import { LatLngTuple } from 'leaflet'
3
import { persistReducer } from 'redux-persist'
3 4
import mapConfig from '../../config/mapConfig'
4 5
import { PathDto } from '../../swagger/data-contracts'
5 6
import buildPathVariants, { PathVariant } from './buildPathVariants'
6 7
import { sendTextForProcessing } from './trackingToolThunks'
8
import storage from 'redux-persist/lib/storage'
7 9

  
8 10
export interface TrackingToolState {
9 11
    isLoading: boolean // whether the data is being loaded
......
36 38
        pathVariant.length,
37 39
]
38 40

  
41
const persistConfig = {
42
    key: 'auth',
43
    storage, // localStorage for browsers
44
}
45

  
39 46
export const trackingToolSlice = createSlice({
40 47
    name: 'trackingTool',
41 48
    initialState,
......
49 56
            ...state,
50 57
            dialogApiCallSuccess: false,
51 58
        }),
59
        clear: (state) => ({...initialState})
52 60
    },
53 61
    extraReducers: (builder) => {
54 62
        builder.addCase(sendTextForProcessing.fulfilled, (state, action) => {
55
            const dto: PathDto = action.payload
56
            const pathVariants = buildPathVariants(dto)
63
            const pathDto: PathDto = action.payload
64
            const pathVariants = buildPathVariants(pathDto)
57 65
            return {
58 66
                ...state,
59 67
                pathVariants,
68
                pathDto,
60 69
                // TODO map this correctly
61 70
                activePaths: new Set(pathVariants.map((_, idx) => idx)),
62 71
                // TODO calculate correctly
......
84 93
    },
85 94
})
86 95

  
87
export const { consumeErr, setPrimaryIdx, resetDialogApiCallSuccess } = trackingToolSlice.actions
96
export const { consumeErr, setPrimaryIdx, resetDialogApiCallSuccess, clear } = trackingToolSlice.actions
88 97
const trackingToolReducer = trackingToolSlice.reducer
89 98
export default trackingToolReducer

Také k dispozici: Unified diff