From 586533ec5ca8feb56bbca3267385f3974e2b5ef4 Mon Sep 17 00:00:00 2001 From: Immanuel Onyeka Date: Tue, 28 May 2024 14:51:15 -0400 Subject: [PATCH] Add page for free trial --- components/app.vue | 6 +++--- components/update-billing/billing.vue | 3 ++- .../feed/21232f297a57a5a743894a0e4a801fc3.yaml | 18 +++++++++--------- grav-admin/user/data/flex/indexes/pages.json | 2 +- .../21232f297a57a5a743894a0e4a801fc3.yaml | 2 +- .../user/js/registration/registration.vue | 14 ++++++++++++-- .../user/pages/08.free-trial/registration.md | 7 +++++++ .../themes/quark/templates/free-trial.twig | 12 ++++++++++++ skouter.go | 8 ++++++-- 9 files changed, 53 insertions(+), 19 deletions(-) create mode 100644 grav-admin/user/pages/08.free-trial/registration.md create mode 100644 grav-admin/user/themes/quark/templates/free-trial.twig diff --git a/components/app.vue b/components/app.vue index 29b7ab3..ce34338 100644 --- a/components/app.vue +++ b/components/app.vue @@ -41,7 +41,7 @@ v-else-if="active == 4" /> - + @@ -238,11 +238,11 @@ function start() { this.refreshToken() fetchUser().then( u => { if (u.sub.customerId && - validStatuses.includes(u.sub.paymentStatus)) { + validStatuses.includes(u.sub.paymentStatus) && + this.user.status != "Unsubscribed") { return } // Payment must be updated - console.log("paying...") this.invalidSub = true }) } diff --git a/components/update-billing/billing.vue b/components/update-billing/billing.vue index 93662a8..1ec4700 100644 --- a/components/update-billing/billing.vue +++ b/components/update-billing/billing.vue @@ -23,12 +23,13 @@ function submit() { //`Elements` instance that was used to create the Payment Element elements, confirmParams: { - return_url: "https://skouter.net/register", + return_url: `https://${process.env.SKOUTER_DOMAIN}`, } }) } onMounted(() => { + console.log(process.env.SKOUTER_DOMAIN) payEl.mount("#payment-element") }) diff --git a/grav-admin/user/data/feed/21232f297a57a5a743894a0e4a801fc3.yaml b/grav-admin/user/data/feed/21232f297a57a5a743894a0e4a801fc3.yaml index aeaa3ad..e07fe60 100644 --- a/grav-admin/user/data/feed/21232f297a57a5a743894a0e4a801fc3.yaml +++ b/grav-admin/user/data/feed/21232f297a57a5a743894a0e4a801fc3.yaml @@ -1,30 +1,30 @@ -last_checked: 1710870233 +last_checked: 1716916759 data: - title: 'macOS 14.0 Sonoma Apache Setup: Upgrading Homebrew' url: 'https://getgrav.org/blog/macos-ventura-apache-upgrade-homebrew' date: 1697803200 - nicetime: '5 months ago' + nicetime: '7 months ago' - title: 'macOS 14.0 Sonoma Apache Setup: LetsEncrypt SSL' url: 'https://getgrav.org/blog/macos-sonoma-apache-ssl' date: 1697799780 - nicetime: '5 months ago' + nicetime: '7 months ago' - title: 'macOS 14.0 Sonoma Apache Setup: MySQL, Xdebug & More...' url: 'https://getgrav.org/blog/macos-sonoma-apache-mysql-vhost-apc' date: 1697799600 - nicetime: '5 months ago' + nicetime: '7 months ago' - title: 'macOS 14.0 Sonoma Apache Setup: Multiple PHP Versions' url: 'https://getgrav.org/blog/macos-sonoma-apache-multiple-php-versions' date: 1697796000 - nicetime: '5 months ago' + nicetime: '7 months ago' - title: 'Big changes for Email plugin' url: 'https://getgrav.org/blog/new-email-plugin' date: 1665048600 - nicetime: '1 years ago' + nicetime: '2 years ago' - title: 'Skeleton Build Automation' url: 'https://getgrav.org/blog/skeletons-build-automation' @@ -46,7 +46,7 @@ data: date: 1611050100 nicetime: '3 years ago' - - title: 'Grav Premium Focus: NextGen Editor' - url: 'https://getgrav.org/blog/premium-focus-nextgen-editor' - date: 1610713140 + title: 'Grav 1.7 Stable Release - One week away!' + url: 'https://getgrav.org/blog/grav-17-stable-imminent' + date: 1610457780 nicetime: '3 years ago' diff --git a/grav-admin/user/data/flex/indexes/pages.json b/grav-admin/user/data/flex/indexes/pages.json index 9705aaa..b216f7e 100644 --- a/grav-admin/user/data/flex/indexes/pages.json +++ b/grav-admin/user/data/flex/indexes/pages.json @@ -1 +1 @@ -{"version":"1.5","timestamp":1710880035,"count":13,"index":{"":{"key":"","storage_key":"","template":null,"storage_timestamp":1710880035,"children":{"01.home":1704396086,"02.about":1704398516,"04.pricing":1704400398,"05.blog":1703638467,"06.register":1710878689,"07.app":1710874534},"checksum":"1fd7a2a72c57a3f77d8d7016060b50de"},"01.home":{"key":"home","storage_key":"01.home","template":"modular","storage_timestamp":1704396086,"markdown":{"":{"modular":1703631506}},"children":{"01._hero":1703718436,"02._features":1703720151,"03._example":1703716188,"04._comparison-pdf":1703719134,"05._info":1703720014,"06._any_device":1704396086},"checksum":"dbbcfea030db5994b105e013be94b15c"},"01.home\/01._hero":{"key":"home\/_hero","storage_key":"01.home\/01._hero","template":"hero","storage_timestamp":1703718436,"markdown":{"":{"hero":1703718436}},"checksum":"45dc2f4a454b5f0609cbe09cfda09790"},"01.home\/02._features":{"key":"home\/_features","storage_key":"01.home\/02._features","template":"features","storage_timestamp":1703720151,"markdown":{"":{"features":1703720151}},"checksum":"ed7be750188fc4ed50ebcdc060f6fb53"},"01.home\/03._example":{"key":"home\/_example","storage_key":"01.home\/03._example","template":"text","storage_timestamp":1703716188,"markdown":{"":{"text":1703713545}},"checksum":"48b2ea373eba19040584a991b21c083c"},"01.home\/04._comparison-pdf":{"key":"home\/_comparison-pdf","storage_key":"01.home\/04._comparison-pdf","template":"text","storage_timestamp":1703719134,"markdown":{"":{"text":1703719134}},"checksum":"f323d6050403b0102c73c174d74b2f0a"},"01.home\/05._info":{"key":"home\/_info","storage_key":"01.home\/05._info","template":"features","storage_timestamp":1703720014,"markdown":{"":{"features":1703720014}},"checksum":"35c9bee0f74fe81449a491e31bf81bcb"},"01.home\/06._any_device":{"key":"home\/_any_device","storage_key":"01.home\/06._any_device","template":"text","storage_timestamp":1704397975,"markdown":{"":{"text":1704397975}},"checksum":"aabfe01503028954e8557c5bff37048d"},"02.about":{"key":"about","storage_key":"02.about","template":"default","storage_timestamp":1704398516,"markdown":{"":{"default":1704398516}},"checksum":"3d12d8cc95786aef7316b6c379752aa0"},"04.pricing":{"key":"pricing","storage_key":"04.pricing","template":"default","storage_timestamp":1704400398,"markdown":{"":{"default":1704400398}},"checksum":"76ddfc1dafa27268dca3f24db2ffa05a"},"05.blog":{"key":"blog","storage_key":"05.blog","template":"blog","storage_timestamp":1703638467,"markdown":{"":{"blog":1703636303}},"checksum":"88a8e8a7109dc2957e9dc3e1fd81fa85"},"06.register":{"key":"register","storage_key":"06.register","template":"registration","storage_timestamp":1710878689,"markdown":{"":{"registration":1710878540}},"checksum":"983a354c44dd4836c96f7a5a0a7b74f1"},"07.app":{"key":"app","storage_key":"07.app","template":"app","storage_timestamp":1710874534,"markdown":{"":{"app":1710874534}},"checksum":"f0e4e99804d225d38720b9454d7b342b"}}} \ No newline at end of file +{"version":"1.5","timestamp":1716921308,"count":14,"index":{"":{"key":"","storage_key":"","template":null,"storage_timestamp":1716919287,"children":{"01.home":1704396086,"02.about":1704398516,"04.pricing":1704400398,"05.blog":1703638467,"06.register":1710878689,"07.app":1710874534,"08.free-trial":1716919287},"checksum":"8f0440315a1e597fd62bd7c941c51caa"},"01.home":{"key":"home","storage_key":"01.home","template":"modular","storage_timestamp":1704396086,"markdown":{"":{"modular":1703631506}},"children":{"01._hero":1703718436,"02._features":1703720151,"03._example":1703716188,"04._comparison-pdf":1703719134,"05._info":1703720014,"06._any_device":1704396086},"checksum":"dbbcfea030db5994b105e013be94b15c"},"01.home\/01._hero":{"key":"home\/_hero","storage_key":"01.home\/01._hero","template":"hero","storage_timestamp":1703718436,"markdown":{"":{"hero":1703718436}},"checksum":"45dc2f4a454b5f0609cbe09cfda09790"},"01.home\/02._features":{"key":"home\/_features","storage_key":"01.home\/02._features","template":"features","storage_timestamp":1703720151,"markdown":{"":{"features":1703720151}},"checksum":"ed7be750188fc4ed50ebcdc060f6fb53"},"01.home\/03._example":{"key":"home\/_example","storage_key":"01.home\/03._example","template":"text","storage_timestamp":1703716188,"markdown":{"":{"text":1703713545}},"checksum":"48b2ea373eba19040584a991b21c083c"},"01.home\/04._comparison-pdf":{"key":"home\/_comparison-pdf","storage_key":"01.home\/04._comparison-pdf","template":"text","storage_timestamp":1703719134,"markdown":{"":{"text":1703719134}},"checksum":"f323d6050403b0102c73c174d74b2f0a"},"01.home\/05._info":{"key":"home\/_info","storage_key":"01.home\/05._info","template":"features","storage_timestamp":1703720014,"markdown":{"":{"features":1703720014}},"checksum":"35c9bee0f74fe81449a491e31bf81bcb"},"01.home\/06._any_device":{"key":"home\/_any_device","storage_key":"01.home\/06._any_device","template":"text","storage_timestamp":1704397975,"markdown":{"":{"text":1704397975}},"checksum":"aabfe01503028954e8557c5bff37048d"},"02.about":{"key":"about","storage_key":"02.about","template":"default","storage_timestamp":1704398516,"markdown":{"":{"default":1704398516}},"checksum":"3d12d8cc95786aef7316b6c379752aa0"},"04.pricing":{"key":"pricing","storage_key":"04.pricing","template":"default","storage_timestamp":1704400398,"markdown":{"":{"default":1704400398}},"checksum":"76ddfc1dafa27268dca3f24db2ffa05a"},"05.blog":{"key":"blog","storage_key":"05.blog","template":"blog","storage_timestamp":1703638467,"markdown":{"":{"blog":1703636303}},"checksum":"88a8e8a7109dc2957e9dc3e1fd81fa85"},"06.register":{"key":"register","storage_key":"06.register","template":"registration","storage_timestamp":1710878689,"markdown":{"":{"registration":1710878540}},"checksum":"983a354c44dd4836c96f7a5a0a7b74f1"},"07.app":{"key":"app","storage_key":"07.app","template":"app","storage_timestamp":1710874534,"markdown":{"":{"app":1710874534}},"checksum":"f0e4e99804d225d38720b9454d7b342b"},"08.free-trial":{"key":"free-trial","storage_key":"08.free-trial","template":"registration","storage_timestamp":1716921308,"markdown":{"":{"registration":1716921308}},"checksum":"bcd1eb947a8e3dc202432d9a9e08ac14"}}} \ No newline at end of file diff --git a/grav-admin/user/data/notifications/21232f297a57a5a743894a0e4a801fc3.yaml b/grav-admin/user/data/notifications/21232f297a57a5a743894a0e4a801fc3.yaml index b42b098..7a7127e 100644 --- a/grav-admin/user/data/notifications/21232f297a57a5a743894a0e4a801fc3.yaml +++ b/grav-admin/user/data/notifications/21232f297a57a5a743894a0e4a801fc3.yaml @@ -1,4 +1,4 @@ -last_checked: 1710888087 +last_checked: 1716921278 data: feed: - diff --git a/grav-admin/user/js/registration/registration.vue b/grav-admin/user/js/registration/registration.vue index 5c3e4f0..ba6daac 100644 --- a/grav-admin/user/js/registration/registration.vue +++ b/grav-admin/user/js/registration/registration.vue @@ -2,7 +2,7 @@

Register

- +
@@ -19,6 +19,7 @@ const step = ref(1) const token = ref("") const user = ref(null) const sub = ref(null) +const trial = ref(false) const clientSecret = new URLSearchParams(window.location.search).get( 'payment_intent_client_secret' @@ -70,8 +71,13 @@ function create(user) { } function intent(u) { + let path = `/api/user/subscribe` - return fetch(`/api/user/subscribe`, + if (trial.value) { + path = `/api/user/trial` + } + + return fetch(path, {method: 'POST', body: JSON.stringify(u), headers: { @@ -101,6 +107,10 @@ function intent(u) { } onMounted(() => { + if (window.location.pathname == "/free-trial") { + trial.value = true + } + getUser().then( u => { if (u) { user.value = u; intent(u) } }) diff --git a/grav-admin/user/pages/08.free-trial/registration.md b/grav-admin/user/pages/08.free-trial/registration.md new file mode 100644 index 0000000..72987b1 --- /dev/null +++ b/grav-admin/user/pages/08.free-trial/registration.md @@ -0,0 +1,7 @@ +--- +title: 'Free trial' +visible: false +--- + +## 30 Day Free Trial +\* Renews at $49/month \ No newline at end of file diff --git a/grav-admin/user/themes/quark/templates/free-trial.twig b/grav-admin/user/themes/quark/templates/free-trial.twig new file mode 100644 index 0000000..32acd1d --- /dev/null +++ b/grav-admin/user/themes/quark/templates/free-trial.twig @@ -0,0 +1,12 @@ +{% extends 'partials/base.html.twig' %} + +{% block javascripts %} + {{ parent() }} + {% do assets.add('theme://js/bricklayer.min.js') %} + {% do assets.add('theme://assets/register.js', {group:'bottom'}) %} +{% endblock %} + +{% block content %} + {{ page.content|raw }} +
+{% endblock %} diff --git a/skouter.go b/skouter.go index e437b46..5e98bc2 100644 --- a/skouter.go +++ b/skouter.go @@ -1192,7 +1192,7 @@ func queryUser(db *sql.DB, id int) (User, error) { u.role, u.address, u.phone, - s.id + coalesce(s.id, 0) FROM user u LEFT JOIN subscription s ON s.user_id = u.id @@ -1230,10 +1230,14 @@ func queryUser(db *sql.DB, id int) (User, error) { return user, err } - user.Sub, err = querySub(db, user.Sub.Id) + if user.Sub.Id > 0 { + user.Sub, err = querySub(db, user.Sub.Id) + } + if err != nil { return user, err } + if user.Branch.Id > 0 { user.Branch, err = queryBranch(db, user.Branch.Id)