develop #3

Merged
behnam merged 39 commits from develop into main 2024-11-26 15:47:00 +00:00
3 changed files with 18 additions and 9 deletions
Showing only changes of commit 22e97cf74f - Show all commits

View File

@ -1,7 +1,7 @@
import { LatestInvoicesSkeleton, RevenueChartSkeleton } from "@/app/dashboard/components/skeletons/skeletons"; import { LatestInvoicesSkeleton, RevenueChartSkeleton } from "@/app/dashboard/components/skeletons/skeletons";
import CardWrapper from "@/app/dashboard/components/cards/cards"; import CardWrapper from "@/app/dashboard/components/cards/cards";
import LatestInvoices from "@/app/dashboard/components/latest-invoices"; import LatestInvoices from "@/app/dashboard/components/latest-invoices";
import RevenueChart from "@/app/dashboard/components/revenue-chart"; import RevenueChart from "@/app/dashboard/components/revenue-chart/revenue-chart";
import { Suspense } from "react"; import { Suspense } from "react";
export default async function Dashboard() { export default async function Dashboard() {

View File

@ -1,7 +1,21 @@
import Revenue from "@/feature/core/revenue/domain/entity/revenue"; import Revenue from "@/feature/core/revenue/domain/entity/revenue";
import fetchRevenuesUsecase from "@/feature/core/revenue/domain/usecase/fetch-revenues-usecase";
export default async function revenueChartController() {
const revenue = await fetchRevenuesUsecase();
const chartHeight = 350;
export const generateYAxis = (revenue: Revenue[]) => { const { yAxisLabels, topLabel } = generateYAxis(revenue);
return {
revenue,
chartHeight,
yAxisLabels,
topLabel
}
}
function generateYAxis(revenue: Revenue[]) {
// Calculate what labels we need to display on the y-axis // Calculate what labels we need to display on the y-axis
// based on highest record and in 1000s // based on highest record and in 1000s
const yAxisLabels = []; const yAxisLabels = [];

View File

@ -1,13 +1,8 @@
import { generateYAxis } from '@/app/lib/utils'; import revenueChartController from '@/app/dashboard/components/revenue-chart/revenue-chart-controller';
import fetchRevenuesUsecase from '@/feature/core/revenue/domain/usecase/fetch-revenues-usecase';
import { CalendarIcon } from '@heroicons/react/24/outline'; import { CalendarIcon } from '@heroicons/react/24/outline';
export default async function RevenueChart() { export default async function RevenueChart() {
const revenue = await fetchRevenuesUsecase(); const { chartHeight, revenue, topLabel, yAxisLabels } = await revenueChartController()
const chartHeight = 350;
const { yAxisLabels, topLabel } = generateYAxis(revenue);
if (!revenue || revenue.length === 0) { if (!revenue || revenue.length === 0) {
return <p className="mt-4 text-gray-400">No data available.</p>; return <p className="mt-4 text-gray-400">No data available.</p>;