import { TAuthor } from "./Author";
import { defaultImageUrls, TImage, TImageUrls } from "./Image";
import { defaultSEO, TSEO } from "./Seo";

export interface TArticleProps {
    article: TArticle;
    author: TAuthor;
    related: TArticle[];
    article_categories: TArticleCategory[];
    next_article: TNextPrevArticle;
    prev_article: TNextPrevArticle;
}

export interface TArticle {
    id: number;
    name: string;
    slug: string;
    article_category_id: number;
    author_id: number;
    author?: TAuthor;
    content: TContent[];
    published_at: string;
    created_at: string;
    updated_at: string;
    article_category: TArticleCategory;
    seo?: TSEO;
}

export interface TArticleCategory {
    id: number;
    name: string;
    slug: string;
    created_at: string;
    updated_at: string;
    articles_count?: number;
}
export interface TContent {
    type: string;
    data: TContentData;
}
export interface TContentData extends TImage {
    content: string;
}

export interface TNextPrevArticle {
    id: number;
    name: string;
    slug: string;
}

export const defaultArticle: TArticle = {
    id: 0,
    name: "",
    slug: "",
    article_category_id: 0,
    author_id: 0,
    content: [
        {
            type: "",
            data: {
                image: 0,
                content: "",
                urls: defaultImageUrls,
                image_preview: "",
                alt_text: "",
            },
        },
    ],
    published_at: "",
    created_at: "",
    updated_at: "",
    article_category: {
        id: 0,
        name: "",
        slug: "",
        created_at: "",
        updated_at: "",
    },
    seo: defaultSEO,
};

export interface TResponse {
    meta: {
        code: number;
        status: string;
        message: string | null;
    };
    data: {
        current_page: 1;
        data: TArticle[];
        first_page_url: string | null;
        from: number;
        last_page: number;
        last_page_url: string | null;
        links: {
            url: string | null;
            label: string;
            active: boolean;
        }[];
        next_page_url: string | null;
        path: string;
        per_page: number;
        prev_page_url: string | null;
        to: number;
        total: number;
    };
}

export interface TPagination {
    total: number;
    current_page: number;
    last_page: number;
    per_page: number;
    first_page_url: string | null;
    next_page_url: string | null;
    prev_page_url: string | null;
    last_page_url: string | null;
}

export interface TParams {
    pageParam: number;
    searchParam: string;
    categoryParam: string;
}

export interface TFilters {
    page: number;
    search: string;
    category: string;
}

export interface TTocItem {
    id: string;
    level: number;
    text: string | null;
}
