generated from fahricansecer/boilerplate-fe
This commit is contained in:
@@ -135,9 +135,11 @@ export interface PaginatedResponse<T> {
|
||||
export interface CreateProjectPayload {
|
||||
title: string;
|
||||
description?: string;
|
||||
prompt: string;
|
||||
topic?: string;
|
||||
prompt?: string;
|
||||
language?: string;
|
||||
aspectRatio?: string;
|
||||
style?: string;
|
||||
videoStyle?: string;
|
||||
targetDuration?: number;
|
||||
seoKeywords?: string[];
|
||||
@@ -146,6 +148,9 @@ export interface CreateProjectPayload {
|
||||
|
||||
export interface CreditBalance {
|
||||
balance: number;
|
||||
remaining: number;
|
||||
total: number;
|
||||
plan: string;
|
||||
monthlyUsed: number;
|
||||
monthlyLimit: number;
|
||||
}
|
||||
@@ -230,6 +235,29 @@ export interface CreateFromTweetPayload {
|
||||
targetDuration?: number;
|
||||
}
|
||||
|
||||
export interface Notification {
|
||||
id: string;
|
||||
userId: string;
|
||||
type: string;
|
||||
title: string;
|
||||
message?: string | null;
|
||||
metadata?: Record<string, unknown> | null;
|
||||
isRead: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface NotificationListResponse {
|
||||
data: Notification[];
|
||||
meta: {
|
||||
total: number;
|
||||
page: number;
|
||||
limit: number;
|
||||
totalPages: number;
|
||||
unreadCount: number;
|
||||
};
|
||||
}
|
||||
|
||||
// ── API Functions ────────────────────────────────────────────────────
|
||||
|
||||
export const projectsApi = {
|
||||
@@ -253,19 +281,48 @@ export const projectsApi = {
|
||||
|
||||
approveAndQueue: (id: string) =>
|
||||
apiClient.post<{ projectId: string; renderJobId: string; bullJobId: string }>(
|
||||
`/projects/${id}/approve-and-queue`,
|
||||
`/projects/${id}/approve`,
|
||||
).then((r) => r.data),
|
||||
|
||||
createFromTweet: (data: CreateFromTweetPayload) =>
|
||||
apiClient.post<Project>('/projects/from-tweet', data).then((r) => r.data),
|
||||
|
||||
updateScene: (projectId: string, sceneId: string, data: Partial<Scene>) =>
|
||||
apiClient.patch<Scene>(`/projects/${projectId}/scenes/${sceneId}`, data).then((r) => r.data),
|
||||
|
||||
regenerateScene: (projectId: string, sceneId: string) =>
|
||||
apiClient.post<Scene>(`/projects/${projectId}/scenes/${sceneId}/regenerate`).then((r) => r.data),
|
||||
};
|
||||
|
||||
// Backend path: /billing/credits/balance (billing controller prefix)
|
||||
export const creditsApi = {
|
||||
getBalance: () =>
|
||||
apiClient.get<CreditBalance>('/credits/balance').then((r) => r.data),
|
||||
apiClient.get<CreditBalance>('/billing/credits/balance').then((r) => r.data),
|
||||
|
||||
getHistory: (params?: { page?: number; limit?: number }) =>
|
||||
apiClient.get('/credits/history', { params }).then((r) => r.data),
|
||||
apiClient.get('/billing/credits/history', { params }).then((r) => r.data),
|
||||
};
|
||||
|
||||
export const billingApi = {
|
||||
createCheckout: (planName: string, billingCycle: 'monthly' | 'yearly') =>
|
||||
apiClient.post<{ sessionId: string; url: string }>('/billing/checkout', { planName, billingCycle }).then((r) => r.data),
|
||||
|
||||
getSubscription: () =>
|
||||
apiClient.get('/billing/subscription').then((r) => r.data),
|
||||
|
||||
getPlans: () =>
|
||||
apiClient.get('/billing/plans').then((r) => r.data),
|
||||
};
|
||||
|
||||
export const usersApi = {
|
||||
getMe: () =>
|
||||
apiClient.get('/users/me').then((r) => r.data),
|
||||
|
||||
updateProfile: (data: { firstName?: string; lastName?: string }) =>
|
||||
apiClient.patch('/users/me', data).then((r) => r.data),
|
||||
|
||||
changePassword: (data: { currentPassword: string; newPassword: string }) =>
|
||||
apiClient.patch('/users/me/password', data).then((r) => r.data),
|
||||
};
|
||||
|
||||
export const templatesApi = {
|
||||
@@ -291,3 +348,21 @@ export const xTwitterApi = {
|
||||
fetch: (tweetUrl: string) =>
|
||||
apiClient.post<ParsedTweet>('/x-twitter/fetch', { tweetUrl }).then((r) => r.data),
|
||||
};
|
||||
|
||||
export const notificationsApi = {
|
||||
list: (params?: { page?: number; limit?: number; unreadOnly?: boolean }) =>
|
||||
apiClient.get<NotificationListResponse>('/notifications', { params }).then((r) => r.data),
|
||||
|
||||
getUnreadCount: () =>
|
||||
apiClient.get<{ count: number }>('/notifications/unread-count').then((r) => r.data),
|
||||
|
||||
markAsRead: (id: string) =>
|
||||
apiClient.patch<Notification>(`/notifications/${id}/read`).then((r) => r.data),
|
||||
|
||||
markAllAsRead: () =>
|
||||
apiClient.patch<{ count: number }>('/notifications/read-all').then((r) => r.data),
|
||||
|
||||
delete: (id: string) =>
|
||||
apiClient.delete(`/notifications/${id}`).then((r) => r.data),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user