Files
guilan-ace-frontend/src/lib/types.ts
Amirhossein Khalili 053b742f89
Some checks failed
Frontend CI/CD / build (push) Has been cancelled
Frontend CI/CD / deploy (push) Has been cancelled
feat(blog): show review feedback in admin
2026-06-13 00:00:40 +03:30

668 lines
14 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;
}
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;
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;
}
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;
start_date: string;
end_date?: string;
location: string;
capacity?: number;
event_image?: string;
requirements?: string;
is_registration_open?: boolean;
}
export interface PaymentAdminSchema {
id: number;
authority?: string | null;
ref_id?: 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;
};
payments: PaymentAdminSchema[];
}
export interface EventAdminDetailSchema extends EventDetailSchema {
registrations: RegistrationAdminSchema[];
}
export interface EventUpdateSchema {
title?: string;
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';
gallery_image_ids?: number[] | null;
}
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;
}
// payment
export interface CreatePaymentOut {
start_pay_url: string;
authority: string;
base_amount: number;
discount_amount: number;
amount: number;
}