package response

import (
	articleCategoriesResponse "netidhub-saas-be/app/module/article_categories/response"
	articleFilesResponse "netidhub-saas-be/app/module/article_files/response"
	"time"
)

type ArticlesResponse struct {
	ID              uint       `json:"id"`
	Title           string     `json:"title"`
	Slug            string     `json:"slug"`
	Description     string     `json:"description"`
	HtmlDescription string     `json:"htmlDescription"`
	CategoryId      int        `json:"categoryId"`
	CategoryName    string     `json:"categoryName"`
	TypeId          int        `json:"typeId"`
	Tags            string     `json:"tags"`
	ThumbnailUrl    string     `json:"thumbnailUrl"`
	PageUrl         *string    `json:"pageUrl"`
	CreatedById     *uint      `json:"createdById"`
	CreatedByName   *string    `json:"createdByName"`
	ShareCount      *int       `json:"shareCount"`
	ViewCount       *int       `json:"viewCount"`
	CommentCount    *int       `json:"commentCount"`
	AiArticleId     *int       `json:"aiArticleId"`
	OldId           *uint      `json:"oldId"`
	StatusId        *int       `json:"statusId"`
	IsBanner        *bool      `json:"isBanner"`
	IsPublish       *bool      `json:"isPublish"`
	PublishedAt     *time.Time `json:"publishedAt"`
	IsActive        *bool      `json:"isActive"`
	CreatedAt       time.Time  `json:"createdAt"`
	UpdatedAt       time.Time  `json:"updatedAt"`

	ArticleFiles      []*articleFilesResponse.ArticleFilesResponse           `json:"files"`
	ArticleCategories []*articleCategoriesResponse.ArticleCategoriesResponse `json:"categories"`
}

type ArticleSummaryStats struct {
	TotalToday    int `json:"totalToday"`
	TotalThisWeek int `json:"totalThisWeek"`
	TotalAll      int `json:"totalAll"`
	TotalViews    int `json:"totalViews"`
	TotalShares   int `json:"totalShares"`
	TotalComments int `json:"totalComments"`
}

type ArticlePerUserLevelStats struct {
	UserLevelID   uint   `json:"userLevelId"`
	UserLevelName string `json:"userLevelName"`
	TotalArticle  int64  `json:"totalArticle"`
}

type ArticleMonthlyStats struct {
	Year    int   `json:"year"`
	Month   int   `json:"month"`
	View    []int `json:"view"`
	Comment []int `json:"comment"`
	Share   []int `json:"share"`
}

// ArticleApprovalStatusResponse represents the approval status of an article
type ArticleApprovalStatusResponse struct {
	ArticleId       uint       `json:"articleId"`
	WorkflowId      *uint      `json:"workflowId"`
	WorkflowName    *string    `json:"workflowName"`
	CurrentStep     int        `json:"currentStep"`
	TotalSteps      int        `json:"totalSteps"`
	Status          string     `json:"status"` // "pending", "in_progress", "approved", "rejected", "revision_requested"
	CurrentApprover *string    `json:"currentApprover"`
	SubmittedAt     *time.Time `json:"submittedAt"`
	LastActionAt    *time.Time `json:"lastActionAt"`
	Progress        float64    `json:"progress"`   // percentage complete
	CanApprove      bool       `json:"canApprove"` // whether current user can approve
	NextStep        *string    `json:"nextStep"`
}

// ArticleApprovalQueueResponse represents an article in the approval queue
type ArticleApprovalQueueResponse struct {
	ID            uint      `json:"id"`
	Title         string    `json:"title"`
	Slug          string    `json:"slug"`
	Description   string    `json:"description"`
	CategoryName  string    `json:"categoryName"`
	AuthorName    string    `json:"authorName"`
	SubmittedAt   time.Time `json:"submittedAt"`
	CurrentStep   int       `json:"currentStep"`
	TotalSteps    int       `json:"totalSteps"`
	Priority      string    `json:"priority"` // "low", "medium", "high", "urgent"
	DaysInQueue   int       `json:"daysInQueue"`
	WorkflowName  string    `json:"workflowName"`
	CanApprove    bool      `json:"canApprove"`
	EstimatedTime string    `json:"estimatedTime"` // estimated time to complete approval
}

// ClientApprovalSettingsResponse represents client-level approval settings
type ClientApprovalSettingsResponse struct {
	ClientId                 string    `json:"clientId"`
	RequiresApproval         bool      `json:"requiresApproval"`
	DefaultWorkflowId        *uint     `json:"defaultWorkflowId"`
	DefaultWorkflowName      *string   `json:"defaultWorkflowName"`
	AutoPublishArticles      bool      `json:"autoPublishArticles"`
	ApprovalExemptUsers      []uint    `json:"approvalExemptUsers"`
	ApprovalExemptRoles      []uint    `json:"approvalExemptRoles"`
	ApprovalExemptCategories []uint    `json:"approvalExemptCategories"`
	RequireApprovalFor       []string  `json:"requireApprovalFor"`
	SkipApprovalFor          []string  `json:"skipApprovalFor"`
	IsActive                 bool      `json:"isActive"`
	CreatedAt                time.Time `json:"createdAt"`
	UpdatedAt                time.Time `json:"updatedAt"`
}
