6 changed files with 172 additions and 78 deletions
-
1.gitignore
-
1package.json
-
61src/app/pages/home/home.component.html
-
105src/app/pages/home/home.component.ts
-
28src/app/pages/home/home.service.ts
-
46src/app/pages/login/login/login.component.ts
@ -1,36 +1,37 @@ |
|||||
<div class="page-container" id="home-page"> |
<div class="page-container" id="home-page"> |
||||
|
|
||||
<div class="header-container"> |
|
||||
<app-header [headerInput]="headerProps"></app-header> |
|
||||
|
<div class="header-container"> |
||||
|
<app-header [headerInput]="headerProps"></app-header> |
||||
|
</div> |
||||
|
<main class="main-container"> |
||||
|
<div class="switch-tab"> |
||||
|
<p [ngClass]="{ active: isSalesForm }" (click)="switchSalesServiceTab()"> |
||||
|
Sales Upload |
||||
|
</p> |
||||
|
<p [ngClass]="{ active: !isSalesForm }" (click)="switchSalesServiceTab()"> |
||||
|
Service Upload |
||||
|
</p> |
||||
</div> |
</div> |
||||
<main class="main-container"> |
|
||||
|
|
||||
<div class="switch-tab"> |
|
||||
<p [ngClass]="{active: isSalesForm}" (click)="switchSalesServiceTab()">Sales Upload</p> |
|
||||
<p [ngClass]="{active: !isSalesForm}" (click)="switchSalesServiceTab()">Service Upload</p> |
|
||||
</div> |
|
||||
|
|
||||
<section id="from-first-section"> |
|
||||
<form [formGroup]="fileUploadForm" (submit)="submitForm()"> |
|
||||
<div class="input-wrapper"> |
|
||||
<br/> |
|
||||
<input |
|
||||
type="file" |
|
||||
formControlName="fileUpload" |
|
||||
class="user-input font-body-small-bold file-input" |
|
||||
placeholder="Upload sales file" |
|
||||
/> |
|
||||
</div> |
|
||||
|
|
||||
<button |
|
||||
[disabled]="(!fileUploadForm.valid || isLoading)"> |
|
||||
{{isLoading ? 'Sending messages' : 'Submit'}} |
|
||||
</button> |
|
||||
|
|
||||
</form> |
|
||||
</section> |
|
||||
|
<section id="from-first-section"> |
||||
|
<form [formGroup]="fileUploadForm" (submit)="submitForm()"> |
||||
|
<div class="input-wrapper"> |
||||
|
<br /> |
||||
|
<input |
||||
|
type="file" |
||||
|
class="user-input font-body-small-bold file-input" |
||||
|
placeholder="Upload sales file" |
||||
|
(change)="addfile($event)" |
||||
|
/> |
||||
|
<!-- formControlName="fileUpload" --> |
||||
|
</div> |
||||
|
|
||||
<p class="error font-body-small">{{error}}</p> |
|
||||
</main> |
|
||||
|
<!-- [disabled]="!fileUploadForm.valid || isLoading" --> |
||||
|
<button type="submit"> |
||||
|
{{ isLoading ? "Sending messages" : "Submit" }} |
||||
|
</button> |
||||
|
</form> |
||||
|
</section> |
||||
|
|
||||
|
<p class="error font-body-small">{{ error }}</p> |
||||
|
</main> |
||||
</div> |
</div> |
@ -1,21 +1,41 @@ |
|||||
// Angular imports
|
// Angular imports
|
||||
import { Injectable } from '@angular/core'; |
import { Injectable } from '@angular/core'; |
||||
import { HttpClient } from '@angular/common/http'; |
|
||||
|
import { HttpClient, HttpHeaders } from '@angular/common/http'; |
||||
import { Observable } from 'rxjs'; |
import { Observable } from 'rxjs'; |
||||
// Local imports
|
// Local imports
|
||||
import { IHomeRequest, IHomeResponse } from '../../../app/model/home'; |
import { IHomeRequest, IHomeResponse } from '../../../app/model/home'; |
||||
|
|
||||
|
const httpOptions = { |
||||
|
headers: new HttpHeaders({ |
||||
|
'Content-Type': 'application/json', |
||||
|
Authorization: |
||||
|
'Basic 2b8cba9008e1da2f2733ff8300cf1973-dc928670-56f9-4a29-8725-69239d669e74', |
||||
|
}), |
||||
|
}; |
||||
|
|
||||
|
// Authorization: 'Basic SW50ZXJuYXRpb25hbFdBX1BPQzpFeHBvcnRzITIwMjE=',
|
||||
|
|
||||
|
const url = 'http://localhost:3000/'; |
||||
|
const whatsAppUrl = |
||||
|
'https://mpwyr4.api.infobip.com/whatsapp/1/message/template'; |
||||
|
|
||||
@Injectable({ |
@Injectable({ |
||||
providedIn: 'root' |
|
||||
|
providedIn: 'root', |
||||
}) |
}) |
||||
export class HomeService { |
export class HomeService { |
||||
private baseUrl = 'http://localhost:8000/home'; |
private baseUrl = 'http://localhost:8000/home'; |
||||
|
|
||||
constructor(private http: HttpClient) { |
|
||||
} |
|
||||
|
constructor(private http: HttpClient) {} |
||||
|
|
||||
post(data: any): Observable<any> { |
post(data: any): Observable<any> { |
||||
return this.http.post<any>(this.baseUrl, data); |
return this.http.post<any>(this.baseUrl, data); |
||||
} |
} |
||||
|
|
||||
|
sendEmail(body: any): Observable<any> { |
||||
|
return this.http.post(url + 'sendEmail', body, httpOptions); |
||||
|
} |
||||
|
|
||||
|
sendWhatsApp(body: any): Observable<any> { |
||||
|
return this.http.post(whatsAppUrl, body, httpOptions); |
||||
|
} |
||||
} |
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue