Files
start-os/web/projects/setup-wizard/src/app/app.component.ts
Alex Inkin 7b41b295b7 chore: refactor install and setup wizards (#2561)
* chore: refactor install and setup wizards

* chore: return tui-root
2024-02-22 06:58:01 -07:00

34 lines
854 B
TypeScript

import { Component, inject } from '@angular/core'
import { Router } from '@angular/router'
import { ErrorService } from '@start9labs/shared'
import { ApiService } from 'src/app/services/api.service'
@Component({
selector: 'app-root',
template: `
<tui-theme-night></tui-theme-night>
<tui-root tuiMode="onDark"><router-outlet /></tui-root>
`,
})
export class AppComponent {
private readonly api = inject(ApiService)
private readonly errorService = inject(ErrorService)
private readonly router = inject(Router)
async ngOnInit() {
try {
const inProgress = await this.api.getSetupStatus()
let route = 'home'
if (inProgress) {
route = inProgress.complete ? 'success' : 'loading'
}
await this.router.navigate([route])
} catch (e: any) {
this.errorService.handleError(e)
}
}
}