import { type FileCardType } from '@material-hu/components/design-system/FileCard/types';

import { type User } from 'src/types/user';

import { type Links } from './actionLinks';
import { type Group } from './groups';
import { type Post } from './posts';

export enum InvitationStatus {
  PENDING = 'PENDING',
  ACCEPTED = 'ACCEPTED',
  DECLINED = 'DECLINED',
  MAY_ASSIST = 'MAY_ASSIST',
}

export enum EventTimeRange {
  PAST = 'PAST',
  UPCOMING = 'UPCOMING',
  ALL = 'ALL',
}

export enum EventFeedPublishPolicy {
  ALL_INVITES = 'all',
  ONLY_ORGANIZERS = 'organizers',
}

export type Event = {
  id: number;
  name: string;
  invitationStatus: InvitationStatus;
  startDateTime: string;
  endDateTime: string | null;
  coverPictureUrl: string | null;
  description: string;
  liveStream: boolean;
  location: string | null;
  videoCallUrl: string | null;
  userId: number;
  user: User;
  groupId?: number;
  group?: Group;
  maxInvitedUsers: number | null;
  remainingSpace?: number;
  imagePreview?: ImagePreview;
  feedPublishPolicy?: EventFeedPublishPolicy;
  _links: Links & { invitations: Links };
};

export type EventUsersStats = {
  accepted: number;
  pending: number;
  declined: number;
  mayAssist: number;
  total: number;
};

export enum EventType {
  IN_PERSON_AND_ONLINE = 'in-person-and-online',
  IN_PERSON = 'in-person',
}

export enum EventTabs {
  INVITATIONS_TAB = 'INVITATIONS',
  MY_EVENTS_TAB = 'MY_EVENTS',
  ORGANIZED_BY_ME_TAB = 'ORGANIZED_BY_ME',
  PAST_EVENTS_TAB = 'PAST_EVENTS',
  DIRECT_LINK = 'DIRECT_LINK',
}

export type EventInvitation = {
  id?: number;
  userIds?: number[];
  selectAllUsers: boolean;
  excludedUserIds?: number[];
  segmentationItemIds?: number[];
};

export type EventPostType = Post & {
  media?: any[];
  files?: any[];
  eventId?: number;
  commentsEnabled?: boolean;
  _links: Links;
};

export enum Steps {
  DETAILS,
  LOCATION,
  VISIBILITY,
}

export enum ResponseFrom {
  EVENT_DETAIL = 'EVENT_DETAIL',
  INVITES_TAB = 'INVITES',
}

export type SegmentationItemsSelected = {
  [segmentationId: number]: number[];
};

export type ImagePreview = FileCardType & {
  url: string;
};

export enum EventOrganizerRole {
  ORGANIZER = 'organizer',
  CO_ORGANIZER = 'co-organizer',
}

export enum EventOrganizerStatus {
  PENDING = 'pending',
  ACCEPTED = 'accepted',
  REJECTED = 'rejected',
}

export type EventOrganizer = {
  id: string;
  userId: number;
  firstName: string;
  lastName: string;
  profilePicture: string;
  role: EventOrganizerRole;
  status: EventOrganizerStatus;
};

export type InvitableEventOrganizer = {
  user: User;
  organizer: EventOrganizer | null;
};

export enum EventActions {
  EDIT = 'edit',
  DELETE = 'delete',
  INVITATIONS = 'invitations',
  CREATE = 'create',
}

export type EventInvitationUser = User & {
  organizerRole: EventOrganizerRole | null;
};
