Skip to content

Instantly share code, notes, and snippets.

@bmdalex
Last active January 24, 2021 20:19
Show Gist options
  • Select an option

  • Save bmdalex/22e27c6fc865792039049096dc70feee to your computer and use it in GitHub Desktop.

Select an option

Save bmdalex/22e27c6fc865792039049096dc70feee to your computer and use it in GitHub Desktop.
Registration Form Component used for testing - short version
<script>
import { validateEmail } from './validateEmail.js'
export default {
name: 'RegistrationForm',
props: {
termsAndConditions: {
type: Boolean,
default: false
}
},
data() {
return {
formData: { email: '', termsAccepted: false }
}
},
methods: {
async handleFormSubmit() {
this.assertEmailIsValidAndTermsAccepted()
const { email } = this.formData
const response = await this.$auth.registerUser({ email })
this.$emit('register-update', response)
}
}
}
</script>
<template>
<form @submit.prevent="handleFormSubmit" data-test-id="registration-form">
<div class="registration-form__field">
<label data-test-id="registration-email-label" for="email-input">Email</label>
<input v-model="formData.email" data-test-id="registration-email-input" />
</div>
<div class="registration-form__field" v-if="termsAndConditions">
<input
v-model="formData.termsAccepted"
type="checkbox"
data-test-id="registration-terms-input"
/>
<label data-test-id="registration-terms-label" for="terms-input">
I agree to the Terms
</label>
</div>
<div class="registration-form__field">
<button type="submit" data-test-id="registration-submit-button">Submit</button>
<span data-test-id="registration-error" v-if="errorMsg">{{ errorMsg }}</span>
</div>
</form>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment