From 9fbb61fef4d81a445ff3d469f84426433b83bc58 Mon Sep 17 00:00:00 2001 From: veenm Date: Tue, 15 Apr 2025 20:45:56 +0200 Subject: [PATCH] -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 --- .github/workflows/deploy-docker-to-tst.yml | 19 +++++++++ .../customer-details.component.html | 7 ++++ .../new-customer/new-customer.component.html | 13 ++++++ .../new-customer/new-customer.component.ts | 4 +- .../new-item/new-item.component.html | 5 ++- .../components/new-item/new-item.component.ts | 18 ++------ src/app/models/customer.ts | 4 +- src/app/pages/agenda/agenda.component.html | 29 ++++++++++--- src/app/pages/agenda/agenda.component.ts | 42 ++++++++++++++++--- src/app/pages/home/home.component.html | 35 +++++++++------- src/app/pages/home/home.component.scss | 8 ++-- src/app/pages/home/home.component.ts | 23 ++++++++-- src/app/services/appointment.service.ts | 6 ++- src/app/services/auth.service.ts | 12 ++++++ src/app/services/company.service.ts | 19 +++++++++ 15 files changed, 190 insertions(+), 54 deletions(-) create mode 100644 src/app/services/company.service.ts diff --git a/.github/workflows/deploy-docker-to-tst.yml b/.github/workflows/deploy-docker-to-tst.yml index 94218ae..c739ac7 100644 --- a/.github/workflows/deploy-docker-to-tst.yml +++ b/.github/workflows/deploy-docker-to-tst.yml @@ -116,3 +116,22 @@ jobs: }' \ 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 diff --git a/src/app/components/customer-details/customer-details.component.html b/src/app/components/customer-details/customer-details.component.html index 30dc765..863076f 100644 --- a/src/app/components/customer-details/customer-details.component.html +++ b/src/app/components/customer-details/customer-details.component.html @@ -10,6 +10,13 @@ [style.color]="'var(--tui-background-accent-1)'"/> {{ customer.email }} +

+ + {{ customer.phone }} + - +


