diff --git a/packages/ocular-ui/components/chat-layout.tsx b/packages/ocular-ui/components/chat-layout.tsx index 84b67c48..238dfa61 100644 --- a/packages/ocular-ui/components/chat-layout.tsx +++ b/packages/ocular-ui/components/chat-layout.tsx @@ -2,7 +2,7 @@ import React, { ReactNode } from 'react'; -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" import { ChatSideBar } from "@/components/chat/chat-sidebar/chat-sidebar" import { GlobalState } from "@/lib/global-state" import { useTheme } from "next-themes" @@ -29,7 +29,7 @@ export default function ChatLayout({ children }: ChatLayoutProps) { const pathname = usePathname() const router = useRouter() const [chatsLoaded, setChatsLoaded] = useState(false) - const { chatMessages, setChats } = useContext(ChatbotUIContext) + const { chatMessages, setChats } = useContext(ApplicationContext) const searchParams = useSearchParams() const tabValue = searchParams.get("tab") || "chats" diff --git a/packages/ocular-ui/components/chat/chat-hooks/use-chat-handler.tsx b/packages/ocular-ui/components/chat/chat-hooks/use-chat-handler.tsx index 1c40f986..53291b8b 100644 --- a/packages/ocular-ui/components/chat/chat-hooks/use-chat-handler.tsx +++ b/packages/ocular-ui/components/chat/chat-hooks/use-chat-handler.tsx @@ -1,4 +1,4 @@ -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" import { buildFinalMessages } from "@/lib/build-prompt" import { useRouter } from "next/navigation" import { useContext, useEffect, useRef } from "react" @@ -25,7 +25,7 @@ export const useChatHandler = () => { chatMessages, setIsPromptPickerOpen, isPromptPickerOpen, - } = useContext(ChatbotUIContext) + } = useContext(ApplicationContext) const chatInputRef = useRef(null) useEffect(() => { diff --git a/packages/ocular-ui/components/chat/chat-hooks/use-chat-history.tsx b/packages/ocular-ui/components/chat/chat-hooks/use-chat-history.tsx index cbb376eb..05181b1c 100644 --- a/packages/ocular-ui/components/chat/chat-hooks/use-chat-history.tsx +++ b/packages/ocular-ui/components/chat/chat-hooks/use-chat-history.tsx @@ -1,4 +1,4 @@ -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" import { useContext, useEffect, useState } from "react" /** @@ -11,7 +11,7 @@ import { useContext, useEffect, useState } from "react" */ export const useChatHistoryHandler = () => { const { setUserInput, chatMessages, isGenerating } = - useContext(ChatbotUIContext) + useContext(ApplicationContext) const userRoleString = "user" const [messageHistoryIndex, setMessageHistoryIndex] = useState( diff --git a/packages/ocular-ui/components/chat/chat-hooks/use-prompt-and-command.tsx b/packages/ocular-ui/components/chat/chat-hooks/use-prompt-and-command.tsx index d0ab59f2..de7b83de 100644 --- a/packages/ocular-ui/components/chat/chat-hooks/use-prompt-and-command.tsx +++ b/packages/ocular-ui/components/chat/chat-hooks/use-prompt-and-command.tsx @@ -1,4 +1,4 @@ -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" // import { getAssistantCollectionsByAssistantId } from "@/db/assistant-collections" // import { getAssistantFilesByAssistantId } from "@/db/assistant-files" // import { getAssistantToolsByAssistantId } from "@/db/assistant-tools" @@ -12,7 +12,7 @@ export const usePromptAndCommand = () => { userInput, setUserInput, setIsPromptPickerOpen, - } = useContext(ChatbotUIContext) + } = useContext(ApplicationContext) const handleInputChange = (value: string) => { const atTextRegex = /@([^ ]*)$/ diff --git a/packages/ocular-ui/components/chat/chat-hooks/use-scroll.tsx b/packages/ocular-ui/components/chat/chat-hooks/use-scroll.tsx index 9c6aea0d..0f783825 100644 --- a/packages/ocular-ui/components/chat/chat-hooks/use-scroll.tsx +++ b/packages/ocular-ui/components/chat/chat-hooks/use-scroll.tsx @@ -1,4 +1,4 @@ -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" import { type UIEventHandler, useCallback, @@ -9,7 +9,7 @@ import { } from "react" export const useScroll = () => { - const { isGenerating, chatMessages } = useContext(ChatbotUIContext) + const { isGenerating, chatMessages } = useContext(ApplicationContext) const messagesStartRef = useRef(null) const messagesEndRef = useRef(null) diff --git a/packages/ocular-ui/components/chat/chat-input.tsx b/packages/ocular-ui/components/chat/chat-input.tsx index c2ec035b..b48ffdb8 100644 --- a/packages/ocular-ui/components/chat/chat-input.tsx +++ b/packages/ocular-ui/components/chat/chat-input.tsx @@ -3,7 +3,7 @@ import { IconSend } from "@tabler/icons-react" -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" import { cn } from "@/lib/utils" import { FC, useContext, useState } from "react" import { TextareaAutosize } from "../ui/textarea-autosize" @@ -22,7 +22,7 @@ export const ChatInput: FC = ({}) => { setFocusPrompt, isPromptPickerOpen, setIsPromptPickerOpen, - } = useContext(ChatbotUIContext) + } = useContext(ApplicationContext) const { chatInputRef, diff --git a/packages/ocular-ui/components/chat/chat-item.tsx b/packages/ocular-ui/components/chat/chat-item.tsx index 40db23da..08fc781b 100644 --- a/packages/ocular-ui/components/chat/chat-item.tsx +++ b/packages/ocular-ui/components/chat/chat-item.tsx @@ -1,4 +1,4 @@ -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" import { cn } from "@/lib/utils" import { Chat } from "@/types/chat" import { useParams, useRouter } from "next/navigation" @@ -14,7 +14,7 @@ export const ChatItem: FC = ({ chat }) => { const { selectedChat, setSelectedChat, - } = useContext(ChatbotUIContext) + } = useContext(ApplicationContext) const router = useRouter() const params = useParams() diff --git a/packages/ocular-ui/components/chat/chat-messages.tsx b/packages/ocular-ui/components/chat/chat-messages.tsx index 093325a8..e45c1829 100644 --- a/packages/ocular-ui/components/chat/chat-messages.tsx +++ b/packages/ocular-ui/components/chat/chat-messages.tsx @@ -1,4 +1,4 @@ -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" import { FC, useContext, useState } from "react" import { Message } from "../messages/message" import { Message as MessageType } from "@/types/chat" @@ -6,7 +6,7 @@ import { Message as MessageType } from "@/types/chat" interface ChatMessagesProps {} export const ChatMessages: FC = ({}) => { - const { chatMessages } = useContext(ChatbotUIContext) + const { chatMessages } = useContext(ApplicationContext) const [editingMessage, setEditingMessage] = useState() return chatMessages diff --git a/packages/ocular-ui/components/chat/chat-secondary-buttons.tsx b/packages/ocular-ui/components/chat/chat-secondary-buttons.tsx index 930fe06e..4c0b06c6 100644 --- a/packages/ocular-ui/components/chat/chat-secondary-buttons.tsx +++ b/packages/ocular-ui/components/chat/chat-secondary-buttons.tsx @@ -1,5 +1,5 @@ import { useChatHandler } from "@/components/chat/chat-hooks/use-chat-handler" -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" import { IconEdit } from "@tabler/icons-react" import { FC, useContext } from "react" import { WithTooltip } from "../ui/with-tooltip" @@ -7,7 +7,7 @@ import { WithTooltip } from "../ui/with-tooltip" interface ChatSecondaryButtonsProps {} export const ChatSecondaryButtons: FC = ({}) => { - const { selectedChat } = useContext(ChatbotUIContext) + const { selectedChat } = useContext(ApplicationContext) const { handleNewChat } = useChatHandler() diff --git a/packages/ocular-ui/components/chat/chat-sidebar/chat-sidebar-data-list.tsx b/packages/ocular-ui/components/chat/chat-sidebar/chat-sidebar-data-list.tsx index b1307d1e..e2b75842 100644 --- a/packages/ocular-ui/components/chat/chat-sidebar/chat-sidebar-data-list.tsx +++ b/packages/ocular-ui/components/chat/chat-sidebar/chat-sidebar-data-list.tsx @@ -1,4 +1,4 @@ -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" import { cn } from "@/lib/utils" import { ContentType, DataItemType, DataListType } from "@/types" import { FC, useContext, useEffect, useRef, useState } from "react" @@ -35,7 +35,7 @@ export const SidebarDataList: FC = ({ // setAssistants, // setTools, // setModels - } = useContext(ChatbotUIContext) + } = useContext(ApplicationContext) const divRef = useRef(null) diff --git a/packages/ocular-ui/components/chat/chat-sidebar/chat-sidebar.tsx b/packages/ocular-ui/components/chat/chat-sidebar/chat-sidebar.tsx index 57568e8b..54e75708 100644 --- a/packages/ocular-ui/components/chat/chat-sidebar/chat-sidebar.tsx +++ b/packages/ocular-ui/components/chat/chat-sidebar/chat-sidebar.tsx @@ -1,4 +1,4 @@ -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" import { ContentType } from "@/types" import { FC, useContext } from "react" import { SIDEBAR_WIDTH } from "../../ui/dashboard" @@ -13,7 +13,7 @@ interface SidebarProps { export const ChatSideBar: FC = ({contentType, showSidebar }) => { const { chats, - } = useContext(ChatbotUIContext) + } = useContext(ApplicationContext) const renderSidebarContent = ( diff --git a/packages/ocular-ui/components/chat/chat-sidebar/use-chat-history.tsx b/packages/ocular-ui/components/chat/chat-sidebar/use-chat-history.tsx index 52a5354f..24075372 100644 --- a/packages/ocular-ui/components/chat/chat-sidebar/use-chat-history.tsx +++ b/packages/ocular-ui/components/chat/chat-sidebar/use-chat-history.tsx @@ -1,4 +1,4 @@ -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" import { useContext, useEffect, useState } from "react" /** @@ -11,7 +11,7 @@ import { useContext, useEffect, useState } from "react" */ export const useChatHistoryHandler = () => { const { setUserInput, chatMessages, isGenerating } = - useContext(ChatbotUIContext) + useContext(ApplicationContext) const userRoleString = "user" const [messageHistoryIndex, setMessageHistoryIndex] = useState( diff --git a/packages/ocular-ui/components/chat/chat-ui.tsx b/packages/ocular-ui/components/chat/chat-ui.tsx index 4c63de8c..e1a41b8e 100644 --- a/packages/ocular-ui/components/chat/chat-ui.tsx +++ b/packages/ocular-ui/components/chat/chat-ui.tsx @@ -1,5 +1,5 @@ import { useChatHandler } from "@/components/chat/chat-hooks/use-chat-handler" -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" import { useParams } from "next/navigation" import { FC, useContext, useEffect, useState } from "react" import { useScroll } from "./chat-hooks/use-scroll" @@ -20,7 +20,7 @@ export const ChatUI: FC = ({}) => { setChatMessages, selectedChat, setSelectedChat, - } = useContext(ChatbotUIContext) + } = useContext(ApplicationContext) const { handleNewChat, handleFocusChatInput } = useChatHandler() diff --git a/packages/ocular-ui/components/date-picker.tsx b/packages/ocular-ui/components/date-picker.tsx index 4bd59945..28cb3d5a 100644 --- a/packages/ocular-ui/components/date-picker.tsx +++ b/packages/ocular-ui/components/date-picker.tsx @@ -5,7 +5,7 @@ import { format as formatDateFns } from "date-fns" import { cn } from "@/lib/utils" import { Button } from "@/components/ui/button" import { Calendar } from "@/components/ui/calendar" -import { ChatbotUIContext } from "@/context/context"; +import { ApplicationContext } from "@/context/context"; import { Popover, PopoverContent, @@ -20,7 +20,7 @@ export function DatePickerWithRange({ className, }: React.HTMLAttributes) { - const { resultFilterDate, setResultFilterDate } = useContext(ChatbotUIContext); + const { resultFilterDate, setResultFilterDate } = useContext(ApplicationContext); const [isSelected, setIsSelected] = useState(false); // Serialize the date to JSON format when logging diff --git a/packages/ocular-ui/components/messages/message-actions.tsx b/packages/ocular-ui/components/messages/message-actions.tsx index 15d84b81..44ac9473 100644 --- a/packages/ocular-ui/components/messages/message-actions.tsx +++ b/packages/ocular-ui/components/messages/message-actions.tsx @@ -1,4 +1,4 @@ -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" import { IconCheck, IconCopy, IconEdit, IconRepeat } from "@tabler/icons-react" import { FC, useContext, useEffect, useState } from "react" import { WithTooltip } from "../ui/with-tooltip" @@ -20,7 +20,7 @@ export const MessageActions: FC = ({ isHovering, onCopy, }) => { - const { isGenerating } = useContext(ChatbotUIContext) + const { isGenerating } = useContext(ApplicationContext) const [showCheckmark, setShowCheckmark] = useState(false) diff --git a/packages/ocular-ui/components/messages/message.tsx b/packages/ocular-ui/components/messages/message.tsx index 34fd0d7c..a3faec5c 100644 --- a/packages/ocular-ui/components/messages/message.tsx +++ b/packages/ocular-ui/components/messages/message.tsx @@ -3,7 +3,7 @@ import { useRouter } from "next/navigation"; import { useTheme } from 'next-themes'; -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" import { cn } from "@/lib/utils" import { IconBolt, @@ -54,7 +54,7 @@ export const Message: FC = ({ setIsGenerating, firstTokenReceived, chatMessages, - } = useContext(ChatbotUIContext) + } = useContext(ApplicationContext) const editInputRef = useRef(null) diff --git a/packages/ocular-ui/components/search/app-filter-option.tsx b/packages/ocular-ui/components/search/app-filter-option.tsx index 135490d0..c6fd0b41 100644 --- a/packages/ocular-ui/components/search/app-filter-option.tsx +++ b/packages/ocular-ui/components/search/app-filter-option.tsx @@ -3,23 +3,24 @@ import { useState, useContext } from 'react'; import Image from 'next/image'; -import { ChatbotUIContext } from "@/context/context"; +import { ApplicationContext } from "@/context/context"; type AppFilterOptionProps = { src: string; - title: string; + label: string; + value: string; results?: any; }; -export default function AppFilterOption({ src, title, results }: AppFilterOptionProps) { - const { setselectedResultSources, activeFilter, setActiveFilter } = useContext(ChatbotUIContext); - +export default function AppFilterOption({ src, label, value, results }: AppFilterOptionProps) { + const { setselectedResultSources, activeFilter, setActiveFilter } = useContext(ApplicationContext); + const handleClick = () => { - setselectedResultSources([title]); - setActiveFilter(title); + setselectedResultSources([value]); + setActiveFilter(value); }; - const isSelected = activeFilter === title; + const isSelected = activeFilter === value; return (
- {title} + {label}

- {title.split('.')[0].charAt(0).toUpperCase() + title.split('.')[0].slice(1)} + {label}

diff --git a/packages/ocular-ui/components/search/app-filter-options.tsx b/packages/ocular-ui/components/search/app-filter-options.tsx index 5f93e007..69e32125 100644 --- a/packages/ocular-ui/components/search/app-filter-options.tsx +++ b/packages/ocular-ui/components/search/app-filter-options.tsx @@ -3,15 +3,16 @@ import { useContext } from 'react'; import AppFilterOption from "./app-filter-option"; import Image from 'next/image'; -import { ChatbotUIContext } from "@/context/context"; +import { ApplicationContext } from "@/context/context"; +import { formatLabel } from '@/lib/utils'; type AppFilterOptionsProps = { results: any; + resultSources: string[]; }; -export default function AppFilterOptions({results}: AppFilterOptionsProps) { - const { resultSources } = useContext(ChatbotUIContext); - const { activeFilter, setActiveFilter, setselectedResultSources } = useContext(ChatbotUIContext); +export default function AppFilterOptions({results, resultSources}: AppFilterOptionsProps) { + const { activeFilter, setActiveFilter, setselectedResultSources } = useContext(ApplicationContext); const handleClick = () => { setselectedResultSources(resultSources); @@ -20,6 +21,12 @@ export default function AppFilterOptions({results}: AppFilterOptionsProps) { const isSelected = activeFilter === 'All'; + const mappedResultSources = resultSources.map(source => ({ + label: formatLabel(source), + value: source, + icon: `/${source}.svg`, + })); + return (

@@ -33,8 +40,8 @@ export default function AppFilterOptions({results}: AppFilterOptionsProps) {

{results ? results : Math.floor(Math.random() * 1000) + 1}

- {resultSources.map((iconName) => ( - + {mappedResultSources.map((iconName) => ( + ))}
diff --git a/packages/ocular-ui/components/search/apps-faceted-filter.tsx b/packages/ocular-ui/components/search/apps-faceted-filter.tsx index b65fc601..11354a4e 100644 --- a/packages/ocular-ui/components/search/apps-faceted-filter.tsx +++ b/packages/ocular-ui/components/search/apps-faceted-filter.tsx @@ -25,13 +25,17 @@ import { } from "@/components/ui/popover"; import { Separator } from "@/components/ui/separator"; -import { ChatbotUIContext } from "@/context/context"; +import { ApplicationContext } from "@/context/context"; interface AppsFacetedFilterProps { results?: TData; // Define appropriate type if needed title?: string; Icon: IconType; - options: string[]; + options: { + label: string + value: string + icon: string + }[] } export function AppsFacetedFilter({ @@ -43,7 +47,7 @@ export function AppsFacetedFilter({ const [selectedValues, setSelectedValues] = useState>(new Set()); // Track selected values with a Set const [selectedArray, setSelectedArray] = useState([]); // Additional state for an array of selected values - const { setselectedResultSources, selectedResultSources } = useContext(ChatbotUIContext); + const { setselectedResultSources, selectedResultSources } = useContext(ApplicationContext); // Effect to print and handle selected values array whenever selectedValues changes useEffect(() => { @@ -51,8 +55,6 @@ export function AppsFacetedFilter({ setSelectedArray(newSelectedArray); setselectedResultSources(newSelectedArray); // Update the result sources whenever selection changes - - console.log("Selected Values 1:", newSelectedArray); // Printing out the selected values }, [selectedValues, setselectedResultSources]); @@ -87,14 +89,14 @@ export function AppsFacetedFilter({ ) : ( options - .filter((option) => selectedValues.has(option)) + .filter((option) => selectedValues.has(option.value)) .map((option) => ( - icon {option} + icon {option.label} )) )} @@ -111,16 +113,16 @@ export function AppsFacetedFilter({ No results found. {options.map((option) => { - const isSelected = selectedValues.has(option); + const isSelected = selectedValues.has(option.value); return ( { const newSelectedValues = new Set(selectedValues); if (isSelected) { - newSelectedValues.delete(option); + newSelectedValues.delete(option.value); } else { - newSelectedValues.add(option); + newSelectedValues.add(option.value); } setSelectedValues(newSelectedValues); // Update state }} @@ -136,9 +138,10 @@ export function AppsFacetedFilter({ {option && ( - icon + icon + )} - {option} + {option.label} ); })} diff --git a/packages/ocular-ui/components/search/header-filter-toolbar.tsx b/packages/ocular-ui/components/search/header-filter-toolbar.tsx index 8c6d895a..f1a6e8a7 100644 --- a/packages/ocular-ui/components/search/header-filter-toolbar.tsx +++ b/packages/ocular-ui/components/search/header-filter-toolbar.tsx @@ -1,10 +1,10 @@ "use client"; import { useContext } from 'react'; -import { ChatbotUIContext } from "@/context/context"; +import { ApplicationContext } from "@/context/context"; import { DatePickerWithRange } from "@/components/date-picker"; import { AppsFacetedFilter } from "./apps-faceted-filter"; -import { apps, resultTypes } from "@/data/data" +import { formatLabel } from '@/lib/utils'; import { CollectionIcon @@ -12,7 +12,13 @@ import { import { LayoutGrid } from 'lucide-react'; export default function HeaderFilterToolbar() { - const { resultSources } = useContext(ChatbotUIContext); + const { resultSources } = useContext(ApplicationContext); + + const mappedResultSources = resultSources.map(source => ({ + label: formatLabel(source), + value: source, + icon: `/${source}.svg`, + })); return (
@@ -20,7 +26,7 @@ export default function HeaderFilterToolbar() { {/* ( <>
{ - results && results.length > 0 ? - results.map((result: any, index: any) => ( -
-
- {result.documentMetadata.title} -
-
- -

- {result.documentMetadata.title.charAt(0).toUpperCase() + result.documentMetadata.title.slice(1)} -

-
-

snippet.content).join(" ... ") }}>

-
-

- { - !isNaN(new Date(result.documentMetadata.updated_at).getTime()) ? - new Date(result.documentMetadata.updated_at).toLocaleDateString(undefined, { day: 'numeric', month: 'long', year: 'numeric', hour: '2-digit', minute: '2-digit' }) - : null - } -

- · -

- {result.documentMetadata.type.charAt(0).toUpperCase() + result.documentMetadata.type.slice(1)} -

+ (results && results.length > 0) ? + results.map((result: any, index: any) => ( +
+
+ {result.documentMetadata.title} +
+
+ +

+ {result.documentMetadata.title.charAt(0).toUpperCase() + result.documentMetadata.title.slice(1)} +

+
+

snippet.content).join(" ... ") }}>

+
+

+ { + !isNaN(new Date(result.documentMetadata.updated_at).getTime()) ? + new Date(result.documentMetadata.updated_at).toLocaleDateString(undefined, { day: 'numeric', month: 'long', year: 'numeric', hour: '2-digit', minute: '2-digit' }) + : null + } +

+ · +

+ {result.documentMetadata.type.charAt(0).toUpperCase() + result.documentMetadata.type.slice(1)} +

+
-
+
)) :

No results found for this query

-
- } -
- )} +
+ } +
); // Results Filter Component -const ResultsFilter = ({ results, isLoadingResults }) => ( +const ResultsFilter = ({ results, isLoadingResults, resultSources }) => (
{ results ? - + : }
@@ -120,7 +120,7 @@ const ResultsFilter = ({ results, isLoadingResults }) => ( ); // Main Component -export default function SearchResults({ search_results, ai_content, isLoadingResults, isLoadingCopilot }) { +export default function SearchResults({ search_results, ai_content, isLoadingResults, isLoadingCopilot, resultSources }) { return (
{/*
@@ -133,7 +133,7 @@ export default function SearchResults({ search_results, ai_content, isLoadingRes ) : ( )} - +
diff --git a/packages/ocular-ui/context/context.tsx b/packages/ocular-ui/context/context.tsx index 8f7a2065..d303aeb5 100644 --- a/packages/ocular-ui/context/context.tsx +++ b/packages/ocular-ui/context/context.tsx @@ -12,7 +12,7 @@ import { da } from "date-fns/locale" import { Dispatch, SetStateAction, createContext } from "react" import { DateRange } from "react-day-picker" -interface ChatbotUIContext { +interface ApplicationContext { // PROFILE STORE // profile: Profile | null // setProfile: Dispatch> @@ -141,7 +141,7 @@ interface ChatbotUIContext { setResultFilterDate: Dispatch>; } -export const ChatbotUIContext = createContext({ +export const ApplicationContext = createContext({ // PROFILE STORE // profile: null, // setProfile: () => {}, diff --git a/packages/ocular-ui/data/data.tsx b/packages/ocular-ui/data/data.tsx index feed5df5..6917cc10 100644 --- a/packages/ocular-ui/data/data.tsx +++ b/packages/ocular-ui/data/data.tsx @@ -1,46 +1,6 @@ import { LinkProps } from "@/types/types" -export const accounts = [ - { - label: "Alicia Koch", - email: "alicia@example.com", - icon: ( - - Vercel - - - ), - }, - { - label: "Alicia Koch", - email: "alicia@gmail.com", - icon: ( - - Gmail - - - ), - }, - { - label: "Alicia Koch", - email: "alicia@me.com", - icon: ( - - iCloud - - - ), - }, -] -export type Account = (typeof accounts)[number] - export const links: LinkProps[] =[ { title: "Search", @@ -69,24 +29,6 @@ export type Link = (typeof links)[number] export type BottomLinks = (typeof links)[number] -export const apps = [ - { - value: "asana", - label: "Asana", - icon: "/asana.svg", - }, - { - value: "google-drive", - label: "Google Drive", - icon: "/google-drive.svg", - }, - { - value: "gmail", - label: "Gmail", - icon: "/gmail.svg", - }, -] - export const resultTypes = [ { value: "documents", diff --git a/packages/ocular-ui/lib/global-state.tsx b/packages/ocular-ui/lib/global-state.tsx index 520897ae..98719da8 100644 --- a/packages/ocular-ui/lib/global-state.tsx +++ b/packages/ocular-ui/lib/global-state.tsx @@ -2,7 +2,7 @@ "use client" -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" import api from "@/services/api" import { DateRange } from "react-day-picker"; import { addDays, format as formatDateFns } from "date-fns" @@ -211,7 +211,7 @@ export const GlobalState: FC = ({ children }) => { } return ( - = ({ children }) => { }} > {children} - + ) } \ No newline at end of file diff --git a/packages/ocular-ui/lib/utils.ts b/packages/ocular-ui/lib/utils.ts index bd0c391d..099dbce7 100644 --- a/packages/ocular-ui/lib/utils.ts +++ b/packages/ocular-ui/lib/utils.ts @@ -4,3 +4,11 @@ import { twMerge } from "tailwind-merge" export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) } + +// Function to format a string of fomart (e.g google-drive) to a label such as Google Drive +export function formatLabel(source: string) { + return source + .split('-') + .map((word :string) => word.charAt(0).toUpperCase() + word.slice(1)) + .join(' '); +} \ No newline at end of file diff --git a/packages/ocular-ui/pages/dashboard/chat/chat-layout.tsx b/packages/ocular-ui/pages/dashboard/chat/chat-layout.tsx index 9329005b..e7d6877c 100644 --- a/packages/ocular-ui/pages/dashboard/chat/chat-layout.tsx +++ b/packages/ocular-ui/pages/dashboard/chat/chat-layout.tsx @@ -6,7 +6,7 @@ import { ChatHelp } from "@/components/chat/chat-help" import { ChatUI } from "@/components/chat/chat-ui" // import { QuickSettings } from "@/components/chat/quick-settings" // import { Brand } from "@/components/ui/brand" -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" import { ChatSideBar } from "@/components/chat/chat-sidebar/chat-sidebar" import { GlobalState } from "@/lib/global-state" // import useHotkey from "@/lib/hooks/use-hotkey" @@ -30,7 +30,7 @@ const ChatLayout: React.FC = ({ children }) => { const [chatsLoaded, setChatsLoaded] = useState(false); - const { chatMessages, setChats } = useContext(ChatbotUIContext) + const { chatMessages, setChats } = useContext(ApplicationContext) const searchParams = useSearchParams() const tabValue = searchParams.get("tab") || "chats" const [contentType, setContentType] = useState( diff --git a/packages/ocular-ui/pages/dashboard/search/index.tsx b/packages/ocular-ui/pages/dashboard/search/index.tsx index 227d9d59..347b13da 100644 --- a/packages/ocular-ui/pages/dashboard/search/index.tsx +++ b/packages/ocular-ui/pages/dashboard/search/index.tsx @@ -8,12 +8,12 @@ import { import { useRef, useContext } from "react"; import { useRouter } from "next/router"; -import { ChatbotUIContext } from "@/context/context"; +import { ApplicationContext } from "@/context/context"; export function Search() { const router = useRouter(); const searchInputRef = useRef(null); - const { resultSources } = useContext(ChatbotUIContext); + const { resultSources } = useContext(ApplicationContext); function search(e: React.FormEvent) { e.preventDefault(); diff --git a/packages/ocular-ui/pages/dashboard/search/results/index.tsx b/packages/ocular-ui/pages/dashboard/search/results/index.tsx index 6507a2fd..f32f5530 100644 --- a/packages/ocular-ui/pages/dashboard/search/results/index.tsx +++ b/packages/ocular-ui/pages/dashboard/search/results/index.tsx @@ -5,7 +5,7 @@ import Head from "next/head"; import Header from "@/components/search/header"; import { useRouter } from "next/router"; import SearchResults from "@/components/search/search-results"; -import { ChatbotUIContext } from "@/context/context" +import { ApplicationContext } from "@/context/context" // Importing API End Points import api from "@/services/api" @@ -17,8 +17,7 @@ export default function Search() { const [isLoadingCopilot, setIsLoadingCopilot] = useState(false); const router = useRouter(); - const { selectedResultSources, resultFilterDate } = useContext(ChatbotUIContext) - const { setResultSources } = useContext(ChatbotUIContext) + const { selectedResultSources, resultFilterDate, setResultSources, resultSources } = useContext(ApplicationContext) // Serialize the date to JSON format when logging const selectedDate = useMemo(() => { @@ -34,7 +33,6 @@ const selectedDate = useMemo(() => { useEffect(() => { setIsLoadingResults(true); setIsLoadingCopilot(true); - console.log("Selected Values 3:", selectedResultSources); api.search.search(router.query.q, selectedResultSources, selectedDate) .then(data => { // setAiResults(data.data.message.content); @@ -56,7 +54,7 @@ const selectedDate = useMemo(() => {
- +
); } \ No newline at end of file