From 628c50ad982ea20a72ecc67da7e0d44b1c279165 Mon Sep 17 00:00:00 2001 From: saparatayev Date: Thu, 23 Mar 2023 12:02:07 +0500 Subject: [PATCH] broker_ demo --- src/router/index.js | 5 + src/stores/broker.js | 83 ++++++++++ src/stores/index.js | 1 + src/views/broker/Main.vue | 310 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 399 insertions(+) create mode 100644 src/stores/broker.js create mode 100644 src/views/broker/Main.vue diff --git a/src/router/index.js b/src/router/index.js index 9128659..7692c84 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -21,6 +21,11 @@ const routes = [ name: "documents", component: () => import("../views/document/Main.vue"), }, + { + path: "broker-application", + name: "broker-applications", + component: () => import("../views/broker/Main.vue"), + }, { path: "ticket-list", name: "ticket-list", diff --git a/src/stores/broker.js b/src/stores/broker.js new file mode 100644 index 0000000..005cf9c --- /dev/null +++ b/src/stores/broker.js @@ -0,0 +1,83 @@ +import { defineStore } from "pinia"; +import { fetchWrapper } from "@/api"; +import { useAlertStore } from "@/stores"; +// import { useAuthStore } from "@/stores"; + +// const authStore = useAuthStore(); +// const { user } = storeToRefs(authStore); + +const baseUrl = `${import.meta.env.VITE_API_URL}/api/broker-application`; + +export const useBrokerStore = defineStore({ + id: "broker", + state: () => ({ + brokerApplication: null, + }), + actions: { + async getApplication() { + try { + const response = await fetchWrapper.get(`${baseUrl}`); + + // update pinia state + this.application = response["data"]; + } catch (error) { + // const alertStore = useAlertStore(); + // alertStore.error(error); + } + }, + + async fileUpload(attachmentId, docFile) { + + try { + let formData = new FormData(); + formData.append("file", docFile); + + const response = await fetchWrapper.post( + `${baseUrl}/upload/${attachmentId}`, + formData, + true + ); + + // update pinia state + await this.getApplication(); + + const alertStore = useAlertStore(); + // trigger alert + alertStore.success('Successfully uploaded'); + + } catch (error) { + // const alertStore = useAlertStore(); + // alertStore.error(error); + } + }, + + async apply() { + try { + const response = await fetchWrapper.post(`${baseUrl}/apply`); + + if(response != undefined) { + + // update pinia state + await this.getApplication(); + + const alertStore = useAlertStore(); + // trigger alert + alertStore.success('Successfully applied'); + } + + } catch (error) { + // const alertStore = useAlertStore(); + // alertStore.error(error); + } + }, + + // async downloadQuestionnaire(token) { + // try { + // await fetchWrapper.get(`http://ba.digital-tps.tk/export-questionnaire/${token}`); + // } catch (error) { + // // const alertStore = useAlertStore(); + // // alertStore.error(error); + // } + // }, + }, +}); diff --git a/src/stores/index.js b/src/stores/index.js index a159995..85f6d72 100644 --- a/src/stores/index.js +++ b/src/stores/index.js @@ -4,3 +4,4 @@ export * from "./countries"; export * from "./categories"; export * from "./application"; export * from "./tickets"; +export * from "./broker"; diff --git a/src/views/broker/Main.vue b/src/views/broker/Main.vue new file mode 100644 index 0000000..f9d1319 --- /dev/null +++ b/src/views/broker/Main.vue @@ -0,0 +1,310 @@ + + +