From 1af947a6fbf7937c4089cb5183e6e1cf6255f7cd Mon Sep 17 00:00:00 2001 From: Hironsan Date: Fri, 21 May 2021 16:07:10 +0900 Subject: [PATCH] Add composition api for project --- frontend/composables/useProjectItem.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 frontend/composables/useProjectItem.ts diff --git a/frontend/composables/useProjectItem.ts b/frontend/composables/useProjectItem.ts new file mode 100644 index 00000000..dc723a37 --- /dev/null +++ b/frontend/composables/useProjectItem.ts @@ -0,0 +1,23 @@ +import _ from 'lodash' +import { reactive, useContext } from '@nuxtjs/composition-api' +import { ProjectDTO } from '@/services/application/project/projectData' + +export const useProjectItem = () => { + const state = reactive({ + project: {} as ProjectDTO + }) + + const { app } = useContext() + const projectService = app.$services.project + + const getProjectById = async( + projectId: string + ) => { + state.project = await projectService.findById(projectId) + } + + return { + state, + getProjectById + } +}