import React, { KeyboardEventHandler, useEffect, useState } from "react"
import {
Command,
CommandEmpty,
CommandInput,
CommandItem,
CommandList,
} from "@/components/ui/command"
import { convertToFlashCard, DivideTaskIntoSubTasks, summarize } from "@/ollama";
import { PromptAI } from "./PromptAI";
export function OllamaCommandPallete({ options, theme }: { options: string[], theme: string }) {
const [selection, setSelection] = useState('')
const [isEnterPressed, setIsEnterPressed] = useState(false);
const handleSelection = (selection: string) => {
setSelection(selection)
setIsEnterPressed(true);
switch (selection) {
case "divide into subtasks":
DivideTaskIntoSubTasks()
break;
case "summarize":
summarize()
break;
case "convert to flash card":
convertToFlashCard()
break;
default:
break;
}
}
if (isEnterPressed && (selection !== 'ask ai' && selection !== 'define' && selection !== 'ask with context')) {
return null
}
return (
selection === 'ask with context' || selection === 'ask ai' || selection === 'define' ? () : (
No results found.
{
options.map((option) => (
{option}
))
}
)
)
}