-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rkt
1712 lines (1581 loc) · 87.2 KB
/
main.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#lang at-exp racket
(provide city-page
city-page-dynamic
summer-camp-pricing-at
discounts-and-faq-section
donate-card
define/provide-course
define/provide-camp
(except-out (struct-out course) course)
(rename-out (make-course course))
(except-out (struct-out camp) camp)
(rename-out (make-camp camp))
generate-random-sku
generate-random-product-id
courses->course-registration
pos
course->datetimes
(rename-out (KEY FRONT-END-STRIPE-KEY))
~p
)
(require website/bootstrap
net/uri-codec
uuid
net/base64
binaryio/integer
gregor
metacoders-dot-org-lib/html-helpers
metacoders-dot-org-lib/imgs
metacoders-dot-org-lib/paths)
(define KEY (make-parameter "pk_live_Kd7tDKVnPMvyCyk5oAuSkbju00pa0xJPPL")
;"pk_test_Jd6aRCVssUu8YfSvltaT3tvU00je9fQbkA"
)
(define (city-page-links-section)
(jumbotron class: "mb-0 pt-4 pb-4 text-center"
(container
(row ;abstract to responsive-row-md?
(div class: "col-md-6 col-xs-12 my-2"
(a href: "#school-year-classes" style: (properties 'text-decoration: "none")
(button-primary class: "btn-lg btn-block"
"Enroll in School-Year Classes")))
(div class: "col-md-6 col-xs-12 my-2"
(a href: "#summer-camps" style: (properties 'text-decoration: "none")
(button-primary class: "btn-lg btn-block"
"Enroll in Summer Camps")))))))
(define (city-page-fold-section)
(define jpg-path city-weekly-class-img-path)
(define webp-path (jpg-path->webp-path jpg-path))
(jumbotron class: "mb-0 pt-5 pb-5 text-center bg-white"
(container
(h2 "MetaCoders Classes and Camps Inspire Students to Create with Technology")
(row class: "align-items-center" ;abstract to responsive-row-lg?
(div class: "col-lg-6 col-xs-12 p-4"
(picture
(source type: "image/webp" srcset: (prefix/pathify webp-path))
(source type: "image/jpeg" srcset: (prefix/pathify jpg-path))
(img class: "img-fluid rounded" src: (prefix/pathify jpg-path) alt: "Young girl shows off her code in a computer science camp for elementary school students"))
)
(div class: "col-lg-6 col-xs-12 p-4 text-left"
(ul class: "pl-4"
(li (p (b "Technology Is The Future: ") (~a "More than ever, K-12 students need to prepare for the future by "
"becoming fluent in coding, and they're not being taught enough coding in schools!")))
(li (p (b "Awesome Instructors: ") (~a "MetaCoders instructors teach computer science year-round. We strive for a 1:10 mentor:student "
"ratio that ensures students get the hands-on attention they deserve.")))
(li (p (b "Focus on Engagement: ") (~a "We belive it's important for students to not only understand technology, but also enjoy creating with "
"it! We want to inspire the next generation of engineers, web developers, and computer scientists.")))
))))))
(define (check-skus courses camps city-name)
(define duplicates (check-duplicates (append (map course-sku courses)
(map camp-sku camps))))
(if duplicates
(error (~a "===== " (string-upcase city-name) " ERROR =====\n"
"Duplicate skus found: " duplicates "\n"
"===== SITE BUILD DID NOT FINISH ===="))
(displayln @~a{ @(~a #:width 20 (string-upcase city-name)): COURSE AND CAMP SKUS CHECKED})))
(define (check-camp-skus camps city-name)
(define duplicates (check-duplicates (map camp-sku camps)))
(if duplicates
(error (~a "===== " (string-upcase city-name) "ERROR =====\n"
"Camp duplicates found: " duplicates "\n"
"===== SITE BUILD DID NOT FINISH ===="))
(displayln @~a{ @(~a #:width 20 (string-upcase city-name)): CAMP SKUS CHECKED})))
(define (city-page-dynamic
#:city-name [city-name ""]
#:banner-url [img-url ""]
#:alt-tag [alt-tag ""]
dynamic-content)
(define jpg-url img-url)
(define webp-url (string-replace jpg-url "jpg" "webp"))
(normal-content-wide #:head (list (title (string-append city-name " | Coding Classes and Camps for K-12 | MetaCoders"))
(meta name: "description" content: (string-append "Learn more about coding classes and camps for kids in " city-name ". MetaCoders doesn’t just teach kids how to code, but how to learn new programming languages!"))
(link 'rel: "preconnect" href:"https://q.stripe.com")
(link 'rel: "preconnect" href:"https://m.stripe.com")
(script src:"https://js.stripe.com/v3")
(common-critical-css))
#:defer-css #t
(section id: "city-banner" class: "jumbotron d-flex align-items-center mb-0 text-center"
style: (properties
background-image: (string-append "url(" webp-url ")") ;pass in webp and fallback to jpg
background-size: "cover"
background-position: "center"
height: "60%"
position: "relative")
role: "img"
alt: alt-tag
@style/inline[type: "text/css"]{
.no-webp #city-banner{
background-image: url('@jpg-url') !important;
}
.webp #city-banner{
background-image: url('@webp-url') !important;
}
}
(div style: (properties background-color: "rgba(0,0,0,0.6)"
width: "100%"
position: "absolute"
top: 0
left: 0
bottom: 0
right: 0
float: "left"))
(container
(div style: (properties
display: "inline-block"
padding: 15
color: "white"
position: "relative")
(h1 (string-append "Coding Classes & Camps in " city-name)))))
dynamic-content
(have-questions-section)
))
(define (pos city-name
#:school-year-courses school-year-courses
#:summer-camps summer-camps
#:camp-pricing camp-pricing
#:camp-lunch-info camp-lunch-info
#:discounts-and-faq discounts-and-faq)
(list
(if (and (empty? school-year-courses)
(empty? summer-camps))
'()
(city-page-links-section))
(city-page-fold-section)
(cond [(and (empty? school-year-courses)
(empty? summer-camps)) (jumbotron class: "mb-0 pt-5 pb-5 text-center"
(container (h2 "Coming Soon!")
(p "Click " (a href: (~a "https://docs.google.com/forms/d/e/1FAIpQLSc8cIS5f23z9UFpdeFzEPeblfeGPUo322NPfXkutY8qt-NkiA/viewform?usp=pp_url&entry.162480533="
(string-replace city-name " " "+"))
"here")
" to join the waitlist for MetaCoders classes and camps in " city-name ".")))]
[(empty? school-year-courses) (list (jumbotron id: "school-year-classes"
class: "mb-0 pt-6 pb-6 text-center"
(container
(h2 "Register for School-Year Classes")
(p "Coming Soon!")))
(camps->camp-registration city-name summer-camps camp-pricing camp-lunch-info discounts-and-faq))]
[(empty? summer-camps) (list (courses->course-registration city-name school-year-courses)
(jumbotron id: "summer-camps"
class: "mb-0 pt-6 pb-6 text-center bg-white"
(container
(h2 "Register for Summer Camps")
(p "Coming Soon!"))))]
[else (list (courses->course-registration city-name school-year-courses)
(camps->camp-registration city-name summer-camps camp-pricing camp-lunch-info discounts-and-faq))
])
))
(define (city-page
#:city-name [city-name ""]
#:banner-url [img-url ""]
#:alt-tag [alt-tag ""]
#:school-year-courses [school-year-courses '()]
#:summer-camps [summer-camps '()]
#:camp-pricing [camp-pricing (summer-camp-pricing-at #:location "TBA"
#:am-camp-time "9am - 1pm"
#:pm-camp-time "1pm - 4pm"
#:full-day-time "9am - 4pm"
#:am-price "TBA"
#:pm-price "TBA"
#:full-day-price "TBA")]
#:camp-lunch-info [camp-lunch-info "All-you-can-eat lunch at the campus dining hall"])
;====== SKU CHECKS ======
(check-skus school-year-courses summer-camps city-name)
(define jpg-url img-url)
(define webp-url (string-replace jpg-url "jpg" "webp"))
(normal-content-wide #:head (list (title (string-append city-name " | Coding Classes and Camps for K-12 | MetaCoders"))
(meta name: "description" content: (string-append "Learn more about coding classes and camps for kids in " city-name ". MetaCoders doesn’t just teach kids how to code, but how to learn new programming languages!"))
(link 'rel: "preconnect" href:"https://q.stripe.com")
(link 'rel: "preconnect" href:"https://m.stripe.com")
(script src:"https://js.stripe.com/v3")
(common-critical-css))
#:defer-css #t
(section id: "city-banner" class: "jumbotron d-flex align-items-center mb-0 text-center"
style: (properties
background-image: (string-append "url(" webp-url ")") ;pass in webp and fallback to jpg
background-size: "cover"
background-position: "center"
height: "60%"
position: "relative")
role: "img"
alt: alt-tag
@style/inline[type: "text/css"]{
.no-webp #city-banner{
background-image: url('@jpg-url') !important;
}
.webp #city-banner{
background-image: url('@webp-url') !important;
}
}
(div style: (properties background-color: "rgba(0,0,0,0.6)"
width: "100%"
position: "absolute"
top: 0
left: 0
bottom: 0
right: 0
float: "left"))
(container
(div style: (properties
display: "inline-block"
padding: 15
color: "white"
position: "relative")
(h1 (string-append "Coding Classes & Camps in " city-name)))))
(if (and (empty? school-year-courses)
(empty? summer-camps))
'()
(city-page-links-section))
(city-page-fold-section)
(cond [(and (empty? school-year-courses)
(empty? summer-camps)) (jumbotron class: "mb-0 pt-5 pb-5 text-center"
(container (h2 "Coming Soon!")
(p "Click " (a href: (~a "https://docs.google.com/forms/d/e/1FAIpQLSfS5L8lP3vLUYhMi7lB5l6ikv4_ZOhejPVf8yjk9uuSiolRIA/viewform?usp=pp_url&entry.162480533="
(string-replace city-name " " "+"))
"here")
" to join the waitlist for MetaCoders classes and camps in " city-name ".")))]
[(empty? school-year-courses) (list (jumbotron id: "school-year-classes"
class: "mb-0 pt-6 pb-6 text-center"
(container
(h2 "Register for School-Year Classes")
(p "Coming Soon!")))
(camps->camp-registration city-name summer-camps camp-pricing camp-lunch-info))]
[(empty? summer-camps) (list (courses->course-registration city-name school-year-courses)
(jumbotron id: "summer-camps"
class: "mb-0 pt-6 pb-6 text-center bg-white"
(container
(h2 "Register for Summer Camps")
(p "Coming Soon!"))))]
[else (list (courses->course-registration city-name school-year-courses)
(camps->camp-registration city-name summer-camps camp-pricing camp-lunch-info))
])
(have-questions-section)
))
(define (~p price)
(if (integer? price)
(~a "$" (~r price #:precision 0))
(~a "$" (~r price #:precision '(= 2)))))
(define (course-buy-button price discount sku key url-suffix #:suffix [suffix ""])
(list (button-primary id:(~a "checkout-button-" sku)
class: "m-0 col-sm-6"
style: (properties border-radius: "0 0 0.18rem 0"
white-space: "normal")
(if (> discount 0)
(list "Enroll for "
(s class: "text-danger"
(~p price))
" " (~p (- price discount))
suffix)
(~a "Enroll for " (~p price) suffix)))
(div id:(~a "error-message" sku))
;(script src:"https://js.stripe.com/v3")
@script/inline{
(function() {
var stripe = Stripe('@key');
var checkoutButton = document.getElementById('checkout-button-@sku');
checkoutButton.addEventListener('click', function () {
var quantity = parseInt(
document.getElementById("student-quantity-@sku").value
);
stripe.redirectToCheckout({
items: [{sku: '@sku', quantity: quantity}],
successUrl: 'https://metacoders.org@(prefix/pathify checkout-success-top-path)@url-suffix',
cancelUrl: 'https://metacoders.org@(prefix/pathify checkout-fail-top-path)',
billingAddressCollection: 'required',
})
.then(function (result) {
if (result.error) {
var displayError = document.getElementById('error-message@sku');
displayError.textContent = result.error.message;
}
});
});
})();}))
(define (camp-modal-buy-button price discount sku key url-suffix)
(list (button-primary id:(~a "modal-checkout-button-" sku)
class: "m-0 col-sm-6 px-2"
style: (properties border-radius: "0 0 0.20rem 0")
(if (> discount 0)
(list "Enroll for "
(s class: "text-danger"
(~p price))
" " (~p (- price discount)))
(~a "Enroll for " (~p price)))
)
(div id:(~a "error-message" sku))
;(script src:"https://js.stripe.com/v3")
@script/inline{
(function() {
var stripe = Stripe('@key');
var checkoutButton = document.getElementById('modal-checkout-button-@sku');
checkoutButton.addEventListener('click', function () {
var quantity = parseInt(
document.getElementById("modal-student-quantity-@sku").value
);
stripe.redirectToCheckout({
items: [{sku: '@sku', quantity: quantity}],
successUrl: 'https://metacoders.org@(prefix/pathify camp-checkout-success-top-path)@url-suffix',
cancelUrl: 'https://metacoders.org@(prefix/pathify checkout-fail-top-path)',
billingAddressCollection: 'required',
})
.then(function (result) {
if (result.error) {
var displayError = document.getElementById('error-message@sku');
displayError.textContent = result.error.message;
}
});
});
})();}))
(define (course-modal-buy-button price discount sku key url-suffix #:suffix [suffix ""])
(list (button-primary id:(~a "modal-checkout-button-" sku)
class: "m-0 col-sm-6 px-2"
style: (properties border-radius: "0 0 0.18rem 0"
white-space: "normal")
(if (> discount 0)
(list "Enroll for "
(s class: "text-danger"
(~p price))
" " (~p (- price discount))
suffix)
(~a "Enroll for " (~p price) suffix)))
(div id:(~a "error-message" sku))
;(script src:"https://js.stripe.com/v3")
@script/inline{
(function() {
var stripe = Stripe('@key');
var checkoutButton = document.getElementById('modal-checkout-button-@sku');
checkoutButton.addEventListener('click', function () {
var quantity = parseInt(
document.getElementById("modal-student-quantity-@sku").value
);
stripe.redirectToCheckout({
items: [{sku: '@sku', quantity: quantity}],
successUrl: 'https://metacoders.org@(prefix/pathify checkout-success-top-path)@url-suffix',
cancelUrl: 'https://metacoders.org@(prefix/pathify checkout-fail-top-path)',
billingAddressCollection: 'required',
})
.then(function (result) {
if (result.error) {
var displayError = document.getElementById('error-message@sku');
displayError.textContent = result.error.message;
}
});
});
})();}))
(define (print-dates dates [s ""])
(if (> (length dates) 1)
(begin (set! s (~a s (first dates) ", "))
(print-dates (rest dates) s))
(begin (set! s (~a s (first dates) "."))
s)))
(define (student-spinner sku price discount)
(div class: "text-center"
(div class: "btn-group justify-content-center"
(button-warning id: (~a "student-subtract-" sku)
class: "btn-sm col-2"
'onclick: (~a "updateStudents" sku "(event);")
(i class: "fas fa-minus fa-xs"))
(input type: "text"
class: "text-center col-3"
id: (~a "student-quantity-" sku)
'value: 1)
(button-warning id: (~a "student-add-" sku)
class: "btn-sm col-2"
'onclick: (~a "updateStudents" sku "(event);")
(i class: "fas fa-plus fa-xs")))
@script/inline{
window.updateStudents@sku = function(evt) {
function formatPrice(price){
if (Number.isInteger(price)){
return "$" + price;
} else {
return new Intl.NumberFormat('en-US', {style: 'currency', currency: 'USD'}).format(price);
}
}
if (evt && evt.type === "keypress" && evt.keyCode !== 13) {
return;
}
var isAdding = evt.target.id === "student-add-@sku";
var inputEl = document.getElementById("student-quantity-@sku");
var currentQuantity = parseInt(inputEl.value);
document.getElementById("student-add-@sku").disabled = false;
document.getElementById("student-subtract-@sku").disabled = false;
var quantity = isAdding ? currentQuantity + 1 : currentQuantity - 1;
quantity = Math.min(5, Math.max(1,quantity));
inputEl.value = quantity;
if (document.getElementById("checkout-button-@sku")) {
@;document.getElementById("checkout-button-@sku").textContent = "Enroll for $" + quantity * @price;
document.getElementById("checkout-button-@sku").innerHTML = @(if (> discount 0)
(~a "'Enroll for <s class=\"text-danger\">' + formatPrice(quantity * " price
") + '</s> ' + formatPrice(quantity * " (- price discount) ");")
(~a "'Enroll for ' + formatPrice(quantity * " price ");"))
}
// Disable the button if the customers hits the max or min
if (quantity <= 1) {
document.getElementById("student-subtract-@sku").disabled = true;
}
if (quantity >= 5) {
document.getElementById("student-add-@sku").disabled = true;
}
}}
(p class: "m-0 text-secondary text-center" "Number of Students")))
(define (modal-student-spinner sku price discount)
(div class: "text-center"
(div class: "btn-group justify-content-center"
(button-warning id: (~a "modal-student-subtract-" sku)
class: "btn-sm col-2"
'onclick: (~a "modalUpdateStudents" sku "(event);")
(i class: "fas fa-minus fa-xs"))
(input type: "text"
class: "text-center col-3"
id: (~a "modal-student-quantity-" sku)
'value: 1)
(button-warning id: (~a "modal-student-add-" sku)
class: "btn-sm col-2"
'onclick: (~a "modalUpdateStudents" sku "(event);")
(i class: "fas fa-plus fa-xs")))
@script/inline{
window.modalUpdateStudents@sku = function(evt) {
function formatPrice(price){
if (Number.isInteger(price)){
return "$" + price;
} else {
return new Intl.NumberFormat('en-US', {style: 'currency', currency: 'USD'}).format(price);
}
}
if (evt && evt.type === "keypress" && evt.keyCode !== 13) {
return;
}
var isAdding = evt.target.id === "modal-student-add-@sku";
var inputEl = document.getElementById("modal-student-quantity-@sku");
var currentQuantity = parseInt(inputEl.value);
document.getElementById("modal-student-add-@sku").disabled = false;
document.getElementById("modal-student-subtract-@sku").disabled = false;
var quantity = isAdding ? currentQuantity + 1 : currentQuantity - 1;
quantity = Math.min(5, Math.max(1,quantity));
inputEl.value = quantity;
if (document.getElementById("modal-checkout-button-@sku")) {
@;document.getElementById("modal-checkout-button-@sku").textContent = "Enroll for $" + quantity * @price;
document.getElementById("modal-checkout-button-@sku").innerHTML = @(if (> discount 0)
(~a "'Enroll for <s class=\"text-danger\">' + formatPrice(quantity * " price
") + '</s> ' + formatPrice(quantity * " (- price discount) ");")
(~a "'Enroll for ' + formatPrice(quantity * " price ");"))
}
// Disable the button if the customers hits the max or min
if (quantity <= 1) {
document.getElementById("modal-student-subtract-@sku").disabled = true;
}
if (quantity >= 5) {
document.getElementById("modal-student-add-@sku").disabled = true;
}
}}
(p class: "m-0 text-secondary text-center" "Number of Students")))
(define-syntax-rule
(define/provide-course id course)
(begin
(provide id)
(define id course)))
(define-syntax-rule
(define/provide-camp id camp)
(begin
(provide id)
(define id camp)))
(struct course (topic
sku
video-path
description
grade-range
location
address
address-link
price
discount
start-time
end-time
meeting-dates
status ; 'open 'almost-full 'full
))
(define (make-course #:topic [topic "TBA"]
#:sku [sku ""]
#:video-path [video-path ""]
#:description [description "TBA"]
#:grade-range [grade-range "TBA"]
#:location [location "TBA"]
#:address [address "TBA"]
#:address-link [address-link (~a "https://www.google.com/maps/place/" (string-replace address " " "+"))]
#:price [price 210]
#:discount [discount 0]
#:start-time [start-time "TBA"]
#:end-time [end-time "TBA"]
#:meeting-dates [meeting-dates '()]
#:status [status 'open])
(course topic sku video-path description grade-range location address address-link price discount start-time end-time meeting-dates status))
(define (course->waitlist-link course)
(~a "mailto:contact@thoughtstem.com?subject="
(uri-encode (~a "Waitlist - " (course-location course)
": " (course-topic course)
" (" (course-grade-range course)
") starting on " (first (course-meeting-dates course))))
"&body="
(uri-encode (~a "Hello, please add me to the waitlist for this class.\n\n"
"My contact information is:\n"
"Name: ________\n"
"Phone Number: ________\n"
"Student Name: ________\n\n"))))
(define (course->enroll-or-full-button city course)
(define key (KEY))
(define price (course-price course))
(define discount (course-discount course))
(define sku (course-sku course))
(define url-suffix (~a "?city=" (form-urlencoded-encode city)
"&location=" (form-urlencoded-encode (course-location course))
"&topic=" (form-urlencoded-encode (course-topic course))
"&grades=" (form-urlencoded-encode (course-grade-range course))
"&total-meetings=" (form-urlencoded-encode (~a (length (course-meeting-dates course))))
"&meets-on=" (form-urlencoded-encode (~a (meeting-date->weekday (first (course-meeting-dates course))) "s"))
"&time=" (form-urlencoded-encode (~a (course-start-time course) " - " (course-end-time course)))
"&start-date=" (form-urlencoded-encode (first (course-meeting-dates course)))
"&address=" (form-urlencoded-encode (course-address course))
"&address-link=" (form-urlencoded-encode (course-address-link course))
"&price=" (form-urlencoded-encode (~a (~p (- price discount)) "/student"))
"&meeting-dates=" (form-urlencoded-encode (print-dates (course-meeting-dates course)))
"&description=" (form-urlencoded-encode (course-description course))
))
(cond [(eq? (course-status course) 'open) (course-buy-button price discount sku key url-suffix)]
[(eq? (course-status course) 'almost-full) (course-buy-button price discount sku key url-suffix #:suffix " (Almost Full)")] ;not used
[(eq? (course-status course) 'full) (a href: (course->waitlist-link course)
class: "btn btn-danger col-sm-6"
style: (properties border-radius: "0 0 0.18rem 0"
white-space: "normal")
"Full (Click to Join Waitlist)"
)]
[(eq? (course-status course) 'registration-closed) (div class: "btn btn-danger col-sm-6"
style: (properties border-radius: "0 0 0.18rem 0"
white-space: "normal")
"Closed"
)]
))
(define (course->modal-enroll-or-full-button city course)
(define key (KEY))
(define price (course-price course))
(define discount (course-discount course))
(define sku (course-sku course))
(define url-suffix (~a "?city=" (form-urlencoded-encode city)
"&location=" (form-urlencoded-encode (course-location course))
"&topic=" (form-urlencoded-encode (course-topic course))
"&grades=" (form-urlencoded-encode (course-grade-range course))
"&total-meetings=" (form-urlencoded-encode (~a (length (course-meeting-dates course))))
"&meets-on=" (form-urlencoded-encode (~a (meeting-date->weekday (first (course-meeting-dates course))) "s"))
"&time=" (form-urlencoded-encode (~a (course-start-time course) " - " (course-end-time course)))
"&start-date=" (form-urlencoded-encode (first (course-meeting-dates course)))
"&address=" (form-urlencoded-encode (course-address course))
"&address-link=" (form-urlencoded-encode (course-address-link course))
"&price=" (form-urlencoded-encode (~a (~p (- price discount)) "/student"))
"&meeting-dates=" (form-urlencoded-encode (print-dates (course-meeting-dates course)))
"&description=" (form-urlencoded-encode (course-description course))
))
(cond [(eq? (course-status course) 'open) (course-modal-buy-button price discount sku key url-suffix)]
[(eq? (course-status course) 'almost-full) (course-modal-buy-button price discount sku key url-suffix #:suffix " (Almost Full)")] ;not used
[(eq? (course-status course) 'full) (a href: (course->waitlist-link course)
class: "btn btn-danger col-sm-6"
style: (properties border-radius: "0 0 0.18rem 0"
white-space: "normal")
"Full (Click to Join Waitlist)"
)]
[(eq? (course-status course) 'registration-closed) (div class: "btn btn-danger col-sm-6"
style: (properties border-radius: "0 0 0.18rem 0"
white-space: "normal")
"Closed"
)]
))
(define (course->course-card city c)
(define key (KEY))
(define topic (course-topic c))
(define sku (course-sku c))
(define video-path (course-video-path c))
(define description (course-description c))
(define grade-range (course-grade-range c))
(define location (course-location c))
(define address (course-address c))
(define address-link (course-address-link c))
(define price (course-price c))
(define discount (course-discount c))
(define start-time (course-start-time c))
(define end-time (course-end-time c))
(define meeting-dates (course-meeting-dates c))
(define status (course-status c))
(define mp4-url video-path)
(define webm-url (mp4-path->webm-path mp4-url))
(card class: "border-secondary text-center"
style: (properties overflow: "hidden"
'flex: 1)
#;(img src: video-path
class: "card-img-top border-secondary border-bottom"
height:"280px"
style: (properties object-fit: "cover"
object-position: "0 0"))
(video 'autoplay: "" 'loop: "" 'muted: "" 'playsinline: ""
class: "card-img-top border-secondary border-bottom"
height: "280px"
style: (properties object-fit: "cover"
object-position: "0 0")
(source src: (prefix/pathify webm-url) type: "video/webm")
(source src: (prefix/pathify mp4-url) type: "video/mp4"))
(card-body
(h5 class: "card-title" (~a topic " (" grade-range ")"))
(table class: "table table-sm table-borderless text-left"
(tr (td (strong "Start Date: ")) (td (first meeting-dates) " @ " start-time))
(tr (td (strong "Schedule: ")) (td (~a (meeting-date->weekday (first meeting-dates)) "s, "
(length meeting-dates) " weeks")))
(tr (td (strong "Location: ")) (td location (br) (a target:"_blank" href: address-link address))))
(student-spinner sku price discount)
)
(card-footer class: "border-secondary text-center"
style: (properties padding: 0
background-color: "transparent"
;border-top: "none"
)
(div class: "btn-group w-100"
(a href: "#" class: "d-flex col-sm-6 m-0 p-0"
style: (properties 'text-decoration: "none")
'data-toggle: "modal" 'data-target: (~a "#details-modal-" sku)
(button-secondary class: "w-100"
style: (properties border-radius: "0 0 0 0.18rem"
'flex: 1)
"Class Details"))
(course->enroll-or-full-button city c))
(course-modal #:id (~a "details-modal-" sku)
#:topic topic
#:description description
#:grade-range grade-range
#:meeting-dates meeting-dates
#:start-time start-time
#:end-time end-time
#:location location
#:address address
#:address-link address-link
#:price price
#:discount discount
#:quantity-spinner (modal-student-spinner sku price discount)
#:buy-button (course->modal-enroll-or-full-button city c)))
)
)
(define (courses->course-registration city courses)
(define (registration-closed-or-full? course)
(or (eq? (course-status course) 'registration-closed)
(eq? (course-status course) 'full)))
(define ordered-courses (sort courses datetime<? #:key (compose first course->datetimes)))
(define sorted-courses (append (filter-not registration-closed-or-full? ordered-courses)
(filter registration-closed-or-full? ordered-courses)))
(define course-cards (map (curry course->course-card city) sorted-courses))
(jumbotron id: "school-year-classes"
class: "mb-0 pt-6 pb-6 text-center"
(container
(h2 "Register for School-Year Classes")
(if (> (length course-cards) 1)
(apply row (map (curry div class: "d-flex col-md-6 col-xs-12 my-3 mx-auto")
course-cards))
(apply row (map (curry div class: "d-flex col-lg-6 col-md-8 col-xs-12 my-3 mx-auto")
course-cards)))
(p "By enrolling in any of these sessions, you agree to the " (link-to terms-and-conditions-path
"terms and conditions") "."))))
(define (summer-camps-links-section #:k-2? k-2?
#:3-5? 3-5?
#:7-10? 7-10?)
(define num-of-age-groups (length (filter identity (list k-2? 3-5? 7-10?))))
(define btn-class (cond [(eq? num-of-age-groups 1) "col-md-12"]
[(eq? num-of-age-groups 2) "col-md-6"]
[(eq? num-of-age-groups 3) "col-md-4"]
[else ""]))
(row id: "summer-buttons" ;abstract to responsive-row-md?
(if k-2?
(div class: (~a btn-class " col-xs-12 my-2")
(a href: "#k-2-summer-options" style: (properties 'text-decoration: "none")
(button-primary class: "btn-lg btn-block"
"K-2nd Summer Options")))
'())
(if 3-5?
(div class: (~a btn-class " col-xs-12 my-2")
(a href: "#3-6-summer-options" style: (properties 'text-decoration: "none")
(button-primary class: "btn-lg btn-block"
"3rd-6th Summer Options")))
'())
(if 7-10?
(div class: (~a btn-class " col-xs-12 my-2")
(a href: "#7-10-summer-options" style: (properties 'text-decoration: "none")
(button-primary class: "btn-lg btn-block"
"7th-10th Summer Options")))
'())
))
(define (summer-camps-info-section location-name lunch-info)
(row class: "align-items-center" ;abstract to responsive-row-lg?
(div class: "col-lg-6 col-xs-12 p-4 text-left"
(h5 class: "text-center" "What Makes a MetaCoders Camp Different?")
(ul class: "pl-4"
(li (p (b "Affordable: ") (~a "We bring summer technology education to local students at a more affordable price. "
"Additional discoutns are available for multiple registrations.")))
(li (p (b "Flexible: ") (~a "Choose between half-day camps or full-day camps"
(if (string=? lunch-info "")
"."
(~a "; morning camps include " (string-downcase lunch-info) ".")))))
(li (p (b "Prestigous Location: ") (~a "Students receive an authentic college experience on the beautiful " location-name " campus.")))
(li (p (b "Awesome Instructors: ") (~a "MetaCoders instructors teach computer science year-round. We strive for a 1:5 "
"mentor:student ratio during the summer, which ensures students get the hands-on "
"attention they deserve.")))
))
(div class: "col-lg-6 col-xs-12 p-4"
(picture
(source type: "image/webp" srcset: (prefix/pathify (jpg-path->webp-path city-summer-camp-img-path)))
(source type: "image/jpeg" srcset: (prefix/pathify city-summer-camp-img-path))
(img src: (prefix/pathify city-summer-camp-img-path)
class: "img-fluid rounded"
alt: "Students and instructors of a computer science, coding, and technology summer camp")))
))
(define (summer-camp-pricing-at #:location location-name
#:am-camp-time am-camp-time
#:pm-camp-time pm-camp-time
#:full-day-time full-day-time
#:am-price am-price
#:pm-price pm-price
#:full-day-price full-day-price
#:lunch-info [lunch-info "All-you-can-eat lunch at the campus dining hall"])
(row class: "align-items-center"
(div class: "col-lg-4 col-xs-12 p-4"
(picture
(source type: "image/webp" srcset: (prefix/pathify (jpg-path->webp-path city-summer-camp-pricing-img-path)))
(source type: "image/jpeg" srcset: (prefix/pathify city-summer-camp-pricing-img-path))
(img src: (prefix/pathify city-summer-camp-pricing-img-path)
class: "img-fluid rounded"
alt: "Happy young boy building and coding his own video game in a summer camp")))
(div class: "col-lg-8 col-xs-12 p-4 text-left"
(h2 class: "mb-4" "Summer Camp Pricing at " location-name)
(strong "Purchasing 1 Half-Day Morning or Afternoon Camp? Purchase using the table above.")
(ul
(if am-camp-time
(li "Morning Only (" am-camp-time " ): " am-price (if lunch-info
(~a ", includes " (string-downcase lunch-info))
""))
'())
(if pm-camp-time
(li "Afternoon Only (" pm-camp-time "): " pm-price "")
'()))
(strong "Purchasing More than 1 Half-Day Camp? Fill out the registration form "
(a href: (prefix/pathify camp-form-path)"here") ", and email it to "
(a href: "mailto:contact@metacoders.org" "contact@metacoders.org"))
(ul
(if (and am-camp-time
pm-camp-time)
(li "Full Day, 1-week (" full-day-time "): " full-day-price (if (string=? lunch-info "")
""
(~a ", includes " (string-downcase lunch-info))))
'())
(li "Want to buy more than 1 week of camp? We'll take an extra 10% off your entire order")))))
(define (discounts-and-faq-section
#:early-bird-discount? early-bird-discount?
#:pick-up-drop-off pick-up-drop-off
#:campus-parking campus-parking
#:additional-paperwork additional-paperwork
#:dining-options dining-options
#:food-allergy food-allergy)
(div class: "text-center"
(if early-bird-discount?
(div (h2 class: "mb-4" "Discounts")
(h4 class: "text-left" "Early Bird Discount - Ends April 1st")
(p class: "text-left" "Sign up before April 1st and get an extra 10% off of your summer camp purchase automatically at checkout! Register soon to take advantage of the best possible pricing for our camps!")
(hr))
'())
(h2 class: "mb-4" "Frequently Asked Questions")
(ol class: "text-left"
(li (strong "Is there a deadline to register? ") "The deadline for the morning camp on any given week is noon on the Wednesday before camp starts. However, you can register for the afternoon camp at this location as late as 6pm on the Sunday before camp starts.")
(li (strong "Where do I drop-off & pick-up my student(s)? ") (html/inline pick-up-drop-off))
(li (strong "Do you have extended daycare options? ") "We do not this year, however if this is something you are interested in for future summer camps, please " (a href: "mailto:contact@metacoders.org" "email") " us to let us know!")
(li (strong "Can I park on campus? ") (html/inline campus-parking))
(li (strong "Do I need to sign any additional paperwork to participate in camps? ") (html/inline additional-paperwork))
(li (strong "Should I consider the grade my student is going into next year or the last grade they completed when registering for summer camp? ") "We generally recommend parents consider the grade their student is going into next year when registering for a summer camp. However, we ultimately leave the choice up to the students and the parents. Feel free to contact us by phone, " (strong (a href: "tel:858-375-4097" "(858)375-4097")) ", if you'd like to discuss those options.")
(li (strong "Are there any additional requirements for students going into Kindergarten next year? ") "We generally recommend parents not enroll a student in our summer camp if this will be the first classroom experience they've ever had. Students who have previously been enrolled in a TK program, however, tend to have a lot of fun at coding camp! We also recommend parents spend a little time with their students before camp going over the basics of using a mouse, but this is by no means a requirement!")
(li (strong "What if I need to pick-up my student early one day of camp? ") "Send us an " (a href: "mailto:contact@metacoders.org" "email") ", and we can facilitate an early pick-up with the instructor. Don’t forget to include your student’s name and the date and time you need to pick him/her up early.")
(li (strong "What if I'm late to pick up my student? ") "If you're running late, please give us a call at " (strong (a href: "tel:858-375-4097" "(858)375-4097")) " so we can tell our staff that you are on your way. Note: parents who are late to pick up their student will be charged a fee to cover overtime pay for instructors waiting with their students. This fee is $15 per 15 minutes.")
(li (strong "I have multiple children who I want to register for camp. Can I get a discount? ") "Yes! We offer a 10% discount for registering siblings! Please use the registration form " (a href: "https://metacoders.org/files/metacoders-summer-camp-registration-form.pdf" "here") " to purchase multiple camps at once so that we can get you a special discount.")
(li (strong "Do you have scholarships available? ") "At this time we do not, but we are always looking for corporate sponsors for scholarships! If you know of someone interested in making a summer camp scholarship donation, please " (a href: "mailto:contact@metacoders.org" "email") " us.")
(if dining-options
(li (strong "What kind of dining options are available? ") (html/inline dining-options))
'())
(if food-allergy
(li (strong "My child has food allergies. Will my child be accomodated?") (html/inline food-allergy))
'())
(li (strong "What is your refund policy? ") "Learn about our refund policy " (a href: "https://metacoders.org/terms-and-conditions.html" "here") ".")
)
))
(define (have-questions-section)
(jumbotron class: "mb-0 pt-5 pb-5 text-center"
(container
(h2 "Have Questions?")
(p "Email us at "
(a href: "mailto:contact@metacoders.org" "contact@metacoders.org")
" or call " (strong "858-375-4097")))))
(define (camps->camp-registration city camps camp-pricing lunch-info discounts-and-faq)
(define location-name (camp-location (first camps)))
(define sorted-camps (sort camps string<? #:key camp-topic)) ;Alphabetical sorting by topic
(define (k-2-camp? c)
(string-contains? (camp-grade-range c) "K - 2nd"))
(define (3-6-camp? c)
(string-contains? (camp-grade-range c) "3rd - 6th"))
(define (7-10-camp? c)
(string-contains? (camp-grade-range c) "7th - 10th"))
(define k-2-camps (filter k-2-camp? sorted-camps))
(define 3-6-camps (filter 3-6-camp? sorted-camps))
(define 7-10-camps (filter 7-10-camp? sorted-camps))
(list (jumbotron id: "summer-camps"
class: "mb-0 pt-6 pb-6 text-center bg-white"
(container
(h2 "Register for Summer Camps")
(summer-camps-links-section #:k-2? (not (empty? k-2-camps))
#:3-5? (not (empty? 3-6-camps))
#:7-10? (not (empty? 7-10-camps))
)
(summer-camps-info-section location-name lunch-info)
(if (empty? k-2-camps)
'()
(list
(br id: "k-2-summer-options")
(h5 class: "mt-5"
"Summer Camp Schedule for Students Entering K-2nd")
(camps->camp-calendar city k-2-camps lunch-info)))
(if (empty? 3-6-camps)
'()
(list
(br id: "3-6-summer-options")
(h5 class: "mt-5"
"Summer Camp Schedule for Students Entering 3rd-6th")
(camps->camp-calendar city 3-6-camps lunch-info)))
(if (empty? 7-10-camps)
'()
(list
(br id: "7-10-summer-options")
(h5 class: "mt-5"
"Summer Camp Schedule for Students Entering 7th-10th")
(camps->camp-calendar city 7-10-camps lunch-info)))
camp-pricing
;(summer-camp-pricing-at location-name)
(p "By enrolling in any of these sessions, you agree to the " (link-to terms-and-conditions-path
"terms and conditions") ".")
(hr)
discounts-and-faq
))
))
;Donate Card
(define (donate-amounts items)
(define (donate-amount amount #:class [class ""])
(label class: (~a "btn btn-secondary m-1" class #:separator " ")
'onclick: (~a "setDonate" amount "();")
(input type: "radio"
name: "amount-options"
id:(~a "donate-amount-" amount)
)
@script/inline{
function setDonate@amount() {
var donateBtn = document.getElementById('donate-button');
donateBtn.innerHTML = "Donate $@amount";
}}
(~a "$" amount)))
(apply (curry div class: "btn-group-toggle"
'data-toggle: "buttons")
(append (list (donate-amount (car (first items)) #:class "active"))
(map (compose donate-amount
car)
(rest items)))))
(define (donate-button items #:mode [mode 'give-once])
(define key (KEY))
(define button-id (if (eq? mode 'monthly)
"monthly-donate-button"
"donate-button"))
(define (generate-js-switch items)
(~a "switch(amount){ "
(apply ~a (map (λ(item)
(~a "case "(car item)": "
"donateSku = \"" (cdr item) "\"; "
"break; "))
items))
"} "))
(list (button-primary id: button-id
class: "btn-block"
style: (properties display: "inline-block"
border-radius: "0 0 0.18rem 0.18rem")
(if (eq? mode 'monthly)
(~a "Donate $" (car (first items)) "/mo")
(~a "Donate $" (car (first items)))))
;(script src:"https://js.stripe.com/v3")
(if (eq? mode 'monthly)
@script/inline{
(function() {
var stripe = Stripe('@key');
var donateButton = document.getElementById('@button-id');
donateButton.addEventListener('click', function () {
var currentButton = document.getElementById('@button-id');
var buttonStr = currentButton.innerText.match(/(\d+)/);
var amount;
if (buttonStr){
amount = parseInt(buttonStr[0]);
}else{
amount = 0;
}
var donateSku;