diff --git a/src/app/components/new-customer/new-customer.component.html b/src/app/components/new-customer/new-customer.component.html index 7188b8a..30323c0 100644 --- a/src/app/components/new-customer/new-customer.component.html +++ b/src/app/components/new-customer/new-customer.component.html @@ -36,6 +36,19 @@ formControlName="email"/>
+ + Telefoonnummer + + +
+ + + +
@@ -88,7 +105,7 @@
- + diff --git a/src/app/pages/agenda/agenda.component.ts b/src/app/pages/agenda/agenda.component.ts index 7fdd6d8..c9ce8f5 100644 --- a/src/app/pages/agenda/agenda.component.ts +++ b/src/app/pages/agenda/agenda.component.ts @@ -11,20 +11,21 @@ import { TuiTextareaModule, TuiTextfieldControllerModule } 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 {DetailsComponent} from '../../components/details/details.component'; import {DateFormatter} from '../../utils/date-formatter'; import {WeekDay} from '../../models/week-day'; import {NewItemComponent} from '../../components/new-item/new-item.component'; import {timeAfterStartValidator} from '../../models/validators/time-after-start-validator'; +import {TuiChevron} from '@taiga-ui/kit'; @Component({ selector: 'app-agenda', imports: [NgFor, TuiButton, CommonModule, NgIf, ModalComponent, ReactiveFormsModule, TuiInputTimeModule, TuiTextfieldControllerModule, - TuiInputModule, TuiTextareaModule, TuiInputDateModule, TuiIcon, DetailsComponent, TuiCalendar, NewItemComponent], + TuiInputModule, TuiTextareaModule, TuiInputDateModule, TuiIcon, DetailsComponent, TuiCalendar, NewItemComponent, TuiChevron], templateUrl: './agenda.component.html', providers: [tuiDateFormatProvider({separator: '-'}), AppointmentService], styleUrl: './agenda.component.scss' @@ -40,13 +41,14 @@ export class AgendaComponent implements OnInit { timeSlots: number[] = Array.from({length: 24}, (_, i) => i); // 24 uren appointments: Appointment[] = []; - isModalOpen = false + showNewItem = false today = new Date() selectedDate = new Date() waiting: boolean = false; selectedAppointment: Appointment; protected value: TuiDay | null = null; showCalendar: boolean = false; + open = false private readonly alerts = inject(TuiAlertService); protected appointmentForm = new FormGroup({ @@ -60,7 +62,7 @@ export class AgendaComponent implements OnInit { registerAppointment(title: string): void { this.getAppointmentsByDate(this.selectedDate); this.waiting = false - this.isModalOpen = false + this.showNewItem = false this.showNotification(title) this.resetForms() } @@ -187,7 +189,7 @@ export class AgendaComponent implements OnInit { } closeNewItemModal() { - this.isModalOpen = false + this.showNewItem = false this.resetForms() } @@ -202,5 +204,35 @@ export class AgendaComponent implements OnInit { appointmentIsEdited($event: Appointment) { 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 + } } diff --git a/src/app/pages/home/home.component.html b/src/app/pages/home/home.component.html index 11fe3a4..5aaded3 100644 --- a/src/app/pages/home/home.component.html +++ b/src/app/pages/home/home.component.html @@ -19,24 +19,27 @@ [tuiObscuredEnabled]="open" (click)="onClick()" (tuiActiveZoneChange)="onActiveZone($event)" - (tuiObscured)="onObscured($event)" - > + (tuiObscured)="onObscured($event)"> - - - + + + + + + diff --git a/src/app/pages/home/home.component.scss b/src/app/pages/home/home.component.scss index 3b716e6..2ca785c 100644 --- a/src/app/pages/home/home.component.scss +++ b/src/app/pages/home/home.component.scss @@ -1,6 +1,7 @@ .navbar { background-color: #f8f9fa; - display: flex + display: flex; + align-items: center; } ul { @@ -48,11 +49,12 @@ tui-avatar { line-height: 1.25rem; padding: 0.25rem 0.75rem; margin-left: 4px; - margin-right: 4px; + margin-right: 20px; margin-bottom: 8px; + min-width: 200px; } -.t-content { +ui-scrollbar.t-scroll.ng-tns-c452864359-10._native-hidden { margin-right: 24px; } diff --git a/src/app/pages/home/home.component.ts b/src/app/pages/home/home.component.ts index f4aa5e1..1d74e02 100644 --- a/src/app/pages/home/home.component.ts +++ b/src/app/pages/home/home.component.ts @@ -1,21 +1,26 @@ 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 {TuiAvatar, TuiChevron,} from '@taiga-ui/kit'; import {AuthService} from '../../services/auth.service'; import {User} from '../../models/user'; import {TuiButton, TuiDropdown} from '@taiga-ui/core'; 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({ 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', styleUrl: './home.component.scss' }) export class HomeComponent implements OnInit { user: User fullName: string + companies: Company[] getInitials(): string { this.user = this.authService.getUserInfo(); @@ -39,17 +44,29 @@ export class HomeComponent implements OnInit { this.open = active && this.open; } - constructor(private authService: AuthService, private router: Router) { + constructor(private authService: AuthService, private router: Router, private companyService: CompanyService) { } ngOnInit(): void { if (!this.authService.isAuthenticated()) { this.router.navigate(['login']); + } else { + this.companyService.getCompanies().subscribe( + response => { + this.companies = response + this.authService.setCurrentCompany(response[0]) + console.log(this.companies) + } + ) } + } logout() { this.authService.logout(); this.router.navigate(['login']); } + + protected readonly environment = environment; + currentCompany: Company; } diff --git a/src/app/services/appointment.service.ts b/src/app/services/appointment.service.ts index e1cd15c..e917452 100644 --- a/src/app/services/appointment.service.ts +++ b/src/app/services/appointment.service.ts @@ -2,6 +2,7 @@ import {Injectable} from '@angular/core'; import {HttpClient} from '@angular/common/http'; import {Appointment} from '../models/appointment'; import {environment} from '../../environments/environment'; +import {AuthService} from './auth.service'; @Injectable({ providedIn: 'root', @@ -9,7 +10,7 @@ import {environment} from '../../environments/environment'; export class AppointmentService { baseApi = `${environment.baseApi}/appointments`; - constructor(private http: HttpClient) { + constructor(private http: HttpClient, private authService: AuthService) { } getAllAppointments() { @@ -24,7 +25,8 @@ export class AppointmentService { } 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) { diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index dd88fed..f76a255 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -4,6 +4,7 @@ import {JwtHelperService} from '@auth0/angular-jwt'; import {Observable} from 'rxjs'; import {jwtDecode} from 'jwt-decode'; import {environment} from '../../environments/environment'; +import {Company} from '../models/company'; @Injectable({ providedIn: 'root', @@ -11,6 +12,7 @@ import {environment} from '../../environments/environment'; export class AuthService { baseApi = `${environment.baseApi}/auth/login`; jwtHelper = new JwtHelperService(); + currentCompany: Company; constructor(private http: HttpClient) { } @@ -39,5 +41,15 @@ export class AuthService { } return null; } + + setCurrentCompany(company: Company): void { + this.currentCompany = company; + console.log(this.currentCompany); + } + + getCurrentCompany(): Company { + console.log(this.currentCompany); + return this.currentCompany; + } } diff --git a/src/app/services/company.service.ts b/src/app/services/company.service.ts new file mode 100644 index 0000000..30f6603 --- /dev/null +++ b/src/app/services/company.service.ts @@ -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 { + return this.http.get(`${this.baseApi}`); + } +}