This commit is contained in:
NotII
2025-03-06 09:24:43 +00:00
parent 0523588c53
commit e26069abfa
3 changed files with 32 additions and 8 deletions

View File

@@ -1,7 +1,7 @@
"use client" "use client"
import React, { useState, useEffect } from "react"; 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 { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
@@ -14,12 +14,21 @@ import { getCookie } from "@/lib/client-utils";
export default function NewChatForm() { export default function NewChatForm() {
const router = useRouter(); const router = useRouter();
const searchParams = useSearchParams();
const [buyerId, setBuyerId] = useState(""); const [buyerId, setBuyerId] = useState("");
const [initialMessage, setInitialMessage] = useState(""); const [initialMessage, setInitialMessage] = useState("");
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [vendorStores, setVendorStores] = useState<{ _id: string, name: string }[]>([]); const [vendorStores, setVendorStores] = useState<{ _id: string, name: string }[]>([]);
const [selectedStore, setSelectedStore] = useState<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 // Fetch vendor stores
useEffect(() => { useEffect(() => {
const fetchVendorStores = async () => { const fetchVendorStores = async () => {

View File

@@ -9,8 +9,6 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/com
import { ShoppingCart } from "lucide-react" import { ShoppingCart } from "lucide-react"
import { ArrowUpCircle, CreditCard, DollarSign, Users } from "lucide-react" import { ArrowUpCircle, CreditCard, DollarSign, Users } from "lucide-react"
import { Skeleton } from "@/components/ui/skeleton" import { Skeleton } from "@/components/ui/skeleton"
import { OrderStats as DashboardOrderStats } from "@/components/dashboard/order-stats"
import OrderStatsData from "@/types/orderStats"
interface ContentProps { interface ContentProps {
username: string username: string

View File

@@ -27,6 +27,7 @@ import {
ChevronRight, ChevronRight,
ArrowUpDown, ArrowUpDown,
Truck, Truck,
MessageCircle
} from "lucide-react"; } from "lucide-react";
import Link from "next/link"; import Link from "next/link";
import { clientFetch } from '@/lib/client-utils'; import { clientFetch } from '@/lib/client-utils';
@@ -51,6 +52,7 @@ interface Order {
totalPrice: number; totalPrice: number;
orderDate: Date; orderDate: Date;
telegramUsername?: string; telegramUsername?: string;
telegramBuyerId?: string;
} }
type SortableColumns = "orderId" | "totalPrice" | "status" | "orderDate"; type SortableColumns = "orderId" | "totalPrice" | "status" | "orderDate";
@@ -411,11 +413,26 @@ export default function OrderTable() {
{order.telegramUsername ? `@${order.telegramUsername}` : "-"} {order.telegramUsername ? `@${order.telegramUsername}` : "-"}
</TableCell> </TableCell>
<TableCell className="text-center"> <TableCell className="text-center">
<Button variant="ghost" size="sm" className="mx-auto" asChild> <div className="flex items-center justify-center gap-1">
<Link href={`/dashboard/orders/${order._id}`}> <Button variant="ghost" size="sm" asChild>
<Eye className="h-4 w-4" /> <Link href={`/dashboard/orders/${order._id}`}>
</Link> <Eye className="h-4 w-4" />
</Button> </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> </TableCell>
</TableRow> </TableRow>
); );