mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-12 22:03:03 -05:00
fix: run prettier on all file to avoid prettier issue inside PR
This commit is contained in:
@@ -2,8 +2,8 @@ import { AsyncPipe, NgFor } from '@angular/common';
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
inject,
|
||||
OnInit,
|
||||
inject,
|
||||
} from '@angular/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { loadActivities } from './store/activity/activity.actions';
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { ApplicationConfig } from '@angular/core';
|
||||
import { provideStore } from '@ngrx/store';
|
||||
import { provideEffects } from '@ngrx/effects';
|
||||
import { provideStore } from '@ngrx/store';
|
||||
import { ActivityEffects } from './store/activity/activity.effects';
|
||||
import { UserEffects } from './store/user/user.effects';
|
||||
import { StatusEffects } from './store/status/status.effects';
|
||||
import {
|
||||
activityFeatureKey,
|
||||
activityReducer,
|
||||
} from './store/activity/activity.reducer';
|
||||
import { StatusEffects } from './store/status/status.effects';
|
||||
import { UserEffects } from './store/user/user.effects';
|
||||
|
||||
import { statusFeatureKey, statusReducer } from './store/status/status.reducer';
|
||||
|
||||
|
||||
@@ -13,18 +13,18 @@ export class ActivityEffects {
|
||||
concatMap(() =>
|
||||
this.ActivityService.fetchActivities().pipe(
|
||||
map((activities) =>
|
||||
ActivityActions.loadActivitiesSuccess({ activities })
|
||||
ActivityActions.loadActivitiesSuccess({ activities }),
|
||||
),
|
||||
catchError((error) =>
|
||||
of(ActivityActions.loadActivitiesFailure({ error }))
|
||||
)
|
||||
)
|
||||
)
|
||||
of(ActivityActions.loadActivitiesFailure({ error })),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
constructor(
|
||||
private actions$: Actions,
|
||||
private ActivityService: ActivityService
|
||||
private ActivityService: ActivityService,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -21,5 +21,5 @@ export const activityReducer = createReducer(
|
||||
on(ActivityActions.loadActivitiesFailure, (state) => ({
|
||||
state,
|
||||
activities: [],
|
||||
}))
|
||||
})),
|
||||
);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createFeatureSelector, createSelector } from '@ngrx/store';
|
||||
import { activityFeatureKey, ActivityState } from './activity.reducer';
|
||||
import { ActivityState, activityFeatureKey } from './activity.reducer';
|
||||
|
||||
export const selectActivityState =
|
||||
createFeatureSelector<ActivityState>(activityFeatureKey);
|
||||
|
||||
export const selectActivities = createSelector(
|
||||
selectActivityState,
|
||||
(state) => state.activities
|
||||
(state) => state.activities,
|
||||
);
|
||||
|
||||
@@ -5,5 +5,5 @@ export const loadStatuses = createAction('[Status] Load Statuses');
|
||||
|
||||
export const loadStatusesSuccess = createAction(
|
||||
'[Status] Load Statuses Success',
|
||||
props<{ statuses: Status[] }>()
|
||||
props<{ statuses: Status[] }>(),
|
||||
);
|
||||
|
||||
@@ -22,7 +22,7 @@ export class StatusEffects {
|
||||
return activities.reduce(
|
||||
(status: Status[], activity): Status[] => {
|
||||
const index = status.findIndex(
|
||||
(s) => s.name === activity.type
|
||||
(s) => s.name === activity.type,
|
||||
);
|
||||
if (index === -1) {
|
||||
return [
|
||||
@@ -34,16 +34,19 @@ export class StatusEffects {
|
||||
return status;
|
||||
}
|
||||
},
|
||||
[]
|
||||
[],
|
||||
);
|
||||
}
|
||||
return [];
|
||||
}),
|
||||
map((statuses) => StatusActions.loadStatusesSuccess({ statuses }))
|
||||
)
|
||||
)
|
||||
map((statuses) => StatusActions.loadStatusesSuccess({ statuses })),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
constructor(private actions$: Actions, private store: Store) {}
|
||||
constructor(
|
||||
private actions$: Actions,
|
||||
private store: Store,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -25,5 +25,5 @@ export const statusReducer = createReducer(
|
||||
statuses,
|
||||
teachersMap: map,
|
||||
};
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { createFeatureSelector, createSelector } from '@ngrx/store';
|
||||
import { ActivityType } from '../activity/activity.model';
|
||||
import { statusFeatureKey, StatusState } from './status.reducer';
|
||||
import { StatusState, statusFeatureKey } from './status.reducer';
|
||||
|
||||
export const selectStatusState =
|
||||
createFeatureSelector<StatusState>(statusFeatureKey);
|
||||
|
||||
export const selectStatuses = createSelector(
|
||||
selectStatusState,
|
||||
(state) => state.statuses
|
||||
(state) => state.statuses,
|
||||
);
|
||||
|
||||
export const selectAllTeachersByActivityType = (name: ActivityType) =>
|
||||
createSelector(
|
||||
selectStatusState,
|
||||
(state) => state.teachersMap.get(name) ?? []
|
||||
(state) => state.teachersMap.get(name) ?? [],
|
||||
);
|
||||
|
||||
@@ -13,11 +13,14 @@ export class UserEffects {
|
||||
concatMap(() =>
|
||||
this.userService.fetchUser().pipe(
|
||||
map((user) => UserActions.loadUsersSuccess({ user })),
|
||||
catchError((error) => of(UserActions.loadUsersFailure({ error })))
|
||||
)
|
||||
)
|
||||
catchError((error) => of(UserActions.loadUsersFailure({ error }))),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
constructor(private actions$: Actions, private userService: UserService) {}
|
||||
constructor(
|
||||
private actions$: Actions,
|
||||
private userService: UserService,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -15,5 +15,5 @@ export const initialState: UserState = {
|
||||
export const userReducer = createReducer(
|
||||
initialState,
|
||||
on(UserActions.loadUsersSuccess, (state, { user }) => ({ ...state, user })),
|
||||
on(UserActions.loadUsersFailure, (state) => ({ ...state, user: undefined }))
|
||||
on(UserActions.loadUsersFailure, (state) => ({ ...state, user: undefined })),
|
||||
);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { createFeatureSelector, createSelector } from '@ngrx/store';
|
||||
import { userFeatureKey, UserState } from './user.reducer';
|
||||
import { UserState, userFeatureKey } from './user.reducer';
|
||||
|
||||
export const selectUserState = createFeatureSelector<UserState>(userFeatureKey);
|
||||
|
||||
export const selectUser = createSelector(
|
||||
selectUserState,
|
||||
(state) => state.user
|
||||
(state) => state.user,
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
import { ApplicationConfig } from '@angular/core';
|
||||
import { provideStore } from '@ngrx/store';
|
||||
import { provideEffects } from '@ngrx/effects';
|
||||
import { TeacherEffects } from './teacher/store/teacher.effects';
|
||||
import { StudentEffects } from './student/store/student.effects';
|
||||
import { provideRouter } from '@angular/router';
|
||||
import { ROUTES } from './routes';
|
||||
import { APP_INITIALIZER, inject } from '@angular/core';
|
||||
import { FakeBackendService } from '@angular-challenges/ngrx-notification/backend';
|
||||
import { APP_INITIALIZER, ApplicationConfig, inject } from '@angular/core';
|
||||
import { provideRouter } from '@angular/router';
|
||||
import { provideEffects } from '@ngrx/effects';
|
||||
import { provideStore } from '@ngrx/store';
|
||||
import { NotificationService } from './data-access/notification.service';
|
||||
import {
|
||||
teacherReducer,
|
||||
teachersFeatureKey,
|
||||
} from './teacher/store/teacher.reducer';
|
||||
import { ROUTES } from './routes';
|
||||
import { StudentEffects } from './student/store/student.effects';
|
||||
import {
|
||||
studentReducer,
|
||||
studentsFeatureKey,
|
||||
} from './student/store/student.reducer';
|
||||
import { TeacherEffects } from './teacher/store/teacher.effects';
|
||||
import {
|
||||
teacherReducer,
|
||||
teachersFeatureKey,
|
||||
} from './teacher/store/teacher.reducer';
|
||||
|
||||
const REDUCERS = {
|
||||
[teachersFeatureKey]: teacherReducer,
|
||||
|
||||
@@ -22,12 +22,12 @@ export class NotificationService {
|
||||
.subscribe((notification: Push) => {
|
||||
if (isTeacher(notification)) {
|
||||
this.store.dispatch(
|
||||
teacherActions.addOneTeacher({ teacher: notification })
|
||||
teacherActions.addOneTeacher({ teacher: notification }),
|
||||
);
|
||||
}
|
||||
if (isStudent(notification)) {
|
||||
this.store.dispatch(
|
||||
studentActions.addOneStudent({ student: notification })
|
||||
studentActions.addOneStudent({ student: notification }),
|
||||
);
|
||||
}
|
||||
if (isSchool(notification)) {
|
||||
|
||||
@@ -35,11 +35,11 @@ export class SchoolStore
|
||||
this.httpService.getAllSchools().pipe(
|
||||
tapResponse(
|
||||
(schools) => this.patchState({ schools }),
|
||||
(_) => _
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(_) => _,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
ngrxOnStoreInit() {
|
||||
|
||||
@@ -16,8 +16,8 @@ export class StudentEffects {
|
||||
switchMap(() =>
|
||||
this.httpService
|
||||
.getAllStudents()
|
||||
.pipe(map((students) => studentActions.addAllStudents({ students })))
|
||||
)
|
||||
)
|
||||
.pipe(map((students) => studentActions.addAllStudents({ students }))),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ export const studentAdapter: EntityAdapter<Student> =
|
||||
export const studentReducer = createReducer(
|
||||
studentAdapter.getInitialState(),
|
||||
on(studentActions.addOneStudent, (state, { student }) =>
|
||||
studentAdapter.upsertOne(student, state)
|
||||
studentAdapter.upsertOne(student, state),
|
||||
),
|
||||
on(studentActions.addAllStudents, (state, { students }) =>
|
||||
studentAdapter.setAll(students, state)
|
||||
)
|
||||
studentAdapter.setAll(students, state),
|
||||
),
|
||||
);
|
||||
|
||||
export const { selectIds, selectEntities, selectAll, selectTotal } =
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { createFeatureSelector, createSelector } from '@ngrx/store';
|
||||
import {
|
||||
StudentState,
|
||||
studentAdapter,
|
||||
studentsFeatureKey,
|
||||
StudentState,
|
||||
} from './student.reducer';
|
||||
|
||||
const selectStudentState =
|
||||
|
||||
@@ -16,8 +16,8 @@ export class TeacherEffects {
|
||||
switchMap(() =>
|
||||
this.httpService
|
||||
.getAllTeachers()
|
||||
.pipe(map((teachers) => teacherActions.addAllTeachers({ teachers })))
|
||||
)
|
||||
)
|
||||
.pipe(map((teachers) => teacherActions.addAllTeachers({ teachers }))),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ export const teacherAdapter: EntityAdapter<Teacher> =
|
||||
export const teacherReducer = createReducer(
|
||||
teacherAdapter.getInitialState(),
|
||||
on(teacherActions.addOneTeacher, (state, { teacher }) =>
|
||||
teacherAdapter.upsertOne(teacher, state)
|
||||
teacherAdapter.upsertOne(teacher, state),
|
||||
),
|
||||
on(teacherActions.addAllTeachers, (state, { teachers }) =>
|
||||
teacherAdapter.setAll(teachers, state)
|
||||
)
|
||||
teacherAdapter.setAll(teachers, state),
|
||||
),
|
||||
);
|
||||
|
||||
export const { selectIds, selectEntities, selectAll, selectTotal } =
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { createFeatureSelector, createSelector } from '@ngrx/store';
|
||||
import {
|
||||
TeacherState,
|
||||
teacherAdapter,
|
||||
teachersFeatureKey,
|
||||
TeacherState,
|
||||
} from './teacher.reducer';
|
||||
|
||||
const selectTeacherState =
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
||||
@@ -5,5 +5,5 @@ import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { AppComponent } from './app/app.component';
|
||||
|
||||
bootstrapApplication(AppComponent, appConfig).catch((err) =>
|
||||
console.error(err)
|
||||
console.error(err),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user