- Rewrite prisma/seed.ts to populate all 27 models with realistic Vietnamese real estate data (8 users with login, 10 properties, 10 listings, orders, payments, reviews, notifications, etc.) - Replace all emoji icons with Lucide React SVG icons across frontend for consistent rendering, sizing, and accessibility - Redesign dashboard nav: grouped sidebar with section headers, primary/secondary split on desktop, icon-only secondary items - Replace language switcher flag emoji with Globe icon - Replace SVG theme toggle with Lucide Moon/Sun icons - Fix API startup: graceful fallback for Sentry profiling, Google OAuth, and Zalo OAuth when credentials are not configured - Relax rate limiting in development mode (10k req/min) - Fix listings API to include media[] array in search response - Add optional chaining for property.media across frontend components - Update OAuth strategy tests to match graceful fallback behavior Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
112 lines
3.7 KiB
TypeScript
112 lines
3.7 KiB
TypeScript
'use client';
|
|
|
|
import { MessageCircle, Phone } from 'lucide-react';
|
|
import { InquiryStatusBadge } from '@/components/inquiries/inquiry-row';
|
|
import { Button } from '@/components/ui/button';
|
|
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogDescription,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
} from '@/components/ui/dialog';
|
|
import { useMarkInquiryRead } from '@/lib/hooks/use-inquiries';
|
|
import type { InquiryReadDto } from '@/lib/inquiries-api';
|
|
|
|
interface InquiryDetailDialogProps {
|
|
inquiry: InquiryReadDto | null;
|
|
open: boolean;
|
|
onOpenChange: (open: boolean) => void;
|
|
}
|
|
|
|
export function InquiryDetailDialog({ inquiry, open, onOpenChange }: InquiryDetailDialogProps) {
|
|
const markAsRead = useMarkInquiryRead();
|
|
|
|
if (!inquiry) return null;
|
|
|
|
const handleMarkRead = () => {
|
|
markAsRead.mutate(inquiry.id, {
|
|
onSuccess: () => {
|
|
onOpenChange(false);
|
|
},
|
|
});
|
|
};
|
|
|
|
const formattedDate = new Date(inquiry.createdAt).toLocaleDateString('vi-VN', {
|
|
weekday: 'long',
|
|
day: '2-digit',
|
|
month: '2-digit',
|
|
year: 'numeric',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
});
|
|
|
|
return (
|
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
<DialogContent className="max-w-md sm:max-w-lg">
|
|
<DialogHeader>
|
|
<DialogTitle>Chi tiết liên hệ</DialogTitle>
|
|
<DialogDescription>
|
|
{inquiry.listingTitle}
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
|
|
<div className="space-y-4 py-2">
|
|
{/* Contact info */}
|
|
<div className="rounded-lg border p-4 space-y-2">
|
|
<div className="flex items-center justify-between">
|
|
<span className="text-sm font-medium">{inquiry.userName}</span>
|
|
<InquiryStatusBadge isRead={inquiry.isRead} />
|
|
</div>
|
|
<div className="space-y-1 text-sm text-muted-foreground">
|
|
<p>SĐT: {inquiry.phone ?? inquiry.userPhone}</p>
|
|
<p>Ngày gửi: {formattedDate}</p>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Message */}
|
|
<div className="space-y-1.5">
|
|
<h4 className="text-sm font-medium">Nội dung</h4>
|
|
<div className="rounded-lg bg-muted p-3 text-sm leading-relaxed">
|
|
{inquiry.message}
|
|
</div>
|
|
</div>
|
|
|
|
{/* Quick actions */}
|
|
<div className="space-y-1.5">
|
|
<h4 className="text-sm font-medium">Liên hệ nhanh</h4>
|
|
<div className="flex flex-wrap gap-2">
|
|
<a
|
|
href={`tel:${inquiry.phone ?? inquiry.userPhone}`}
|
|
className="inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-sm transition-colors hover:bg-accent"
|
|
>
|
|
<Phone className="h-4 w-4" aria-hidden="true" /> Gọi điện
|
|
</a>
|
|
<a
|
|
href={`https://zalo.me/${(inquiry.phone ?? inquiry.userPhone).replace(/^0/, '84')}`}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-sm transition-colors hover:bg-accent"
|
|
>
|
|
<MessageCircle className="h-4 w-4" aria-hidden="true" /> Zalo
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<DialogFooter>
|
|
<Button variant="outline" onClick={() => onOpenChange(false)}>
|
|
Đóng
|
|
</Button>
|
|
{!inquiry.isRead && (
|
|
<Button onClick={handleMarkRead} disabled={markAsRead.isPending}>
|
|
{markAsRead.isPending ? 'Đang xử lý...' : 'Đánh dấu đã đọc'}
|
|
</Button>
|
|
)}
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
}
|