-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Миграция проекта на NGRX для управления состоянием приложения #106
base: master
Are you sure you want to change the base?
Conversation
server.ts
Outdated
import { dirname, join, resolve } from 'node:path'; | ||
import bootstrap from './src/main.server'; | ||
|
||
// The Express app is exported so that it can be used by serverless Functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
почистите комменты
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Внес все правки и запушил изменения. Все в последнем коммите
export const loadUserEffect = createEffect( | ||
() => { | ||
const api = inject(UserApiService); | ||
const actions$ = inject(Actions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
перед return всегда ставьте empty line
src/app/NGRX/reducer.ts
Outdated
|
||
export const userReducer = createReducer( | ||
initialState, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лишняя пустая строка
src/app/NGRX/selector.ts
Outdated
@@ -0,0 +1,18 @@ | |||
// import { User } from '../user-card/user-card.component'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
почистите комментарии везде
src/app/NGRX/state.ts
Outdated
export interface UserState { | ||
users: User[]; | ||
loading: boolean; | ||
error: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
типизируйте ошибку
@Output() deleteUserRequest = new EventEmitter<number>(); // Создание события удаления пользователя | ||
|
||
title = 'title'; | ||
constructor() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем пустой constructor удалите
@Input() user!: User; | ||
@Output() deleteUserRequest = new EventEmitter<number>(); // Создание события удаления пользователя | ||
|
||
title = 'title'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавляйте модификаторы доступа и readonly по надобности
<div>{{ user.username }}</div> | ||
<button (click)="deleteUser(user.id)">delete</button> | ||
|
||
<!-- <button (click)="editUser(user)">edit</button> --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
чистите комментарии
imports: [NgFor, AsyncPipe, CreateEditCard], | ||
}) | ||
export class UserList implements OnInit { | ||
private store = inject(Store); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавляйте readonly по надобности
// }); | ||
|
||
this.users$.subscribe((users) => { | ||
console.log('Current Users:', users); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем лог?
.gitignore
Outdated
@@ -40,3 +40,7 @@ testem.log | |||
# System files | |||
.DS_Store | |||
Thumbs.db | |||
|
|||
# Игнорировать изображения |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
удалите комментарий
src/app/NGRX/actions.ts
Outdated
export const setUsers = createAction( | ||
'[User] Set Users', | ||
props<{ users: User[] }>() | ||
); // Добавлен метод setUsers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
удалите комментарий
src/app/NGRX/selector.ts
Outdated
@@ -0,0 +1,18 @@ | |||
// import { User } from '../user-card/user-card.component'; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лишняя пустая строка
src/app/app.component.ts
Outdated
}) | ||
export class AppComponent { | ||
title = 'mentoring-first-project'; | ||
title = 'title'; | ||
currentUser: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не используйте any
left: 50%; | ||
transform: translate(-50%, -50%); | ||
border: 1px solid black; /* добавляем рамку толщиной 1px и цвета #ccc */ | ||
padding: 20px; /* добавляем отступы внутри формы */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
удалите комментарий
}); | ||
|
||
// const usersFromLocalStorage = localStorage.getItem('users'); | ||
// if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
удалите комментарий
// JSON.parse(usersFromLocalStorage).length === 0 | ||
// ) { | ||
// this.userApiService.getUsers().subscribe((data: any[]) => { | ||
this.store.dispatch(UserActions.loadUsers()); // Загружаем пользователей |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
удалите комментарий
} | ||
|
||
openModal(user?: User) { | ||
const isEdit = Boolean(user); // todo подумай как можно обойтись без этого |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
удалите комментарий
dialogRef.afterClosed().subscribe((newUser) => { | ||
if (!newUser) return; | ||
|
||
// Приведение типов данных |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
удалите комментарий
// Приведение типов данных | ||
newUser.id = +newUser.id; | ||
|
||
console.log('User to save: ', newUser); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
удалите лог
No description provided.