feat: add currency support to CardReport and update dashboard data structure

This commit is contained in:
fredy.siswanto 2025-03-03 21:17:46 +07:00
parent 030de2c2dd
commit 1538869e49
5 changed files with 28 additions and 24 deletions

View File

@ -5,6 +5,7 @@ import { formatNumberWithPeriods } from '~/utils/formatter'
type CardReportProperty = { type CardReportProperty = {
title: string title: string
amount: number amount: number
currency?: string
icon: ( icon: (
properties: React.JSX.IntrinsicAttributes & React.SVGProps<SVGSVGElement>, properties: React.JSX.IntrinsicAttributes & React.SVGProps<SVGSVGElement>,
) => JSX.Element ) => JSX.Element
@ -13,7 +14,7 @@ type CardReportProperty = {
} }
export const CardReport = (properties: CardReportProperty) => { export const CardReport = (properties: CardReportProperty) => {
const { title, amount, icon: Icon, counter } = properties const { title, amount, icon: Icon, counter, currency } = properties
return ( return (
<div className="rounded bg-white px-4 py-6 shadow-sm"> <div className="rounded bg-white px-4 py-6 shadow-sm">
<div className="flex items-center"> <div className="flex items-center">
@ -22,15 +23,17 @@ export const CardReport = (properties: CardReportProperty) => {
height={48} height={48}
width={48} width={48}
/> />
<div className="ml-10"> <div className="ml-7">
<h2 className="text-lg font-semibold">{title}</h2> <h2 className="text-lg font-semibold">{title}</h2>
<p className="text-2xl font-bold text-[#2E2F7C]"> <p className="text-2xl font-bold text-[#2E2F7C]">
Rp. {formatNumberWithPeriods(amount)} {currency
? `${currency} ${formatNumberWithPeriods(amount)}`
: formatNumberWithPeriods(amount)}
</p> </p>
</div> </div>
</div> </div>
{counter?.length && ( {counter?.length && (
<div className="flex items-center"> <div className="flex items-center pt-2">
Pribadi: {counter[0]} | Perusahaan: {counter[1]} Pribadi: {counter[0]} | Perusahaan: {counter[1]}
</div> </div>
)} )}

View File

@ -215,7 +215,7 @@ export const ChartSubscription = () => {
<div className="rounded-xl bg-white p-6 shadow-lg"> <div className="rounded-xl bg-white p-6 shadow-lg">
<h2 className="mb-4 text-[20px]">Subscription Selesai</h2> <h2 className="mb-4 text-[20px]">Subscription Selesai</h2>
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<div style={{ height: '200px', width: '100%' }}> <div style={{ height: 'auto', width: '100%' }}>
<Doughnut <Doughnut
data={data} data={data}
options={options} options={options}

View File

@ -2,8 +2,7 @@ import { MENU as ADMIN_MENU } from '~/layouts/admin/menu'
export const APP = { export const APP = {
title: 'LegalGo', title: 'LegalGo',
description: description: 'Legalgo Platform Berita Dunia dan Indonesia.',
'Bonus judex secundum aequum et\n bonum judicat et aequitatem stricto juri praefert',
logo: '/images/logo.png', logo: '/images/logo.png',
} }

View File

@ -2,20 +2,25 @@ import { DoctorIcon } from '~/components/icons/doctor'
import { GraphIcon } from '~/components/icons/graph' import { GraphIcon } from '~/components/icons/graph'
export const REPORT = [ export const REPORT = [
{ title: 'Total Transaksi', amount: 10_800_000_000, icon: GraphIcon }, { title: 'Total User', amount: 10_800, icon: GraphIcon },
{ title: 'Transaksi Tertagih', amount: 2_000_000, icon: GraphIcon }, { title: 'Total User Subscribe', amount: 5000, icon: GraphIcon },
{ title: 'Transaksi Tertagih', amount: 2_000_000, icon: GraphIcon }, {
title: 'Total Nilai Subscribe',
amount: 250_000_000,
icon: GraphIcon,
currency: 'Rp. ',
},
] ]
export const HISTORY = [ export const HISTORY = [
{ {
title: 'Total Kunjungan', title: 'Total Content Biasa',
amount: 2890, amount: 2890,
icon: GraphIcon, icon: GraphIcon,
counter: [2190, 700], counter: [2190, 700],
}, },
{ {
title: 'Total User Memesan', title: 'Total Content Premium',
amount: 274, amount: 274,
icon: DoctorIcon, icon: DoctorIcon,
counter: [211, 54], counter: [211, 54],

View File

@ -24,12 +24,13 @@ export const DashboardPage = () => {
</div> </div>
</section> </section>
<div className="mt-5 grid grid-cols-1 grid-rows-1 gap-6 sm:grid-cols-3"> <div className="mt-5 grid grid-cols-1 grid-rows-1 gap-6 sm:grid-cols-3">
{REPORT.map(({ title, amount, icon }, index) => ( {REPORT.map(({ title, amount, icon, currency }, index) => (
<CardReport <CardReport
key={index} key={index}
title={title} title={title}
amount={amount} amount={amount}
icon={icon} icon={icon}
currency={currency}
/> />
))} ))}
</div> </div>
@ -49,22 +50,18 @@ export const DashboardPage = () => {
</div> </div>
</div> </div>
<div className="mt-5 grid max-h-[280px] grid-cols-1 grid-rows-2 gap-6 sm:grid-cols-5 sm:grid-rows-1"> <div className="flex flex-wrap gap-5 py-5 sm:flex-nowrap">
<div className="sm:col-span-3"> <div className="h-full w-full sm:w-[60%]">
<div className="h-30 w-full">
<div className="shadow-sm"> <div className="shadow-sm">
<UiChartBar /> <UiChartBar />
</div> </div>
</div> </div>
</div> <div className="w-ful h-full sm:w-[40%]">
<div className="sm:col-span-2 sm:col-start-4">
<div className="h-30 w-full">
<div className="shadow-sm"> <div className="shadow-sm">
<ChartSubscription /> <ChartSubscription />
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
) )
} }