17 changed files with 238 additions and 77 deletions
@ -0,0 +1,20 @@ |
|||
export type GlobalEnum = { |
|||
category: CategoryDTO[]; |
|||
mark: MarkDTO[]; |
|||
nutrient: NutrientDTO[]; |
|||
}; |
|||
|
|||
export type CategoryDTO = { |
|||
key: string; |
|||
value: string; |
|||
}; |
|||
export type MarkDTO = { |
|||
key: string; |
|||
value: string; |
|||
}; |
|||
export type NutrientDTO = { |
|||
key: string; |
|||
value: string; |
|||
measurement: string; |
|||
nrv: number; |
|||
}; |
@ -1,2 +1,3 @@ |
|||
export * from "./org.dto"; |
|||
export * from "./user.dto"; |
|||
export * from "./enum.dto"; |
|||
|
@ -1,17 +1,19 @@ |
|||
import { inject } from "@angular/core"; |
|||
import { Router } from "@angular/router"; |
|||
import { map } from "rxjs"; |
|||
import { ApiService } from "./api.service"; |
|||
|
|||
const accountTokenName = "account"; |
|||
|
|||
export const authGuard = () => { |
|||
const router = inject(Router); |
|||
const token = localStorage.getItem(accountTokenName); |
|||
const api = inject(ApiService); |
|||
|
|||
if (!token) { |
|||
router.navigate(["/login"]); |
|||
return false; |
|||
} else { |
|||
return true; |
|||
} |
|||
|
|||
return api.getAllEnum(); |
|||
}; |
|||
|
Loading…
Reference in new issue