chore: ai, public course and other ui improvements

This commit is contained in:
Rotimi Best
2026-05-09 06:05:03 +01:00
parent 5717dd8004
commit c31ad63955
318 changed files with 20668 additions and 4788 deletions
@@ -0,0 +1,25 @@
import type { TAgentCreditPurchase } from '@cio/utils/validation/agent';
import { classroomio, type InferResponseType } from '$lib/utils/services/api';
import { getApiKeyHeaders, safeServerApi } from '$lib/utils/services/api/server';
type RecordPurchaseRequest = typeof classroomio.agent.credits.purchase.$post;
type RecordPurchaseSuccess = Extract<InferResponseType<RecordPurchaseRequest>, { success: true }>;
export class CreditPurchaseApiServer {
/**
* Record a token-pack purchase from the Polar webhook (server-side, API key auth).
*/
static async recordPurchase(params: TAgentCreditPurchase) {
const result = await safeServerApi<RecordPurchaseSuccess>(() =>
classroomio.agent.credits.purchase.$post({ json: params }, getApiKeyHeaders())
);
if (!result.ok) {
console.error('Error recording credit purchase (server):', result);
return null;
}
return result.body.data;
}
}