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:
@@ -7,9 +7,9 @@ import {
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
} from "@/components/common/card";
|
||||
import { Button } from "@/components/common/button";
|
||||
import { useToast } from "@/lib/hooks/use-toast";
|
||||
import { RefreshCw } from "lucide-react";
|
||||
import {
|
||||
getGrowthAnalyticsWithStore,
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
ResponsiveContainer,
|
||||
Area,
|
||||
} from "recharts";
|
||||
import { formatGBP, formatNumber } from "@/lib/utils/format";
|
||||
|
||||
interface GrowthAnalyticsChartProps {
|
||||
hideNumbers?: boolean;
|
||||
@@ -63,14 +64,6 @@ export default function GrowthAnalyticsChart({
|
||||
fetchGrowthData();
|
||||
};
|
||||
|
||||
const formatCurrency = (value: number) => {
|
||||
if (hideNumbers) return "£***";
|
||||
return new Intl.NumberFormat("en-GB", {
|
||||
style: "currency",
|
||||
currency: "GBP",
|
||||
maximumFractionDigits: 0,
|
||||
}).format(value);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
@@ -115,9 +108,7 @@ export default function GrowthAnalyticsChart({
|
||||
Total Orders
|
||||
</div>
|
||||
<div className="text-2xl font-bold">
|
||||
{hideNumbers
|
||||
? "***"
|
||||
: growthData.cumulative.orders.toLocaleString()}
|
||||
{hideNumbers ? "***" : formatNumber(growthData.cumulative.orders)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -127,7 +118,7 @@ export default function GrowthAnalyticsChart({
|
||||
Total Revenue
|
||||
</div>
|
||||
<div className="text-2xl font-bold text-green-600">
|
||||
{formatCurrency(growthData.cumulative.revenue)}
|
||||
{hideNumbers ? "£***" : formatGBP(growthData.cumulative.revenue)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -137,9 +128,7 @@ export default function GrowthAnalyticsChart({
|
||||
Customers
|
||||
</div>
|
||||
<div className="text-2xl font-bold">
|
||||
{hideNumbers
|
||||
? "***"
|
||||
: growthData.cumulative.customers.toLocaleString()}
|
||||
{hideNumbers ? "***" : formatNumber(growthData.cumulative.customers)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -149,9 +138,7 @@ export default function GrowthAnalyticsChart({
|
||||
Products
|
||||
</div>
|
||||
<div className="text-2xl font-bold">
|
||||
{hideNumbers
|
||||
? "***"
|
||||
: growthData.cumulative.products.toLocaleString()}
|
||||
{hideNumbers ? "***" : formatNumber(growthData.cumulative.products)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -161,7 +148,7 @@ export default function GrowthAnalyticsChart({
|
||||
Avg Order Value
|
||||
</div>
|
||||
<div className="text-2xl font-bold">
|
||||
{formatCurrency(growthData.cumulative.avgOrderValue)}
|
||||
{hideNumbers ? "£***" : formatGBP(growthData.cumulative.avgOrderValue)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -236,16 +223,16 @@ export default function GrowthAnalyticsChart({
|
||||
Orders:{" "}
|
||||
{hideNumbers
|
||||
? "***"
|
||||
: data.orders.toLocaleString()}
|
||||
: formatNumber(data.orders)}
|
||||
</p>
|
||||
<p className="text-sm text-green-600">
|
||||
Revenue: {formatCurrency(data.revenue)}
|
||||
Revenue: {hideNumbers ? "£***" : formatGBP(data.revenue)}
|
||||
</p>
|
||||
<p className="text-sm text-purple-600">
|
||||
Customers:{" "}
|
||||
{hideNumbers
|
||||
? "***"
|
||||
: data.customers.toLocaleString()}
|
||||
: formatNumber(data.customers)}
|
||||
</p>
|
||||
{data.newCustomers !== undefined && (
|
||||
<p className="text-sm text-cyan-600">
|
||||
@@ -327,16 +314,16 @@ export default function GrowthAnalyticsChart({
|
||||
)}
|
||||
</td>
|
||||
<td className="text-right p-2">
|
||||
{hideNumbers ? "***" : month.orders.toLocaleString()}
|
||||
{hideNumbers ? "***" : formatNumber(month.orders)}
|
||||
</td>
|
||||
<td className="text-right p-2 text-green-600">
|
||||
{formatCurrency(month.revenue)}
|
||||
{hideNumbers ? "£***" : formatGBP(month.revenue)}
|
||||
</td>
|
||||
<td className="text-right p-2">
|
||||
{hideNumbers ? "***" : month.customers.toLocaleString()}
|
||||
{hideNumbers ? "***" : formatNumber(month.customers)}
|
||||
</td>
|
||||
<td className="text-right p-2">
|
||||
{formatCurrency(month.avgOrderValue)}
|
||||
{hideNumbers ? "£***" : formatGBP(month.avgOrderValue)}
|
||||
</td>
|
||||
<td className="text-right p-2">
|
||||
{hideNumbers ? "***" : (month.newCustomers ?? 0)}
|
||||
@@ -352,3 +339,5 @@ export default function GrowthAnalyticsChart({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user