Skip to content

Commit

Permalink
add legacy voucher management
Browse files Browse the repository at this point in the history
  • Loading branch information
skyYaga committed Jul 16, 2023
1 parent 77f65dc commit 065b84b
Show file tree
Hide file tree
Showing 8 changed files with 354 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions src/components/NavBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@
}}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item
v-if="!$auth.loading && $auth.isAuthenticated && isAdminOrModerator"
link
:to="'/' + $i18n.locale + '/legacy-vouchers'"
>
<v-list-item-action>
<v-icon>mdi-file-certificate</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>{{
$t("voucher.legacy-vouchers")
}}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item
v-if="!$auth.loading && $auth.isAuthenticated && isAdminOrModerator"
link
Expand Down
21 changes: 21 additions & 0 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"ok": "OK",
"operating": "Sprungbetrieb",
"overview": "Übersicht",
"phone": "Telefon",
"picAndVid": {
"available": "Foto u. Video verfügbar",
"booked": "Foto u. Video gebucht",
Expand Down Expand Up @@ -243,6 +244,7 @@
"statistics": {
"header": "Tagesstatistik"
},
"street": "Straße",
"streetAdress": "Straße und Hausnummer",
"tandem": {
"available": "Tandem verfügbar",
Expand Down Expand Up @@ -321,7 +323,26 @@
"videoflyer": "Videoflyer"
},
"voucher": {
"back-payment": "Gutschein ist seit {years} Jahr(en) abgelaufen. Zuzahlung: {backPayment}€",
"buyDate": "Kaufdatum",
"details": "Gutscheindetails",
"id": "Gutschein-ID",
"info": "Bitte setze einen Haken, wenn der Springer einen Gutschein hat.",
"legacy-vouchers": "Altgutscheine",
"number": "Gutscheinnummer",
"paid": "Bezahlt",
"paymentProvider": "Bezahldienstleister",
"productDescription": "Produktbeschreibung",
"redeem": "Gutschein einlösen",
"redeem-error": "Fehler beim Einlösen des Gutscheins",
"redeem-successful": "Gutschein erfolgreich eingelöst",
"redeemDate": "Einlösedatum",
"redeemed": "Eingelöst",
"salutation": "Begrüßung",
"tax": "Steuer",
"transactionId": "Transaktions-ID",
"validUntil": "Gültig bis",
"value": "Wert",
"voucher": "Gutschein"
},
"weightMax90": "Gewicht maximal 90 kg",
Expand Down
21 changes: 21 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"ok": "OK",
"operating": "Operating",
"overview": "Overview",
"phone": "Phone",
"picAndVid": {
"available": "Pic and Vid available",
"booked": "Pic and Vid booked",
Expand Down Expand Up @@ -243,6 +244,7 @@
"statistics": {
"header": "Daily Statistics"
},
"street": "Street",
"streetAdress": "Street address",
"tandem": {
"available": "Tandem available",
Expand Down Expand Up @@ -321,7 +323,26 @@
"videoflyer": "Videoflyer"
},
"voucher": {
"back-payment": "Voucher expired since {years} year(s). Back payment: {backPayment}€",
"buyDate": "Buy date",
"details": "Voucher details",
"id": "Voucher ID",
"info": "Please check, if the jumper has a voucher",
"legacy-vouchers": "Legacy Vouchers",
"number": "Voucher number",
"paid": "Paid",
"paymentProvider": "Payment provider",
"productDescription": "Product description",
"redeem": "Redeem voucher",
"redeem-error": "Error redeeming voucher",
"redeem-successful": "Voucher redeemed sucessfully",
"redeemDate": "Redeem date",
"redeemed": "Redeemed",
"salutation": "Salutation",
"tax": "Tax",
"transactionId": "Transaction ID",
"validUntil": "Valid until",
"value": "Value",
"voucher": "Voucher"
},
"weightMax90": "Weight max 90 kg",
Expand Down
6 changes: 6 additions & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ let router = new Router({
component: () => import("./views/UserSettings.vue"),
beforeEnter: authGuard,
},
{
path: "legacy-vouchers",
name: "legacy-vouchers",
component: () => import("./views/LegacyVouchers.vue"),
beforeEnter: authGuard,
},
],
},
{
Expand Down
39 changes: 39 additions & 0 deletions src/shared/legacy-voucher-service.js
Original file line number Diff line number Diff line change
@@ -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,
};
7 changes: 7 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */

Expand Down
Loading

0 comments on commit 065b84b

Please sign in to comment.