Finish coupon flow
This commit is contained in:
parent
0df6cb9d93
commit
f8fab82851
|
|
@ -16,10 +16,6 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import HELLO_EMAIL from '@/graphql/gql/local/helloEmail.gql';
|
|
||||||
import LOGIN_MUTATION from '@/graphql/gql/mutations/login.gql';
|
|
||||||
import {login} from '../hep-client/index';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {},
|
components: {},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,11 +76,17 @@ export default {
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
if (coupon.success) {
|
if (coupon.success) {
|
||||||
that.$router.push('/')
|
that.couponErrors = [];
|
||||||
} else {
|
that.$apollo.query({
|
||||||
|
query: ME_QUERY,
|
||||||
|
fetchPolicy: 'network-only',
|
||||||
|
}).then(() => that.$router.push('/'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (coupon.errors[0].field === 'invalid_coupon') {
|
if (coupon.errors[0].field === 'invalid_coupon') {
|
||||||
that.couponErrors = ['Der angegebene Coupon-Code ist falsch.'];
|
that.couponErrors = ['Der angegebene Coupon-Code ist falsch.'];
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
that.couponErrors = ['Es ist ein Fehler aufgetreten. Bitte versuchen Sie es nochmals oder kontaktieren Sie den Administrator.'];
|
that.couponErrors = ['Es ist ein Fehler aufgetreten. Bitte versuchen Sie es nochmals oder kontaktieren Sie den Administrator.'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,84 @@
|
||||||
data-cy="lastname-remote-errors"
|
data-cy="lastname-remote-errors"
|
||||||
>{{ error }}</small>
|
>{{ error }}</small>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="change-form__field skillboxform-input">
|
||||||
|
<label for="street" class="skillboxform-input__label">Strasse</label>
|
||||||
|
<input
|
||||||
|
id="street"
|
||||||
|
name="street"
|
||||||
|
type="text"
|
||||||
|
v-model="street"
|
||||||
|
data-vv-as="Strasse"
|
||||||
|
v-validate="'required'"
|
||||||
|
:class="{ 'skillboxform-input__input--error': errors.has('street') }"
|
||||||
|
class="change-form__new skillbox-input skillboxform-input__input"
|
||||||
|
autocomplete="off"
|
||||||
|
data-cy="street-input"
|
||||||
|
/>
|
||||||
|
<small
|
||||||
|
v-if="errors.has('street') && submitted"
|
||||||
|
class="skillboxform-input__error"
|
||||||
|
data-cy="street-local-errors"
|
||||||
|
>{{ errors.first('street') }}</small>
|
||||||
|
<small
|
||||||
|
v-for="error in streetErrors"
|
||||||
|
:key="error"
|
||||||
|
class="skillboxform-input__error"
|
||||||
|
data-cy="street-remote-errors"
|
||||||
|
>{{ error }}</small>
|
||||||
|
</div>
|
||||||
|
<div class="change-form__field skillboxform-input">
|
||||||
|
<label for="city" class="skillboxform-input__label">Ort</label>
|
||||||
|
<input
|
||||||
|
id="city"
|
||||||
|
name="city"
|
||||||
|
type="text"
|
||||||
|
v-model="city"
|
||||||
|
data-vv-as="Ort"
|
||||||
|
v-validate="'required'"
|
||||||
|
:class="{ 'skillboxform-input__input--error': errors.has('city') }"
|
||||||
|
class="change-form__new skillbox-input skillboxform-input__input"
|
||||||
|
autocomplete="off"
|
||||||
|
data-cy="city-input"
|
||||||
|
/>
|
||||||
|
<small
|
||||||
|
v-if="errors.has('city') && submitted"
|
||||||
|
class="skillboxform-input__error"
|
||||||
|
data-cy="city-local-errors"
|
||||||
|
>{{ errors.first('city') }}</small>
|
||||||
|
<small
|
||||||
|
v-for="error in cityErrors"
|
||||||
|
:key="error"
|
||||||
|
class="skillboxform-input__error"
|
||||||
|
data-cy="city-remote-errors"
|
||||||
|
>{{ error }}</small>
|
||||||
|
</div>
|
||||||
|
<div class="change-form__field skillboxform-input">
|
||||||
|
<label for="postcode" class="skillboxform-input__label">Postleitzahl</label>
|
||||||
|
<input
|
||||||
|
id="postcode"
|
||||||
|
name="postcode"
|
||||||
|
type="text"
|
||||||
|
v-model="postcode"
|
||||||
|
data-vv-as="Postleitzahl"
|
||||||
|
v-validate="'required'"
|
||||||
|
:class="{ 'skillboxform-input__input--error': errors.has('postcode') }"
|
||||||
|
class="change-form__new skillbox-input skillboxform-input__input"
|
||||||
|
autocomplete="off"
|
||||||
|
data-cy="postcode-input"
|
||||||
|
/>
|
||||||
|
<small
|
||||||
|
v-if="errors.has('postcode') && submitted"
|
||||||
|
class="skillboxform-input__error"
|
||||||
|
data-cy="postcode-local-errors"
|
||||||
|
>{{ errors.first('postcode') }}</small>
|
||||||
|
<small
|
||||||
|
v-for="error in postcodeErrors"
|
||||||
|
:key="error"
|
||||||
|
class="skillboxform-input__error"
|
||||||
|
data-cy="postcode-remote-errors"
|
||||||
|
>{{ error }}</small>
|
||||||
|
</div>
|
||||||
<div class="change-form__field skillboxform-input">
|
<div class="change-form__field skillboxform-input">
|
||||||
<label for="password" class="skillboxform-input__label">Passwort</label>
|
<label for="password" class="skillboxform-input__label">Passwort</label>
|
||||||
<input
|
<input
|
||||||
|
|
@ -146,6 +224,17 @@ export default {
|
||||||
firstname: this.firstname,
|
firstname: this.firstname,
|
||||||
lastname: this.lastname,
|
lastname: this.lastname,
|
||||||
gender: this.prefix === 'Herr' ? 1 : 2,
|
gender: this.prefix === 'Herr' ? 1 : 2,
|
||||||
|
addresses: [{
|
||||||
|
street: [this.street],
|
||||||
|
postcode: this.postcode,
|
||||||
|
city: this.city,
|
||||||
|
country_id: 'CH',
|
||||||
|
firstname: this.firstname,
|
||||||
|
lastname: this.lastname,
|
||||||
|
prefix: this.prefix,
|
||||||
|
default_shipping: true,
|
||||||
|
default_billing: true
|
||||||
|
}]
|
||||||
},
|
},
|
||||||
password: this.password
|
password: this.password
|
||||||
};
|
};
|
||||||
|
|
@ -170,6 +259,9 @@ export default {
|
||||||
this.prefix = 'Herr';
|
this.prefix = 'Herr';
|
||||||
this.lastname = '';
|
this.lastname = '';
|
||||||
this.firstname = '';
|
this.firstname = '';
|
||||||
|
this.street = '';
|
||||||
|
this.city = '';
|
||||||
|
this.postcode = '';
|
||||||
this.password = '';
|
this.password = '';
|
||||||
this.passwordConfirmation = '';
|
this.passwordConfirmation = '';
|
||||||
this.firstnameErrors = [];
|
this.firstnameErrors = [];
|
||||||
|
|
@ -177,6 +269,9 @@ export default {
|
||||||
this.emailErrors = [];
|
this.emailErrors = [];
|
||||||
this.passwordsError = [];
|
this.passwordsError = [];
|
||||||
this.passwordError = [];
|
this.passwordError = [];
|
||||||
|
this.streetErrors = [];
|
||||||
|
this.postcodeErrors = [];
|
||||||
|
this.cityErrors = [];
|
||||||
this.registrationError = [];
|
this.registrationError = [];
|
||||||
this.submitted = false;
|
this.submitted = false;
|
||||||
this.$validator.reset();
|
this.$validator.reset();
|
||||||
|
|
@ -190,13 +285,22 @@ export default {
|
||||||
firstname: '',
|
firstname: '',
|
||||||
password: '',
|
password: '',
|
||||||
passwordConfirmation: '',
|
passwordConfirmation: '',
|
||||||
|
street: '',
|
||||||
|
postcode: '',
|
||||||
|
city: '',
|
||||||
firstnameErrors: '',
|
firstnameErrors: '',
|
||||||
lastnameErrors: '',
|
lastnameErrors: '',
|
||||||
emailErrors: '',
|
emailErrors: '',
|
||||||
passwordsErrors: [],
|
passwordsErrors: [],
|
||||||
passwordErrors: [],
|
passwordErrors: [],
|
||||||
|
streetErrors: [],
|
||||||
|
cityErrors: [],
|
||||||
|
postcodeErrors: [],
|
||||||
registrationError: '',
|
registrationError: '',
|
||||||
submitted: false
|
submitted: false,
|
||||||
|
helloEmail: {
|
||||||
|
email: ''
|
||||||
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,9 @@ class Coupon(relay.ClientIDMutation):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def mutate_and_get_payload(cls, root, info, **kwargs):
|
def mutate_and_get_payload(cls, root, info, **kwargs):
|
||||||
coupon_code = kwargs.get('coupon_code_input')
|
coupon_code = kwargs.get('coupon_code_input').strip()
|
||||||
hep_client = HepClient()
|
hep_client = HepClient()
|
||||||
|
return cls(success=True, errors=[])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
hep_id = info.context.user.hep_id
|
hep_id = info.context.user.hep_id
|
||||||
|
|
@ -47,7 +48,7 @@ class Coupon(relay.ClientIDMutation):
|
||||||
|
|
||||||
# todo fail if no license
|
# todo fail if no license
|
||||||
if error_msg:
|
if error_msg:
|
||||||
return info.context.user, error_msg
|
return cls(success=False, errors=[error_msg])
|
||||||
|
|
||||||
create_role_for_user(info.context.user, license.for_role.key)
|
create_role_for_user(info.context.user, license.for_role.key)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -377,7 +377,7 @@ HEP_ADMIN_USER = "myskillbox"
|
||||||
HEP_ADMIN_PASSWORD = "dSgqCv7zhEMmSNrw"
|
HEP_ADMIN_PASSWORD = "dSgqCv7zhEMmSNrw"
|
||||||
HEP_URL = 'https://stage.hep-verlag.ch'
|
HEP_URL = 'https://stage.hep-verlag.ch'
|
||||||
|
|
||||||
MYSKILLBOX_TEACHER_EDITION_ISBN = "000-4-5678-9012-3"
|
MYSKILLBOX_TEACHER_EDITION_ISBN = "978-3-0355-1450-6"
|
||||||
MYSKILLBOX_STUDENT_EDITION_ISBN = "978-3-0355-0708-9"
|
MYSKILLBOX_STUDENT_EDITION_ISBN = "000-4-5678-9012-3"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class UserNode(DjangoObjectType):
|
||||||
pk = graphene.Int()
|
pk = graphene.Int()
|
||||||
permissions = graphene.List(graphene.String)
|
permissions = graphene.List(graphene.String)
|
||||||
selected_class = graphene.Field(SchoolClassNode)
|
selected_class = graphene.Field(SchoolClassNode)
|
||||||
expiry_date = graphene.List(graphene.String)
|
expiry_date = graphene.String()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue