diff --git a/services/web/app/src/Features/Helpers/StringHelper.mjs b/services/web/app/src/Features/Helpers/StringHelper.mjs index a0d12150dc..2e4f141c0f 100644 --- a/services/web/app/src/Features/Helpers/StringHelper.mjs +++ b/services/web/app/src/Features/Helpers/StringHelper.mjs @@ -15,6 +15,20 @@ const JSON_ESCAPE = { '\u2029': '\\u2029', } +/** + * Converts a snake_case string into a user friendly string with each word capitalized. + * @param {string} snakecaseStr + * @returns {string} + */ +export function wordifySnakecase(snakecaseStr) { + return snakecaseStr + .split('_') + .map(word => { + return word.charAt(0).toUpperCase() + word.slice(1) + }) + .join(' ') +} + export default StringHelper = { // stringifies and escapes a json object for use in a script. This ensures that &, < and > characters are escaped, // along with quotes. This ensures that the string can be safely rendered into HTML. See rationale at: diff --git a/services/web/app/src/Features/Subscription/SubscriptionLocator.mjs b/services/web/app/src/Features/Subscription/SubscriptionLocator.mjs index 1417b1be1a..f5360281ad 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionLocator.mjs +++ b/services/web/app/src/Features/Subscription/SubscriptionLocator.mjs @@ -106,6 +106,20 @@ const SubscriptionLocator = { ) }, + async getUniqueManagedSubscriptionUserAssociation(userId) { + return await Subscription.findOne( + { + managedUsersEnabled: true, + $or: [ + { member_ids: userId }, + { manager_ids: userId }, + { admin_id: userId }, + ], + }, + { _id: 1 } + ) + }, + async getGroupsWithEmailInvite(email) { return await Subscription.find({ invited_emails: email }).exec() }, diff --git a/services/web/types/stripe/webhook-event.ts b/services/web/types/stripe/webhook-event.ts index 3a15d00147..7a61ed005e 100644 --- a/services/web/types/stripe/webhook-event.ts +++ b/services/web/types/stripe/webhook-event.ts @@ -114,6 +114,21 @@ export interface CustomerCreatedWebhookEvent extends Stripe.EventBase { } } +export interface CustomerUpdatedWebhookEvent extends Stripe.EventBase { + type: 'customer.updated' + data: { + object: Stripe.Customer + previous_attributes?: { + invoice_settings?: { + default_payment_method?: string + } + address?: Stripe.Address + name?: string + email?: string + } + } +} + export type CustomerSubscriptionWebhookEvent = | CustomerSubscriptionUpdatedWebhookEvent | CustomerSubscriptionCreatedWebhookEvent @@ -127,3 +142,4 @@ export type WebhookEvent = | SetupIntentSetupFailedWebhookEvent | InvoiceOverdueWebhookEvent | CustomerCreatedWebhookEvent + | CustomerUpdatedWebhookEvent