Files
twenty/packages/twenty-server/src/utils/find-or-throw.util.ts
T
Antoine Moreaux 1c4568c8b1 feat(pricing/ai): improve billing metered pricing + add pricing on ai chat (#14092)
## TODO:

- [x] display "yearly" or "monthly" wording everywhere it's needed
- [ ] Add button with "downgrade" or "upgrade" to save the change of
credits price + modal to validate
- [x] Add renewal date 
- [ ] Implement
https://docs.stripe.com/billing/subscriptions/subscription-schedules for
`switchFromYearlyToMonthly` and decrease number of credits
2025-08-29 16:23:07 +00:00

15 lines
278 B
TypeScript

import { isDefined } from 'twenty-shared/utils';
export const findOrThrow = <T>(
array: T[],
predicate: (value: T) => boolean,
): T => {
const result = array.find(predicate);
if (!isDefined(result)) {
throw new Error('Element not found');
}
return result;
};