import { type ApprovalStatus } from './groups';
import {
  type Post,
  type PostRequestActionType,
  type PostRequestContent,
} from './posts';
import { type Pagination } from './services';
import { type User } from './user';

export enum PostState {
  POSTED = 'POSTED',
  SCHEDULED = 'SCHEDULED',
  FAILED_PUBLICATION = 'FAILED_PUBLICATION',
}

export const POST_STATE = {
  POSTED: 'POSTED',
  SCHEDULED: 'SCHEDULED',
  FAILED_PUBLICATION: 'FAILED_PUBLICATION',
};

export const DEFAULT_EMOJI = {
  emoji: '👍',
  unified: '1f44d',
};

export const MAX_EMOJIS = 10;

export type PollState = {
  form: {
    disabled: boolean;
    message: string;
  };
  cancel: {
    disabled: boolean;
    message: string;
  };
};

export type FeedPendingPost = {
  id: number;
  instanceId: number;
  updatedAt: string;
  createdAt: string;
  approvalStatus: ApprovalStatus;
  resolutionDatetime: string | null;
  resolutionUser: Pick<
    User,
    | 'createdAt'
    | 'deleted'
    | 'email'
    | 'employeeInternalId'
    | 'firstName'
    | 'hiringDate'
    | 'id'
    | 'isAgent'
    | 'lastName'
    | 'profilePicture'
  > | null;
  resolutionUserId: number | null;
  post: Post;
  postId: number;
} & (
  | {
      actionType: PostRequestActionType.CREATION;
      postContent: null;
    }
  | {
      actionType: PostRequestActionType.EDITION;
      postContent: PostRequestContent;
    }
);

export type FeedPendingApprovalPostList = Pagination<FeedPendingPost[]>;

export enum OrderBy {
  ASC = 'ASC',
  DESC = 'DESC',
}

export enum FeedSource {
  FEED = 'FEED',
  GROUP = 'GROUP',
  KEY_UPDATES = 'KEY_UPDATES',
  PROFILE_GROUP_POSTS = 'PROFILE_GROUP_POSTS',
}
