From 4c96fa349c6fe2409a54ee7bb6c8a43b85a4e109 Mon Sep 17 00:00:00 2001 From: Dhravya Shah Date: Sat, 20 Jul 2024 20:49:33 -0500 Subject: changes in queryinput home layout --- apps/web/app/(dash)/chat/chatQueryInput.tsx | 181 +++++++++ apps/web/app/(dash)/chat/chatWindow.tsx | 6 +- apps/web/app/(dash)/dialogContentContainer.tsx | 234 ++++++++++++ apps/web/app/(dash)/dialogTriggerWrapper.tsx | 50 +++ apps/web/app/(dash)/home/filterSpaces.tsx | 102 ++++++ apps/web/app/(dash)/home/homeVariants.ts | 50 --- apps/web/app/(dash)/home/page.tsx | 27 +- apps/web/app/(dash)/home/queryinput.tsx | 166 ++------- apps/web/app/(dash)/menu.tsx | 485 ++++++++----------------- bun.lockb | Bin 1192716 -> 1192756 bytes packages/ui/shadcn/command.tsx | 2 - 11 files changed, 763 insertions(+), 540 deletions(-) create mode 100644 apps/web/app/(dash)/chat/chatQueryInput.tsx create mode 100644 apps/web/app/(dash)/dialogContentContainer.tsx create mode 100644 apps/web/app/(dash)/dialogTriggerWrapper.tsx create mode 100644 apps/web/app/(dash)/home/filterSpaces.tsx delete mode 100644 apps/web/app/(dash)/home/homeVariants.ts diff --git a/apps/web/app/(dash)/chat/chatQueryInput.tsx b/apps/web/app/(dash)/chat/chatQueryInput.tsx new file mode 100644 index 00000000..c7267298 --- /dev/null +++ b/apps/web/app/(dash)/chat/chatQueryInput.tsx @@ -0,0 +1,181 @@ +"use client"; + +import { ArrowRightIcon } from "@repo/ui/icons"; +import Image from "next/image"; +import React, { useEffect, useMemo, useState } from "react"; +import Divider from "@repo/ui/shadcn/divider"; +import { useRouter } from "next/navigation"; +import { getSpaces } from "@/app/actions/fetchers"; +import Combobox from "@repo/ui/shadcn/combobox"; +import { MinusIcon } from "lucide-react"; +import { toast } from "sonner"; +import { createSpace } from "@/app/actions/doers"; + +function QueryInput({ + initialQuery = "", + initialSpaces = [], + disabled = false, + className, + mini = false, + handleSubmit, + setInitialSpaces, +}: { + initialQuery?: string; + initialSpaces?: { + id: number; + name: string; + }[]; + disabled?: boolean; + className?: string; + mini?: boolean; + handleSubmit: (q: string, spaces: { id: number; name: string }[]) => void; + setInitialSpaces?: React.Dispatch< + React.SetStateAction<{ id: number; name: string }[]> + >; +}) { + const [q, setQ] = useState(initialQuery); + + const [selectedSpaces, setSelectedSpaces] = useState([]); + + const options = useMemo( + () => + initialSpaces.map((x) => ({ + label: x.name, + value: x.id.toString(), + })), + [initialSpaces], + ); + + const preparedSpaces = useMemo( + () => + initialSpaces + .filter((x) => selectedSpaces.includes(x.id)) + .map((x) => { + return { + id: x.id, + name: x.name, + }; + }), + [selectedSpaces, initialSpaces], + ); + + return ( +
+
+ {/* input and action button */} +
{ + handleSubmit(q, preparedSpaces); + setQ(""); + }} + className="flex gap-4 p-3" + > +