mirror of
https://github.com/hanzoai/calendar.git
synced 2026-10-30 14:46:43 +00:00
* feat: add web phone call for cal ai * fix: web call * refactor: improvements * chore * refactor: web call improvements * chore: error message * refactor: improvements * fix: err * refactor: feedback and improvements * fix: type errors * refactor: hasAvailable * chore: use orgid * fix: types --------- Co-authored-by: Peer Richelsen <[email protected]>
26 lines
731 B
TypeScript
26 lines
731 B
TypeScript
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
|
|
|
|
import type { THasAvailableCreditsSchema } from "./hasAvailableCredits.schema";
|
|
|
|
type HasAvailableCreditsOptions = {
|
|
ctx: {
|
|
user: NonNullable<TrpcSessionUser>;
|
|
};
|
|
input: THasAvailableCreditsSchema;
|
|
};
|
|
|
|
export const hasAvailableCreditsHandler = async ({ ctx, input }: HasAvailableCreditsOptions) => {
|
|
const { teamId } = input;
|
|
|
|
const orgId = ctx.user.organization?.id;
|
|
|
|
const { CreditService } = await import("@calcom/features/ee/billing/credit-service");
|
|
const creditService = new CreditService();
|
|
|
|
const hasCredits = await creditService.hasAvailableCredits({
|
|
userId: ctx.user.id,
|
|
teamId: teamId ?? orgId,
|
|
});
|
|
return hasCredits;
|
|
};
|