import {SourceProp} from '@user/types';

import {EventId, timestamp} from '@configs/types';

export type EventID = string;
export type EventType = 'event' | 'eventStore';

export enum EventThemes {
  default = 0,
  small = 1,
}

export interface BasicEventProp<T1> {
  source: SourceProp;
  url?: string;
  data?: T1;
}

export function createEventProp<T1>(
  source: SourceProp,
  data?: T1,
  url?: string,
): BasicEventProp<T1> {
  return {source, data, url};
}

export type EventBannerPictureType = BasicEventProp<Blob | undefined>;

export interface EventBannerPicture {
  lq: EventBannerPictureType; //low quality
  hq?: EventBannerPictureType; //high quality
}

export interface PAEvent {
  UUID: EventId;
  Name: BasicEventProp<string>;
  Description: BasicEventProp<string>;
  StartDate: BasicEventProp<timestamp>;
  EndDate: BasicEventProp<timestamp>;
  Latitude: BasicEventProp<number>;
  Longitude: BasicEventProp<number>;
  Type: BasicEventProp<EventType>;
  Theme: BasicEventProp<EventThemes>;
  lastUpdateTimestamp: timestamp;
  FriendList: BasicEventProp<string[]>;
  UserLength: BasicEventProp<number>;
  EventBannerPicture: EventBannerPicture;
  ButtonAction: BasicEventProp<string>;
  //isJoined
  //minAge
  //AddressText
}

export function NumToEventType(num: number): EventType {
  switch (num) {
    case 0:
      return 'event';
    case 1:
      return 'eventStore';
    default:
      return 'event';
  }
}

export function EventTypeToNum(type: EventType): number {
  switch (type) {
    case 'event':
      return 0;
    case 'eventStore':
      return 1;
    default:
      return 0;
  }
}
