diff --git a/.eslintrc.js b/.eslintrc.js index 22aaa660..1672b284 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,7 +3,10 @@ module.exports = { env: { node: true, }, - extends: ["eslint:recommended", "plugin:vue/recommended", "@vue/prettier"], + extends: [ + "plugin:vue/recommended", + "eslint:recommended", + ], rules: { "no-console": process.env.NODE_ENV === "production" ? "error" : "off", "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off", diff --git a/src/components/NavBar.vue b/src/components/NavBar.vue index ae76cefc..ac078181 100644 --- a/src/components/NavBar.vue +++ b/src/components/NavBar.vue @@ -44,6 +44,20 @@ }} + + + mdi-file-certificate + + + {{ + $t("voucher.legacy-vouchers") + }} + + import("./views/UserSettings.vue"), beforeEnter: authGuard, }, + { + path: "legacy-vouchers", + name: "legacy-vouchers", + component: () => import("./views/LegacyVouchers.vue"), + beforeEnter: authGuard, + }, ], }, { diff --git a/src/shared/legacy-voucher-service.js b/src/shared/legacy-voucher-service.js new file mode 100644 index 00000000..fc04ff54 --- /dev/null +++ b/src/shared/legacy-voucher-service.js @@ -0,0 +1,39 @@ +import * as axios from "axios"; +import { responseHandler } from "./response-handler"; + +const apiPath = process.env.VUE_APP_API; + +const searchVoucher = async function (id, token) { + try { + const response = await axios.get(apiPath + "/legacy-voucher/" + id, { + headers: { + Authorization: `Bearer ${token}`, + }, + }); + return responseHandler.handleResponse(response, 200); + } catch (error) { + return responseHandler.handleError(error); + } +}; + +const redeemVoucher = async function (id, token) { + try { + const response = await axios.patch( + apiPath + "/legacy-voucher/" + id + "/redeem", + {}, + { + headers: { + Authorization: `Bearer ${token}`, + }, + } + ); + return responseHandler.handleResponse(response, 200); + } catch (error) { + return responseHandler.handleError(error); + } +}; + +export const legacyVoucherService = { + searchVoucher, + redeemVoucher, +}; diff --git a/src/store/index.js b/src/store/index.js index 553c9705..6aab119b 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -14,6 +14,7 @@ import tandemmaster from "./modules/tandemmaster"; import videoflyer from "./modules/videoflyer"; import { appointmentService } from "../shared/appointment-service"; +import { legacyVoucherService } from "../shared/legacy-voucher-service"; import { userService } from "../shared/user-service"; Vue.use(Vuex); @@ -171,6 +172,12 @@ const actions = { async getRolesAction({ commit }, token) { return await userService.getRoles(token); }, + async getLegacyVoucherAction({ commit }, payload) { + return await legacyVoucherService.searchVoucher(payload.id, payload.token); + }, + async redeemLegacyVoucherAction({ commit }, payload) { + return await legacyVoucherService.redeemVoucher(payload.id, payload.token); + }, }; /* eslint-enable no-unused-vars */ diff --git a/src/views/LegacyVouchers.vue b/src/views/LegacyVouchers.vue new file mode 100644 index 00000000..d54ef1f0 --- /dev/null +++ b/src/views/LegacyVouchers.vue @@ -0,0 +1,242 @@ + + + + +