Skip to content
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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Azat-it
Copy link

@Azat-it Azat-it commented Dec 31, 2024

No description provided.

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

почистите комменты

Copy link
Author

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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

перед return всегда ставьте empty line


export const userReducer = createReducer(
initialState,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лишняя пустая строка

@@ -0,0 +1,18 @@
// import { User } from '../user-card/user-card.component';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

почистите комментарии везде

export interface UserState {
users: User[];
loading: boolean;
error: any;

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() {}

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';

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

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);

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);

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

# Игнорировать изображения

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

удалите комментарий

export const setUsers = createAction(
'[User] Set Users',
props<{ users: User[] }>()
); // Добавлен метод setUsers

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

удалите комментарий

@@ -0,0 +1,18 @@
// import { User } from '../user-card/user-card.component';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лишняя пустая строка

})
export class AppComponent {
title = 'mentoring-first-project';
title = 'title';
currentUser: any;

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; /* добавляем отступы внутри формы */

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 (

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()); // Загружаем пользователей

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 подумай как можно обойтись без этого

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;

// Приведение типов данных

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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

удалите лог

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants