Skip to content

Commit

Permalink
work pinia & types update
Browse files Browse the repository at this point in the history
  • Loading branch information
nc2U committed May 26, 2024
1 parent d14bde5 commit 2488f5b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
31 changes: 31 additions & 0 deletions app/vue/src/store/pinia/work.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
IssueProject,
ProjectFilter,
Member,
Version,
Role,
Tracker,
IssueStatus,
Expand Down Expand Up @@ -162,6 +163,30 @@ export const useWork = defineStore('work', () => {
)
.catch(err => errorHandle(err.response.data))

// version states & getters
const version = ref<Version | null>(null)
const versionList = ref<Version[]>([])

const fetchVersion = (pk: number) =>
api
.get(`/version/${pk}/`)
.then(res => (version.value = res.data))
.catch(err => errorHandle(err.response.data))

const fetchVersionList = () =>
api
.get(`/version/`)
.then(res => (versionList.value = res.data.results))
.catch(err => errorHandle(err.response.data))

const patchVersion = (payload: { pk: number; user?: number; roles?: number[]; slug: string }) =>
api
.patch(`/version/${payload.pk}/`, payload)
.then(res =>
fetchIssueProject(payload.slug).then(() => fetchVersion(res.data.pk).then(() => message())),
)
.catch(err => errorHandle(err.response.data))

// tracker states & getters
const trackerList = ref<Tracker[]>([])
const getTrackers = computed(() => trackerList.value.map(t => ({ value: t.pk, label: t.name })))
Expand Down Expand Up @@ -579,6 +604,12 @@ export const useWork = defineStore('work', () => {
fetchMemberList,
patchMember,

version,
versionList,
fetchVersion,
fetchVersionList,
patchVersion,

trackerList,
getTrackers,
trackerSum,
Expand Down
11 changes: 11 additions & 0 deletions app/vue/src/store/types/work.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,17 @@ export interface Member {
roles: { pk: number; name: string }[]
}

export interface Version {
pk: number
project: number
name: string
status: '1' | '2' | '3'
sharing: '0' | '1' | '2' | '3' | '4'
due_date: string | null
description: string
wiki_page_title: string
}

export interface Tracker {
pk: number
name: string
Expand Down

0 comments on commit 2488f5b

Please sign in to comment.