/* Types */

// User Table in DB
export type User = {
  id: number;
  appleId: string | null;
  email: string;
  fullName: string;
  pfpUrl: string | null;
  pushToken: string;
  createdAt: Date;
  metadata?: Record<string, string>;
};
// Relationship Table in DB
export type Relationship = {
  id: number;
  title: string;
  requestorId: number;
  isAccepted: boolean;
  relationshipStartDate: Date;
};
export type UserRelationship = {
  id: number;
  userId: number;
  relationshipId: number;
};
// Mutated Data from Relationship
// & UserRelationship Tables in DB
export type RelationshipData = {
  relationship: Relationship;
  partner: User;
};
// Countdown Table in DB
export type Countdown = {
  id: number;
  relationshipId: number;
  title: string;
  date: Date;
  createdAt: Date;
};
// Mutated Data for Login
// API Response
export type InitialData = {
  user: User;
  relationshipData?: RelationshipData;
  countdown?: Countdown;
};
// Message Table in DB
export type Message = {
  id: number;
  senderId: number;
  receiverId: number;
  text: string;
  createdAt: Date;
  isRead: boolean;
  hasLocation: boolean;
  hasMedia: boolean;
  hasQuickReply: boolean;
};
// MessageMedia Table in DB
export type MessageMedia = {
  id: number;
  messageId: number;
  mediaType:
    'image' | 'video' | 'audio' | 'file';
  url: string;
  size?: number;
  metadata?: string;
  order: number;
};
// MessageLocation Table in DB
export type MessageLocation = {
  id: number;
  messageId: number;
  latitude: number;
  longitude: number;
};
// Quick Reply Table in DB
export type QuickReply = {
  id: number;
  messageId: number;
  type: 'radio' | 'checkbox';
  keepIt: boolean;
};
// Quick Reply Option Table in DB
export type QuickReplyOption = {
  id: number;
  quickReplyId: number;
  title: string;
  value: string;
};

export type GCUser = {
  _id: number;
  name: string;
  avatar?: string;
};
export type GCQuickReplies = {
  type: 'radio' | 'checkbox';
  values: GCQuickReplyOptions[];
  keepIt?: boolean;
};
export type GCQuickReplyOptions = {
  title: string;
  value: string;
};
export type GCLocation = {
  latitude: number;
  longitude: number;
};
export type GCMessage = {
  _id: number;
  text: string;
  createdAt: Date;
  user: GCUser;
  image?: string;
  video?: string;
  audio?: string;
  location?: GCLocation;
  system?: boolean;
  sent?: boolean;
  received?: boolean;
  pending?: boolean;
  quickReplies?: GCQuickReplies;
};
export type GCState = {
  messages: any[];
  step: number;
  loadEarlier?: boolean;
  isLoadingEarlier?: boolean;
  isTyping: boolean;
};
export enum ActionKind {
  SEND_MESSAGE = 'SEND_MESSAGE',
  LOAD_EARLIER_MESSAGES = 'LOAD_EARLIER_MESSAGES',
  LOAD_EARLIER_START = 'LOAD_EARLIER_START',
  SET_IS_TYPING = 'SET_IS_TYPING',
  // LOAD_EARLIER_END = 'LOAD_EARLIER_END',
};
export type GCStateAction = {
  type: ActionKind;
  payload?: any;
};
export type NotificationMessage = {
  sound?: string;
  title: string;
  body: string;
  data?: any;
};

