1
1
<template >
2
2
<div class =" subfooter-form" >
3
- <div :class =" ['form-field-container', { error: fieldError}]" >
4
3
5
- <div class =" detail-wrapper" >
6
- <svg
7
- width =" 400"
8
- viewBox =" 0 0 400 41"
9
- fill =" none"
10
- xmlns =" http://www.w3.org/2000/svg"
11
- class =" detail" >
12
- <path
13
- :d =" path"
14
- stroke =" #FFC582"
15
- stroke-width =" 2"
16
- shape-rendering =" crispEdges"
17
- class =" stroke-path" />
18
- </svg >
19
- </div >
4
+ <div class =" form-wrapper" >
5
+ <div :class =" ['form-field-container', { error: fieldError}]" >
6
+ <div class =" detail-wrapper" >
7
+ <svg
8
+ width =" 400"
9
+ viewBox =" 0 0 400 41"
10
+ fill =" none"
11
+ xmlns =" http://www.w3.org/2000/svg"
12
+ class =" detail" >
13
+ <path
14
+ :d =" path"
15
+ stroke =" #FFC582"
16
+ stroke-width =" 2"
17
+ shape-rendering =" crispEdges"
18
+ class =" stroke-path" />
19
+ </svg >
20
+ </div >
20
21
21
- <div class =" field-email" >
22
- <input
23
- class =" email"
24
- :placeholder =" placeholder"
25
- type =" email"
26
- required =" true"
27
- @input =" updateValue($event.target.value)" />
22
+ <div class =" field-email" >
23
+ <input
24
+ class =" email"
25
+ :placeholder =" placeholder"
26
+ type =" email"
27
+ required =" true"
28
+ @input =" updateValue($event.target.value)" />
29
+ </div >
28
30
</div >
31
+
32
+ <ButtonCtaWithLoader
33
+ :class =" ['submit-button', { submitted: formSubmitted }]"
34
+ theme =" secondary"
35
+ loader =" subfooter-card-newsletter-signup"
36
+ @clicked =" submitForm" >
37
+ <template #button-content >
38
+ <span class =" button-label" > {{ buttonText }} </span >
39
+ </template >
40
+ </ButtonCtaWithLoader >
29
41
</div >
30
42
31
- <ButtonCtaWithLoader
32
- :class =" ['submit-button', { submitted: formSubmitted }]"
33
- theme =" secondary"
34
- loader =" subfooter-card-newsletter-signup"
35
- @clicked =" submitForm" >
36
- <template #button-content >
37
- <span class =" button-label" > {{ buttonText }} </span >
38
- </template >
39
- </ButtonCtaWithLoader >
43
+ <span v-if =" submitError" class =" submit-error" v-html =" errorMessage" />
40
44
41
45
</div >
42
46
</template >
@@ -60,6 +64,8 @@ const props = defineProps({
60
64
61
65
// ======================================================================== Data
62
66
const formSubmitted = ref (false )
67
+ const submitError = ref (false )
68
+ const errorMessage = " Uh oh, we were not able to send that data due to an error — please try again, or reach out to us via Slack"
63
69
const fieldError = ref (false )
64
70
const field = ref (false )
65
71
// ==================================================================== Computed
@@ -89,8 +95,7 @@ const updateValue = (val) => {
89
95
* @method submitForm
90
96
*/
91
97
const submitForm = async () => {
92
- // if (formSubmitted.value) { $button('triple-line-loader').set({ loading: false }); return }
93
- if (formSubmitted .value ) { return }
98
+ if (formSubmitted .value ) { $button (' triple-line-loader' ).set ({ loading: false }); return }
94
99
if (field .value ) {
95
100
const body = {
96
101
records: [
@@ -105,16 +110,18 @@ const submitForm = async () => {
105
110
' Content-Type' : ' application/json' ,
106
111
' Authorization' : ` Bearer ${ config .public .airtableToken } `
107
112
}
108
- const res = await $fetch (' https://api.airtable.com/v0/apphbQmrNLNNXiaqG/tblSB1NYasWQIDGlp' , {
113
+ await $fetch (' https://api.airtable.com/v0/apphbQmrNLNNXiaqG/tblSB1NYasWQIDGlp' , {
109
114
method: ' POST' ,
110
115
body,
111
116
headers
112
- })
113
- if (res) {
117
+ }).then (() => {
114
118
buttonStore .set ({id: ' subfooter-card-newsletter-signup' , loading: false })
115
119
formSubmitted .value = true
116
120
return
117
- }
121
+ }).catch (() => {
122
+ submitError .value = true
123
+ buttonStore .set ({id: ' subfooter-card-newsletter-signup' , loading: false })
124
+ })
118
125
}
119
126
if (! field .value ) {
120
127
fieldError .value = true
@@ -127,6 +134,11 @@ const submitForm = async () => {
127
134
<style lang="scss" scoped>
128
135
// ///////////////////////////////////////////////////////////////////// General
129
136
.subfooter-form {
137
+ position : relative ;
138
+ }
139
+
140
+ .form-wrapper {
141
+ position : relative ;
130
142
display : flex ;
131
143
white-space : nowrap ;
132
144
margin-left : 1.5625rem ;
@@ -138,6 +150,19 @@ const submitForm = async () => {
138
150
}
139
151
}
140
152
153
+ .submit-error {
154
+ display : block ;
155
+ width : 66% ;
156
+ margin-top : toRem (5 );
157
+ word-break : break-word ;
158
+ text-align : right ;
159
+ @include formFieldErrorMessage ;
160
+ color : var (--error );
161
+ @include mini {
162
+ width : calc (100% - toRem (2 ));
163
+ }
164
+ }
165
+
141
166
// ////////////////////////////////////////////////////////////// Detail Wrapper
142
167
.detail-wrapper {
143
168
position : absolute ;
0 commit comments