FIX
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
@@ -14,12 +14,21 @@ import { getCookie } from "@/lib/client-utils";
|
||||
|
||||
export default function NewChatForm() {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const [buyerId, setBuyerId] = useState("");
|
||||
const [initialMessage, setInitialMessage] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [vendorStores, setVendorStores] = useState<{ _id: string, name: string }[]>([]);
|
||||
const [selectedStore, setSelectedStore] = useState<string>("");
|
||||
|
||||
// Parse URL parameters for buyerId
|
||||
useEffect(() => {
|
||||
const buyerIdParam = searchParams.get('buyerId');
|
||||
if (buyerIdParam) {
|
||||
setBuyerId(buyerIdParam);
|
||||
}
|
||||
}, [searchParams]);
|
||||
|
||||
// Fetch vendor stores
|
||||
useEffect(() => {
|
||||
const fetchVendorStores = async () => {
|
||||
|
||||
@@ -9,8 +9,6 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/com
|
||||
import { ShoppingCart } from "lucide-react"
|
||||
import { ArrowUpCircle, CreditCard, DollarSign, Users } from "lucide-react"
|
||||
import { Skeleton } from "@/components/ui/skeleton"
|
||||
import { OrderStats as DashboardOrderStats } from "@/components/dashboard/order-stats"
|
||||
import OrderStatsData from "@/types/orderStats"
|
||||
|
||||
interface ContentProps {
|
||||
username: string
|
||||
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
ChevronRight,
|
||||
ArrowUpDown,
|
||||
Truck,
|
||||
MessageCircle
|
||||
} from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { clientFetch } from '@/lib/client-utils';
|
||||
@@ -51,6 +52,7 @@ interface Order {
|
||||
totalPrice: number;
|
||||
orderDate: Date;
|
||||
telegramUsername?: string;
|
||||
telegramBuyerId?: string;
|
||||
}
|
||||
|
||||
type SortableColumns = "orderId" | "totalPrice" | "status" | "orderDate";
|
||||
@@ -411,11 +413,26 @@ export default function OrderTable() {
|
||||
{order.telegramUsername ? `@${order.telegramUsername}` : "-"}
|
||||
</TableCell>
|
||||
<TableCell className="text-center">
|
||||
<Button variant="ghost" size="sm" className="mx-auto" asChild>
|
||||
<Link href={`/dashboard/orders/${order._id}`}>
|
||||
<Eye className="h-4 w-4" />
|
||||
</Link>
|
||||
</Button>
|
||||
<div className="flex items-center justify-center gap-1">
|
||||
<Button variant="ghost" size="sm" asChild>
|
||||
<Link href={`/dashboard/orders/${order._id}`}>
|
||||
<Eye className="h-4 w-4" />
|
||||
</Link>
|
||||
</Button>
|
||||
|
||||
{(order.telegramBuyerId || order.telegramUsername) && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
asChild
|
||||
title={`Chat with customer${order.telegramUsername ? ` @${order.telegramUsername}` : ''}`}
|
||||
>
|
||||
<Link href={`/dashboard/chats/new?buyerId=${order.telegramBuyerId || order.telegramUsername}`}>
|
||||
<MessageCircle className="h-4 w-4 text-primary" />
|
||||
</Link>
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user