mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
New client settings (#8886)
* Added initial settings page * Initial cleanup and translations * Ported api settings * Ported promocode settings * POrted notifications code * Fixed styles and translatins for site page * Ported over rest of settings functions * Ported payments over * Initial lint clean up * Added amazon modal * Added stripe * Added site settings
This commit is contained in:
61
website/client/components/settings/promoCode.vue
Normal file
61
website/client/components/settings/promoCode.vue
Normal file
@@ -0,0 +1,61 @@
|
||||
<template lang="pug">
|
||||
.row.standard-page
|
||||
.col-md-6
|
||||
h2 {{ $t('promoCode') }}
|
||||
.form-inline(role='form')
|
||||
input.form-control(type='text', v-model='couponCode', :placeholder="$t('promoPlaceholder')")
|
||||
button.btn.btn-primary(@click='enterCoupon()') {{ $t('submit') }}
|
||||
div
|
||||
small {{ $t('couponText') }}
|
||||
div(v-if='user.contributor.sudo')
|
||||
hr
|
||||
h4 {{ $t('generateCodes') }}
|
||||
.form(role='form')
|
||||
.form-group
|
||||
input.form-control(type='text', v-model='codes.event', placeholder="Event code (eg, 'wondercon')")
|
||||
.form-group
|
||||
input.form-control(type='number', v-model='codes.count', placeholder="Number of codes to generate (eg, 250)")
|
||||
.form-group
|
||||
button.btn.btn-primary(type='submit', @click='generateCodes(codes)') {{ $t('generate') }}
|
||||
a.btn.btn-default(:href='getCodesUrl') {{ $t('getCodes') }}
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios';
|
||||
import { mapState } from 'client/libs/store';
|
||||
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
codes: {
|
||||
event: '',
|
||||
count: '',
|
||||
},
|
||||
couponCode: '',
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState({user: 'user.data'}),
|
||||
getCodesUrl () {
|
||||
if (!this.user) return '';
|
||||
return `/api/v3/coupons?_id=${this.user._id}&apiToken=${this.user.apiToken}`;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
generateCodes () {
|
||||
// $http.post(ApiUrl.get() + '/api/v2/coupons/generate/'+codes.event+'?count='+(codes.count || 1))
|
||||
// .success(function(res,code){
|
||||
// $scope._codes = {};
|
||||
// if (code!==200) return;
|
||||
// window.location.href = '/api/v2/coupons?limit='+codes.count+'&_id='+User.user._id+'&apiToken='+User.settings.auth.apiToken;
|
||||
// })
|
||||
},
|
||||
async enterCoupon () {
|
||||
let code = await axios.get(`/api/v3/coupons/enter/${this.couponCode}`);
|
||||
if (!code) return;
|
||||
// @TODO: what needs to be updated? User.sync();
|
||||
// @TODO: mixin Notification.text(env.t('promoCodeApplied'));
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user