Refactor UI imports and update component paths
Some checks failed
Build Frontend / build (push) Failing after 7s
Some checks failed
Build Frontend / build (push) Failing after 7s
Replaces imports from 'components/ui' with 'components/common' across the app and dashboard pages, and updates model and API imports to use new paths under 'lib'. Removes redundant authentication checks from several dashboard pages. Adds new dashboard components and utility files, and reorganizes hooks and services into the 'lib' directory for improved structure.
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
import { useState, useEffect } from "react"
|
||||
import { motion } from "framer-motion"
|
||||
import { ShoppingBag, CreditCard, Truck, MessageSquare, AlertCircle } from "lucide-react"
|
||||
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card"
|
||||
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/common/card"
|
||||
import { clientFetch } from "@/lib/api"
|
||||
import { Skeleton } from "@/components/ui/skeleton"
|
||||
import { RelativeTime } from "@/components/ui/relative-time"
|
||||
import { Skeleton } from "@/components/common/skeleton"
|
||||
import { RelativeTime } from "@/components/common/relative-time"
|
||||
import Link from "next/link"
|
||||
import { OrderPeek } from "./order-peek"
|
||||
|
||||
interface ActivityItem {
|
||||
_id: string;
|
||||
@@ -21,6 +22,13 @@ interface ActivityItem {
|
||||
export default function RecentActivity() {
|
||||
const [activities, setActivities] = useState<ActivityItem[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [selectedOrderId, setSelectedOrderId] = useState<string | null>(null);
|
||||
const [isPeekOpen, setIsPeekOpen] = useState(false);
|
||||
|
||||
const handlePeek = (id: string) => {
|
||||
setSelectedOrderId(id);
|
||||
setIsPeekOpen(true);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchRecentOrders() {
|
||||
@@ -89,16 +97,19 @@ export default function RecentActivity() {
|
||||
className="flex items-start gap-4 relative"
|
||||
>
|
||||
{index !== activities.length - 1 && (
|
||||
<div className="absolute left-[15px] top-8 bottom-[-24px] w-[2px] bg-border/50" />
|
||||
<div className="absolute left-[17px] top-8 bottom-[-24px] w-[2px] bg-border/50" />
|
||||
)}
|
||||
<div className={`mt-1 p-2 rounded-full z-10 ${getStatusColor(item.status)}`}>
|
||||
{getStatusIcon(item.status)}
|
||||
</div>
|
||||
<div className="flex-1 space-y-1">
|
||||
<div className="flex items-center justify-between">
|
||||
<Link href={`/dashboard/orders/${item._id}`} className="font-medium hover:underline">
|
||||
<button
|
||||
onClick={() => handlePeek(item._id)}
|
||||
className="font-medium hover:text-primary transition-colors text-left"
|
||||
>
|
||||
Order #{item.orderId}
|
||||
</Link>
|
||||
</button>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
<RelativeTime date={item.orderDate} />
|
||||
</span>
|
||||
@@ -106,14 +117,21 @@ export default function RecentActivity() {
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{item.status === "paid" ? "Payment received" :
|
||||
item.status === "shipped" ? "Order marked as shipped" :
|
||||
`Order status: ${item.status}`} for £{item.totalPrice.toFixed(2)}
|
||||
`Order status: ${item.status}`}
|
||||
</p>
|
||||
</div>
|
||||
</motion.div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<OrderPeek
|
||||
orderId={selectedOrderId}
|
||||
open={isPeekOpen}
|
||||
onOpenChange={setIsPeekOpen}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user