Dashboard shadcn-vue sidebar + i18n + NavProjects conectado a KAPPA API
- Dashboard-01 block de shadcn-vue instalado (sidebar con tabs) - vue-i18n para traducciones ES/EN (detecta idioma del navegador) - NavProjects ahora usa initiative_name de KAPPA API - Dashboard stats conectados a API (HUs, sesiones, planeaciones) - Work items table con datos reales de KAPPA - Login: toggle password con icono de ojo - Toggle theme restaurado en SiteHeader - i18n con locale/en.json y locale/es.json -Nuevos componentes: NavMain, NavDocuments, NavSecondary en dashboard/ - NavUser原来的 - NavUser原来的
This commit is contained in:
+49
-4
@@ -1,17 +1,31 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import { ref, computed } from 'vue'
|
||||
import { kappa } from '@/services/kappa-api'
|
||||
import type { KappaUserStory } from '@/types/kappa'
|
||||
import type { KappaUserStory, KappaLogbookEntry, KappaPlanningEntry } from '@/types/kappa'
|
||||
|
||||
export const useWorkItemsStore = defineStore('workitems', () => {
|
||||
const creating = ref(false)
|
||||
const loading = ref(false)
|
||||
const error = ref<string | null>(null)
|
||||
|
||||
const userStories = ref<KappaUserStory[]>([])
|
||||
const logbooks = ref<KappaLogbookEntry[]>([])
|
||||
const plannings = ref<KappaPlanningEntry[]>([])
|
||||
|
||||
const totalHUs = computed(() => userStories.value.length)
|
||||
const inProgressHUs = computed(() =>
|
||||
userStories.value.filter(us =>
|
||||
us.status && ['in_progress', 'doing', 'wip', 'active'].includes(us.status.toLowerCase())
|
||||
).length
|
||||
)
|
||||
const totalSessions = computed(() => logbooks.value.length)
|
||||
|
||||
async function createUserStory(story: KappaUserStory): Promise<KappaUserStory | null> {
|
||||
creating.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const result = await kappa.createUserStory(story)
|
||||
userStories.value.push(result)
|
||||
return result
|
||||
} catch (e: any) {
|
||||
error.value = e.message
|
||||
@@ -21,5 +35,36 @@ export const useWorkItemsStore = defineStore('workitems', () => {
|
||||
}
|
||||
}
|
||||
|
||||
return { creating, error, createUserStory }
|
||||
})
|
||||
async function fetchWorkItems(initiativeId?: number) {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const [stories, logs, plans] = await Promise.all([
|
||||
kappa.getUserStories(initiativeId),
|
||||
kappa.getLogbooks(initiativeId),
|
||||
kappa.getPlannings(initiativeId),
|
||||
])
|
||||
userStories.value = Array.isArray(stories) ? stories : (stories.results ?? [])
|
||||
logbooks.value = Array.isArray(logs) ? logs : (logs.results ?? [])
|
||||
plannings.value = Array.isArray(plans) ? plans : (plans.results ?? [])
|
||||
} catch (e: any) {
|
||||
error.value = e.message
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
creating,
|
||||
loading,
|
||||
error,
|
||||
userStories,
|
||||
logbooks,
|
||||
plannings,
|
||||
totalHUs,
|
||||
inProgressHUs,
|
||||
totalSessions,
|
||||
createUserStory,
|
||||
fetchWorkItems,
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user