-
Notifications
You must be signed in to change notification settings - Fork 228
Feat improved billing #1742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feat improved billing #1742
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
}), | ||
queryClient.invalidateQueries({ | ||
queryKey: ['billing:*'], | ||
queryKey: ['*'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrkaye97 heads up this doesnt work 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which part of it? the wildcard? if yes, I don't think I'd expect it to, there's nothing on this in the docs AFAICT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting... ok then this is a gabe hallucination and not an llm one -- i could have sworn it supported wildcard query keys
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heh yeah I'm not sure, I thought I'd seen them before too but I was looking in the docs and couldn't find anything. I think maybe the right thing would be to split up the query keys into e.g. ['billing', 'foo']
, ['billing', 'bar']
, .. and then use 'billing'
as the key to invalidate? idk
@@ -85,6 +94,23 @@ func (r *tenantAPIRepository) CreateTenant(ctx context.Context, opts *repository | |||
return nil, err | |||
} | |||
|
|||
if user != nil { | |||
// add the user as an owner of the tenant | |||
_, err = r.CreateTenantMember(ctx, tenantId, &repository.CreateTenantMemberOpts{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it makes more sense to me to create a tenant owner on create, without this the hook is racy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some comments / questions!
useEffect(() => { | ||
setShowAnnual(active?.period?.includes('yearly') || false); | ||
}, [active]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this was just moved up from below, but I'd think we could get rid of this effect hook and use derived state?
const showAnnual = active?.period?.includes("yearly") || false
@@ -80,7 +80,7 @@ export function PaymentMethods({ | |||
<Icon size={24} /> | |||
{method.brand.toUpperCase()} | |||
{method.last4 && ` *** *** ${method.last4} `} | |||
{method.expiration && `(Expires {method.expiration})`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😬
useEffect(() => { | ||
setShowAnnual(active?.period?.includes('yearly') || false); | ||
}, [active]); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here re: derived state
}), | ||
queryClient.invalidateQueries({ | ||
queryKey: ['billing:*'], | ||
queryKey: ['*'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which part of it? the wildcard? if yes, I don't think I'd expect it to, there's nothing on this in the docs AFAICT
let adjusted = priceCents; | ||
for (const coupon of coupons) { | ||
if (coupon.percent) { | ||
adjusted = Math.round(adjusted * (1 - coupon.percent / 100)); | ||
} | ||
} | ||
|
||
// Then apply fixed-amount coupons | ||
for (const coupon of coupons) { | ||
if (coupon.amount_cents) { | ||
adjusted = Math.max(0, adjusted - coupon.amount_cents); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be great to use reduce
for these IMO
func (r *tenantAPIRepository) RegisterCreateCallback(callback repository.UnscopedCallback[*dbsqlc.Tenant]) { | ||
if r.createCallbacks == nil { | ||
r.createCallbacks = make([]repository.UnscopedCallback[*dbsqlc.Tenant], 0) | ||
} | ||
|
||
r.createCallbacks = append(r.createCallbacks, callback) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O_O does Go allow this? Haven't seen this pattern before so I'm curious about it, since this feels a lot more like Java getter/setter patterns to me than Go's no-class approach to things
Description
Improvements for usage based billing