mirror of
https://github.com/ershisan99/it-incubator-todolist-ts-17-live-2024-08-17.git
synced 2026-02-05 05:12:08 +00:00
chore: refactor app reducer to use rtk
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
import { todolistsAPI, TodolistType } from 'api/todolists-api'
|
||||
import { Dispatch } from 'redux'
|
||||
import {
|
||||
RequestStatusType,
|
||||
SetAppErrorActionType,
|
||||
setAppStatusAC,
|
||||
SetAppStatusActionType,
|
||||
} from 'app/app-reducer'
|
||||
import { RequestStatusType, setAppStatusAC } from 'app/app-reducer'
|
||||
import { handleServerNetworkError } from 'utils/error-utils'
|
||||
import { AppThunk } from 'app/store'
|
||||
|
||||
@@ -110,8 +105,8 @@ export const fetchTodolistsTC = (): AppThunk => {
|
||||
})
|
||||
}
|
||||
}
|
||||
export const removeTodolistTC = (todolistId: string) => {
|
||||
return (dispatch: ThunkDispatch) => {
|
||||
export const removeTodolistTC = (todolistId: string): AppThunk => {
|
||||
return (dispatch) => {
|
||||
//изменим глобальный статус приложения, чтобы вверху полоса побежала
|
||||
dispatch(setAppStatusAC('loading'))
|
||||
//изменим статус конкретного тудулиста, чтобы он мог задизеблить что надо
|
||||
@@ -125,8 +120,8 @@ export const removeTodolistTC = (todolistId: string) => {
|
||||
})
|
||||
}
|
||||
}
|
||||
export const addTodolistTC = (title: string) => {
|
||||
return (dispatch: ThunkDispatch) => {
|
||||
export const addTodolistTC = (title: string): AppThunk => {
|
||||
return (dispatch) => {
|
||||
dispatch(setAppStatusAC('loading'))
|
||||
todolistsAPI.createTodolist(title).then((res) => {
|
||||
dispatch(addTodolistAC(res.data.data.item))
|
||||
@@ -158,6 +153,3 @@ export type TodolistDomainType = TodolistType & {
|
||||
filter: FilterValuesType
|
||||
entityStatus: RequestStatusType
|
||||
}
|
||||
type ThunkDispatch = Dispatch<
|
||||
ActionsType | SetAppStatusActionType | SetAppErrorActionType
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user