-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39588fc
commit c1d4cbe
Showing
9 changed files
with
208 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import Request from "../utils/request"; | ||
|
||
|
||
|
||
export interface ChatGeneration { | ||
answer: string; | ||
chat_history: any; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
import React from 'react'; | ||
import React from "react"; | ||
|
||
interface TooltipProps { | ||
message: string; | ||
children: React.ReactNode; | ||
message: string; | ||
children: React.ReactNode; | ||
} | ||
|
||
export default function Tooltip({ message, children }: TooltipProps) { | ||
return ( | ||
<div className="group relative flex"> | ||
{children} | ||
<span className="absolute top-10 scale-0 transition-all rounded bg-gray-800 p-2 text-xs text-white group-hover:scale-100">{message}</span> | ||
</div> | ||
) | ||
return ( | ||
<div className="group relative flex"> | ||
{children} | ||
<span className="absolute top-10 scale-0 transition-all rounded bg-gray-800 p-2 text-xs text-white group-hover:scale-100"> | ||
{message} | ||
</span> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,103 @@ | ||
import { createClient } from '@supabase/supabase-js' | ||
import { Auth, ThemeSupa } from '@supabase/auth-ui-react' | ||
import { createClient } from "@supabase/supabase-js"; | ||
import { Auth, ThemeSupa } from "@supabase/auth-ui-react"; | ||
|
||
import { Fragment, SetStateAction, useState } from 'react' | ||
import { Dialog, Transition } from '@headlessui/react' | ||
import { CheckIcon } from '@heroicons/react/24/outline' | ||
import { useCookies } from 'react-cookie'; | ||
import { Fragment, SetStateAction, useState } from "react"; | ||
import { Dialog, Transition } from "@headlessui/react"; | ||
import { CheckIcon } from "@heroicons/react/24/outline"; | ||
import { useCookies } from "react-cookie"; | ||
|
||
export default function AuthModal({ | ||
open, | ||
setOpen, | ||
}: { | ||
open: boolean; | ||
setOpen: React.Dispatch<SetStateAction<boolean>>; | ||
}) { | ||
const supabase = createClient( | ||
process.env.NEXT_PUBLIC_SUPABASE_URL as string, | ||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY as string | ||
); | ||
const [cookies, setCookie, removeCookie] = useCookies(["Token"]); | ||
|
||
supabase.auth.onAuthStateChange(async (event, session) => { | ||
if (event === "SIGNED_IN") { | ||
setCookie("Token", session?.access_token); | ||
setOpen(false); | ||
} | ||
}); | ||
|
||
export default function AuthModal({ open, setOpen }: { open: boolean, setOpen: React.Dispatch<SetStateAction<boolean>> }) { | ||
const supabase = createClient(process.env.NEXT_PUBLIC_SUPABASE_URL as string, process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY as string) | ||
const [cookies, setCookie, removeCookie] = useCookies(['Token']); | ||
return ( | ||
<Transition.Root show={open} as={Fragment}> | ||
<Dialog as="div" className="relative z-10" onClose={setOpen}> | ||
<Transition.Child | ||
as={Fragment} | ||
enter="ease-out duration-300" | ||
enterFrom="opacity-0" | ||
enterTo="opacity-100" | ||
leave="ease-in duration-200" | ||
leaveFrom="opacity-100" | ||
leaveTo="opacity-0" | ||
> | ||
<div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" /> | ||
</Transition.Child> | ||
|
||
supabase.auth.onAuthStateChange(async (event,session) => { | ||
if (event === 'SIGNED_IN') { | ||
setCookie("Token", session?.access_token); | ||
setOpen(false); | ||
} | ||
}) | ||
|
||
return ( | ||
<Transition.Root show={open} as={Fragment}> | ||
<Dialog as="div" className="relative z-10" onClose={setOpen}> | ||
<Transition.Child | ||
as={Fragment} | ||
enter="ease-out duration-300" | ||
enterFrom="opacity-0" | ||
enterTo="opacity-100" | ||
leave="ease-in duration-200" | ||
leaveFrom="opacity-100" | ||
leaveTo="opacity-0" | ||
> | ||
<div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" /> | ||
</Transition.Child> | ||
|
||
<div className="fixed inset-0 z-10 overflow-y-auto"> | ||
<div className="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0"> | ||
<Transition.Child | ||
as={Fragment} | ||
enter="ease-out duration-300" | ||
enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95" | ||
enterTo="opacity-100 translate-y-0 sm:scale-100" | ||
leave="ease-in duration-200" | ||
leaveFrom="opacity-100 translate-y-0 sm:scale-100" | ||
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95" | ||
> | ||
<Dialog.Panel className="relative transform overflow-hidden rounded-lg bg-white px-4 pt-5 pb-4 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-sm sm:p-6"> | ||
<div> | ||
<div className="mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-green-100"> | ||
<CheckIcon className="h-6 w-6 text-green-600" aria-hidden="true" /> | ||
</div> | ||
<div className="mt-3 text-center sm:mt-5"> | ||
<Dialog.Title as="h3" className="text-lg font-medium leading-6 text-gray-900"> | ||
Login/Signup | ||
</Dialog.Title> | ||
<Auth | ||
supabaseClient={supabase} | ||
appearance={{ | ||
theme: ThemeSupa, | ||
variables: { | ||
default: { | ||
|
||
colors: { | ||
brand: '#F48B11', | ||
brandAccent: 'darkred', | ||
}, | ||
}, | ||
}, | ||
}} | ||
providers={['google']} | ||
|
||
/> | ||
</div> | ||
</div> | ||
<div className="mt-5 sm:mt-6"> | ||
<button | ||
type="button" | ||
className="inline-flex w-full justify-center rounded-md border border-transparent bg-primary-500 px-4 py-2 text-base font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:text-sm" | ||
onClick={() => setOpen(false)} | ||
> | ||
Back | ||
</button> | ||
</div> | ||
</Dialog.Panel> | ||
</Transition.Child> | ||
</div> | ||
<div className="fixed inset-0 z-10 overflow-y-auto"> | ||
<div className="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0"> | ||
<Transition.Child | ||
as={Fragment} | ||
enter="ease-out duration-300" | ||
enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95" | ||
enterTo="opacity-100 translate-y-0 sm:scale-100" | ||
leave="ease-in duration-200" | ||
leaveFrom="opacity-100 translate-y-0 sm:scale-100" | ||
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95" | ||
> | ||
<Dialog.Panel className="relative transform overflow-hidden rounded-lg bg-white px-4 pt-5 pb-4 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-sm sm:p-6"> | ||
<div> | ||
<div className="mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-green-100"> | ||
<CheckIcon | ||
className="h-6 w-6 text-green-600" | ||
aria-hidden="true" | ||
/> | ||
</div> | ||
<div className="mt-3 text-center sm:mt-5"> | ||
<Dialog.Title | ||
as="h3" | ||
className="text-lg font-medium leading-6 text-gray-900" | ||
> | ||
Login/Signup | ||
</Dialog.Title> | ||
<Auth | ||
supabaseClient={supabase} | ||
appearance={{ | ||
theme: ThemeSupa, | ||
variables: { | ||
default: { | ||
colors: { | ||
brand: "#F48B11", | ||
brandAccent: "darkred", | ||
}, | ||
}, | ||
}, | ||
}} | ||
providers={["google"]} | ||
/> | ||
</div> | ||
</div> | ||
<div className="mt-5 sm:mt-6"> | ||
<button | ||
type="button" | ||
className="inline-flex w-full justify-center rounded-md border border-transparent bg-primary-500 px-4 py-2 text-base font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:text-sm" | ||
onClick={() => setOpen(false)} | ||
> | ||
Back | ||
</button> | ||
</div> | ||
</Dialog> | ||
</Transition.Root> | ||
) | ||
</Dialog.Panel> | ||
</Transition.Child> | ||
</div> | ||
</div> | ||
</Dialog> | ||
</Transition.Root> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.