diff --git a/src/s2-homeworks/hw05/pages/Junior.tsx b/src/s2-homeworks/hw05/pages/Junior.tsx index 540acec..df6e621 100644 --- a/src/s2-homeworks/hw05/pages/Junior.tsx +++ b/src/s2-homeworks/hw05/pages/Junior.tsx @@ -1,7 +1,7 @@ import React from 'react' import HW6 from '../../hw06/HW6' import HW7 from '../../hw07/HW7' -// import HW8 from '../../hw08/HW8' +import HW8 from '../../hw08/HW8' // import HW9 from '../../hw09/HW9' function Junior() { @@ -9,7 +9,7 @@ function Junior() {
- {/**/} + {/**/}
) diff --git a/src/s2-homeworks/hw08/HW8.module.css b/src/s2-homeworks/hw08/HW8.module.css index ce36473..bbccbfb 100644 --- a/src/s2-homeworks/hw08/HW8.module.css +++ b/src/s2-homeworks/hw08/HW8.module.css @@ -20,15 +20,18 @@ display: flex; flex-direction: column; align-items: flex-end; - width: max-content; gap: 20px; + width: max-content; + height: 400px; } .thead { + height: 36px; padding-left: 17px; + background-color: #E5E5E5; border: none; - height: 36px; + font-weight: 600; font-size: 14px; line-height: 16px; diff --git a/src/s2-homeworks/hw08/HW8.tsx b/src/s2-homeworks/hw08/HW8.tsx index 4fe190e..3b26e88 100644 --- a/src/s2-homeworks/hw08/HW8.tsx +++ b/src/s2-homeworks/hw08/HW8.tsx @@ -5,8 +5,13 @@ import s2 from '../../s1-main/App.module.css' import SuperButton from '../hw04/common/c2-SuperButton/SuperButton' import User from './User' +/* +* 1 - дописать типы и логику (сортировка по имени, фильтрация по совершеннолетию) homeWorkReducer, проверить тестом +* 2 - дописать компоненту User +* 3 - сделать стили в соответствии с дизайном +* */ + export type UserType = { - // need to fix any _id: number name: string age: number @@ -23,9 +28,9 @@ const initialPeople: UserType[] = [ ] const HW8 = () => { - const [people, setPeople] = useState(initialPeople) // need to fix any + const [people, setPeople] = useState(initialPeople) const [currentSort, setCurrentSort] = useState('') - // need to fix any + const finalPeople = people.map((u: UserType) => ) const sortUp = () => { @@ -77,7 +82,6 @@ const HW8 = () => { - @@ -85,6 +89,7 @@ const HW8 = () => { + {finalPeople}
Age
diff --git a/src/s2-homeworks/hw08/User.tsx b/src/s2-homeworks/hw08/User.tsx index acda042..fbc006b 100644 --- a/src/s2-homeworks/hw08/User.tsx +++ b/src/s2-homeworks/hw08/User.tsx @@ -11,9 +11,13 @@ const User: React.FC = ({ u }) => { return ( + {/*отобразить имя*/} {u.name} - {u.age} + + {/*отобразить возраст*/} + {u.age} + ) } diff --git a/src/s2-homeworks/hw08/bll/homeWorkReducer.ts b/src/s2-homeworks/hw08/bll/homeWorkReducer.ts index a231def..5161ddc 100644 --- a/src/s2-homeworks/hw08/bll/homeWorkReducer.ts +++ b/src/s2-homeworks/hw08/bll/homeWorkReducer.ts @@ -1,18 +1,13 @@ -import { UserType } from '../HW8' +import {UserType} from '../HW8' 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 // делают студенты - ) { - case 'sort': { +export const homeWorkReducer = (state: any, action: any): any => { // need to fix any + switch (action.type) { + // делают студенты + case 'sort': { // by name const newState = [...state].sort((a, b) => { if (a.name > b.name) return 1 else if (a.name < b.name) return -1 @@ -22,7 +17,7 @@ export const homeWorkReducer = ( return action.payload === 'up' ? newState : newState.reverse() } case 'check': { - return state.filter((a) => a.age >= action.payload) + return state.filter((a: any) => a.age >= action.payload) } default: return state