"use client" import { AlertTriangle, CheckCircle2, MessageSquare, RefreshCw, Star, XCircle } from "lucide-react" import Link from "next/link" import { useEffect, useState } from "react" import { Button } from "@/components/ui/button" import { notifySuccess } from "@/lib/toast" import type { OrderStatus } from "@/lib/types" import { useChatStore } from "@/store/chat" import { useOrderStore } from "@/store/orders" interface OrderActionsProps { orderId: string initialStatus: OrderStatus chatSessionId?: string serviceId: string } function showFeedback(message: string) { notifySuccess(message) } export default function OrderActions({ orderId, initialStatus, chatSessionId, serviceId, }: OrderActionsProps) { const order = useOrderStore((state) => state.orders.find((item) => item.id === orderId)) const updateOrderStatus = useOrderStore((state) => state.updateOrderStatus) const ensureOrderSession = useChatStore((state) => state.ensureOrderSession) const [resolvedChatSessionId, setResolvedChatSessionId] = useState(chatSessionId) const status = order?.status ?? initialStatus useEffect(() => { if (chatSessionId) { setResolvedChatSessionId(chatSessionId) return } if (!order) return const session = ensureOrderSession(order) setResolvedChatSessionId(session.id) }, [chatSessionId, order, ensureOrderSession]) return (