Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

Commit 60fb339

Browse files
committed
adds label to birth field
1 parent 60b4be2 commit 60fb339

File tree

1 file changed

+100
-110
lines changed

1 file changed

+100
-110
lines changed

src/views/Register/Step2.vue

Lines changed: 100 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,122 @@
11
<template>
2-
<v-form @submit.prevent="validate" ref="form" v-model="isValid">
3-
<v-card-text>
4-
<v-row no-gutters>
5-
<v-col>
6-
<v-text-field
7-
v-bind="fields.firstName"
8-
v-model="fields.firstName.value"
9-
:disabled="isSubmitting"
10-
/>
11-
</v-col>
12-
<v-col>
13-
<v-text-field
14-
v-bind="fields.lastName"
15-
v-model="fields.lastName.value"
16-
:disabled="isSubmitting"
17-
/>
18-
</v-col>
19-
</v-row>
20-
<v-text-field
21-
v-bind="fields.studentEmail"
22-
v-model="fields.studentEmail.value"
23-
:disabled="isSubmitting"
24-
/>
25-
<date-of-birth-field v-model="fields.dateOfBirth.value" />
26-
</v-card-text>
2+
<v-form @submit.prevent="validate" ref="form" v-model="isValid">
3+
<v-card-text>
4+
<v-row no-gutters>
5+
<v-col>
6+
<v-text-field
7+
v-bind="fields.firstName"
8+
v-model="fields.firstName.value"
9+
:disabled="isSubmitting"
10+
/>
11+
</v-col>
12+
<v-col>
13+
<v-text-field
14+
v-bind="fields.lastName"
15+
v-model="fields.lastName.value"
16+
:disabled="isSubmitting"
17+
/>
18+
</v-col>
19+
</v-row>
20+
<v-text-field
21+
v-bind="fields.studentEmail"
22+
v-model="fields.studentEmail.value"
23+
:disabled="isSubmitting"
24+
/>
25+
<date-of-birth-field :label="fields.dateOfBirth.label" v-model="fields.dateOfBirth.value" />
26+
</v-card-text>
2727

28-
<v-card-text v-if="showParentConsentAlert">
29-
<v-alert colored-border icon="mdi-firework">
30-
You are not 13 years of age.
31-
<p>
32-
In order to continue with the code challenge you must have your
33-
parent's permission. Have your parent or guardian complete the rest of
34-
this page.
35-
</p>
36-
<v-switch
37-
v-model="hasParentConsent"
38-
class="mx-2"
39-
:rules="[
28+
<v-card-text v-if="showParentConsentAlert">
29+
<v-alert colored-border icon="mdi-firework">
30+
You are not 13 years of age.
31+
<p>
32+
In order to continue with the code challenge you must have your
33+
parent's permission. Have your parent or guardian complete the rest of
34+
this page.
35+
</p>
36+
<v-switch
37+
v-model="hasParentConsent"
38+
class="mx-2"
39+
:rules="[
4040
v =>
4141
!!v ||
4242
'Please have your parent or guardian review this form before continuing'
4343
]"
44-
:label="
44+
:label="
4545
'I, the parent or guardian of ' +
4646
this.fields.firstName.value +
4747
' ' +
4848
this.fields.lastName.value +
4949
', give my consent to participate in the CodeWizardsHQ Code Challenge.'
5050
"
51-
></v-switch>
52-
</v-alert>
53-
</v-card-text>
51+
></v-switch>
52+
</v-alert>
53+
</v-card-text>
5454

55-
<v-card-actions>
56-
<v-btn
57-
color="secondary darken-2"
58-
@click="() => $emit('back')"
59-
:disabled="isSubmitting"
60-
>Back</v-btn
61-
>
62-
<v-spacer />
63-
<v-btn color="secondary darken-2" type="submit" :disabled="isSubmitting">
64-
Next
65-
<v-progress-circular
66-
size="14"
67-
class="ml-3"
68-
indeterminate
69-
v-if="isSubmitting"
70-
/>
71-
</v-btn>
72-
</v-card-actions>
73-
</v-form>
55+
<v-card-actions>
56+
<v-btn color="secondary darken-2" @click="() => $emit('back')" :disabled="isSubmitting">Back</v-btn>
57+
<v-spacer />
58+
<v-btn color="secondary darken-2" type="submit" :disabled="isSubmitting">
59+
Next
60+
<v-progress-circular size="14" class="ml-3" indeterminate v-if="isSubmitting" />
61+
</v-btn>
62+
</v-card-actions>
63+
</v-form>
7464
</template>
7565

7666
<script>
7767
import DateOfBirthField from "./DateOfBirthField";
7868
import moment from "moment";
7969
8070
export default {
81-
name: "register-step-2",
82-
props: ["fields"],
83-
components: {
84-
DateOfBirthField
85-
},
86-
watch: {
87-
"fields.dateOfBirth.value"() {
88-
if (!this.needsParentConsent) {
89-
this.showParentConsentAlert = false;
90-
}
91-
}
92-
},
93-
computed: {
94-
age() {
95-
return moment().diff(this.fields.dateOfBirth.value, "years", false);
96-
},
97-
needsParentConsent() {
98-
return this.age < 13;
99-
}
100-
},
101-
methods: {
102-
async submit() {
103-
if (this.isSubmitting) {
104-
return;
105-
}
106-
this.isSubmitting = true;
107-
const cb = () => {
108-
this.isSubmitting = false;
109-
};
110-
this.$emit("submit", cb);
111-
},
112-
validate() {
113-
if (this.$refs.form.validate()) {
114-
if (this.needsParentConsent && !this.hasParentConsent) {
115-
this.showParentConsentAlert = true;
116-
} else {
117-
this.submit();
118-
}
119-
}
120-
}
121-
},
122-
data() {
123-
return {
124-
showParentConsentAlert: false,
125-
hasParentConsent: false,
126-
isValid: false,
127-
isSubmitting: false,
128-
showCalendar: false
129-
};
130-
}
71+
name: "register-step-2",
72+
props: ["fields"],
73+
components: {
74+
DateOfBirthField
75+
},
76+
watch: {
77+
"fields.dateOfBirth.value"() {
78+
if (!this.needsParentConsent) {
79+
this.showParentConsentAlert = false;
80+
}
81+
}
82+
},
83+
computed: {
84+
age() {
85+
return moment().diff(this.fields.dateOfBirth.value, "years", false);
86+
},
87+
needsParentConsent() {
88+
return this.age < 13;
89+
}
90+
},
91+
methods: {
92+
async submit() {
93+
if (this.isSubmitting) {
94+
return;
95+
}
96+
this.isSubmitting = true;
97+
const cb = () => {
98+
this.isSubmitting = false;
99+
};
100+
this.$emit("submit", cb);
101+
},
102+
validate() {
103+
if (this.$refs.form.validate()) {
104+
if (this.needsParentConsent && !this.hasParentConsent) {
105+
this.showParentConsentAlert = true;
106+
} else {
107+
this.submit();
108+
}
109+
}
110+
}
111+
},
112+
data() {
113+
return {
114+
showParentConsentAlert: false,
115+
hasParentConsent: false,
116+
isValid: false,
117+
isSubmitting: false,
118+
showCalendar: false
119+
};
120+
}
131121
};
132122
</script>

0 commit comments

Comments
 (0)