From b17e5d42b700da137939f2ae967a5e6b08da4ac3 Mon Sep 17 00:00:00 2001 From: Kangyang Ji Date: Thu, 2 Apr 2026 07:56:35 +0100 Subject: [PATCH] feat(dashboard): Enhance Types in Settings.vue (#7241) * feat: Strict Types for Settings.vue, Enhance Error Handling feat: Fixed Type in Theme Constant for better TypeScript in Settings.vue * fix: add other error handling and improve api create type behavier * fix error messages --- dashboard/src/theme/constants.ts | 3 + dashboard/src/types/api.ts | 37 +++++ dashboard/src/types/themeTypes/ThemeType.ts | 4 +- dashboard/src/views/Settings.vue | 166 +++++++++++++------- 4 files changed, 150 insertions(+), 60 deletions(-) create mode 100644 dashboard/src/types/api.ts diff --git a/dashboard/src/theme/constants.ts b/dashboard/src/theme/constants.ts index 7844da86d..f36c90dcf 100644 --- a/dashboard/src/theme/constants.ts +++ b/dashboard/src/theme/constants.ts @@ -1,2 +1,5 @@ export const LIGHT_THEME_NAME = "BlueBusinessTheme"; export const DARK_THEME_NAME = "BlueBusinessDarkTheme"; + +// Theme related types +export type ThemeMode = "light" | "dark" | "auto"; \ No newline at end of file diff --git a/dashboard/src/types/api.ts b/dashboard/src/types/api.ts new file mode 100644 index 000000000..efa99e99e --- /dev/null +++ b/dashboard/src/types/api.ts @@ -0,0 +1,37 @@ +// API Key related types +export interface ApiKey { + key_id: string; + name: string; + key_prefix: string; + scopes: string[]; + is_revoked: boolean; + is_expired: boolean; + last_used_at: string | null; + created_at: string; + expires_at: string | null; +} + +export type ApiKeyExpiresDays = 1 | 7 | 30 | 90 | "permanent"; + +export interface ApiKeyCreatePayload { + name: string; + scopes: string[]; + expires_in_days?: number; +} + +export interface ApiKeyListResponse { + status: "ok" | "error"; + data: ApiKey[]; + message?: string; +} + +export interface ApiKeyCreateResponse { + status: "ok" | "error"; + data?: ApiKey & { api_key: string }; // Include the full API key in the response + message?: string; +} + +export interface ApiKeyActionResponse { + status: "ok" | "error"; + message?: string; +} diff --git a/dashboard/src/types/themeTypes/ThemeType.ts b/dashboard/src/types/themeTypes/ThemeType.ts index 010a7a1c3..ae4cdd2d6 100644 --- a/dashboard/src/types/themeTypes/ThemeType.ts +++ b/dashboard/src/types/themeTypes/ThemeType.ts @@ -3,8 +3,8 @@ export type ThemeTypes = { dark: boolean; variables?: object; colors: { - primary?: string; - secondary?: string; + primary: string; + secondary: string; tertiary?: string; info?: string; success?: string; diff --git a/dashboard/src/views/Settings.vue b/dashboard/src/views/Settings.vue index aecbc2161..dc731779b 100644 --- a/dashboard/src/views/Settings.vue +++ b/dashboard/src/views/Settings.vue @@ -338,7 +338,7 @@