-een gebruiker kan meerdere bedrijven hebben
-manier van afspraken maken veranderd in de backend ivm meerdere bedrijven gebruiker -email is aangepast op bedrijf en gebruiker -dropdown voor instellingen toegevoegd
This commit is contained in:
19
.github/workflows/deploy-docker-to-tst.yml
vendored
19
.github/workflows/deploy-docker-to-tst.yml
vendored
@@ -116,3 +116,22 @@ jobs:
|
|||||||
}' \
|
}' \
|
||||||
https://mattermost.melvanveen.nl/api/v4/posts
|
https://mattermost.melvanveen.nl/api/v4/posts
|
||||||
|
|
||||||
|
notify-failure:
|
||||||
|
needs: [ build-and-push, deploy ]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: failure()
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Notify Mattermost via Bot on failure
|
||||||
|
env:
|
||||||
|
MATTERMOST_BOT_TOKEN: ${{ secrets.MATTERMOST_BOT_TOKEN }}
|
||||||
|
REPO: ${{ gitea.repository }}
|
||||||
|
BRANCH: ${{ gitea.ref }}
|
||||||
|
run: |
|
||||||
|
curl --fail -X POST -H "Authorization: Bearer $MATTERMOST_BOT_TOKEN" \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{
|
||||||
|
"channel_id": "9a8obynkd7rctk6qf8rfe6oppy",
|
||||||
|
"message": "@all ❌ *Build gefaald!* De pipeline is stukgelopen voor *'"$REPO"'* op branch *'"$BRANCH"'*."
|
||||||
|
}' \
|
||||||
|
https://mattermost.melvanveen.nl/api/v4/posts
|
||||||
|
|||||||
@@ -10,6 +10,13 @@
|
|||||||
[style.color]="'var(--tui-background-accent-1)'"/>
|
[style.color]="'var(--tui-background-accent-1)'"/>
|
||||||
{{ customer.email }}
|
{{ customer.email }}
|
||||||
</h2>
|
</h2>
|
||||||
|
<h2>
|
||||||
|
<tui-icon
|
||||||
|
icon="@tui.phone"
|
||||||
|
[style.color]="'var(--tui-background-accent-1)'"/>
|
||||||
|
<span *ngIf="customer.phone"> {{ customer.phone }}</span>
|
||||||
|
<span *ngIf="!customer.phone"> -</span>
|
||||||
|
</h2>
|
||||||
<ng-template *ngIf="appointment">
|
<ng-template *ngIf="appointment">
|
||||||
<br>
|
<br>
|
||||||
<h2>
|
<h2>
|
||||||
|
|||||||
@@ -36,6 +36,19 @@
|
|||||||
formControlName="email"/>
|
formControlName="email"/>
|
||||||
</tui-input>
|
</tui-input>
|
||||||
<br>
|
<br>
|
||||||
|
<tui-input
|
||||||
|
formControlName="phone"
|
||||||
|
tuiTextfieldSize="m"
|
||||||
|
id="telefoon-nieuwe-klant"
|
||||||
|
[tuiTextfieldCleaner]="true">
|
||||||
|
Telefoonnummer
|
||||||
|
<input
|
||||||
|
tuiTextfieldLegacy
|
||||||
|
autocomplete=""
|
||||||
|
type="tel"
|
||||||
|
formControlName="phone"/>
|
||||||
|
</tui-input>
|
||||||
|
<br>
|
||||||
<button
|
<button
|
||||||
appearance="secondary"
|
appearance="secondary"
|
||||||
size="m"
|
size="m"
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ export class NewCustomerComponent {
|
|||||||
firstName: new FormControl('', [Validators.required]),
|
firstName: new FormControl('', [Validators.required]),
|
||||||
lastName: new FormControl('', [Validators.required]),
|
lastName: new FormControl('', [Validators.required]),
|
||||||
email: new FormControl('', [Validators.required, Validators.pattern(this.emailRegex)]),
|
email: new FormControl('', [Validators.required, Validators.pattern(this.emailRegex)]),
|
||||||
|
phone: new FormControl('', [Validators.required]),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +40,8 @@ export class NewCustomerComponent {
|
|||||||
const firstName = this.customerForm.get('firstName').value
|
const firstName = this.customerForm.get('firstName').value
|
||||||
const lastName = this.customerForm.get('lastName').value
|
const lastName = this.customerForm.get('lastName').value
|
||||||
const email = this.customerForm.get('email').value
|
const email = this.customerForm.get('email').value
|
||||||
const customer = new Customer(firstName, lastName, email);
|
const phone = this.customerForm.get('phone').value
|
||||||
|
const customer = new Customer(firstName, lastName, email, phone);
|
||||||
|
|
||||||
this.customerService.addCustomer(customer).subscribe(() => {
|
this.customerService.addCustomer(customer).subscribe(() => {
|
||||||
this.customerAdded.emit(customer);
|
this.customerAdded.emit(customer);
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
tuiTextfieldSize="m">
|
tuiTextfieldSize="m">
|
||||||
Klant
|
Klant
|
||||||
<tui-data-list-wrapper
|
<tui-data-list-wrapper
|
||||||
|
id="klant-input"
|
||||||
*tuiDataList
|
*tuiDataList
|
||||||
[itemContent]="stringify | tuiStringifyContent"
|
[itemContent]="stringify | tuiStringifyContent"
|
||||||
[items]="items | tuiFilterByInput"
|
[items]="items | tuiFilterByInput"
|
||||||
@@ -90,7 +91,7 @@
|
|||||||
<ng-container *ngIf="appointments.length > 0">
|
<ng-container *ngIf="appointments.length > 0">
|
||||||
<h3>Geplande afspraken die dag:</h3>
|
<h3>Geplande afspraken die dag:</h3>
|
||||||
<div class="appointments-container">
|
<div class="appointments-container">
|
||||||
<div *ngFor="let appointment of appointments" class="appointment-object" [attr.id]="appointment.title + '-' + appointment.customer">
|
<div *ngFor="let appointment of appointments" class="appointment-object" [attr.id]="appointment.title.toLowerCase() + '-' + appointment.startDate + '-' + appointment.startHour + appointment.startMinute">
|
||||||
<span class="title" id="titel-afspraak">{{ appointment.title }}</span>
|
<span class="title" id="titel-afspraak">{{ appointment.title }}</span>
|
||||||
<span class="name" id="titel-naam">
|
<span class="name" id="titel-naam">
|
||||||
<tui-icon
|
<tui-icon
|
||||||
@@ -110,7 +111,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<br>
|
<br>
|
||||||
<tui-textarea formControlName="notes">Notities</tui-textarea>
|
<tui-textarea formControlName="notes" id="notities">Notities</tui-textarea>
|
||||||
</form>
|
</form>
|
||||||
<br>
|
<br>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
TuiTextfieldControllerModule
|
TuiTextfieldControllerModule
|
||||||
} from "@taiga-ui/legacy";
|
} from "@taiga-ui/legacy";
|
||||||
import {Appointment} from '../../models/appointment';
|
import {Appointment} from '../../models/appointment';
|
||||||
import {TuiDay, TuiTime, TuiValidationError} from '@taiga-ui/cdk';
|
import {TuiDay, TuiValidationError} from '@taiga-ui/cdk';
|
||||||
import {AppointmentService} from '../../services/appointment.service';
|
import {AppointmentService} from '../../services/appointment.service';
|
||||||
import {TuiDataListWrapperComponent, TuiFilterByInputPipe, TuiStringifyContentPipe} from '@taiga-ui/kit';
|
import {TuiDataListWrapperComponent, TuiFilterByInputPipe, TuiStringifyContentPipe} from '@taiga-ui/kit';
|
||||||
import {Customer} from '../../models/customer';
|
import {Customer} from '../../models/customer';
|
||||||
@@ -70,25 +70,13 @@ export class NewItemComponent implements OnInit {
|
|||||||
lastName: new FormControl('', Validators.required),
|
lastName: new FormControl('', Validators.required),
|
||||||
email: new FormControl('', [Validators.required, Validators.email]),
|
email: new FormControl('', [Validators.required, Validators.email]),
|
||||||
})
|
})
|
||||||
this.appointmentForm.get('startTime').setValue(new TuiTime(this.today.getHours(), this.today.getMinutes()), Validators.required)
|
this.appointmentForm.get('startTime').setValue('', Validators.required)
|
||||||
this.appointmentForm.get('endTime').setValue(new TuiTime(this.getEndTime().getHours(), this.getEndTime().getMinutes()), [Validators.required, timeAfterStartValidator('startTime')])
|
this.appointmentForm.get('endTime').setValue('', [Validators.required, timeAfterStartValidator('startTime')])
|
||||||
this.appointments.sort((a, b) => {
|
this.appointments.sort((a, b) => {
|
||||||
return a.startHour - b.startHour || a.startMinute - b.startMinute;
|
return a.startHour - b.startHour || a.startMinute - b.startMinute;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getEndTime(): Date {
|
|
||||||
const endTime = new Date(this.today); // Kopieer startTime
|
|
||||||
endTime.setMinutes(endTime.getMinutes() + 30); // 30 minuten toevoegen
|
|
||||||
|
|
||||||
// Controleer of de dag nog steeds hetzelfde is
|
|
||||||
if (endTime.getDate() !== this.today.getDate()) {
|
|
||||||
endTime.setHours(23, 59, 59, 999); // Zet naar 23:59:59 als het overloopt
|
|
||||||
}
|
|
||||||
|
|
||||||
return endTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
registerAppointment() {
|
registerAppointment() {
|
||||||
const title = this.appointmentForm.get('title').value
|
const title = this.appointmentForm.get('title').value
|
||||||
const description = this.appointmentForm.get('notes').value
|
const description = this.appointmentForm.get('notes').value
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ export class Customer {
|
|||||||
firstName: string;
|
firstName: string;
|
||||||
lastName: string;
|
lastName: string;
|
||||||
email: string;
|
email: string;
|
||||||
|
phone: string;
|
||||||
|
|
||||||
|
|
||||||
constructor(firstName: string, lastName: string, email: string) {
|
constructor(firstName: string, lastName: string, email: string, phone: string) {
|
||||||
this.firstName = firstName;
|
this.firstName = firstName;
|
||||||
this.lastName = lastName;
|
this.lastName = lastName;
|
||||||
this.email = email;
|
this.email = email;
|
||||||
|
this.phone = phone
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
size="m"
|
size="m"
|
||||||
tuiButton
|
tuiButton
|
||||||
id="afspraakMaken"
|
id="afspraakMaken"
|
||||||
(click)="isModalOpen = true"
|
(click)="showNewItem = true"
|
||||||
type="button">
|
type="button">
|
||||||
<tui-icon
|
<tui-icon
|
||||||
icon="@tui.plus"
|
icon="@tui.plus"
|
||||||
@@ -60,6 +60,23 @@
|
|||||||
/>
|
/>
|
||||||
Afspraak maken
|
Afspraak maken
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
appearance="secondary"
|
||||||
|
size="m"
|
||||||
|
tuiButton
|
||||||
|
id="instellingen"
|
||||||
|
(click)="openSettings()"
|
||||||
|
[tuiDropdown]="dropdownContent"
|
||||||
|
[tuiDropdownManual]="open"
|
||||||
|
type="button">
|
||||||
|
<tui-icon
|
||||||
|
icon="@tui.settings"
|
||||||
|
[style.height.rem]="1">
|
||||||
|
</tui-icon>
|
||||||
|
</button>
|
||||||
|
<ng-template #dropdownContent>
|
||||||
|
<div class="dropdown">But there is nothing to choose...</div>
|
||||||
|
</ng-template>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="agenda-container">
|
<div class="agenda-container">
|
||||||
@@ -88,7 +105,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<app-modal title="Nieuwe afspraak" (close)="closeNewItemModal()" *ngIf="isModalOpen">
|
<app-modal title="Nieuwe afspraak" (close)="closeNewItemModal()" *ngIf="showNewItem">
|
||||||
<app-new-item [appointments]="appointments" [appointmentForm]="appointmentForm"
|
<app-new-item [appointments]="appointments" [appointmentForm]="appointmentForm"
|
||||||
(appointmentAddedEvent)="registerAppointment($event)"></app-new-item>
|
(appointmentAddedEvent)="registerAppointment($event)"></app-new-item>
|
||||||
</app-modal>
|
</app-modal>
|
||||||
|
|||||||
@@ -11,20 +11,21 @@ import {
|
|||||||
TuiTextareaModule,
|
TuiTextareaModule,
|
||||||
TuiTextfieldControllerModule
|
TuiTextfieldControllerModule
|
||||||
} from '@taiga-ui/legacy';
|
} from '@taiga-ui/legacy';
|
||||||
import {TuiDay, TuiTime} from '@taiga-ui/cdk';
|
import {TuiDay, TuiMonth, TuiTime} from '@taiga-ui/cdk';
|
||||||
import {AppointmentService} from '../../services/appointment.service';
|
import {AppointmentService} from '../../services/appointment.service';
|
||||||
import {DetailsComponent} from '../../components/details/details.component';
|
import {DetailsComponent} from '../../components/details/details.component';
|
||||||
import {DateFormatter} from '../../utils/date-formatter';
|
import {DateFormatter} from '../../utils/date-formatter';
|
||||||
import {WeekDay} from '../../models/week-day';
|
import {WeekDay} from '../../models/week-day';
|
||||||
import {NewItemComponent} from '../../components/new-item/new-item.component';
|
import {NewItemComponent} from '../../components/new-item/new-item.component';
|
||||||
import {timeAfterStartValidator} from '../../models/validators/time-after-start-validator';
|
import {timeAfterStartValidator} from '../../models/validators/time-after-start-validator';
|
||||||
|
import {TuiChevron} from '@taiga-ui/kit';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-agenda',
|
selector: 'app-agenda',
|
||||||
imports: [NgFor,
|
imports: [NgFor,
|
||||||
TuiButton, CommonModule, NgIf, ModalComponent, ReactiveFormsModule,
|
TuiButton, CommonModule, NgIf, ModalComponent, ReactiveFormsModule,
|
||||||
TuiInputTimeModule, TuiTextfieldControllerModule,
|
TuiInputTimeModule, TuiTextfieldControllerModule,
|
||||||
TuiInputModule, TuiTextareaModule, TuiInputDateModule, TuiIcon, DetailsComponent, TuiCalendar, NewItemComponent],
|
TuiInputModule, TuiTextareaModule, TuiInputDateModule, TuiIcon, DetailsComponent, TuiCalendar, NewItemComponent, TuiChevron],
|
||||||
templateUrl: './agenda.component.html',
|
templateUrl: './agenda.component.html',
|
||||||
providers: [tuiDateFormatProvider({separator: '-'}), AppointmentService],
|
providers: [tuiDateFormatProvider({separator: '-'}), AppointmentService],
|
||||||
styleUrl: './agenda.component.scss'
|
styleUrl: './agenda.component.scss'
|
||||||
@@ -40,13 +41,14 @@ export class AgendaComponent implements OnInit {
|
|||||||
|
|
||||||
timeSlots: number[] = Array.from({length: 24}, (_, i) => i); // 24 uren
|
timeSlots: number[] = Array.from({length: 24}, (_, i) => i); // 24 uren
|
||||||
appointments: Appointment[] = [];
|
appointments: Appointment[] = [];
|
||||||
isModalOpen = false
|
showNewItem = false
|
||||||
today = new Date()
|
today = new Date()
|
||||||
selectedDate = new Date()
|
selectedDate = new Date()
|
||||||
waiting: boolean = false;
|
waiting: boolean = false;
|
||||||
selectedAppointment: Appointment;
|
selectedAppointment: Appointment;
|
||||||
protected value: TuiDay | null = null;
|
protected value: TuiDay | null = null;
|
||||||
showCalendar: boolean = false;
|
showCalendar: boolean = false;
|
||||||
|
open = false
|
||||||
|
|
||||||
private readonly alerts = inject(TuiAlertService);
|
private readonly alerts = inject(TuiAlertService);
|
||||||
protected appointmentForm = new FormGroup({
|
protected appointmentForm = new FormGroup({
|
||||||
@@ -60,7 +62,7 @@ export class AgendaComponent implements OnInit {
|
|||||||
registerAppointment(title: string): void {
|
registerAppointment(title: string): void {
|
||||||
this.getAppointmentsByDate(this.selectedDate);
|
this.getAppointmentsByDate(this.selectedDate);
|
||||||
this.waiting = false
|
this.waiting = false
|
||||||
this.isModalOpen = false
|
this.showNewItem = false
|
||||||
this.showNotification(title)
|
this.showNotification(title)
|
||||||
this.resetForms()
|
this.resetForms()
|
||||||
}
|
}
|
||||||
@@ -187,7 +189,7 @@ export class AgendaComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
closeNewItemModal() {
|
closeNewItemModal() {
|
||||||
this.isModalOpen = false
|
this.showNewItem = false
|
||||||
this.resetForms()
|
this.resetForms()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,5 +204,35 @@ export class AgendaComponent implements OnInit {
|
|||||||
appointmentIsEdited($event: Appointment) {
|
appointmentIsEdited($event: Appointment) {
|
||||||
this.getAppointmentsByDate(this.selectedDate);
|
this.getAppointmentsByDate(this.selectedDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected firstMonth = TuiMonth.currentLocal().append({month: -1});
|
||||||
|
|
||||||
|
protected middleMonth = TuiMonth.currentLocal();
|
||||||
|
|
||||||
|
protected lastMonth = TuiMonth.currentLocal().append({month: 2});
|
||||||
|
|
||||||
|
protected hoveredItem: TuiDay | null = null;
|
||||||
|
|
||||||
|
protected onMonthChangeFirst(month: TuiMonth): void {
|
||||||
|
this.firstMonth = month.append({month: -1});
|
||||||
|
this.middleMonth = month
|
||||||
|
this.lastMonth = month.append({month: 2});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected onMonthChangeMiddle(month: TuiMonth): void {
|
||||||
|
this.firstMonth = month.append({month: -1});
|
||||||
|
this.middleMonth = month;
|
||||||
|
this.lastMonth = month.append({month: 1});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected onMonthChangeLast(month: TuiMonth): void {
|
||||||
|
this.firstMonth = month.append({month: -2});
|
||||||
|
this.middleMonth = month.append({month: -1});
|
||||||
|
this.lastMonth = month;
|
||||||
|
}
|
||||||
|
|
||||||
|
openSettings() {
|
||||||
|
this.open = !this.open
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,24 +19,27 @@
|
|||||||
[tuiObscuredEnabled]="open"
|
[tuiObscuredEnabled]="open"
|
||||||
(click)="onClick()"
|
(click)="onClick()"
|
||||||
(tuiActiveZoneChange)="onActiveZone($event)"
|
(tuiActiveZoneChange)="onActiveZone($event)"
|
||||||
(tuiObscured)="onObscured($event)"
|
(tuiObscured)="onObscured($event)">
|
||||||
>
|
|
||||||
<tui-avatar src="{{getInitials()}}"/>
|
<tui-avatar src="{{getInitials()}}"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</button>
|
||||||
<ng-template #dropdownContent>
|
<ng-template #dropdownContent>
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<h3>{{ fullName }}</h3>
|
<h3>{{ fullName }}</h3>
|
||||||
|
<h4>{{ currentCompany.name }}</h4>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
size="m"
|
size="m"
|
||||||
tuiButton
|
tuiButton
|
||||||
type="button"
|
type="button"
|
||||||
id="uitloggen"
|
id="uitloggen"
|
||||||
(click)="logout()"
|
(click)="logout()">
|
||||||
>
|
|
||||||
Uitloggen
|
Uitloggen
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
.navbar {
|
.navbar {
|
||||||
background-color: #f8f9fa;
|
background-color: #f8f9fa;
|
||||||
display: flex
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
@@ -48,11 +49,12 @@ tui-avatar {
|
|||||||
line-height: 1.25rem;
|
line-height: 1.25rem;
|
||||||
padding: 0.25rem 0.75rem;
|
padding: 0.25rem 0.75rem;
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
margin-right: 4px;
|
margin-right: 20px;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
|
min-width: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.t-content {
|
ui-scrollbar.t-scroll.ng-tns-c452864359-10._native-hidden {
|
||||||
margin-right: 24px;
|
margin-right: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,26 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||||
import {Router, RouterLink, RouterLinkActive, RouterModule} from '@angular/router';
|
import {Router, RouterLink, RouterLinkActive, RouterModule} from '@angular/router';
|
||||||
import {TuiAvatar, TuiChevron,} from '@taiga-ui/kit';
|
import {TuiAvatar, TuiChevron,} from '@taiga-ui/kit';
|
||||||
import {AuthService} from '../../services/auth.service';
|
import {AuthService} from '../../services/auth.service';
|
||||||
import {User} from '../../models/user';
|
import {User} from '../../models/user';
|
||||||
import {TuiButton, TuiDropdown} from '@taiga-ui/core';
|
import {TuiButton, TuiDropdown} from '@taiga-ui/core';
|
||||||
import {TuiActiveZone, TuiObscured} from '@taiga-ui/cdk';
|
import {TuiActiveZone, TuiObscured} from '@taiga-ui/cdk';
|
||||||
|
import {environment} from '../../../environments/environment';
|
||||||
|
import {Company} from '../../models/company';
|
||||||
|
import {CompanyService} from '../../services/company.service';
|
||||||
|
import {TuiSelectModule} from '@taiga-ui/legacy';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-home',
|
selector: 'app-home',
|
||||||
imports: [TuiAvatar, RouterModule, FormsModule, RouterLink, RouterLinkActive, TuiDropdown, TuiObscured, TuiActiveZone, TuiButton, TuiChevron],
|
imports: [TuiAvatar, RouterModule, FormsModule, RouterLink, RouterLinkActive, TuiDropdown, TuiObscured, TuiActiveZone, TuiButton, TuiChevron, TuiSelectModule, ReactiveFormsModule],
|
||||||
templateUrl: './home.component.html',
|
templateUrl: './home.component.html',
|
||||||
styleUrl: './home.component.scss'
|
styleUrl: './home.component.scss'
|
||||||
})
|
})
|
||||||
export class HomeComponent implements OnInit {
|
export class HomeComponent implements OnInit {
|
||||||
user: User
|
user: User
|
||||||
fullName: string
|
fullName: string
|
||||||
|
companies: Company[]
|
||||||
|
|
||||||
getInitials(): string {
|
getInitials(): string {
|
||||||
this.user = this.authService.getUserInfo();
|
this.user = this.authService.getUserInfo();
|
||||||
@@ -39,17 +44,29 @@ export class HomeComponent implements OnInit {
|
|||||||
this.open = active && this.open;
|
this.open = active && this.open;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private authService: AuthService, private router: Router) {
|
constructor(private authService: AuthService, private router: Router, private companyService: CompanyService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (!this.authService.isAuthenticated()) {
|
if (!this.authService.isAuthenticated()) {
|
||||||
this.router.navigate(['login']);
|
this.router.navigate(['login']);
|
||||||
|
} else {
|
||||||
|
this.companyService.getCompanies().subscribe(
|
||||||
|
response => {
|
||||||
|
this.companies = response
|
||||||
|
this.authService.setCurrentCompany(response[0])
|
||||||
|
console.log(this.companies)
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
this.authService.logout();
|
this.authService.logout();
|
||||||
this.router.navigate(['login']);
|
this.router.navigate(['login']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected readonly environment = environment;
|
||||||
|
currentCompany: Company;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {Injectable} from '@angular/core';
|
|||||||
import {HttpClient} from '@angular/common/http';
|
import {HttpClient} from '@angular/common/http';
|
||||||
import {Appointment} from '../models/appointment';
|
import {Appointment} from '../models/appointment';
|
||||||
import {environment} from '../../environments/environment';
|
import {environment} from '../../environments/environment';
|
||||||
|
import {AuthService} from './auth.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@@ -9,7 +10,7 @@ import {environment} from '../../environments/environment';
|
|||||||
export class AppointmentService {
|
export class AppointmentService {
|
||||||
baseApi = `${environment.baseApi}/appointments`;
|
baseApi = `${environment.baseApi}/appointments`;
|
||||||
|
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient, private authService: AuthService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllAppointments() {
|
getAllAppointments() {
|
||||||
@@ -24,7 +25,8 @@ export class AppointmentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addAppointment(appointment: Appointment) {
|
addAppointment(appointment: Appointment) {
|
||||||
return this.http.post(`${this.baseApi}`, appointment);
|
let companyId = this.authService.getCurrentCompany().id
|
||||||
|
return this.http.post(`${this.baseApi}/${companyId}`, appointment);
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteAppointment(appointment: Appointment) {
|
deleteAppointment(appointment: Appointment) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {JwtHelperService} from '@auth0/angular-jwt';
|
|||||||
import {Observable} from 'rxjs';
|
import {Observable} from 'rxjs';
|
||||||
import {jwtDecode} from 'jwt-decode';
|
import {jwtDecode} from 'jwt-decode';
|
||||||
import {environment} from '../../environments/environment';
|
import {environment} from '../../environments/environment';
|
||||||
|
import {Company} from '../models/company';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@@ -11,6 +12,7 @@ import {environment} from '../../environments/environment';
|
|||||||
export class AuthService {
|
export class AuthService {
|
||||||
baseApi = `${environment.baseApi}/auth/login`;
|
baseApi = `${environment.baseApi}/auth/login`;
|
||||||
jwtHelper = new JwtHelperService();
|
jwtHelper = new JwtHelperService();
|
||||||
|
currentCompany: Company;
|
||||||
|
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient) {
|
||||||
}
|
}
|
||||||
@@ -39,5 +41,15 @@ export class AuthService {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setCurrentCompany(company: Company): void {
|
||||||
|
this.currentCompany = company;
|
||||||
|
console.log(this.currentCompany);
|
||||||
|
}
|
||||||
|
|
||||||
|
getCurrentCompany(): Company {
|
||||||
|
console.log(this.currentCompany);
|
||||||
|
return this.currentCompany;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
19
src/app/services/company.service.ts
Normal file
19
src/app/services/company.service.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {HttpClient} from '@angular/common/http';
|
||||||
|
import {Observable} from 'rxjs';
|
||||||
|
import {environment} from '../../environments/environment';
|
||||||
|
import {Company} from '../models/company';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class CompanyService {
|
||||||
|
baseApi = `${environment.baseApi}/company`;
|
||||||
|
|
||||||
|
constructor(private http: HttpClient) {
|
||||||
|
}
|
||||||
|
|
||||||
|
getCompanies(): Observable<Company[]> {
|
||||||
|
return this.http.get<Company[]>(`${this.baseApi}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user