๐Ÿ“„ src/web3/vue/composables/useLoadProjects.ts
D-OPEN SOVEREIGN

Documentation & Insights

Reactive project list for one chain/language (spec ยง13.3). `tech` is dropped
from the signature entirely (ยง11 Q11) โ€” loadProjects(chainId, language)
resolves the read client internally via getReadClient(chainId).
1import { ref, unref, type MaybeRef, type Ref } from 'vue';
2import { loadProjects, type ProjectLocale } from '../../session/projects';
3
4export interface UseLoadProjectsReturn {
5  projects: Ref<Array<ProjectLocale | null>>;
6  isLoading: Ref<boolean>;
7  error: Ref<Error | null>;
8  reload(): Promise<void>;
9}
10
11/**
12 * Reactive project list for one chain/language (spec ยง13.3). `tech` is dropped
13 * from the signature entirely (ยง11 Q11) โ€” loadProjects(chainId, language)
14 * resolves the read client internally via getReadClient(chainId).
15 */
16export function useLoadProjects(chainId: MaybeRef<number>, language: MaybeRef<string>): UseLoadProjectsReturn {
17  const projects = ref<Array<ProjectLocale | null>>([]) as Ref<Array<ProjectLocale | null>>;
18  const isLoading = ref(false);
19  const error = ref<Error | null>(null);
20
21  async function reload(): Promise<void> {
22    isLoading.value = true;
23    error.value = null;
24    try {
25      projects.value = await loadProjects(unref(chainId), unref(language));
26    } catch (e: any) {
27      error.value = e instanceof Error ? e : new Error(String(e));
28    } finally {
29      isLoading.value = false;
30    }
31  }
32
33  reload();
34
35  return { projects, isLoading, error, reload };
36}
37