removed all references to credits. now credits are completely replaced by addons.
This commit is contained in:
@@ -363,15 +363,7 @@ export type TenantPackageSummary = {
|
||||
|
||||
export type NotificationPreferences = Record<string, boolean>;
|
||||
|
||||
export type NotificationPreferencesMeta = {
|
||||
credit_warning_sent_at?: string | null;
|
||||
credit_warning_threshold?: number | null;
|
||||
};
|
||||
|
||||
export type CreditBalance = {
|
||||
balance: number;
|
||||
free_event_granted_at?: string | null;
|
||||
};
|
||||
export type NotificationPreferencesMeta = Record<string, never>;
|
||||
|
||||
export type PaddleTransactionSummary = {
|
||||
id: string | null;
|
||||
@@ -1975,37 +1967,6 @@ export async function getTenantAddonHistory(page = 1, perPage = 25): Promise<{
|
||||
return { data: rows, meta };
|
||||
}
|
||||
|
||||
export async function getCreditBalance(): Promise<CreditBalance> {
|
||||
const response = await authorizedFetch('/api/v1/tenant/credits/balance');
|
||||
if (response.status === 404) {
|
||||
return { balance: 0 };
|
||||
}
|
||||
const data = await jsonOrThrow<CreditBalance>(response, 'Failed to load credit balance');
|
||||
return { balance: Number(data.balance ?? 0), free_event_granted_at: data.free_event_granted_at ?? null };
|
||||
}
|
||||
|
||||
export async function getCreditLedger(page = 1): Promise<PaginatedResult<CreditLedgerEntry>> {
|
||||
const response = await authorizedFetch(`/api/v1/tenant/credits/ledger?page=${page}`);
|
||||
if (!response.ok) {
|
||||
const payload = await safeJson(response);
|
||||
console.error('[API] Failed to load credit ledger', response.status, payload);
|
||||
throw new Error('Failed to load credit ledger');
|
||||
}
|
||||
const json = (await response.json()) as LedgerResponse;
|
||||
const entries = Array.isArray(json.data) ? json.data.map((entry) => ({
|
||||
id: Number(entry.id ?? 0),
|
||||
delta: Number(entry.delta ?? 0),
|
||||
reason: String(entry.reason ?? 'unknown'),
|
||||
note: entry.note ?? null,
|
||||
related_purchase_id: entry.related_purchase_id ?? null,
|
||||
created_at: entry.created_at ?? '',
|
||||
})) : [];
|
||||
return {
|
||||
data: entries,
|
||||
meta: buildPagination(json as JsonValue, entries.length),
|
||||
};
|
||||
}
|
||||
|
||||
export async function createTenantPackagePaymentIntent(packageId: number): Promise<string> {
|
||||
const response = await authorizedFetch('/api/v1/tenant/packages/payment-intent', {
|
||||
method: 'POST',
|
||||
@@ -2102,19 +2063,6 @@ export async function recordCreditPurchase(payload: {
|
||||
return { balance: Number(data.balance ?? 0) };
|
||||
}
|
||||
|
||||
export async function syncCreditBalance(payload: {
|
||||
balance: number;
|
||||
subscription_active?: boolean;
|
||||
last_sync?: string;
|
||||
}): Promise<{ balance: number; subscription_active: boolean; server_time: string }> {
|
||||
const response = await authorizedFetch('/api/v1/tenant/credits/sync', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
return jsonOrThrow(response, 'Failed to sync credit balance');
|
||||
}
|
||||
|
||||
export async function getTaskCollections(params: {
|
||||
page?: number;
|
||||
per_page?: number;
|
||||
|
||||
Reference in New Issue
Block a user