add prettier and reformat all files

This commit is contained in:
2022-07-11 12:23:43 +02:00
parent 35e4d96726
commit dfab85da65
72 changed files with 1065 additions and 823 deletions

View File

@@ -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
}
}
}