mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-15 11:21:09 +02:00
- Restructure chat as apps/mobile, apps/web, apps/landing, backend - Add NestJS backend for secure Azure OpenAI API calls - Remove exposed API key from mobile app (security fix) - Add shared chat-types package - Create SvelteKit web app scaffold - Create Astro landing page scaffold - Update pnpm workspace configuration - Add project-level CLAUDE.md documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
50 lines
No EOL
1,022 B
TypeScript
50 lines
No EOL
1,022 B
TypeScript
import { useState } from 'react';
|
|
import { useAppTheme } from '../theme/ThemeProvider';
|
|
|
|
interface UseChatInputProps {
|
|
onSend: (message: string) => void;
|
|
isLoading?: boolean;
|
|
initialText?: string;
|
|
placeholder?: string;
|
|
maxLength?: number;
|
|
}
|
|
|
|
interface UseChatInputReturn {
|
|
text: string;
|
|
setText: (text: string) => void;
|
|
handleSend: () => void;
|
|
canSend: boolean;
|
|
isLoading: boolean;
|
|
isDarkMode: boolean;
|
|
placeholder: string;
|
|
}
|
|
|
|
export default function useChatInput({
|
|
onSend,
|
|
isLoading = false,
|
|
initialText = '',
|
|
placeholder = 'Nachricht eingeben...',
|
|
maxLength = 1000,
|
|
}: UseChatInputProps): UseChatInputReturn {
|
|
const [text, setText] = useState(initialText);
|
|
const { isDarkMode } = useAppTheme();
|
|
|
|
const canSend = text.trim().length > 0 && !isLoading;
|
|
|
|
const handleSend = () => {
|
|
if (canSend) {
|
|
onSend(text.trim());
|
|
setText('');
|
|
}
|
|
};
|
|
|
|
return {
|
|
text,
|
|
setText,
|
|
handleSend,
|
|
canSend,
|
|
isLoading,
|
|
isDarkMode,
|
|
placeholder,
|
|
};
|
|
} |