1
1
{{ define "main" }}
2
- < script >
3
- let __plan_name = "Professional" ;
4
- </ script >
5
2
< div class ="isolate px-6 py-24 sm:py-32 lg:px-8 ">
6
3
< div class ="mx-auto max-w-2xl text-center ">
7
4
< h2 class ="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl ">
@@ -13,7 +10,6 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
13
10
</ div >
14
11
15
12
< script >
16
- let start_trial_form_submitted = false ;
17
13
window . onload = function ( ) {
18
14
let referralCode = localStorage . getItem ( "referral-code" ) ;
19
15
@@ -25,55 +21,66 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
25
21
document . getElementById ( "referral-code" ) . value = referralCode ;
26
22
}
27
23
28
- const serviceName = getQueryParam ( "service" ) ;
24
+ const serviceId = getQueryParam ( "service_id" ) ;
25
+ const serviceName = getQueryParam ( "service_name" ) ;
29
26
30
- if ( serviceName ) {
27
+ if ( serviceId && serviceName ) {
28
+ document . getElementById ( "service-id" ) . value = serviceId ;
31
29
document . getElementById ( "service-name" ) . value = serviceName ;
32
30
} else {
33
31
window . location = "/" ;
34
32
}
35
33
} ;
36
34
37
- function loading ( ) {
35
+ async function submitForm ( form ) {
36
+ event . preventDefault ( ) ;
37
+
38
38
const btn = document . getElementById ( "submit-btn" ) ;
39
39
40
40
btn . disabled = true ;
41
41
btn . textContent = "Submitting..." ;
42
- }
43
42
44
- function onFormSubmit ( ) {
45
- if ( start_trial_form_submitted ) {
46
- const plans = {
47
- startup : "https://buy.stripe.com/4gwaF0bWd3nh2AwaEF" ,
48
- professional : "https://buy.stripe.com/00gaF0gct9LF6QM6oq" ,
49
- business : "https://buy.stripe.com/cN29AW4tL9LFeje7sv" ,
50
- enterprise : "https://buy.stripe.com/dR614q2lD9LF0so6os" ,
51
- } ;
43
+ const formData = new FormData ( form ) ;
44
+ const requestData = Object . fromEntries ( formData . entries ( ) ) ;
45
+
46
+ delete requestData . terms_and_conditions ;
52
47
53
- __plan_name = __plan_name . toLowerCase ( ) ;
48
+ requestData . plan = requestData . plan . toLowerCase ( ) ;
54
49
55
- const paymentLink = plans [ __plan_name ] || plans . professional ;
50
+ try {
51
+ const response = await fetch (
52
+ "https://admin.octabyte.app/items/customer_services" ,
53
+ {
54
+ method : "POST" ,
55
+ headers : {
56
+ "Content-Type" : "application/json" ,
57
+ } ,
58
+ body : JSON . stringify ( requestData ) ,
59
+ } ,
60
+ ) ;
61
+
62
+ if ( ! response . ok ) {
63
+ throw new Error ( "There was an error submitting the form." ) ;
64
+ }
56
65
57
66
localStorage . removeItem ( "referral-code" ) ;
58
- window . location = paymentLink ;
67
+
68
+ const data = await response . json ( ) ;
69
+ const session_url = data . data . session_url ;
70
+ window . location = session_url ;
71
+ } catch ( error ) {
72
+ console . error ( "Error submitting form:" , error ) ;
73
+ alert ( "There was an error submitting the form." ) ;
59
74
}
60
75
}
61
76
</ script >
62
77
63
- < iframe
64
- name ="hidden_iframe "
65
- id ="hidden_iframe "
66
- style ="display:none; "
67
- onload ="onFormSubmit() "> </ iframe >
68
-
69
78
< form
70
- action ="https://docs.google.com/forms/d/e/1FAIpQLSeaxk4nWWZZw6LvQPPS80PuSOfEC3rmAWPtzOYapioaYguzqQ/formResponse "
71
79
method ="post "
72
- target ="hidden_iframe "
73
- onsubmit ="start_trial_form_submitted = true; loading() "
80
+ onsubmit ="submitForm(this) "
74
81
class ="mx-auto mt-16 max-w-xl sm:mt-20 ">
75
82
<!-- Referral Code -->
76
- < input id ="referral-code " type ="hidden " name ="entry.1415040235 " />
83
+ < input id ="referral-code " type ="hidden " name ="referral_code " />
77
84
78
85
< div class ="grid grid-cols-1 gap-x-8 gap-y-6 sm:grid-cols-2 ">
79
86
< div >
@@ -85,7 +92,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
85
92
< div class ="mt-2.5 ">
86
93
< input
87
94
type ="text "
88
- name ="entry.973173615 "
95
+ name ="first_name "
89
96
id ="first-name "
90
97
autocomplete ="given-name "
91
98
placeholder ="John "
@@ -102,7 +109,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
102
109
< div class ="mt-2.5 ">
103
110
< input
104
111
type ="text "
105
- name ="entry.876595051 "
112
+ name ="last_name "
106
113
id ="last-name "
107
114
autocomplete ="family-name "
108
115
placeholder ="Smith "
@@ -120,7 +127,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
120
127
< div class ="mt-2.5 ">
121
128
< input
122
129
type ="email "
123
- name ="entry.943957029 "
130
+ name ="admin_email "
124
131
id ="email "
125
132
autocomplete ="email "
126
133
placeholder ="Please provide valid email address to receive credentials "
@@ -137,7 +144,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
137
144
< div class ="mt-2.5 ">
138
145
< input
139
146
type ="tel "
140
- name ="entry.621899747 "
147
+ name ="phone_number "
141
148
id ="phone-number "
142
149
autocomplete ="tel "
143
150
placeholder ="+1 (555) 987-6543 "
@@ -151,9 +158,10 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
151
158
Service Name
152
159
</ label >
153
160
< div class ="mt-2.5 ">
161
+ < input type ="hidden " id ="service-id " name ="service_id " />
154
162
< input
155
163
type ="text "
156
- name ="entry.2107164949 "
164
+ name ="service_name "
157
165
id ="service-name "
158
166
required
159
167
readonly
@@ -184,7 +192,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
184
192
< div class ="flex h-5 items-center ">
185
193
< input
186
194
id ="terms-and-conditions "
187
- name ="terms-and-conditions "
195
+ name ="terms_and_conditions "
188
196
type ="checkbox "
189
197
required
190
198
class ="h-4 w-4 cursor-pointer rounded border-gray-300 text-indigo-600 focus:ring-indigo-500 " />
0 commit comments