This commit is contained in:
2025-05-21 08:52:33 +03:00
parent e992d388fb
commit 4e5fca2402
68 changed files with 358 additions and 1398 deletions

View File

@@ -7,12 +7,7 @@ import type { Uuid } from "~/lib/api/types"; // Adjust path
import { cn, formatFileSize } from "~/lib/utils"; // Adjust path
import TextBox from "./custom-ui/text-box"; // Adjust path, assuming TextBox is in ./custom-ui/
import { Button } from "./ui/button"; // Adjust path
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "./ui/tooltip"; // Adjust path
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./ui/tooltip"; // Adjust path
export interface MessageBoxProps {
channelId: string;
@@ -87,8 +82,7 @@ export default function MessageBox({ channelId }: MessageBoxProps) {
setTimeout(() => textBoxRef.current?.focus(), 0);
}, [channelId]);
const canSend =
(text.trim().length > 0 || attachments.length > 0) && !isLoading;
const canSend = (text.trim().length > 0 || attachments.length > 0) && !isLoading;
const attachmentsRemaining = 10 - attachments.length;
return (
@@ -100,17 +94,10 @@ export default function MessageBox({ channelId }: MessageBoxProps) {
key={`${file.name}-${file.lastModified}-${i}`}
className="flex items-center gap-2.5 rounded-md border bg-card p-2 text-sm shadow-sm"
>
<FileIcon
contentType={file.type}
className="h-7 w-7 flex-shrink-0 text-muted-foreground"
/>
<FileIcon contentType={file.type} className="h-7 w-7 flex-shrink-0 text-muted-foreground" />
<div className="min-w-0 flex-1">
<p className="truncate font-medium text-card-foreground">
{file.name}
</p>
<p className="text-xs text-muted-foreground">
{formatFileSize(file.size)}
</p>
<p className="truncate font-medium text-card-foreground">{file.name}</p>
<p className="text-xs text-muted-foreground">{formatFileSize(file.size)}</p>
</div>
<TooltipProvider delayDuration={100}>
<Tooltip>
@@ -164,9 +151,7 @@ export default function MessageBox({ channelId }: MessageBoxProps) {
size="icon"
variant="ghost"
onClick={addAttachment}
disabled={
attachments.length >= 10 || isLoading
}
disabled={attachments.length >= 10 || isLoading}
aria-label="Add attachment"
>
<Paperclip className="h-5 w-5" />
@@ -177,10 +162,7 @@ export default function MessageBox({ channelId }: MessageBoxProps) {
{attachments.length >= 10 ? (
<p>Maximum 10 attachments</p>
) : (
<p>
Add attachment ({attachmentsRemaining}{" "}
remaining)
</p>
<p>Add attachment ({attachmentsRemaining} remaining)</p>
)}
</TooltipContent>
</Tooltip>
@@ -207,11 +189,7 @@ export default function MessageBox({ channelId }: MessageBoxProps) {
disabled={!canSend}
aria-label="Send message"
>
{isLoading ? (
<Loader2 className="h-5 w-5 animate-spin" />
) : (
<Send className="h-5 w-5" />
)}
{isLoading ? <Loader2 className="h-5 w-5 animate-spin" /> : <Send className="h-5 w-5" />}
</Button>
</div>
</div>