diff --git a/server/db/db.js b/server/db/db.js index dfc0fea..d8092c5 100644 --- a/server/db/db.js +++ b/server/db/db.js @@ -79,7 +79,6 @@ export default class Database { } updateNode(prefix, id, toEdit) { - console.log("update node, ", toEdit) try { let model = nodeModels[prefix] if(model) { @@ -130,9 +129,7 @@ export default class Database { try { let model = edgeModels[prefix] if(model) { - console.log(model.indices[0] + (id - 1)) this.edges[model.indices[0] + (id - 1)] = 0 - console.log(this.edges[model.indices[0] + (id - 1)]) } else { throw new Error("Type does not exist for edge: " + prefix) } diff --git a/server/index.js b/server/index.js index f4e799c..e7fed8a 100644 --- a/server/index.js +++ b/server/index.js @@ -75,7 +75,7 @@ class Server { const contact = contactRaw.trim() ? JSON.parse(contactRaw) : []; const members = db.members.getByNetwork(networkId) let stripeMembers = await payments.getCustomers(networkId) - stripeMembers = stripeMembers.data + console.log("stripemenbers: ", stripeMembers) res.json({ join, diff --git a/server/payments.js b/server/payments.js index c7abf5d..82b57a8 100644 --- a/server/payments.js +++ b/server/payments.js @@ -8,7 +8,6 @@ export default class PaymentsHandler { static async finishConnectSetup(req, res) { const { code, networkId } = req.body; - console.log("onboarded", networkId) const response = await stripe.oauth.token({ grant_type: "authorization_code", @@ -54,10 +53,26 @@ export default class PaymentsHandler { throw new Error("Can't get customers for account that doesn't exist!") } const customers = await stripe.customers.list( - { limit: 100 }, + { limit: 100, expand: ['data.subscriptions'] }, { stripeAccount: network.stripeAccountId } ); - return customers + console.log(customers) + + return customers.data.map(customer => ({ + id: customer.id, + email: customer.email, + created: customer.created, + name: customer.name, + phone: customer.phone, + city: customer.address?.city, + subscriptions: customer.subscriptions?.data.map(sub => ({ + id: sub.id, + status: sub.status, + amount: sub.items.data[0]?.price.unit_amount / 100, // converts cents to dollars + currency: sub.items.data[0]?.price.currency, + interval: sub.items.data[0]?.price.recurring?.interval + })) + })) } static async newSubscription(req, res) { diff --git a/ui/desktop/apps/People/People.js b/ui/desktop/apps/People/People.js index c221701..25f33af 100644 --- a/ui/desktop/apps/People/People.js +++ b/ui/desktop/apps/People/People.js @@ -4,56 +4,116 @@ class People extends Shadow { h1("Members") .fontWeight("bold") .marginBottom(2, em) + .marginLeft(4, em) - HStack(() => { + VStack(() => { VStack(() => { p("Officers") .marginBottom(2, vh) + .marginLeft(8, em) .fontStyle("italic") - for(let i = 0; i < global.currentNetwork.data.members.length; i++) { - let member = global.currentNetwork.data.members[i] - HStack(() => { - p(member.firstName + " " + member.lastName) - .width(10, vw) - p(member.email) - .width(10, vw) - }) - } + ZStack(() => { + new gridjs.Grid({ + columns: ["Name", "Email"], + data: global.currentNetwork.data.members.map(m => [ + m.firstName + " " + m.lastName, + m.email + ]), + sort: true, + search: true, + style: { + table: { + 'background-color': 'var(--window)', + 'color': 'var(--accent)', + 'box-shadow': 'none', + 'font-size': '0.9em' + }, + th: { + 'background-color': 'var(--window)', + 'color': 'var(--accent)', + 'border': 'none', + 'border-bottom': '1px solid rgb(69 53 53)' + }, + td: { + 'background-color': 'var(--window)', + 'color': 'var(--accent)', + 'border': 'none', + 'border-bottom': '1px solid rgb(69 53 53)' + } + } + }).render(quill.rendering.last) + }) }) .gap(0.5, em) VStack(() => { p("Stripe Subscribers") .marginBottom(2, vh) + .marginLeft(8, em) .fontStyle("italic") - for(let i = 0; i < global.currentNetwork.data.stripeMembers.length; i++) { - let member = global.currentNetwork.data.stripeMembers[i] - HStack(() => { - p(member.name) - .width(10, vw) - p(member.email) - .width(20, vw) - p(new Date(member.created * 1000).toLocaleString('en-US', { - timeZone: 'America/Chicago', - hour: 'numeric', - minute: '2-digit', - month: 'numeric', - day: 'numeric', - year: 'numeric' - })) - .width(40, vw) - }) - } + ZStack(() => { + new gridjs.Grid({ + columns: ["Amount", "Name", "Email", "Phone", "Area", "Created"], + data: global.currentNetwork.data.stripeMembers.map(m => [ + "$" + m.subscriptions[0].amount, + m.name, + m.email, + m.phone, + m.city, + new Date(m.created * 1000).toLocaleString('en-US', { + timeZone: 'America/Chicago', + hour: 'numeric', + minute: '2-digit', + month: 'numeric', + day: 'numeric', + year: 'numeric' + }) + ]), + sort: true, + search: true, + style: { + input: { + 'background-color': 'var(--window)', + }, + table: { + 'background-color': 'var(--window)', + 'color': 'var(--accent)', + 'box-shadow': 'none', + 'font-size': '0.9em' + }, + th: { + 'background-color': 'var(--window)', + 'color': 'var(--accent)', + 'border': 'none', + 'border-bottom': '1px solid rgb(69 53 53)' + }, + td: { + 'background-color': 'var(--window)', + 'color': 'var(--accent)', + 'border': 'none', + 'border-bottom': '1px solid rgb(69 53 53)' + } + } + }).render(quill.rendering.last) + + css(` + input.gridjs-input { + background-color: var(--window); + color: var(--accent); + border: 1px solid rgb(69 53 53); + margin-left: 8em + } + `) + }) }) .gap(0.5, em) }) - .gap(10, vw) + .gap(4, em) }) .gap(0.5, em) .paddingTop(4, pct) - .paddingLeft(5, pct) .width(100, pct) .height(100, pct); } diff --git a/ui/desktop/apps/Settings/Settings.js b/ui/desktop/apps/Settings/Settings.js index 6acc2fd..7a9c9e5 100644 --- a/ui/desktop/apps/Settings/Settings.js +++ b/ui/desktop/apps/Settings/Settings.js @@ -34,7 +34,7 @@ class Settings extends Shadow { p("Stripe Integration") if(this.stripeDetails && this.stripeDetails.data.email) { - p("connected") + p("Connected") } else if(this.stripeDetails && this.stripeDetails.data.connected === false) { button("Set up Stripe") .maxWidth(10, em) diff --git a/ui/desktop/index.html b/ui/desktop/index.html index ec7f25a..4aa51d6 100644 --- a/ui/desktop/index.html +++ b/ui/desktop/index.html @@ -3,6 +3,8 @@