Archived
some stuff idk what is it😂
This commit is contained in:
1 parent
9216dd0726
commit
972b7f292c
6 files changed
+64
-4
No files matched your search
@@ -1,5 +1,8 @@
|
||||
import { CommentModel } from './comment.model';
|
||||
|
||||
export interface SolutionModel {
|
||||
comments: CommentModel[];
|
||||
title: string,
|
||||
description: string,
|
||||
comments: CommentModel[],
|
||||
createdAt: Date
|
||||
}
|
||||
@@ -1 +1,4 @@
|
||||
<p>solutions works!</p>
|
||||
<div *ngFor="let solution of solutions$ | async">
|
||||
{{solution.title}}
|
||||
</div>
|
||||
gv gvghv
|
||||
@@ -1,10 +1,22 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { EMPTY, Observable } from 'rxjs';
|
||||
import { SolutionModel } from 'src/app/models/solution.model';
|
||||
import { receiveAllIssuesAction } from 'src/app/store/actions/issue.actions';
|
||||
import { selectAllSolutions } from 'src/app/store/selectors/issue.selectors';
|
||||
import { SolutionsModule } from './solutions.module';
|
||||
|
||||
@Component({
|
||||
selector: 'app-solutions',
|
||||
templateUrl: './solutions.component.html',
|
||||
styleUrls: ['./solutions.component.scss']
|
||||
})
|
||||
export class SolutionsComponent {
|
||||
export class SolutionsComponent implements OnInit {
|
||||
solutions$: Observable<SolutionModel[]> = EMPTY
|
||||
constructor(private store: Store){}
|
||||
ngOnInit(): void {
|
||||
this.store.dispatch(receiveAllIssuesAction())
|
||||
this.solutions$ = this.store.select(selectAllSolutions)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { map } from 'rxjs';
|
||||
import { SolutionModel } from '../models/solution.model';
|
||||
import { CommentModel } from '../models/comment.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class IssueService {
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
getSolutions(id: string) {
|
||||
return this.http.get<SolutionDto[]>('/issue/'+id+'/solution').pipe(
|
||||
map<SolutionDto[], SolutionModel[]>((solution) =>
|
||||
solution.map((solution) => ({
|
||||
title: solution.title,
|
||||
description: solution.description,
|
||||
comments: solution.comments,
|
||||
createdAt: solution.createdAt
|
||||
}))
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
interface SolutionDto {
|
||||
title: string,
|
||||
description: string,
|
||||
comments: CommentModel[],
|
||||
createdAt: Date
|
||||
}
|
||||
@@ -24,6 +24,12 @@ const initialState: IssueState = {
|
||||
photos: [],
|
||||
status: 'new',
|
||||
type: 'problem',
|
||||
solution: {
|
||||
comments: [],
|
||||
createdAt: new Date(),
|
||||
description: "eoooo",
|
||||
title: "title"
|
||||
},
|
||||
comments: [],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { createFeatureSelector, createSelector } from '@ngrx/store';
|
||||
import { IssueState } from '../state/issue.state';
|
||||
import { SolutionModel } from 'src/app/models/solution.model';
|
||||
import { IssueModel } from 'src/app/models/issue.model';
|
||||
|
||||
const selectIssueFeatureState = createFeatureSelector<IssueState>('issueState');
|
||||
|
||||
@@ -12,3 +14,5 @@ export const selectIssue = (id: string) =>
|
||||
createSelector(selectAllIssues, (issues) =>
|
||||
issues.find((issue) => issue.id === id)
|
||||
);
|
||||
|
||||
export const selectAllSolutions = createSelector<any, IssueModel[], SolutionModel[]>(selectAllIssues, issues => issues.map(issue => issue.solution).filter(solution => solution !== undefined) as SolutionModel[])
|
||||
Reference in new issue
Block a user