managarten/chat/apps/mobile/hooks/useChatInput.ts
Till-JS c638a7ffee feat(chat): integrate chat project into monorepo with full app structure
- 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>
2025-11-25 13:48:24 +01:00

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,
};
}