www.spaceplanner.app

Web client to the spaceplanner API
git clone git://jacobedwards.org/www.spaceplanner.app
Log | Files | Refs

commit f784ba451303c0e50d1a943908638a2d65df3f33
parent 83aa37034ba6557a00bcd949d35e8ea4c88f6fa2
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Fri, 11 Oct 2024 12:43:50 -0700

Show subscribe button in bar when not subscribed

Otherwise if you make an account and come back to pay later you'll
be unable to find the services page.

Diffstat:
Mfiles/lib/etc.js | 22+++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/files/lib/etc.js b/files/lib/etc.js @@ -48,7 +48,17 @@ export function bar(on) { l.classList.add("pop") additem(right, l) } else { - additem(left, link("Floorplans", "/floorplans")) + userService() + .then(function(service) { + if (service == null) { + additem(left, link("Subscribe", "/services")) + } else { + additem(left, ) + } + }) + .catch(function() { + additem(left, link("Floorplans", "/floorplans")) + }) additem(right, link("Settings", "/settings", "settings")) additem(right, link("Logout", "/logout", "log-out")) @@ -57,6 +67,16 @@ export function bar(on) { on.prepend(nav) } +export function userService() { + return api.fetch("GET", "users/:user/services/subscribed") + .then(function(r) { + if (r.services.length > 1) { + console.error("Only returning one service when multiple are subscribed to") + } + return r.services[0] + }) +} + export function authorize() { if (!api.authorized()) { // Maybe add a parameter which has /login redirect