import {createContext} from 'react';
import {ImageOrVideo} from 'react-native-image-crop-picker';
import {EditorBridge} from '@10play/tentap-editor';
import {Attachment, GifAttachment} from '@interfaces/attachments';
import {BodyAttributes} from '@interfaces/bodyAttributes';
import {LinkPreviewsBodyParam} from '@interfaces/linkPreview';
import {SetState} from '@interfaces/generic';
import {PollConfiguration, Post} from '@modules/post/interfaces';

import {AttachmentsData} from '../interfaces';

export interface NewPostContextType {
  currentSize: number;
  setCurrentSize: SetState<number>;
  messageBody: string;
  messageBodyWithoutLastTag: string;
  setMessageBody: SetState<string>;
  setMessageBodyWithoutLastTag: SetState<string>;
  hasPoll: boolean;
  editor: EditorBridge;
  isLoading: boolean;
  setIsLoading: SetState<boolean>;
  post?: Partial<Post>;
  linkPreviews?: LinkPreviewsBodyParam;
  setLinkPreviews: SetState<LinkPreviewsBodyParam>;
  initialAttachments: AttachmentsData;
  pollOptions: string[];
  setPollOptions: SetState<string[]>;
  taggedUsers: BodyAttributes[];
  images: Attachment[];
  videos: Attachment[];
  files: Attachment[];
  gif: Nullable<GifAttachment>;
  segmentationItemIds: number[];
  setSegmentationItemIds: SetState<number[]>;
  setTaggedUsers: SetState<BodyAttributes[]>;
  setImages: SetState<Attachment[]>;
  setVideos: SetState<Attachment[]>;
  setFiles: SetState<Attachment[]>;
  setHasPoll: SetState<boolean>;
  setGif: SetState<Nullable<GifAttachment>>;
  inputChanged: boolean;
  setInputChanged: SetState<boolean>;
  setSendPushNotification: SetState<boolean>;
  sendPushNotification: boolean;
  scheduleDateTime?: Date;
  setScheduleDateTime: SetState<Date | undefined>;
  pollConfiguration: PollConfiguration;
  setPollConfiguration: SetState<PollConfiguration>;
  pickedAssets: ImageOrVideo[];
  setPickedAssets: SetState<ImageOrVideo[]>;
}

export const NewPostContext = createContext<NewPostContextType | undefined>(
  undefined,
);
