From b11813ac668a8cf2318e3b3e119a47f4eca4db2f Mon Sep 17 00:00:00 2001
From: "jvanboxtel@wisc.edu" <jvanboxtel@wisc.edu>
Date: Tue, 2 Jul 2019 13:20:03 -0500
Subject: [PATCH] ROENROLL-1852 setup requests with real dars api

---
 proxy.json                                     | 11 +----------
 src/app/dars/audit/audit.component.html        |  2 +-
 src/app/dars/dars-view/dars-view.component.ts  | 11 +++++++++--
 src/app/dars/services/api.service.ts           | 10 +++++-----
 src/app/degree-planner/services/api.service.ts |  3 ++-
 5 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/proxy.json b/proxy.json
index 45cb026..ff5f877 100644
--- a/proxy.json
+++ b/proxy.json
@@ -1,15 +1,6 @@
 {
-  "/api/dars": {
-    "target": "https://wb30v3sls6.execute-api.us-east-1.amazonaws.com/dev",
-    "secure": false,
-    "changeOrigin": true,
-    "logLevel": "info",
-    "pathRewrite": {
-      "^/api/dars": ""
-    }
-  },
   "/api": {
-    "target": "https://j5dg9sv034.execute-api.us-east-1.amazonaws.com/dev",
+    "target": "https://test.enroll.wisc.edu:8443",
     "secure": false,
     "changeOrigin": true,
     "logLevel": "info"
diff --git a/src/app/dars/audit/audit.component.html b/src/app/dars/audit/audit.component.html
index fbe33ef..04d7fd7 100644
--- a/src/app/dars/audit/audit.component.html
+++ b/src/app/dars/audit/audit.component.html
@@ -1,4 +1,4 @@
-<mat-card id="audit">
+<mat-card id="audit" *ngIf="audit">
   <header id="audit-header" class="no-horizontal-padding">
     <div class="audit-metadata">
       <div>
diff --git a/src/app/dars/dars-view/dars-view.component.ts b/src/app/dars/dars-view/dars-view.component.ts
index 7240c02..5cc995c 100644
--- a/src/app/dars/dars-view/dars-view.component.ts
+++ b/src/app/dars/dars-view/dars-view.component.ts
@@ -1,3 +1,4 @@
+import { StartSendingAudit } from './../store/actions';
 import { MediaMatcher } from '@angular/cdk/layout';
 import { Component, OnInit } from '@angular/core';
 import { AuditMetadata } from '../models/audit-metadata';
@@ -50,7 +51,6 @@ export class DARSViewComponent implements OnInit {
     this.whatIfMetadata$ = this.store.select(selectors.whatIfMetadata);
     this.visibleAuditStatus$ = this.store.select(selectors.visibleAuditStatus);
     // this.audit$ = this.store.select(selectors.visibleAudit);
-    this.audit$ = this.api.getAudit(3);
     this.alerts$ = this.store.select(selectors.alerts);
   }
 
@@ -62,7 +62,14 @@ export class DARSViewComponent implements OnInit {
     this.dialog
       .open<any, any, NewDegreeAuditFields>(NewDegreeAuditDialogComponent)
       .afterClosed()
-      .subscribe(event => console.log(event));
+      .subscribe(event =>
+        this.store.dispatch(
+          new StartSendingAudit({
+            darsInstitutionCode: 'L&S',
+            darsDegreeProgramCode: 'BA  608',
+          }),
+        ),
+      );
   }
 
   public openWhatIfAuditDialog() {
diff --git a/src/app/dars/services/api.service.ts b/src/app/dars/services/api.service.ts
index ae64371..a4ddc66 100644
--- a/src/app/dars/services/api.service.ts
+++ b/src/app/dars/services/api.service.ts
@@ -12,7 +12,7 @@ const degreeProgramsResponse: DegreePrograms = require('../../../assets/mock-dat
 
 const HTTP_OPTIONS = {
   headers: new HttpHeaders({
-    'Content-Type': 'applications/json',
+    'Content-Type': 'application/json',
   }),
 };
 
@@ -66,9 +66,9 @@ export class DarsApiService {
    * Get a single audit.
    */
   public getAudit(reportId: number): Observable<Audit> {
-    // const url = `${environment.apiDarsUrl}/reports/${reportId}`;
-    // return this.http.get<any>(url, HTTP_OPTIONS);
-    return of(auditResponse);
+    const url = `${environment.apiDarsUrl}/auditresults?reportId=${reportId}`;
+    return this.http.get<any>(url, HTTP_OPTIONS);
+    // return of(auditResponse);
   }
 
   /**
@@ -78,7 +78,7 @@ export class DarsApiService {
     darsInstitutionCode: string,
     darsDegreeProgramCode: string,
   ): Observable<AuditMetadata> {
-    const url = `${environment.apiDarsUrl}/single-audit-requests`;
+    const url = `${environment.apiDarsUrl}/auditrequest`;
     return this.http.post<AuditMetadata>(
       url,
       { darsInstitutionCode, darsDegreeProgramCode },
diff --git a/src/app/degree-planner/services/api.service.ts b/src/app/degree-planner/services/api.service.ts
index 0d7c307..aba3236 100644
--- a/src/app/degree-planner/services/api.service.ts
+++ b/src/app/degree-planner/services/api.service.ts
@@ -355,7 +355,8 @@ export class DegreePlannerApiService {
 
   public getStudentInfo() {
     const url = `${environment.apiEnrollUrl}/studentInfo`;
-    return this.http.get<StudentInfo>(url, HTTP_OPTIONS);
+    // return this.http.get<StudentInfo>(url, HTTP_OPTIONS);
+    return of({});
   }
 
   /**
-- 
GitLab