Skip to content

Commit e6c0dfd

Browse files
committed
feat: form submits to airtable
1 parent d8d9120 commit e6c0dfd

File tree

1 file changed

+45
-7
lines changed

1 file changed

+45
-7
lines changed

components/signup-card.vue

+45-7
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@
44
:style="cardStyles">
55
<div class="content">
66

7-
<div class="text">
7+
<div class="title-wrapper">
88

99
<IconPieChartIcon />
1010

1111
<div v-if="title" class="title">
1212
{{ title }}
1313
</div>
1414

15-
<div v-if="description" class="description">
16-
{{ description }}
17-
</div>
1815

1916
</div>
2017

18+
<div v-if="description" class="description">
19+
{{ description }}
20+
</div>
21+
2122
<div class="signup-form">
2223

2324
<div class="name-fields">
@@ -58,7 +59,7 @@
5859
{{ selected.label }}
5960
</p>
6061
<p v-else class="toggle-button-label">
61-
Select an option
62+
Country
6263
</p>
6364
</div>
6465
</template>
@@ -104,13 +105,20 @@
104105
</template>
105106
</ZeroDropdown>
106107

108+
<ZeroButton
109+
class="submit-button"
110+
@clicked="submitForm">
111+
<span class="button-label"> Register </span>
112+
</ZeroButton>
113+
107114
</div>
108115

109116
</div>
110117
</div>
111118
</template>
112119

113120
<script setup>
121+
const SINGULARITY_DEMO_SIGNUPS_TOKEN = import.meta.env.VITE_AIRTABLE_SINGULARITY_DEMO_TOKEN
114122
// ======================================================================= Props
115123
const props = defineProps({
116124
signupCard: {
@@ -124,7 +132,7 @@ const props = defineProps({
124132
const firstName = ref(false)
125133
const lastName = ref(false)
126134
const email = ref(false)
127-
const org = ref(false)
135+
const organization = ref(false)
128136
const country = ref(false)
129137
const filecoinFamiliarity = ref(false)
130138
@@ -169,7 +177,7 @@ const updateInputValue = (val, field) => {
169177
email.value = val
170178
break
171179
case 'org':
172-
org.value = val
180+
organization.value = val
173181
break
174182
}
175183
}
@@ -190,6 +198,36 @@ const selectOption = (setSelected, closePanel, option, field) => {
190198
}
191199
}
192200
}
201+
/**
202+
* @method submitForm
203+
*/
204+
const submitForm = async () => {
205+
if (firstName.value && lastName.value && email.value && organization.value && country.value && filecoinFamiliarity.value) {
206+
const body = {
207+
records: [
208+
{
209+
fields: {
210+
email: email.value,
211+
firstName: firstName.value,
212+
lastName: lastName.value,
213+
organization: organization.value,
214+
country: country.value.label,
215+
filecoinFamiliarity: filecoinFamiliarity.value
216+
}
217+
}
218+
]
219+
}
220+
const headers = {
221+
'Content-Type': 'application/json',
222+
'Authorization': `Bearer ${SINGULARITY_DEMO_SIGNUPS_TOKEN}`
223+
}
224+
await $fetch('https://api.airtable.com/v0/apphbQmrNLNNXiaqG/tblDUSr66nczukX9Y', {
225+
method: 'POST',
226+
body,
227+
headers
228+
})
229+
}
230+
}
193231
</script>
194232

195233
<style lang="scss" scoped>

0 commit comments

Comments
 (0)