From 972b7f292cccbd022d10b14d8b04b7326a35c5d9 Mon Sep 17 00:00:00 2001
From: Just-Simon-Dev <39631698+Just-Simon-Dev@users.noreply.github.com>
Date: Sat, 27 May 2023 04:00:16 +0200
Subject: [PATCH] =?UTF-8?q?some=20stuff=20idk=20what=20is=20it=F0=9F=98=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../frontend/src/app/models/solution.model.ts | 5 ++-
.../solutions/solutions.component.html | 5 ++-
.../modules/solutions/solutions.component.ts | 18 +++++++++--
.../src/app/services/solutions.service.ts | 32 +++++++++++++++++++
.../src/app/store/reducer/issue.reducer.ts | 6 ++++
.../app/store/selectors/issue.selectors.ts | 4 +++
6 files changed, 65 insertions(+), 5 deletions(-)
create mode 100644 apps/frontend/src/app/services/solutions.service.ts
diff --git a/apps/frontend/src/app/models/solution.model.ts b/apps/frontend/src/app/models/solution.model.ts
index d7d9569..fed9526 100644
--- a/apps/frontend/src/app/models/solution.model.ts
+++ b/apps/frontend/src/app/models/solution.model.ts
@@ -1,5 +1,8 @@
import { CommentModel } from './comment.model';
export interface SolutionModel {
- comments: CommentModel[];
+ title: string,
+ description: string,
+ comments: CommentModel[],
+ createdAt: Date
}
diff --git a/apps/frontend/src/app/modules/solutions/solutions.component.html b/apps/frontend/src/app/modules/solutions/solutions.component.html
index c418c67..90e3e1e 100644
--- a/apps/frontend/src/app/modules/solutions/solutions.component.html
+++ b/apps/frontend/src/app/modules/solutions/solutions.component.html
@@ -1 +1,4 @@
-
solutions works!
+
+ {{solution.title}}
+
+gv gvghv
\ No newline at end of file
diff --git a/apps/frontend/src/app/modules/solutions/solutions.component.ts b/apps/frontend/src/app/modules/solutions/solutions.component.ts
index 906aff9..c774346 100644
--- a/apps/frontend/src/app/modules/solutions/solutions.component.ts
+++ b/apps/frontend/src/app/modules/solutions/solutions.component.ts
@@ -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 = EMPTY
+ constructor(private store: Store){}
+ ngOnInit(): void {
+ this.store.dispatch(receiveAllIssuesAction())
+ this.solutions$ = this.store.select(selectAllSolutions)
+
+ }
}
diff --git a/apps/frontend/src/app/services/solutions.service.ts b/apps/frontend/src/app/services/solutions.service.ts
new file mode 100644
index 0000000..1af2224
--- /dev/null
+++ b/apps/frontend/src/app/services/solutions.service.ts
@@ -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('/issue/'+id+'/solution').pipe(
+ map((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
+}
diff --git a/apps/frontend/src/app/store/reducer/issue.reducer.ts b/apps/frontend/src/app/store/reducer/issue.reducer.ts
index d24f399..3daeb1b 100644
--- a/apps/frontend/src/app/store/reducer/issue.reducer.ts
+++ b/apps/frontend/src/app/store/reducer/issue.reducer.ts
@@ -24,6 +24,12 @@ const initialState: IssueState = {
photos: [],
status: 'new',
type: 'problem',
+ solution: {
+ comments: [],
+ createdAt: new Date(),
+ description: "eoooo",
+ title: "title"
+ },
comments: [],
},
{
diff --git a/apps/frontend/src/app/store/selectors/issue.selectors.ts b/apps/frontend/src/app/store/selectors/issue.selectors.ts
index 2a566fc..878c4ba 100644
--- a/apps/frontend/src/app/store/selectors/issue.selectors.ts
+++ b/apps/frontend/src/app/store/selectors/issue.selectors.ts
@@ -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');
@@ -12,3 +14,5 @@ export const selectIssue = (id: string) =>
createSelector(selectAllIssues, (issues) =>
issues.find((issue) => issue.id === id)
);
+
+ export const selectAllSolutions = createSelector(selectAllIssues, issues => issues.map(issue => issue.solution).filter(solution => solution !== undefined) as SolutionModel[])
\ No newline at end of file