diff options
Diffstat (limited to 'packages/ui/src/models')
| -rw-r--r-- | packages/ui/src/models/java.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/packages/ui/src/models/java.ts b/packages/ui/src/models/java.ts new file mode 100644 index 0000000..3e5d2d0 --- /dev/null +++ b/packages/ui/src/models/java.ts @@ -0,0 +1,25 @@ +import { create } from "zustand/react"; +import { detectJava, refreshJavaCatalog } from "@/client"; +import type { JavaCatalog, JavaInstallation } from "@/types"; + +export interface JavaState { + catalog: JavaCatalog | null; + installations: JavaInstallation[] | null; + + refresh: () => Promise<void>; + refreshInstallations: () => Promise<void>; +} + +export const useJavaStore = create<JavaState>((set) => ({ + catalog: null, + installations: null, + + refresh: async () => { + const catalog = await refreshJavaCatalog(); + set({ catalog }); + }, + refreshInstallations: async () => { + const installations = await detectJava(); + set({ installations }); + }, +})); |