import React = require('react');
import { Doc } from "../../../fields/Doc";
import { observer } from "mobx-react";
import { computed } from "mobx";
import { StrCast } from "../../../fields/Types";
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Colors, ListBox } from 'browndash-components';
import { DocumentManager } from '../../util/DocumentManager';
import { DocFocusOptions } from '../nodes/DocumentView';

export interface SelectedDocViewProps {
    selectedDocs: Doc[];
}

@observer
export class SelectedDocView extends React.Component<SelectedDocViewProps> {

    @computed get selectedDocs() {
        return this.props.selectedDocs;
    }
    

    render() {
        return <div className={`selectedDocView-container`}>
            <ListBox
                items={this.selectedDocs.map((doc) => {
                    const icon = Doc.toIcon(doc);
                    const iconEle = <FontAwesomeIcon size={'1x'} icon={icon} />;
                    const text = StrCast(doc.title)
                    const finished = () => {
                        
                    };
                    const options: DocFocusOptions = {
                        playAudio: false,
                    };
                    return {
                        text: text,
                        val: StrCast(doc._id),
                        icon: iconEle,
                        onClick: () => {DocumentManager.Instance.showDocument(doc, options, finished);}
                    }
                })}
                color={StrCast(Doc.UserDoc().userColor)}
            />
        </div>
    }
}