Files
guilan-ace-frontend/src/lib/types.ts

955 lines
22 KiB
TypeScript

// API Response Types based on Swagger schema
export interface MessageSchema {
message: string;
}
export interface ErrorSchema {
detail: string;
}
// Auth Types
export interface TokenSchema {
access_token: string;
refresh_token: string;
token_type?: string;
}
export interface MajorOption {
code: string;
label: string;
id?: number;
name?: string;
user_count?: number;
}
export interface MetaOptionSchema {
id: number;
code: string;
name: string;
label: string;
user_count?: number;
}
export interface PagedMetaOptionSchema {
count: number;
results: MetaOptionSchema[];
}
export interface MetaOptionWriteSchema {
code: string;
name: string;
}
export interface UserProfileSchema {
id: number;
email?: string | null;
mobile?: string | null;
username: string;
first_name: string;
last_name: string;
profile_picture?: string;
profile_picture_thumbnail_url?: string | null;
profile_picture_preview_url?: string | null;
bio?: string;
student_id?: string | null;
year_of_study?: number;
university?: string;
major?: string;
date_joined: string;
is_email_verified?: boolean;
is_mobile_verified?: boolean;
requires_mobile_verification?: boolean;
has_google_link?: boolean;
is_active?: boolean;
is_staff?: boolean;
is_superuser?: boolean;
is_committee?: boolean;
is_deleted?: boolean;
deleted_at?: string | null;
can_access_blog_admin?: boolean;
can_write_blog_posts?: boolean;
can_review_blog_posts?: boolean;
}
export interface UserListSchema {
id: number;
username: string;
email?: string | null;
mobile?: string | null;
first_name: string;
last_name: string;
full_name?: string | null;
university?: string | null;
major?: string | null;
profile_picture?: string | null;
profile_picture_thumbnail_url?: string | null;
profile_picture_preview_url?: string | null;
student_id?: string | null;
year_of_study?: number | null;
bio?: string | null;
is_email_verified?: boolean;
is_mobile_verified?: boolean;
is_deleted?: boolean;
deleted_at?: string | null;
can_access_blog_admin?: boolean;
can_write_blog_posts?: boolean;
can_review_blog_posts?: boolean;
is_active: boolean;
is_staff: boolean;
is_superuser: boolean;
date_joined: string;
}
export interface AuthorizationRoleSchema {
key: string;
label: string;
description: string;
enabled: boolean;
locked: boolean;
}
export interface UserAuthorizationSchema {
id: number;
username: string;
email?: string | null;
mobile?: string | null;
first_name: string;
last_name: string;
is_active: boolean;
is_staff: boolean;
is_superuser: boolean;
groups: string[];
roles: AuthorizationRoleSchema[];
}
export interface UserAuthorizationUpdateSchema {
is_staff: boolean;
groups: string[];
}
export interface UserRegistrationSchema {
mobile: string;
code: string;
password: string;
username: string;
email?: string | null;
first_name?: string | null;
last_name?: string | null;
student_id?: string | null;
year_of_study?: number | null;
major?: string | null;
university?: string | null;
}
export type UserUpdateSchema = {
email?: string | null;
first_name?: string | null;
last_name?: string | null;
bio?: string | null;
year_of_study?: number | null;
major?: string | null;
university?: string | null;
student_id?: string | null;
};
export interface UserLoginSchema {
identifier: string;
password: string;
}
export interface UserOtpLoginSchema {
mobile: string;
code: string;
}
export interface RegisterOtpVerifySchema {
mobile: string;
code: string;
}
export interface OtpSendSchema {
mobile: string;
mode: "register" | "login" | "reset_password" | "verify_mobile" | "google_claim";
}
export interface OtpSendResponseSchema {
message: string;
expires_in_seconds: number;
expires_at: string;
}
export interface TokenRefreshIn {
refresh_token: string;
}
export interface UsernameCheckSchema {
exists: boolean;
}
export interface MobileLookupSchema {
exists: boolean;
has_password: boolean;
}
export interface PasswordResetSchema {
mobile: string;
code: string;
new_password: string;
}
export interface MobileOtpSendSchema {
mobile: string;
}
export interface MobileOtpVerifySchema {
mobile: string;
code: string;
}
export interface GoogleFlowResponseSchema {
status: "authenticated" | "collect_profile" | "claim_required" | "error";
email?: string | null;
first_name?: string | null;
last_name?: string | null;
avatar_url?: string | null;
resolution?: "new_account" | "existing_email_claim" | "existing_mobile_claim" | null;
mobile?: string | null;
mobile_hint?: string | null;
detail?: string | null;
access_token?: string | null;
refresh_token?: string | null;
}
export interface GoogleCompleteSchema {
flow: string;
mobile: string;
username?: string | null;
student_id?: string | null;
year_of_study?: number | null;
major?: string | null;
university?: string | null;
first_name?: string | null;
last_name?: string | null;
}
export interface NotificationSchema {
id: string;
type: string;
title: string;
message: string;
level: "info" | "success" | "warning" | "error";
created_at: string;
is_seen: boolean;
delete_on_seen: boolean;
action_url?: string | null;
entity_type?: string | null;
entity_id?: string | number | null;
meta?: Record<string, unknown>;
}
export interface NotificationListSchema {
count: number;
unread_count: number;
notifications: NotificationSchema[];
}
export interface NotificationSeenResponseSchema {
marked_read: boolean;
notification_id?: string | null;
deleted?: boolean;
notification?: NotificationSchema | null;
unread_count?: number | null;
}
export interface NotificationDeleteResponseSchema {
deleted: boolean;
notification_id?: string | null;
unread_count?: number | null;
}
export interface NotificationStreamTokenResponseSchema {
token: string;
expires_in: number;
}
// Blog Types
export interface PostListSchema {
id: number;
title: string;
slug: string;
excerpt?: string;
featured_image?: string;
absolute_featured_image_url?: string | null;
absolute_featured_image_thumbnail_url?: string | null;
absolute_featured_image_preview_url?: string | null;
author: {
id: number;
username: string;
first_name: string;
last_name: string;
bio?: string | null;
profile_picture?: string;
profile_picture_thumbnail_url?: string | null;
profile_picture_preview_url?: string | null;
};
category?: {
id: number;
name: string;
slug: string;
description?: string;
parent_id?: number | null;
};
category_path?: Array<{
id: number;
name: string;
slug: string;
}>;
writers?: Array<{
id: number;
username: string;
first_name: string;
last_name: string;
bio?: string | null;
profile_picture?: string;
profile_picture_thumbnail_url?: string | null;
profile_picture_preview_url?: string | null;
}>;
tags: Array<{
id: number;
name: string;
slug: string;
}>;
status: string;
published_at?: string;
created_at: string;
is_featured: boolean;
reading_time?: number;
updated_at: string;
seo_title?: string;
seo_description?: string;
canonical_url?: string;
og_title?: string;
og_description?: string;
noindex?: boolean;
focus_keyword?: string;
likes_count?: number;
saves_count?: number;
comments_count?: number;
}
export interface PostDetailSchema extends PostListSchema {
content: string;
content_html?: string;
review_note?: string;
og_image_url?: string | null;
views_count?: number;
assets?: PostAssetSchema[];
}
export interface PostCreateSchema {
title: string;
content: string;
excerpt?: string;
category_id?: number | null;
tag_ids?: number[];
writer_ids?: number[];
is_featured?: boolean;
status?: 'draft' | 'submitted' | 'changes_requested' | 'published' | 'archived';
seo_title?: string;
seo_description?: string;
canonical_url?: string;
og_title?: string;
og_description?: string;
noindex?: boolean;
focus_keyword?: string;
}
export interface PostReviewSchema {
action: 'publish' | 'approve' | 'request_changes' | 'changes_requested' | 'archive';
note?: string;
}
export interface PostAssetSchema {
id: number;
file_type: 'image' | 'video' | 'document' | 'archive' | 'other';
title: string;
alt_text?: string;
caption?: string;
size: number;
mime_type?: string;
created_at: string;
absolute_file_url?: string | null;
absolute_thumbnail_url?: string | null;
absolute_preview_url?: string | null;
absolute_blur_url?: string | null;
markdown_image?: string | null;
markdown_link?: string | null;
uploaded_by: {
id: number;
username: string;
first_name: string;
last_name: string;
};
}
export interface CommentSchema {
id: number;
content: string;
author: {
id: number;
username: string;
first_name: string;
last_name: string;
bio?: string | null;
profile_picture?: string | null;
profile_picture_thumbnail_url?: string | null;
profile_picture_preview_url?: string | null;
};
post_id: number;
post_title: string;
post_slug: string;
parent_id?: number;
created_at: string;
updated_at?: string;
is_approved: boolean;
is_hidden?: boolean;
is_deleted?: boolean;
hidden_at?: string | null;
deleted_at?: string | null;
hidden_replies_count?: number;
replies?: CommentSchema[];
}
export interface CommentCreateSchema {
content: string;
parent_id?: number;
}
export interface CommentUpdateSchema {
content: string;
}
export interface BlogBannerSchema {
id: number;
title?: string;
alt_text?: string;
image_url: string;
url: string;
sort_order: number;
}
export interface BlogInteractionSchema {
liked: boolean;
saved: boolean;
likes_count: number;
saves_count: number;
comments_count: number;
}
export interface BlogProfileActivitySchema {
liked_posts: PostListSchema[];
saved_posts: PostListSchema[];
comments: CommentSchema[];
replies: CommentSchema[];
}
export interface CategorySchema {
id: number;
name: string;
slug: string;
description?: string;
parent_id?: number | null;
created_at: string;
}
export interface AdminCategorySchema extends CategorySchema {
post_count: number;
}
export interface CategoryWriteSchema {
name: string;
slug?: string | null;
description?: string | null;
parent_id?: number | null;
}
export interface TagSchema {
id: number;
name: string;
slug: string;
created_at: string;
}
export interface AdminTagSchema extends TagSchema {
post_count: number;
}
export interface TagWriteSchema {
name: string;
slug?: string | null;
}
export interface BlogFilterCategory {
id: number;
name: string;
slug: string;
parent_id?: number | null;
post_count: number;
children: BlogFilterCategory[];
}
export interface BlogFilterTag {
id: number;
name: string;
slug: string;
post_count: number;
}
export interface BlogFilterAuthor {
id: number;
username: string;
first_name: string;
last_name: string;
post_count: number;
}
export interface BlogFiltersSchema {
categories: BlogFilterCategory[];
tags: BlogFilterTag[];
authors: BlogFilterAuthor[];
}
// Events Types
export interface EventListItemSchema {
id: number;
title: string;
slug: string;
description: string;
featured_image?: string | null;
absolute_featured_image_url?: string | null;
absolute_featured_image_thumbnail_url?: string | null;
absolute_featured_image_preview_url?: string | null;
event_type: 'online' | 'on_site' | 'hybrid';
address?: string | null;
location?: string | null;
online_link?: string | null;
start_time: string; // ISO
end_time: string; // ISO
registration_start_date?: string | null;
registration_end_date?: string | null;
capacity?: number | null;
price?: number | null;
status: 'draft' | 'published' | 'cancelled' | 'completed';
status_label?: string;
event_type_label?: string;
registration_count: number;
created_at: string;
}
export interface EventGalleryItem {
id: number;
title: string;
description: string;
absolute_image_url?: string | null;
absolute_image_preview_url?: string | null;
absolute_image_blur_url?: string | null;
width?: number;
height?: number;
file_size_mb?: number;
markdown_url?: string;
image?: string;
alt_text?: string | null;
is_public?: boolean;
created_at?: string;
}
export interface EventDetailSchema extends EventListItemSchema {
description_html: string;
gallery_images: EventGalleryItem[];
updated_at: string;
registration_success_markdown: string;
}
export interface EventCreateSchema {
title: string;
description: string;
slug?: string | null;
event_type: 'online' | 'on_site' | 'hybrid';
address?: string | null;
location?: string | null;
online_link?: string | null;
start_time: string;
end_time: string;
registration_start_date?: string | null;
registration_end_date?: string | null;
capacity?: number | null;
price?: number | null;
status?: 'draft' | 'published' | 'cancelled' | 'completed';
registration_success_markdown?: string | null;
gallery_image_ids?: number[] | null;
}
export interface PaymentAdminSchema {
id: number;
authority?: string | null;
ref_id?: string | null;
card_pan?: string | null;
card_hash?: string | null;
status: number;
status_label: string;
base_amount: number;
discount_amount: number;
amount: number;
verified_at?: string | null;
created_at: string;
discount_code?: string | null;
}
export interface RegistrationAdminSchema {
id: number;
ticket_id: string;
status: 'pending' | 'confirmed' | 'cancelled' | 'attended';
status_label: string;
registered_at: string;
final_price?: number | null;
discount_amount?: number | null;
user: {
id: number;
username: string;
first_name: string;
last_name: string;
email: string;
mobile?: string | null;
profile_picture?: string | null;
profile_picture_thumbnail_url?: string | null;
profile_picture_preview_url?: string | null;
university?: string | null;
major?: string | null;
student_id?: string | null;
year_of_study?: number | null;
};
payments: PaymentAdminSchema[];
}
export interface EventAdminDetailSchema extends EventDetailSchema {
registrations: RegistrationAdminSchema[];
}
export interface EventUpdateSchema {
title?: string;
slug?: string | null;
description?: string;
event_type?: 'online' | 'on_site' | 'hybrid';
address?: string | null;
location?: string | null;
online_link?: string | null;
start_time?: string;
end_time?: string | null;
registration_start_date?: string | null;
registration_end_date?: string | null;
capacity?: number | null;
price?: number | null;
status?: 'draft' | 'published' | 'cancelled' | 'completed';
registration_success_markdown?: string | null;
gallery_image_ids?: number[] | null;
}
export interface DiscountCodeSchema {
id: number;
code: string;
type: 'percent' | 'fixed';
value: number;
max_discount?: number | null;
is_active: boolean;
starts_at?: string | null;
ends_at?: string | null;
usage_limit_total?: number | null;
usage_limit_per_user?: number | null;
min_amount?: number | null;
applicable_event_ids: number[];
usage_count: number;
created_at: string;
updated_at: string;
}
export interface PagedDiscountCodeSchema {
count: number;
results: DiscountCodeSchema[];
}
export interface DiscountCodeWriteSchema {
code: string;
type: 'percent' | 'fixed';
value: number;
max_discount?: number | null;
is_active?: boolean;
starts_at?: string | null;
ends_at?: string | null;
usage_limit_total?: number | null;
usage_limit_per_user?: number | null;
min_amount?: number | null;
applicable_event_ids?: number[];
}
export interface EventRegistrationSchema {
id: number;
status: 'pending' | 'confirmed' | 'cancelled' | 'attended';
ticket_id: string;
registered_at: string;
created_at: string;
updated_at: string;
user: {
id: number;
username: string;
first_name: string;
last_name: string;
};
event_id: number;
}
export interface RegistrationStatusSchema {
is_registered: boolean;
}
export interface MyEventRegistrationSchema {
id: number;
created_at: string;
status: 'pending' | 'confirmed' | 'cancelled' | 'attended';
event: EventListItemSchema;
}
// Gallery Types
export interface GalleryImageSchema {
id: number;
title: string;
description?: string;
image: string;
absolute_image_url?: string | null;
absolute_image_preview_url?: string | null;
absolute_image_blur_url?: string | null;
width?: number | null;
height?: number | null;
uploaded_by: {
id: number;
username: string;
};
created_at: string;
tags: TagSchema[];
}
export interface GalleryImageCreateSchema {
title: string;
description?: string;
tag_ids?: number[];
}
// Pagination
export interface PaginatedResponse<T> {
results: T[];
count: number;
next?: string;
previous?: string;
}
// Admin analytics
export interface AnalyticsPointSchema {
label: string;
value: number;
}
export interface AnalyticsPointGroupSchema {
items: AnalyticsPointSchema[];
top_items: AnalyticsPointSchema[];
other_count: number;
total_count: number;
}
export interface AnalyticsTrendPointSchema {
date: string;
label: string;
value: number;
}
export interface AnalyticsRegistrationStatusSchema {
status: string;
label: string;
value: number;
}
export interface AnalyticsTopEventSchema {
id: number;
title: string;
slug: string;
attendees: number;
capacity?: number | null;
fill_rate?: number | null;
revenue: number;
}
export interface AnalyticsPostPopularitySchema {
id: number;
title: string;
slug: string;
likes: number;
saves: number;
comments: number;
}
export interface AnalyticsPostPopularityGroupSchema {
items: AnalyticsPostPopularitySchema[];
top_items: AnalyticsPostPopularitySchema[];
other_count: number;
total_count: number;
}
export interface AnalyticsTopPostSchema extends AnalyticsPostPopularitySchema {
score: number;
}
export interface AdminDashboardAnalyticsSchema {
filters: {
date_from?: string | null;
date_to?: string | null;
event_id?: number | null;
granularity: 'day' | 'week' | 'month';
};
summary: {
total_users: number;
verified_users: number;
total_events: number;
total_registrations: number;
total_revenue: number;
total_discount: number;
published_posts: number;
total_likes: number;
total_saves: number;
total_comments: number;
};
users: {
signup_trend: AnalyticsTrendPointSchema[];
by_major: AnalyticsPointSchema[];
by_university: AnalyticsPointSchema[];
by_year: AnalyticsPointSchema[];
};
events: {
registration_status: AnalyticsRegistrationStatusSchema[];
by_major: AnalyticsPointSchema[];
by_university: AnalyticsPointSchema[];
top_events: AnalyticsTopEventSchema[];
registration_trend: AnalyticsTrendPointSchema[];
};
revenue: {
trend: AnalyticsTrendPointSchema[];
by_event: AnalyticsPointSchema[];
payment_status: AnalyticsRegistrationStatusSchema[];
total_paid: number;
total_discount: number;
total_base: number;
};
blog: {
totals: {
posts: number;
likes: number;
saves: number;
comments: number;
};
post_popularity: AnalyticsPostPopularitySchema[];
top_posts: AnalyticsTopPostSchema[];
activity_trend: Array<{ date: string; likes: number; saves: number; comments: number }>;
by_category: AnalyticsPointSchema[];
by_tag: AnalyticsPointSchema[];
};
achievements: {
distinct_participants: number;
learning_hours: number;
published_content: number;
community_engagement: number;
};
}
export interface AnalyticsEventOptionsSchema {
count: number;
results: Array<{
value: string;
label: string;
description?: string | null;
}>;
}
export interface UserAnalyticsSchema {
filters: {
date_from?: string | null;
date_to?: string | null;
granularity: 'day' | 'week' | 'month';
};
summary: {
total_users: number;
verified_users: number;
unverified_users: number;
profile_completion_rate: number;
};
signup_trend: AnalyticsTrendPointSchema[];
by_major: AnalyticsPointGroupSchema;
by_university: AnalyticsPointGroupSchema;
by_year: AnalyticsPointGroupSchema;
}
export interface EventAnalyticsSchema {
filters: {
date_from?: string | null;
date_to?: string | null;
event_id?: number | null;
};
summary: {
total_events: number;
total_registrations: number;
distinct_participants: number;
total_revenue: number;
total_discount: number;
total_base: number;
learning_hours: number;
};
registration_status: AnalyticsRegistrationStatusSchema[];
payment_status: AnalyticsRegistrationStatusSchema[];
attendee_by_major: AnalyticsPointGroupSchema;
attendee_by_university: AnalyticsPointGroupSchema;
registration_trend: AnalyticsTrendPointSchema[];
revenue_trend: AnalyticsTrendPointSchema[];
revenue_by_event: AnalyticsPointGroupSchema;
top_events: {
top_items: AnalyticsTopEventSchema[];
other_count: number;
total_count: number;
};
}
export interface BlogAnalyticsSchema {
filters: {
date_from?: string | null;
date_to?: string | null;
};
summary: {
published_posts: number;
total_likes: number;
total_saves: number;
total_comments: number;
community_engagement: number;
};
activity_trend: Array<{ date: string; likes: number; saves: number; comments: number }>;
post_popularity: AnalyticsPostPopularityGroupSchema;
top_posts: AnalyticsTopPostSchema[];
by_category: AnalyticsPointGroupSchema;
by_tag: AnalyticsPointGroupSchema;
}
// payment
export interface CreatePaymentOut {
start_pay_url: string;
authority: string;
base_amount: number;
discount_amount: number;
amount: number;
}