showing stripe subscribers. loading really slow.

This commit is contained in:
metacryst
2026-03-05 05:41:45 -06:00
parent 661bf86a1a
commit 4061e86ce7
5 changed files with 57 additions and 17 deletions

View File

@@ -21,7 +21,7 @@ export default class Network {
.strict() .strict()
get(id) { get(id) {
if(typeof id === "string") { if(id.length > 1) {
id = id.split("-")[1] id = id.split("-")[1]
} }
let index = this.indices[0] + (id - 1) let index = this.indices[0] + (id - 1)

View File

@@ -74,11 +74,14 @@ class Server {
const join = joinRaw.trim() ? JSON.parse(joinRaw) : []; const join = joinRaw.trim() ? JSON.parse(joinRaw) : [];
const contact = contactRaw.trim() ? JSON.parse(contactRaw) : []; const contact = contactRaw.trim() ? JSON.parse(contactRaw) : [];
const members = db.members.getByNetwork(networkId) const members = db.members.getByNetwork(networkId)
let stripeMembers = await payments.getCustomers(networkId)
stripeMembers = stripeMembers.data
res.json({ res.json({
join, join,
contact, contact,
members members,
stripeMembers
}); });
} else { } else {
const members = db.members.getByNetwork(networkId) const members = db.members.getByNetwork(networkId)

View File

@@ -48,12 +48,16 @@ export default class PaymentsHandler {
} }
} }
static async getCustomers() { static async getCustomers(networkId) {
let network = global.db.networks.get(networkId)
if(!network.stripeAccountId) {
throw new Error("Can't get customers for account that doesn't exist!")
}
const customers = await stripe.customers.list( const customers = await stripe.customers.list(
{ limit: 100 }, { limit: 100 },
{ stripeAccount: 'acct_connected_account_id' } { stripeAccount: network.stripeAccountId }
); );
console.log(customers) return customers
} }
static async newSubscription(req, res) { static async newSubscription(req, res) {

View File

@@ -65,6 +65,7 @@ export default class Socket {
payload = jwt.verify(token, process.env.JWT_SECRET); payload = jwt.verify(token, process.env.JWT_SECRET);
} catch(e) { } catch(e) {
console.error("error: jwt is expired ", e) console.error("error: jwt is expired ", e)
return
} }
ws.userEmail = payload.email; ws.userEmail = payload.email;
@@ -87,7 +88,6 @@ export default class Socket {
try { try {
const text = msg.toString(); const text = msg.toString();
const req = JSON.parse(text); const req = JSON.parse(text);
console.log(req)
if(this.appOperationSchema.safeParse(req).success) { if(this.appOperationSchema.safeParse(req).success) {
this.handleAppOperation(req, ws) this.handleAppOperation(req, ws)
@@ -127,7 +127,6 @@ export default class Socket {
} }
async handleFunction(req, ws) { async handleFunction(req, ws) {
console.log("func call: ", req.name, req.args)
let responseData = await server[req.name](...req.args) let responseData = await server[req.name](...req.args)
let response = { let response = {
@@ -135,8 +134,6 @@ export default class Socket {
} }
response.data = responseData response.data = responseData
console.log(response)
if(!this.functionCallSchema.safeParse(response).success) throw new Error("Socket.handleMessage: Outgoing ws message has incorrect format!") if(!this.functionCallSchema.safeParse(response).success) throw new Error("Socket.handleMessage: Outgoing ws message has incorrect format!")
ws.send(JSON.stringify(response)) ws.send(JSON.stringify(response))
} }

View File

@@ -5,15 +5,51 @@ class People extends Shadow {
.fontWeight("bold") .fontWeight("bold")
.marginBottom(2, em) .marginBottom(2, em)
for(let i = 0; i < global.currentNetwork.data.members.length; i++) { HStack(() => {
let member = global.currentNetwork.data.members[i] VStack(() => {
HStack(() => { p("Officers")
p(member.firstName + " " + member.lastName) .marginBottom(2, vh)
.width(10, pct) .fontStyle("italic")
p(member.email)
.width(10, pct) 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)
})
}
}) })
} .gap(0.5, em)
VStack(() => {
p("Stripe Subscribers")
.marginBottom(2, vh)
.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)
})
}
})
.gap(0.5, em)
})
.gap(10, vw)
}) })
.gap(0.5, em) .gap(0.5, em)
.paddingTop(4, pct) .paddingTop(4, pct)