Skip to content

Commit 55ec848

Browse files
committed
fix: signup form works again
1 parent 058b07f commit 55ec848

17 files changed

+52
-95
lines changed

components/form/field-container.vue

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<template>
22
<ZeroFormField
33
v-slot="{ field, fieldId, fieldType, state, required, disabled, validationMessage, updateValue, toggleState }"
4-
v-bind="props"
5-
:class="['field-container', { focused }]">
4+
v-bind="props">
65

76
<label v-if="scaffold.label" :for="fieldId" :class="['field-label', state]">
87
{{ scaffold.label }}
@@ -20,7 +19,7 @@
2019
:disabled="disabled"
2120
@update-value="updateValue"
2221
@toggle-state="toggleState"
23-
@toggle-focused="handleFocus($event, toggleState)" />
22+
@toggle-focused="toggleState" />
2423

2524
<slot />
2625

@@ -77,15 +76,6 @@ const map = {
7776
'FieldSelect': resolveComponent('FormFieldSelect'),
7877
'FieldUpload': resolveComponent('FormFieldUpload')
7978
}
80-
81-
// ======================================================================== Data
82-
const focused = ref(false)
83-
84-
// ===================================================================== Methods
85-
const handleFocus = (state, toggleState) => {
86-
focused.value = state
87-
toggleState(state)
88-
}
8979
</script>
9080

9181
<style lang="scss" scoped>

components/signup-card.vue

+2-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
{{ title }}
1212
</h1>
1313

14-
1514
</div>
1615

1716
<div v-if="description" class="description">
@@ -30,8 +29,6 @@
3029
:scaffold="emailFieldScaffold" />
3130
<FormFieldContainer
3231
:scaffold="orgFieldScaffold" />
33-
<FormFieldContainer
34-
:scaffold="orgFieldScaffold" />
3532
<FormFieldContainer
3633
:scaffold="countryFieldScaffold" />
3734

@@ -59,7 +56,7 @@
5956

