/**
 * The staff inbox, as the server sends it.
 *
 * A conversation is a subject, the people on it and the optional outside
 * contact; messages carry the channel they were sent by so the screen can show
 * which replies also left the building.
 */

export type MessagePerson = {
    id: number;
    name: string;
    email: string;
    avatar: string | null;
    job_title: string | null;
};

export type MessageExternalContact = {
    name: string | null;
    email: string;
};

export type MessageThreadSummary = {
    id: number;
    subject: string;
    participants: MessagePerson[];
    external: MessageExternalContact | null;
    unread: number;
    preview: string | null;
    last_sender: string | null;
    last_message_at: string | null;
};

export type InboxMessage = {
    id: number;
    body: string;
    /** A photo, screenshot or PDF that travelled with the message. */
    attachment: {
        name: string;
        url: string;
        download_url: string;
        is_image: boolean;
    } | null;
    channel: "internal" | "email";
    email_to: string | null;
    created_at: string | null;
    mine: boolean;
    user: MessagePerson | null;
};

export type InboxThread = {
    id: number;
    subject: string;
    participants: MessagePerson[];
    external: MessageExternalContact | null;
    messages: InboxMessage[];
};

export type InboxPageProps = {
    threads: MessageThreadSummary[];
    thread: InboxThread | null;
    search: string | null;
    staff: MessagePerson[];
    can: {
        external: boolean;
        email: boolean;
    };
    external_enabled: boolean;
};
