Wire team, user, persona, FAQ, and ratings flows to backend endpoints; rebuild profile and user detail views with learning activity and subscriptions; fetch Vimeo lesson duration on module cards; add shared filters, permissions helpers, and notification UX improvements. Co-authored-by: Cursor <cursoragent@cursor.com>
256 lines
6.0 KiB
TypeScript
256 lines
6.0 KiB
TypeScript
// This matches the API response 1:1 (GET /users); many fields are optional on partial profiles.
|
|
export interface UserApiDTO {
|
|
id: number
|
|
first_name?: string
|
|
last_name?: string
|
|
gender?: string
|
|
birth_day?: string | null
|
|
|
|
email?: string
|
|
phone_number?: string
|
|
role: string
|
|
|
|
age_group?: string
|
|
education_level?: string
|
|
country?: string
|
|
region?: string
|
|
|
|
nick_name?: string
|
|
occupation?: string
|
|
learning_goal?: string
|
|
language_goal?: string
|
|
language_challange?: string
|
|
favoutite_topic?: string
|
|
|
|
email_verified?: boolean
|
|
phone_verified?: boolean
|
|
status: string
|
|
|
|
profile_completed?: boolean
|
|
profile_picture_url?: string
|
|
preferred_language?: string
|
|
profile_completion_percentage?: number
|
|
|
|
created_at: string
|
|
updated_at?: string
|
|
/** Billing / plan state for list UI (e.g. "Unsubscribed", "Active"). */
|
|
subscription_status?: string
|
|
}
|
|
|
|
export interface GetUsersResponse {
|
|
status: string
|
|
message: string
|
|
data: {
|
|
total: number
|
|
users: UserApiDTO[]
|
|
}
|
|
timestamp: string
|
|
}
|
|
|
|
export interface User {
|
|
id: number
|
|
firstName: string
|
|
lastName: string
|
|
nickName: string
|
|
email: string
|
|
phoneNumber: string
|
|
role: string
|
|
region: string
|
|
country: string
|
|
lastLogin: string | null
|
|
status: string
|
|
/** From API `subscription_status` (e.g. "Unsubscribed"). */
|
|
subscriptionStatus: string
|
|
/** ISO 8601 from API `created_at`. */
|
|
createdAt: string
|
|
}
|
|
|
|
export const mapUserApiToUser = (u: UserApiDTO): User => ({
|
|
id: u.id,
|
|
firstName: u.first_name ?? "",
|
|
lastName: u.last_name ?? "",
|
|
nickName: u.nick_name ?? "",
|
|
email: u.email ?? "",
|
|
phoneNumber: u.phone_number ?? "",
|
|
role: u.role,
|
|
region: u.region ?? "",
|
|
country: u.country ?? "",
|
|
lastLogin: null,
|
|
status: u.status,
|
|
subscriptionStatus: u.subscription_status?.trim() ? u.subscription_status.trim() : "—",
|
|
createdAt: u.created_at ?? "",
|
|
})
|
|
|
|
/** GET /user/single/:id — single learner profile */
|
|
export interface UserProfileData {
|
|
id: number
|
|
first_name: string
|
|
last_name: string
|
|
gender: string
|
|
birth_day: string | null
|
|
email: string
|
|
role: string
|
|
age_group: string
|
|
education_level: string
|
|
country: string
|
|
region: string
|
|
nick_name: string
|
|
occupation: string
|
|
learning_goal: string
|
|
language_goal: string
|
|
language_challange: string
|
|
favoutite_topic: string
|
|
email_verified: boolean
|
|
phone_verified: boolean
|
|
status: string
|
|
last_login: string | null
|
|
profile_completed: boolean
|
|
profile_completion_percentage: number
|
|
profile_picture_url: string
|
|
preferred_language: string
|
|
created_at: string
|
|
subscription_status: string
|
|
}
|
|
|
|
export interface UserProfileResponse {
|
|
status: string
|
|
message: string
|
|
data: UserProfileData
|
|
timestamp: string
|
|
}
|
|
|
|
/** GET /admin/users/:user_id/recent-activity */
|
|
export interface UserRecentActivityItem {
|
|
id: string
|
|
kind: string
|
|
occurred_at: string
|
|
headline: string
|
|
}
|
|
|
|
export interface UserRecentActivityData {
|
|
user_id: number
|
|
items: UserRecentActivityItem[]
|
|
}
|
|
|
|
export interface UserRecentActivityResponse {
|
|
message: string
|
|
data: UserRecentActivityData
|
|
success: boolean
|
|
status_code: number
|
|
metadata: null
|
|
}
|
|
|
|
export interface UserSummary {
|
|
total_users: number
|
|
active_users: number
|
|
joined_this_month: number
|
|
}
|
|
|
|
export interface UserSummaryResponse {
|
|
message: string
|
|
data: UserSummary
|
|
success: boolean
|
|
status_code: number
|
|
}
|
|
|
|
export interface UpdateProfileRequest {
|
|
first_name?: string
|
|
last_name?: string
|
|
gender?: string
|
|
birth_day?: string
|
|
age_group?: string
|
|
education_level?: string
|
|
country?: string
|
|
region?: string
|
|
nick_name?: string
|
|
occupation?: string
|
|
learning_goal?: string
|
|
language_goal?: string
|
|
language_challange?: string
|
|
favoutite_topic?: string
|
|
profile_picture_url?: string
|
|
preferred_language?: string
|
|
}
|
|
|
|
export type DeletionUserStatus = "ACTIVE" | "PENDING" | "SUSPENDED" | "DEACTIVATED"
|
|
export type DeletionState = "PENDING" | "DUE" | "CANCELLED"
|
|
|
|
export interface DeletionRequestApiItem {
|
|
UserID?: number
|
|
FirstName?: string
|
|
LastName?: string
|
|
Email?: string
|
|
PhoneNumber?: string
|
|
Role?: string
|
|
Status?: DeletionUserStatus | string
|
|
DeletionRequestedAt?: string | null
|
|
DeletionScheduledAt?: string | null
|
|
DeletionCancelledAt?: string | null
|
|
DeletionState?: DeletionState | string
|
|
|
|
user_id?: number
|
|
first_name?: string
|
|
last_name?: string
|
|
email?: string
|
|
phone_number?: string
|
|
role?: string
|
|
status?: DeletionUserStatus | string
|
|
deletion_requested_at?: string | null
|
|
deletion_scheduled_at?: string | null
|
|
deletion_cancelled_at?: string | null
|
|
deletion_state?: DeletionState | string
|
|
}
|
|
|
|
export interface DeletionRequest {
|
|
user_id: number
|
|
first_name: string
|
|
last_name: string
|
|
email: string
|
|
phone_number: string
|
|
role: string
|
|
status: string
|
|
deletion_requested_at: string | null
|
|
deletion_scheduled_at: string | null
|
|
deletion_cancelled_at: string | null
|
|
deletion_state: string
|
|
}
|
|
|
|
export interface GetDeletionRequestsParams {
|
|
query?: string
|
|
role?: string
|
|
status?: DeletionUserStatus
|
|
state?: DeletionState
|
|
requested_before?: string
|
|
requested_after?: string
|
|
scheduled_before?: string
|
|
scheduled_after?: string
|
|
page?: number
|
|
page_size?: number
|
|
}
|
|
|
|
export interface GetDeletionRequestsResponse {
|
|
status: string
|
|
message: string
|
|
data: {
|
|
items: DeletionRequestApiItem[]
|
|
total: number
|
|
page: number
|
|
page_size: number
|
|
}
|
|
timestamp: string
|
|
}
|
|
|
|
export const mapDeletionRequestApiItem = (item: DeletionRequestApiItem): DeletionRequest => ({
|
|
user_id: item.user_id ?? item.UserID ?? 0,
|
|
first_name: item.first_name ?? item.FirstName ?? "",
|
|
last_name: item.last_name ?? item.LastName ?? "",
|
|
email: item.email ?? item.Email ?? "",
|
|
phone_number: item.phone_number ?? item.PhoneNumber ?? "",
|
|
role: item.role ?? item.Role ?? "",
|
|
status: item.status ?? item.Status ?? "",
|
|
deletion_requested_at: item.deletion_requested_at ?? item.DeletionRequestedAt ?? null,
|
|
deletion_scheduled_at: item.deletion_scheduled_at ?? item.DeletionScheduledAt ?? null,
|
|
deletion_cancelled_at: item.deletion_cancelled_at ?? item.DeletionCancelledAt ?? null,
|
|
deletion_state: item.deletion_state ?? item.DeletionState ?? "",
|
|
})
|