from pydantic import BaseModel
from datetime import datetime
from typing import Optional, Dict, Any
from enum import Enum


class ActivityType(str, Enum):
    TASK_CREATED = "task_created"
    TASK_UPDATED = "task_updated"
    TASK_ASSIGNED = "task_assigned"
    TASK_STATUS_CHANGED = "task_status_changed"
    SUBMISSION_CREATED = "submission_created"
    SUBMISSION_REVIEWED = "submission_reviewed"
    COMMENT_ADDED = "comment_added"
    ASSET_CREATED = "asset_created"
    ASSET_UPDATED = "asset_updated"
    SHOT_CREATED = "shot_created"
    SHOT_UPDATED = "shot_updated"
    PROJECT_CREATED = "project_created"
    PROJECT_UPDATED = "project_updated"
    USER_JOINED_PROJECT = "user_joined_project"
    SHOT_DELETED = "shot_deleted"
    ASSET_DELETED = "asset_deleted"
    SHOT_RECOVERED = "shot_recovered"
    ASSET_RECOVERED = "asset_recovered"


class ActivityBase(BaseModel):
    type: ActivityType
    description: str
    activity_metadata: Optional[Dict[str, Any]] = None


class ActivityCreate(ActivityBase):
    user_id: int
    project_id: Optional[int] = None
    task_id: Optional[int] = None
    asset_id: Optional[int] = None
    shot_id: Optional[int] = None
    submission_id: Optional[int] = None


class UserInfo(BaseModel):
    id: int
    first_name: str
    last_name: str
    email: str

    class Config:
        from_attributes = True


class ActivityResponse(ActivityBase):
    id: int
    user_id: int
    user: UserInfo
    project_id: Optional[int] = None
    task_id: Optional[int] = None
    asset_id: Optional[int] = None
    shot_id: Optional[int] = None
    submission_id: Optional[int] = None
    created_at: datetime

    class Config:
        from_attributes = True
