diff --git a/src/components/07_agencies-management/FormBasicInfoAgencies.vue b/src/components/07_agencies-management/FormBasicInfoAgencies.vue new file mode 100644 index 00000000..b2fdd203 --- /dev/null +++ b/src/components/07_agencies-management/FormBasicInfoAgencies.vue @@ -0,0 +1,73 @@ + + + diff --git a/src/components/ProfileBanner.vue b/src/components/ProfileBanner.vue index e242e535..f9d4fe26 100644 --- a/src/components/ProfileBanner.vue +++ b/src/components/ProfileBanner.vue @@ -1,6 +1,7 @@ + + diff --git a/src/pages/07_agencies-management/MainPage.vue b/src/pages/07_agencies-management/MainPage.vue new file mode 100644 index 00000000..b52da96b --- /dev/null +++ b/src/pages/07_agencies-management/MainPage.vue @@ -0,0 +1,723 @@ + + + diff --git a/src/router/routes.ts b/src/router/routes.ts index 1d35d94a..1b1fcf58 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -89,6 +89,11 @@ const routes: RouteRecordRaw[] = [ name: 'document-management', component: () => import('pages/06_edm/MainPage.vue'), }, + { + path: '/agencies-management', + name: 'agencies-management', + component: () => import('pages/07_agencies-management/MainPage.vue'), + }, ], }, diff --git a/src/stores/institution/index.ts b/src/stores/institution/index.ts new file mode 100644 index 00000000..ef2775a9 --- /dev/null +++ b/src/stores/institution/index.ts @@ -0,0 +1,75 @@ +import { defineStore } from 'pinia'; +import { ref } from 'vue'; +import { Institution, InstitutionPayload } from './types'; +import { api } from 'src/boot/axios'; +import { PaginationResult } from 'src/types'; + +export const useInstitution = defineStore('institution-store', () => { + const data = ref([]); + const page = ref(1); + const pageMax = ref(1); + const pageSize = ref(30); + + async function getInstitution(id: string) { + const res = await api.get(`/institution/${id}`); + if (res.status < 400) { + return res.data; + } + return null; + } + + async function getInstitutionList(params?: { + page?: number; + pageSize?: number; + query?: string; + group?: string; + }) { + const res = await api.get>('/institution', { + params, + }); + if (res.status < 400) { + return res.data; + } + return null; + } + + async function createInstitution(data: InstitutionPayload) { + const res = await api.post('/institution', data); + if (res.status < 400) { + return res.data; + } + return null; + } + + async function editInstitution(data: InstitutionPayload & { id: string }) { + const res = await api.put(`/institution/${data.id}`, { + ...data, + id: undefined, + }); + if (res.status < 400) { + return res.data; + } + return null; + } + + async function deleteInstitution(id: string) { + const res = await api.delete(`/institution/${id}`); + if (res.status < 400) { + return res.data; + } + return null; + } + + return { + data, + page, + pageMax, + pageSize, + + getInstitution, + getInstitutionList, + createInstitution, + editInstitution, + deleteInstitution, + }; +}); diff --git a/src/stores/institution/types.ts b/src/stores/institution/types.ts new file mode 100644 index 00000000..c0353f52 --- /dev/null +++ b/src/stores/institution/types.ts @@ -0,0 +1,45 @@ +import { District, Province, SubDistrict } from '../address'; + +export type Institution = { + id: string; + code: string; + group: string; + name: string; + nameEN: string; + + addressEN: string; + address: string; + soi: string | null; + soiEN: string | null; + moo: string | null; + mooEN: string | null; + street: string | null; + streetEN: string | null; + province?: Province; + district?: District; + subDistrict?: SubDistrict; + + subDistrictId: string; + districtId: string; + provinceId: string; +}; + +export type InstitutionPayload = { + code: string; + name: string; + nameEN: string; + group?: string; + + addressEN: string; + address: string; + soi?: string | null; + soiEN?: string | null; + moo?: string | null; + mooEN?: string | null; + street?: string | null; + streetEN?: string | null; + + subDistrictId: string; + districtId: string; + provinceId: string; +};