-
Notifications
You must be signed in to change notification settings - Fork 278
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
Showing
3 changed files
with
101 additions
and
22 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
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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { useSearchParams } from '@remix-run/react' | ||
import { useState, type ReactNode } from 'react' | ||
import { useRoomContext } from '~/hooks/useRoomContext' | ||
import type { ClientMessage } from '~/types/Messages' | ||
import { Button } from './Button' | ||
import { Dialog, DialogContent, DialogOverlay, Portal } from './Dialog' | ||
|
||
export function InviteAiDialog(props: { children?: ReactNode }) { | ||
const [open, setOpen] = useState(false) | ||
|
||
const { | ||
room: { websocket }, | ||
} = useRoomContext() | ||
|
||
const [params] = useSearchParams() | ||
|
||
const instructions = params.get('instructions') | ||
const voice = params.get('voice') | ||
|
||
return ( | ||
<Dialog open={open} onOpenChange={setOpen}> | ||
{props.children} | ||
<Portal> | ||
<DialogOverlay /> | ||
<DialogContent> | ||
<form | ||
className="flex flex-col gap-4 mt-8" | ||
onSubmit={(e) => { | ||
e.preventDefault() | ||
websocket.send( | ||
JSON.stringify({ | ||
type: 'enableAi', | ||
...Object.fromEntries(new FormData(e.currentTarget)), | ||
} satisfies ClientMessage) | ||
) | ||
setOpen(false) | ||
}} | ||
> | ||
<div className="flex flex-col gap-2"> | ||
<div> | ||
<label className="font-medium" htmlFor="instructions"> | ||
Instructions | ||
</label> | ||
</div> | ||
|
||
<div> | ||
<textarea | ||
className="bg-gray-100 dark:bg-zinc-800 w-full" | ||
id="instructions" | ||
name="instructions" | ||
rows={15} | ||
defaultValue={ | ||
instructions ?? | ||
'You are a helpful AI assistant for a video chat application called Orange Meets' | ||
} | ||
/> | ||
</div> | ||
</div> | ||
<div className="flex flex-col gap-2"> | ||
<div> | ||
<label className="font-medium" htmlFor="voice"> | ||
Voice | ||
</label> | ||
</div> | ||
|
||
<div> | ||
<select | ||
className="bg-gray-100 dark:bg-zinc-800 w-full" | ||
id="voice" | ||
name="voice" | ||
defaultValue={voice ?? 'ash'} | ||
> | ||
<option value="ash">Ash</option> | ||
<option value="ballad">Ballad</option> | ||
</select> | ||
</div> | ||
</div> | ||
|
||
<Button type="submit" className="self-end text-xs"> | ||
Invite AI | ||
</Button> | ||
</form> | ||
</DialogContent> | ||
</Portal> | ||
</Dialog> | ||
) | ||
} |