mirror of
https://github.com/IgnatZakalinsky/home-works.git
synced 2026-01-30 04:52:05 +00:00
add prettier and reformat all files
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
import {UserType} from '../HW8'
|
||||
import { UserType } from '../HW8'
|
||||
|
||||
type ActionType = {type: 'sort', payload: 'up' | 'down'} | {type: 'check', payload: number}
|
||||
type ActionType =
|
||||
| { type: 'sort'; payload: 'up' | 'down' }
|
||||
| { type: 'check'; payload: number }
|
||||
|
||||
export const homeWorkReducer = (state: UserType[], action: ActionType): UserType[] => { // need to fix any
|
||||
switch (action.type) { // делают студенты
|
||||
export const homeWorkReducer = (
|
||||
state: UserType[],
|
||||
action: ActionType
|
||||
): UserType[] => {
|
||||
// need to fix any
|
||||
switch (
|
||||
action.type // делают студенты
|
||||
) {
|
||||
case 'sort': {
|
||||
const newState = [...state].sort((a, b) => {
|
||||
if (a.name > b.name) return 1
|
||||
@@ -14,8 +22,9 @@ export const homeWorkReducer = (state: UserType[], action: ActionType): UserType
|
||||
return action.payload === 'up' ? newState : newState.reverse()
|
||||
}
|
||||
case 'check': {
|
||||
return state.filter(a => a.age >= action.payload)
|
||||
return state.filter((a) => a.age >= action.payload)
|
||||
}
|
||||
default: return state
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user