From dfc20a325475f5e2bae268e7e27be61abe78978d Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 15 Jul 2022 08:37:33 +0200 Subject: [PATCH] change code, to review from moriz --- .../Contributions/ContributionForm.vue | 26 ++++++++++--------- frontend/src/i18n.js | 8 ++++++ frontend/src/locales/de.json | 4 +-- frontend/src/locales/en.json | 4 +-- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index ff74786d6..f00b128a7 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -15,7 +15,7 @@ {{ $t('form.amount') }}
- + {{ $t('contribution.submit') }} {{date}}, {{amount}}, {{ memo}} @@ -80,8 +80,6 @@ export default { return { minlength: 50, maxlength: 255, - lastMonth: new Date(new Date(new Date().setMonth(new Date().getMonth() - 1))), - min: new Date(new Date(new Date().setMonth(new Date().getMonth() - 1)).setDate(1)), max: new Date(), form: { date: this.date, @@ -98,10 +96,16 @@ export default { }, }, computed: { - disable() { + lastMonth(){ + return new Date(new Date(new Date().setMonth(new Date().getMonth() - 1))) + }, + min() { + return new Date(new Date(new Date().setMonth(new Date().getMonth() - 1)).setDate(1)) + }, + disabled() { if ( this.form.memo.length < this.minlength || - this.form.amount === 0 || + this.form.amount <= 0 || this.form.amount > 1000 ) return true @@ -110,16 +114,14 @@ export default { lastMonthObject() { // new Date().getMonth === 1 If the current month is January, then one year must be gone back in the previous month const obj = { - month: new Date(this.lastMonth).toLocaleString(this.$i18n.locale, { month: 'long' }), - year: new Date().getMonth === 1 ? new Date().getFullYear() - 1 : new Date().getFullYear(), + monthAndYear: this.$d(new Date(this.lastMonth), 'monthAndYear'), creation: this.$store.state.creation[1], } return this.$t('contribution.formText.lastMonth', obj) }, thisMonthObject() { const obj = { - month: new Date().toLocaleString(this.$i18n.locale, { month: 'long' }), - year: new Date().getFullYear(), + monthAndYear: this.$d(new Date(), 'monthAndYear'), creation: this.$store.state.creation[2], } return this.$t('contribution.formText.thisMonth', obj) diff --git a/frontend/src/i18n.js b/frontend/src/i18n.js index 74de46c29..3136c6d80 100644 --- a/frontend/src/i18n.js +++ b/frontend/src/i18n.js @@ -84,6 +84,10 @@ const dateTimeFormats = { year: { year: 'numeric', }, + monthAndYear: { + month: 'long', + year: 'numeric', + }, }, de: { short: { @@ -108,6 +112,10 @@ const dateTimeFormats = { year: { year: 'numeric', }, + monthAndYear: { + month: 'long', + year: 'numeric', + }, }, } diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 12ebc86b3..5c8b8b366 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -35,10 +35,10 @@ "activity": "Tätigkeit", "formText": { "h3": "Dein Beitrag zum Gemeinwohl", - "lastMonth": "Für {month} {year} kannst du noch {creation} GDD einreichen.", + "lastMonth": "Für {monthAndYear} kannst du noch {creation} GDD einreichen.", "text1": "Bring dich mit deinen Talenten in die Gemeinschaft ein! Dein freiwilliges Engagement honorieren wir mit 20 GDD pro Stunde bis maximal 1.000 GDD im Monat.", "text2": "Beschreibe deine Gemeinwohl-Tätigkeit mit Angabe der Stunden und trage einen Betrag von 20 GDD pro Stunde ein! Nach Bestätigung durch einen Moderator wird der Betrag deinem Konto gutgeschrieben.", - "thisMonth": "Für {month} {year} kannst du noch {creation} GDD einreichen. " + "thisMonth": "Für {monthAndYear} kannst du noch {creation} GDD einreichen. " }, "noDateSelected": "Kein Datum ausgewählt", "submit": "Einreichen" diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 1ef7052d5..8b0df2595 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -35,10 +35,10 @@ "activity": "Activity", "formText": { "h3": "Your contribution to the common good", - "lastMonth": "For {month} {year}, you can still submit {creation} GDD.", + "lastMonth": "For {monthAndYear}, you can still submit {creation} GDD.", "text1": "Bring your talents to the community! Your voluntary commitment will be rewarded with 20 GDD per hour up to a maximum of 1,000 GDD per month.", "text2": "Describe your community service activity with hours and enter an amount of 20 GDD per hour! After confirmation by a moderator, the amount will be credited to your account.", - "thisMonth": "For {month} {year}, you can still submit {creation} GDD." + "thisMonth": "For {monthAndYear}, you can still submit {creation} GDD." }, "noDateSelected": "No date selected", "submit": "Submit"