Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2d3a4e2b

Přidáno uživatelem Michal Schwob před asi 2 roky(ů)

Fixed registering a closing the dialog after success
re #9627

Zobrazit rozdíly:

frontend/src/features/Auth/userSlice.ts
1 1
import { createSlice } from '@reduxjs/toolkit'
2 2
import { persistReducer } from 'redux-persist'
3 3
import storage from 'redux-persist/lib/storage'
4
import { logIn } from './userThunks'
4
import {logIn, register} from './userThunks'
5 5

  
6 6
export interface UserState {
7 7
    accessToken?: string
......
10 10
    roles: string[]
11 11
    isLoggingIn: boolean
12 12
    isLoggedIn: boolean
13
    lastErr?: string // consumable for errors during thunks
13
    lastErr?: string// consumable for errors during thunks
14
    isRegistered: boolean
14 15
}
15 16

  
16 17
const persistConfig = {
......
24 25
    isLoggedIn: false,
25 26
    isLoggingIn: false,
26 27
    username: '',
28
    isRegistered: false,
27 29
}
28 30

  
29 31
export const userSlice = createSlice({
......
43 45
        }),
44 46
        setUserState: (state, action) => ({ ...state, ...action.payload }),
45 47
        resetLoggingIn: (state) => ({ ...state, isLoggingIn: false }),
48
        resetIsRegistered: (state) => ({ ...state, isRegistered: false }),
46 49
    },
47 50

  
48 51
    // Thunks
......
58 61
        builder.addCase(logIn.pending, (state) => {
59 62
            return { ...state, isLoggingIn: true }
60 63
        })
64
        builder.addCase(register.fulfilled, (state, action) => {
65
            return {...state, isRegistered: true}
66
        })
61 67
    },
62 68
})
63 69

  
64 70
const userReducer = persistReducer(persistConfig, userSlice.reducer)
65 71

  
66
export const { logout, refreshTokens, setErr, setUserState, resetLoggingIn } =
72
export const { logout, refreshTokens, setErr, setUserState, resetLoggingIn, resetIsRegistered } =
67 73
    userSlice.actions
68 74

  
69 75
export default userReducer

Také k dispozici: Unified diff