import {ReadonlyDataset} from "@opennetwork/rdf-dataset"
import {AnswerQuad, isAnswerQuad, isQuestionQuad, QuestionQuad} from "../main";
import {Literal} from "@opennetwork/rdf-data-model";
import {getEnvironmentConfig} from "@opennetwork/environment";

export function UIStart(this: ReadonlyDataset<AnswerQuad | QuestionQuad>) {
    const { module: { h } } = getEnvironmentConfig()

    for (const quad of this) {
        if (isAnswerQuad(quad)) {
            // We know this is a literal here
            const answer: Literal = quad.object

        } else if (isQuestionQuad(quad)) {

        } else {
            // never
        }
    }

    const question = this.filter(isQuestionQuad)
    const answer = this.filter(isAnswerQuad)
    return (
        <view>
            <text>
                Questions: {question.size}
                Answers: {answer.size}
            </text>
        </view>
    )
}
