import { JsonPipe } from '@angular/common'; import { Component, effect, inject, signal } from '@angular/core'; import * as api from '../../generated-api/api'; import { Authentication } from '../../services/authentication'; @Component({ selector: 'app-test', imports: [JsonPipe], templateUrl: './test.html', styleUrl: './test.scss', }) export class Test { protected auth = inject(Authentication); protected apiStatus = signal("Waiting"); protected authTest = signal("Waiting"); public constructor(){ effect(()=>{ const loggedIn=this.auth.loggedIn(); if(!loggedIn){ this.apiStatus.set("N/A - not logged in"); this.authTest.set("N/A - not logged in"); return; } this.apiStatus.set("Waiting for API"); this.authTest.set("Waiting for API"); api.getOk().then((status) => { this.apiStatus.set("Ok"); }).catch((e) => { this.apiStatus.set("Error"); }); api.getAuth().then((response) => { this.authTest.set("Ok"); }).catch((e) => { this.authTest.set(e); }); }) } }