Skip to content

Commit

Permalink
Opens new chat when language changed (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad authored Jan 11, 2024
1 parent 71f2b0b commit 7be3ac0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export default function Chat(params: {
onAudio={handleAudio}
errors={[(converseMutation.error as any)?.error?.error]}
loading={converseMutation.isLoading || isTyping}
projectId={project_id}
/>
<p className="text-xs pl-0.5 text-center text-gray-500">
{" "}
Expand Down
1 change: 1 addition & 0 deletions src/app/(main)/project/[project_id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export default function Chat(params: { params: { project_id: string } }) {
loading={
newChatMutation.isLoading || converseMutation.isLoading || isTyping
}
projectId={project_id}
/>
<p className="text-xs pl-0.5 text-center text-gray-500">
{process.env.NEXT_PUBLIC_AI_WARNING}
Expand Down
4 changes: 2 additions & 2 deletions src/app/admin/tests/[testsuite_id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,8 @@ export default function Page({ params }: { params: { testsuite_id: string } }) {
currentQuestion.question,
currentQuestion.human_answer,
currentQuestion.language,
)
}
);
}}
>
Save
</Button>
Expand Down
11 changes: 9 additions & 2 deletions src/components/chatbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { storageAtom } from "@/store";
import { useAtom } from "jotai";
import Modal from "./modal";
import { useAudioRecorder } from "./recorder";
import { useRouter } from "next/navigation";

export default function ChatBar(props: {
chat: string;
Expand All @@ -15,8 +16,11 @@ export default function ChatBar(props: {
onAudio: (blobUrl: string) => void;
errors: string[];
loading?: boolean;
projectId: string;
}) {
const { chat, onChange, onSubmit, errors, loading, onAudio } = props;
const { chat, onChange, onSubmit, errors, loading, onAudio, projectId } =
props;
const router = useRouter();

const [storage, setStorage] = useAtom(storageAtom);
const { status, startRecording, stopRecording } = useAudioRecorder(onAudio);
Expand Down Expand Up @@ -77,7 +81,10 @@ export default function ChatBar(props: {
<br />
<select
value={storage?.language || "en"}
onChange={(e) => setStorage({ ...storage, language: e.target.value })}
onChange={(e) => {
setStorage({ ...storage, language: e.target.value });
router.push(`/project/${projectId}`);
}}
className="block w-full bg-white border border-gray-400 hover:border-gray-500 px-4 py-2 rounded leading-tight focus:outline-none focus:shadow-outline-blue focus:border-green-500 transition duration-150 ease-in-out sm:text-sm sm:leading-5"
>
{supportedLanguages.map((language) => (
Expand Down

1 comment on commit 7be3ac0

@vercel
Copy link

@vercel vercel bot commented on 7be3ac0 Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.