mirror of
https://github.com/bitbaum/causius.git
synced 2026-12-03 20:07:44 +01:00
A shared TextBox wraps DictationField with the app's transcription route, the reader's language and the speech note the composer already shows. It replaces the letter text and title on the new-case page, the document-review questions, the request to a helper, a helper's headline and bio, and the reviewer's note on a credential. Claude-Session: https://claude.ai/code/session_019MDtmvMF3FdDhEarp43f78 Co-authored-by: Claude <noreply@anthropic.com>
80 lines
2.2 KiB
TypeScript
80 lines
2.2 KiB
TypeScript
"use client";
|
|
|
|
import { DictationField, type DictationFieldProps } from "@bitbaum/chatkit/react";
|
|
import "@bitbaum/chatkit/styles.css";
|
|
import { useTranslations } from "next-intl";
|
|
import { Link } from "@/i18n/navigation";
|
|
import { API, ROUTES } from "@/lib/routes";
|
|
|
|
/**
|
|
* Every place a person types words that is not a conversation: chatkit's
|
|
* DictationField, so the microphone, the 16px text and the take-back are the
|
|
* package's. Speech goes to /api/transcribe, and — as in the composer — the
|
|
* field says before the first take that a voice cannot be anonymised.
|
|
*/
|
|
export function TextBox({
|
|
hint,
|
|
voice,
|
|
voiceNote = true,
|
|
...props
|
|
}: DictationFieldProps & {
|
|
/** `false` where the page shows `<VoiceNote />` once for several fields. */
|
|
voiceNote?: boolean;
|
|
}) {
|
|
const t = useTranslations("Chat");
|
|
const speaks = voice !== false && voiceNote;
|
|
return (
|
|
<DictationField
|
|
{...props}
|
|
voice={voice === false ? false : (voice ?? { transcribeUrl: API.transcribe, prefer: "server" })}
|
|
hint={
|
|
hint || speaks ? (
|
|
<>
|
|
{hint}
|
|
{hint && speaks ? " " : null}
|
|
{speaks && <VoiceNoteWords />}
|
|
</>
|
|
) : undefined
|
|
}
|
|
labels={{
|
|
voice: t("voice"),
|
|
voiceStop: t("voiceStop"),
|
|
cancelRecording: t("cancelRecording"),
|
|
confirmRecording: t("confirmRecording"),
|
|
listening: t("listening"),
|
|
transcribing: t("transcribing"),
|
|
dismiss: t("dismiss"),
|
|
retryTake: t("retryTake"),
|
|
dictation: {
|
|
mic: t("dictMic"),
|
|
silence: t("dictSilence"),
|
|
unavailable: t("dictUnavailable"),
|
|
fileTooLarge: t("dictFileTooLarge"),
|
|
},
|
|
...props.labels,
|
|
}}
|
|
/>
|
|
);
|
|
}
|
|
|
|
function VoiceNoteWords() {
|
|
const t = useTranslations("Chat");
|
|
return (
|
|
<>
|
|
{t("voiceNote")}{" "}
|
|
<Link href={ROUTES.security} className="text-link">
|
|
{t("voiceWhy")}
|
|
</Link>
|
|
</>
|
|
);
|
|
}
|
|
|
|
/** The speech note, once, under a group of fields that each pass `voiceNote={false}`. */
|
|
export function VoiceNote() {
|
|
return (
|
|
<p className="text-xs text-fg-secondary">
|
|
<VoiceNoteWords />
|
|
</p>
|
|
);
|
|
}
|