showing stripe subscribers. loading really slow.
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,17 +5,53 @@ class People extends Shadow {
|
|||||||
.fontWeight("bold")
|
.fontWeight("bold")
|
||||||
.marginBottom(2, em)
|
.marginBottom(2, em)
|
||||||
|
|
||||||
|
HStack(() => {
|
||||||
|
VStack(() => {
|
||||||
|
p("Officers")
|
||||||
|
.marginBottom(2, vh)
|
||||||
|
.fontStyle("italic")
|
||||||
|
|
||||||
for(let i = 0; i < global.currentNetwork.data.members.length; i++) {
|
for(let i = 0; i < global.currentNetwork.data.members.length; i++) {
|
||||||
let member = global.currentNetwork.data.members[i]
|
let member = global.currentNetwork.data.members[i]
|
||||||
HStack(() => {
|
HStack(() => {
|
||||||
p(member.firstName + " " + member.lastName)
|
p(member.firstName + " " + member.lastName)
|
||||||
.width(10, pct)
|
.width(10, vw)
|
||||||
p(member.email)
|
p(member.email)
|
||||||
.width(10, pct)
|
.width(10, vw)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.gap(0.5, em)
|
.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)
|
||||||
.paddingTop(4, pct)
|
.paddingTop(4, pct)
|
||||||
.paddingLeft(5, pct)
|
.paddingLeft(5, pct)
|
||||||
.width(100, pct)
|
.width(100, pct)
|
||||||
|
|||||||
Reference in New Issue
Block a user