diff --git a/apps/shelve/app/pages/environments.vue b/apps/shelve/app/pages/environments.vue index 6d7026ba..fbebb671 100644 --- a/apps/shelve/app/pages/environments.vue +++ b/apps/shelve/app/pages/environments.vue @@ -3,7 +3,7 @@ import { type Environment, TeamRole } from '@shelve/types' import { ConfirmModal } from '#components' import { hasAccess } from '~/utils/hasAccess' -const teamEnv = useTeamEnv() +const teamEnv = ref([]) const teamId = useTeamId() const teamRole = useTeamRole() @@ -13,6 +13,7 @@ const { const newEnv = ref('') const loading = ref(false) +const ceateLoading = ref(false) const updateLoading = ref(false) const columns = [ @@ -20,14 +21,29 @@ const columns = [ accessorKey: 'name', header: 'Name', }, + { + accessorKey: 'variablesCount', + header: 'Variable Count', + }, { accessorKey: 'actions', header: 'Actions', } ] -async function create() { +async function fetchEnvironments() { loading.value = true + try { + teamEnv.value = await $fetch(`/api/environments?teamId=${ teamId.value }`) + } catch (error) { + console.error(error) + } + loading.value = false +} +fetchEnvironments() + +async function create() { + ceateLoading.value = true try { if (!newEnv.value) { toast.error('Environment name is required') @@ -43,12 +59,12 @@ async function create() { name: newEnv.value }, }) - await fetchTeams() + await fetchEnvironments() newEnv.value = '' } catch (error) { console.error(error) } - loading.value = false + ceateLoading.value = false } async function updateEnv(env: Environment) { @@ -59,7 +75,7 @@ async function updateEnv(env: Environment) { name: env.name }, }) - await fetchTeams() + await fetchEnvironments() updateLoading.value = false } @@ -67,7 +83,7 @@ async function deleteEnv(environments: Environment) { await $fetch(`/api/teams/${teamId.value}/environments/${environments.id}`, { method: 'DELETE', }) - await fetchTeams() + await fetchEnvironments() } const modal = useModal() @@ -121,14 +137,17 @@ function updateEnvironment(env: Environment) {
- +
- + +