6057
<script setup>
6158
// const config = useRuntimeConfig()
62-
const buttonStore = useZeroButtonStore()
59+
// const buttonStore = useZeroButtonStore()
6360
// ======================================================================= Props
6461
const props = defineProps({
6562
signupCard: {
@@ -169,7 +166,7 @@ const submitForm = async () => {
169166
// submitError.value = true
170167
// })
171168
// }
172-
buttonStore.set({id: 'signup-card-form', loading: false})
169+
// buttonStore.set({id: 'signup-card-form', loading: false})
173170
}
174171
</script>
175172

content/core/general.json

-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
{
2-
"seo": {
3-
"title": "Singularity",
4-
"description": "Singularity facilitates onboarding of large quantaties of data (PB-scale) to the Filecoin network in an efficient, secure, and flexible way."
5-
},
6-
"og": {
7-
"site_name": "Singularity",
8-
"url": "https://singularity.storage",
9-
"type": "website",
10-
"image": "images/singularity-open-graph.jpg"
11-
},
122
"header": {
133
"navigation": [
144
{

content/core/index.json

-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
{
2-
"seo": {
3-
"title": "Singularity",
4-
"description": "Singularity facilitates onboarding of large quantaties of data (PB-scale) to the Filecoin network in an efficient, secure, and flexible way."
5-
},
6-
"og": {
7-
"site_name": "Singularity",
8-
"url": "https://singularity.storage",
9-
"type": "website",
10-
"image": "images/singularity-open-graph.jpg"
11-
},
122
"page_content": [
133
{
144
"id": "hero-header",

content/core/signup.json

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
{
2-
"seo": {
3-
"title": "Singularity",
4-
"description": ""
5-
},
6-
"og": {
7-
"site_name": "Singularity",
8-
"url": "",
9-
"type": "website",
10-
"image": "images/singularity-open-graph.jpg"
11-
},
122
"page_content": {
133
"back_home_cta": {
144
"text": "Back home",
@@ -24,6 +14,7 @@
2414
"borderGradientAngle": "30deg",
2515
"signup_form": {
2616
"first_name": {
17+
"id": "firstName",
2718
"type": "input",
2819
"formId": "app_preview_signup_form",
2920
"inputType": "text",
@@ -44,6 +35,7 @@
4435
}
4536
},
4637
"last_name": {
38+
"id": "lastName",
4739
"type": "input",
4840
"formId": "app_preview_signup_form",
4941
"inputType": "text",
@@ -64,6 +56,7 @@
6456
}
6557
},
6658
"email": {
59+
"id": "email",
6760
"type": "input",
6861
"formId": "app_preview_signup_form",
6962
"inputType": "email",
@@ -84,6 +77,7 @@
8477
}
8578
},
8679
"org": {
80+
"id": "organization",
8781
"type": "input",
8882
"formId": "app_preview_signup_form",
8983
"inputType": "text",
@@ -104,6 +98,7 @@
10498
}
10599
},
106100
"country": {
101+
"id": "country",
107102
"type": "select",
108103
"formId": "app_preview_signup_form",
109104
"required": true,

layouts/default.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template>
22
<div class="layout default" tabindex="-1">
33

4-
<SiteHeader />
4+
<!-- <SiteHeader /> -->
55

66
<slot />
77

8-
<SiteFooter />
8+
<!-- <SiteFooter /> -->
99

1010
</div>
1111
</template>

modules/zero/modules/form/components/zero-field-boolean.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div :class="['field field-boolean', state, { disabled, checked: value }]">
2+
<div :class="['field-boolean', state, { disabled, checked: value }]">
33

44
<div class="boolean-container">
55
<div v-if="disabled" :class="['boolean', { checked: value }]" />

modules/zero/modules/form/components/zero-field-checkbox.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div :class="['field field-checkbox', state, { disabled }]">
2+
<div :class="['field-checkbox', state, { disabled }]">
33

44
<div
55
v-for="(option, index) in options"

modules/zero/modules/form/components/zero-field-datepicker.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div :class="['field field-datepicker', state, { disabled, empty }]">
2+
<div :class="['field-datepicker', state, { disabled, empty }]">
33

44
<VueDatePicker
55
:model-value="value"

modules/zero/modules/form/components/zero-field-input.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div :class="['field field-input', inputType, state, { empty, disabled, 'no-validate': !validate, 'with-controls': showControls }]">
2+
<div :class="['field-input', inputType, state, { empty, disabled, 'no-validate': !validate, 'with-controls': showControls }]">
33

44
<div v-if="disabled" class="input-container">
55
<div class="input">

modules/zero/modules/form/components/zero-field-json.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div :class="['field field-json', state, { empty, disabled, 'no-validate': !validate }]">
2+
<div :class="['field-json', state, { empty, disabled, 'no-validate': !validate }]">
33

44
<ZeroMarkdownParser
55
v-if="disabled"

modules/zero/modules/form/components/zero-field-radio.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div :class="['field field-radio', state, { disabled }]">
2+
<div :class="['field-radio', state, { disabled }]">
33

44
<div
55
v-for="(option, index) in options"

modules/zero/modules/form/components/zero-field-select.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<template>
44
<div
55
tabindex="-1"
6-
:class="['field field-select', state, {
6+
:class="['field-select', state, {
77
'select-container-focused': selectContainerFocused,
88
'select-native-focused': selectNativeFocused,
99
'dropdown-open': dropdownOpen,

modules/zero/modules/form/components/zero-field-textarea.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div :class="['field field-textarea', state, { empty, disabled, 'no-validate': !validate }]">
2+
<div :class="['field-textarea', state, { empty, disabled, 'no-validate': !validate }]">
33

44
<div v-if="disabled" class="textarea">
55
{{ value || placeholder }}

modules/zero/modules/form/components/zero-form-field.vue

+10-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<component
33
:is="rootHtmlTag"
44
v-if="field && displayField"
5-
:class="['field', state, { disabled }]">
5+
:class="['field-container', state, { disabled }]">
66

77
<slot
88
:field="field"
@@ -20,7 +20,6 @@
2020

2121
<script setup>
2222
// ===================================================================== Imports
23-
import { storeToRefs } from 'pinia'
2423
import Debounce from 'lodash/debounce'
2524
2625
// ======================================================================= Props
@@ -60,14 +59,17 @@ const required = scaffold.required
6059
const react = scaffold.react
6160
const conditions = scaffold.conditions
6261
const deregisterOnDestroy = scaffold.hasOwnProperty('deregisterOnDestroy') ? scaffold.deregisterOnDestroy : true
63-
const id = modelKey || scaffold.id || useUuid().v4()
62+
const id = modelKey || scaffold.id
63+
if (!id || id === '') {
64+
throw new Error('Form field is missing "id" key. Fields must always have a unique id.')
65+
}
6466
let debounceSaveFieldToLsUponValueUpdate = null
6567
const store = useZeroFormStore()
6668
const { fields } = storeToRefs(store)
6769
let field = fields.value[id]
6870
6971
if (!field) {
70-
await store.setField(useRegisterField(
72+
store.setField(useRegisterField(
7173
id,
7274
formId,
7375
scaffold,
@@ -101,6 +103,7 @@ const fieldType = computed(() => {
101103
case 'wysiwyg' : component = 'FieldWysiwyg'; break
102104
case 'datepicker' : component = 'FieldDatepicker'; break
103105
case 'json' : component = 'FieldJson'; break
106+
case 'upload' : component = 'FieldUpload'; break
104107
default : component = `Field${useUnSlugify(type)}`
105108
}
106109
return component
@@ -116,14 +119,6 @@ const validationMessage = computed(() => {
116119
// ======================================================================= Hooks
117120
onMounted(async () => {
118121
await nextTick(async () => {
119-
if (!field.value) {
120-
await store.setField(useRegisterField(
121-
id,
122-
formId,
123-
scaffold,
124-
props.forceValidate
125-
))
126-
}
127122
const fieldToRestoreFromLsOrToDisplay = await getLocalStorageValue() || {
128123
id,
129124
mounted: displayField.value
@@ -156,7 +151,7 @@ onBeforeUnmount(() => {
156151
* @method toggleState
157152
*/
158153
159-
const toggleState = async (focused) => {
154+
const toggleState = async focused => {
160155
const update = { id }
161156
if (focused) {
162157
update.state = 'in-progress'
@@ -177,7 +172,7 @@ const toggleState = async (focused) => {
177172
* @method updateValue
178173
*/
179174
180-
const updateValue = async (value) => {
175+
const updateValue = async value => {
181176
const updated = { id, value }
182177
await store.setField(updated)
183178
debounceSaveFieldToLsUponValueUpdate()
@@ -206,7 +201,7 @@ const getLocalStorageValue = () => {
206201
* @method initializeReactions
207202
*/
208203
209-
const initializeReactions = async (updatedField) => {
204+
const initializeReactions = async updatedField => {
210205
if (!react) { return }
211206
const len = react.length
212207
for (let i = 0; i < len; i++) {

pages/index.vue

-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import BlockBuilder from '@/components/blocks/block-builder'
1313
// ======================================================================== Data
1414
const generalStore = useGeneralStore()
1515
const route = useRoute()
16-
const { $GetSeo, $CompileSeo } = useNuxtApp()
1716
const { data } = await useAsyncData('core', async () => {
1817
return queryContent('core').find()
1918
})
@@ -22,7 +21,6 @@ const { data } = await useAsyncData('core', async () => {
2221
watch(data, async (val) => {
2322
await generalStore.getBaseData('general')
2423
await generalStore.getBaseData({ key: 'index', data: val.find((item) => item._file === 'core/index.json') })
25-
useHead($CompileSeo($GetSeo('general', 'index')))
2624
}, { immediate: true })
2725
2826
// ==================================================================== Computed

pages/signup.vue

+23-21
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@
66

77
<ButtonCta
88
class="back-home-button"
9-
:theme="content.back_home_cta.theme"
10-
:arrow-direction="content.back_home_cta.arrow_direction"
11-
:tag="content.back_home_cta.tag"
12-
:to="content.back_home_cta.to">
9+
:theme="pageContent.back_home_cta.theme"
10+
:arrow-direction="pageContent.back_home_cta.arrow_direction"
11+
:tag="pageContent.back_home_cta.tag"
12+
:to="pageContent.back_home_cta.to">
1313
<template #button-content>
14-
<span class="button-label"> {{ content.back_home_cta.text }} </span>
14+
<span class="button-label"> {{ pageContent.back_home_cta.text }} </span>
1515
</template>
1616
</ButtonCta>
1717

18-
19-
<SignupCard :signup-card="content.signup_card" />
18+
<SignupCard :signup-card="pageContent.signup_card" />
2019
</div>
2120

2221
</div>
@@ -25,28 +24,31 @@
2524
</template>
2625

2726
<script setup>
27+
// ===================================================================== Imports
28+
import Content from '@/content/core/signup.json'
29+
30+
// ======================================================================= Setup
2831
definePageMeta({
2932
layout: 'warped-torus-background'
3033
})
34+
3135
// ======================================================================== Data
32-
const generalStore = useGeneralStore()
33-
const { $GetSeo, $CompileSeo } = useNuxtApp()
34-
const { data } = await useAsyncData('signup', async () => {
35-
return queryContent('core').find()
36-
})
36+
const pageContent = Content.page_content
37+
// const generalStore = useGeneralStore()
38+
// const { data } = await useAsyncData('signup', async () => {
39+
// return queryContent('core').find()
40+
// })
3741
3842
// ==================================================================== Watchers
39-
watch(data, async (val) => {
40-
await generalStore.getBaseData('general')
41-
await generalStore.getBaseData({ key: 'signup', data: val.find((item) => item._file === 'core/signup.json') })
42-
useHead($CompileSeo($GetSeo('general', 'signup')))
43-
}, { immediate: true })
43+
// watch(data, async (val) => {
44+
// await generalStore.getBaseData('general')
45+
// await generalStore.getBaseData({ key: 'signup', data: val.find((item) => item._file === 'core/signup.json') })
46+
// }, { immediate: true })
4447
4548
// ==================================================================== Computed
46-
const content = computed(() => {
47-
return generalStore.siteContent?.signup?.page_content
48-
})
49-
49+
// const content = computed(() => {
50+
// return generalStore.siteContent?.signup?.page_content
51+
// })
5052
</script>
5153

5254
<style lang="scss" scoped>

0 commit comments

Comments
 (0)