// TypeScript interfaces for the social module

export type FriendshipStatusValue = 'none' | 'pending' | 'accepted' | 'declined' | 'blocked' | 'self';

export interface FriendUser {
  id: string;
  email: string;
  name: string | null;
  role: string;
  createdAt: string;
}

export interface FriendListItem {
  friendshipId: number;
  acceptedAt: string | null;
  user: FriendUser;
}

export interface PendingReceivedItem {
  friendshipId: number;
  createdAt: string;
  from: FriendUser;
}

export interface PendingSentItem {
  friendshipId: number;
  createdAt: string;
  to: FriendUser;
}

export interface FriendshipStatusResponse {
  status: FriendshipStatusValue;
  friendshipId?: number;
  direction?: 'sent' | 'received';
}

export interface MutualFriendsResponse {
  count: number;
  users: FriendUser[];
}

export interface PrivacySettings {
  id: number;
  userId: string;
  showOnlineStatus: boolean | null;
  showCurrentlyWatching: boolean | null;
  showInFriendActivity: boolean | null;
  anonymizePublicComments: boolean | null;
  hidePublicReactions: boolean | null;
  hidePublicFinishes: boolean | null;
  allowFriendRequests: boolean | null;
  closeFriendsOnlyWatching: boolean | null;
}

export interface SocialNotification {
  id: number;
  userId: string;
  type: string;
  title: string;
  message: string;
  metadata: Record<string, unknown> | null;
  isRead: boolean;
  createdAt: string;
  readAt: string | null;
}

export interface NotificationPreferences {
  id: number;
  userId: string;
  enableFriendRequests: boolean;
  enableComments: boolean;
  enableUploadApprovals: boolean;
  enableAchievements: boolean;
  enableSystemUpdates: boolean;
  emailNotifications: boolean;
  digestFrequency: 'none' | 'daily' | 'weekly';
  lastDigestSentAt: string | null;
}

export interface SocialProfile {
  user: FriendUser;
  friendCount: number;
  stats: { shiftSignups: number; canvassVisits: number } | null;
  friendshipStatus: FriendshipStatusResponse;
  mutualFriends: MutualFriendsResponse;
}

export interface SocialProfileMe {
  user: FriendUser;
  stats: {
    friendCount: number;
    pendingReceived: number;
    shiftSignups: number;
    canvassVisits: number;
  };
  privacy: PrivacySettings | null;
}

export interface BlockedUser {
  blockId: number;
  blockedAt: string;
  user: { id: string; email: string; name: string | null };
}

// Poke types
export interface Poke {
  id: number;
  fromUserId: string;
  toUserId: string;
  isRead: boolean | null;
  createdAt: string;
  from: { id: string; name: string | null; email: string };
}

export interface PokeCooldown {
  onCooldown: boolean;
  ttlSeconds: number | null;
}

// Video Recommendation types
export interface VideoRecommendation {
  id: number;
  fromUserId: string;
  toUserId: string;
  mediaId: number;
  message: string | null;
  isRead: boolean | null;
  createdAt: string;
  from: { id: string; name: string | null; email: string };
  media: { id: number; title: string | null; filename: string; path?: string };
}

// Integration types
export interface FriendOnShift {
  id: string;
  name: string | null;
  email: string;
}

export interface FriendOnCampaign {
  id: string;
  name: string | null;
  email: string;
}

export interface FriendOnMap {
  id: string;
  name: string | null;
  email: string;
  cutName: string;
  cutId: number;
  startedAt: string;
}

// Group types
export interface SocialGroupSummary {
  id: string;
  name: string;
  type: 'SHIFT_TEAM' | 'CAMPAIGN_TEAM' | 'CUSTOM';
  referenceId: string | null;
  memberCount: number;
  joinedAt: string;
  hasActiveCall: boolean;
}

export interface SocialGroupDetail {
  id: string;
  name: string;
  type: 'SHIFT_TEAM' | 'CAMPAIGN_TEAM' | 'CUSTOM';
  referenceId: string | null;
  createdAt: string;
  memberCount: number;
  members: {
    id: string;
    userId: string;
    joinedAt: string;
    user: { id: string; name: string | null; email: string; role: string };
  }[];
  meeting: { id: string; slug: string; isActive: boolean } | null;
}

// Achievement types
export interface AchievementDef {
  id: string;
  name: string;
  description: string;
  icon: string;
  category: 'shifts' | 'canvass' | 'campaigns' | 'social';
  threshold: number;
}

export interface AchievementWithProgress extends AchievementDef {
  progress: number;
  unlocked: boolean;
  unlockedAt: string | null;
}

export interface VolunteerStats {
  shiftSignups: number;
  canvassSessions: number;
  canvassVisits: number;
  campaignEmails: number;
  campaignsParticipated: number;
  friendCount: number;
  groupCount: number;
}

export interface LeaderboardEntry {
  rank: number;
  userId: string;
  name: string | null;
  email: string;
  score: number;
}

export interface VideoRecommendationSent {
  id: number;
  fromUserId: string;
  toUserId: string;
  mediaId: number;
  message: string | null;
  isRead: boolean | null;
  createdAt: string;
  to: { id: string; name: string | null; email: string };
  media: { id: number; title: string | null; filename: string; path?: string };
}
