implementing domain selector

This commit is contained in:
Emily
2025-01-21 18:07:01 +01:00
parent 13e94cb0f0
commit 8922507a64
68 changed files with 273 additions and 79 deletions

View File

@@ -0,0 +1,36 @@
const { token } = useAccessToken();
const { projectId } = useProject();
const domainsRequest = useFetch<{ _id: string }[]>('/api/domains/list', {
headers: computed(() => {
return {
'Authorization': `Bearer ${token.value}`,
'x-pid': projectId.value || ''
}
})
});
const domainList = computed(() => {
return domainsRequest.data.value?.map(e => e._id);
})
const activeDomain = ref<string>();
const domain = computed(() => {
if (activeDomain.value) return activeDomain.value;
if (!domainList.value) return;
if (domainList.value.length == 0) return;
activeDomain.value = domainList.value[0];
return domainList.value[0];
})
function setActiveDomain(domain: string) {
activeDomain.value = domain;
}
export function useDomain() {
return { domainList, domain, setActiveDomain }
}