-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinventory.component.ts
30 lines (27 loc) · 1.24 KB
/
inventory.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { Component, inject, ViewEncapsulation } from '@angular/core'
import { MatButtonModule } from '@angular/material/button'
import { MatIconModule } from '@angular/material/icon'
import { MatTabsModule } from '@angular/material/tabs'
import { ActivatedRoute, Router } from '@angular/router'
import { InventoryTabComponent } from '@seed/components'
import { SharedImports } from '@seed/directives'
import type { InventoryType } from './inventory.types'
@Component({
selector: 'seed-inventory',
templateUrl: './inventory.component.html',
encapsulation: ViewEncapsulation.None,
imports: [MatButtonModule, MatIconModule, MatTabsModule, SharedImports, InventoryTabComponent],
})
export class InventoryComponent {
private _activatedRoute = inject(ActivatedRoute)
private _router = inject(Router)
readonly tabs: InventoryType[] = ['properties', 'taxlots']
readonly type = this._activatedRoute.snapshot.paramMap.get('type') as InventoryType
async toggleInventoryType(type: InventoryType) {
if (type !== this.type) {
// Hack to route to reload the current component
await this._router.navigateByUrl('/', { skipLocationChange: true })
await this._router.navigate([this.type === 'properties' ? 'taxlots' : 'properties'])
}
}
}