Files
Taekwondo-Admin/packages/frontend/src/app/components/test/test.ts
T
2025-12-07 12:51:57 +01:00

43 lines
1.1 KiB
TypeScript

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<string>("Waiting");
protected authTest = signal<string>("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);
});
})
}
}