Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sweepstake
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Arjun Jhukal
sweepstake
Commits
5b5f2797
Commit
5b5f2797
authored
Oct 10, 2025
by
Arjun Jhukal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made analaytics dynamic
parent
aaff4469
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
123 additions
and
28 deletions
+123
-28
AdminTransactionChart.tsx
src/app/(dashboard)/(admin)/AdminTransactionChart.tsx
+113
-26
dashboardApi.ts
src/services/dashboardApi.ts
+2
-2
dashboard.ts
src/types/dashboard.ts
+8
-0
No files found.
src/app/(dashboard)/(admin)/AdminTransactionChart.tsx
View file @
5b5f2797
// import React from "react";
// import Chart from "react-apexcharts";
// import { ApexOptions } from "apexcharts";
// import { useGetAdminTransactionsQuery } from "@/services/dashboardApi";
// export default function AdminTransactionChart() {
// const { data, isLoading } = useGetAdminTransactionsQuery();
// const chartOptions: ApexOptions = {
// chart: {
// type: "donut",
// },
// labels: data?.data.length ? data?.data.map((item) => item.label) : ["User Transaction", "My Settled", "My Unsettled"],
// colors: ["#8B5CF6", "#FACC15", "#22C55E"],
// legend: { show: false },
// dataLabels: { enabled: false },
// stroke: {
// width: 2,
// colors: ["#fff"],
// },
// plotOptions: {
// pie: {
// donut: {
// size: "65%",
// },
// },
// },
// };
// const chartSeries = data?.data.length ? data?.data.map((item) => item.data) : [0, 0, 0];
// if (!data) return null;
// return (
// <div className="px-6 pb-6">
// {/* Donut Chart */}
// <Chart options={chartOptions} series={chartSeries} type="donut" height={280} />
// {/* Custom Legend */}
// <div className="grid grid-cols-3 gap-4 mt-4 text-sm">
// {
// data?.data.map((item) => (
// <div className="flex flex-col items-start">
// <span className="flex items-center gap-1">
// <span className="w-3 h-3 rounded-full inline-block bg-purple-500"></span>
// {item.label}
// </span>
// <strong className="text-gray-800 ">${item.data}</strong>
// </div>
// ))
// }
// <div className="flex flex-col items-center">
// <span className="flex items-center gap-1">
// <span className="w-3 h-3 rounded-full inline-block bg-yellow-400"></span>
// My Settled
// </span>
// <strong className="text-gray-800">$26,894</strong>
// </div>
// <div className="flex flex-col items-center">
// <span className="flex items-center gap-1">
// <span className="w-3 h-3 rounded-full inline-block bg-green-500"></span>
// My Unsettled
// </span>
// <strong className="text-gray-800">$13,894</strong>
// </div>
// </div>
// </div>
// );
// }
"use client"
;
import
React
from
"react"
;
import
React
from
"react"
;
import
Chart
from
"react-apexcharts"
;
import
Chart
from
"react-apexcharts"
;
import
{
ApexOptions
}
from
"apexcharts"
;
import
{
ApexOptions
}
from
"apexcharts"
;
import
{
useGetAdminTransactionsQuery
}
from
"@/services/dashboardApi"
;
export
default
function
AdminTransactionChart
()
{
export
default
function
AdminTransactionChart
()
{
const
{
data
,
isLoading
}
=
useGetAdminTransactionsQuery
();
const
defaultLabels
=
[
"User Transaction"
,
"My Settled"
,
"My Unsettled"
];
const
defaultColors
=
[
"#8B5CF6"
,
"#FACC15"
,
"#22C55E"
];
const
chartOptions
:
ApexOptions
=
{
const
chartOptions
:
ApexOptions
=
{
chart
:
{
chart
:
{
type
:
"donut"
,
type
:
"donut"
,
},
},
labels
:
[
"User Transaction"
,
"My Settled"
,
"My Unsettled"
],
labels
:
data
?.
data
?.
length
colors
:
[
"#8B5CF6"
,
"#FACC15"
,
"#22C55E"
],
// purple, yellow, green
?
data
.
data
.
map
((
item
:
any
)
=>
item
.
label
)
legend
:
{
show
:
false
},
// hide default legend
:
defaultLabels
,
colors
:
defaultColors
,
legend
:
{
show
:
false
},
dataLabels
:
{
enabled
:
false
},
dataLabels
:
{
enabled
:
false
},
stroke
:
{
stroke
:
{
width
:
2
,
width
:
2
,
...
@@ -24,36 +103,44 @@ export default function AdminTransactionChart() {
...
@@ -24,36 +103,44 @@ export default function AdminTransactionChart() {
},
},
};
};
const
chartSeries
=
[
483569
,
26894
,
13894
];
// sample values for 3 segments
const
chartSeries
=
data
?.
data
?.
length
?
data
.
data
.
map
((
item
:
any
)
=>
item
.
data
)
:
[
0
,
0
,
0
];
if
(
isLoading
)
{
return
<
div
className=
"px-6 py-10 text-center"
>
Loading chart...
</
div
>;
}
if
(
!
data
?.
data
?.
length
)
{
return
<
div
className=
"px-6 py-10 text-center"
>
No transaction data found
</
div
>;
}
return
(
return
(
<
div
className=
"px-6 pb-6"
>
<
div
className=
"px-6 pb-6"
>
{
/* Donut Chart */
}
{
/* Donut Chart */
}
<
Chart
options=
{
chartOptions
}
series=
{
chartSeries
}
type=
"donut"
height=
{
280
}
/>
<
Chart
options=
{
chartOptions
}
series=
{
chartSeries
}
type=
"donut"
height=
{
280
}
/>
{
/* Custom Legend */
}
{
/* Custom Legend */
}
<
div
className=
"grid grid-cols-3 gap-4 mt-4 text-sm"
>
<
div
className=
"grid grid-cols-3 gap-4 mt-4 text-sm"
>
<
div
className=
"flex flex-col items-center"
>
{
data
.
data
.
map
((
item
:
any
,
index
:
number
)
=>
(
<
span
className=
"flex items-center gap-1"
>
<
div
key=
{
index
}
className=
"flex flex-col items-start"
>
<
span
className=
"w-3 h-3 rounded-full inline-block bg-purple-500"
></
span
>
<
span
className=
"flex items-start gap-1 text-para-light"
>
User Transaction
<
span
</
span
>
className=
"w-3 h-3 rounded-full inline-block mt-1 "
<
strong
className=
"text-gray-800"
>
$483,569
</
strong
>
style=
{
{
backgroundColor
:
defaultColors
[
index
]
}
}
</
div
>
></
span
>
<
div
className=
"flex flex-col items-center"
>
{
item
.
label
}
<
span
className=
"flex items-center gap-1"
>
</
span
>
<
span
className=
"w-3 h-3 rounded-full inline-block bg-yellow-400"
></
span
>
<
strong
className=
"text-gray-800 block mt-2"
>
My Settled
$
{
item
.
data
?.
toLocaleString
()
}
</
span
>
</
strong
>
<
strong
className=
"text-gray-800"
>
$26,894
</
strong
>
</
div
>
</
div
>
))
}
<
div
className=
"flex flex-col items-center"
>
<
span
className=
"flex items-center gap-1"
>
<
span
className=
"w-3 h-3 rounded-full inline-block bg-green-500"
></
span
>
My Unsettled
</
span
>
<
strong
className=
"text-gray-800"
>
$13,894
</
strong
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
);
);
...
...
src/services/dashboardApi.ts
View file @
5b5f2797
import
{
createApi
}
from
"@reduxjs/toolkit/query/react"
;
import
{
createApi
}
from
"@reduxjs/toolkit/query/react"
;
import
{
baseQuery
}
from
"./baseQuery"
;
import
{
baseQuery
}
from
"./baseQuery"
;
import
{
AnalyticsResponse
}
from
"@/types/dashboard"
;
import
{
A
dminTrasactionResponse
,
A
nalyticsResponse
}
from
"@/types/dashboard"
;
export
const
dashboardApi
=
createApi
({
export
const
dashboardApi
=
createApi
({
reducerPath
:
"dashboardApi"
,
reducerPath
:
"dashboardApi"
,
...
@@ -14,7 +14,7 @@ export const dashboardApi = createApi({
...
@@ -14,7 +14,7 @@ export const dashboardApi = createApi({
}),
}),
providesTags
:
[
"Analytics"
],
providesTags
:
[
"Analytics"
],
}),
}),
getAdminTransactions
:
builder
.
query
<
any
,
void
>
({
getAdminTransactions
:
builder
.
query
<
AdminTrasactionResponse
,
void
>
({
query
:
()
=>
({
query
:
()
=>
({
url
:
`/api/admin/dashboard/deposits`
,
url
:
`/api/admin/dashboard/deposits`
,
method
:
"GET"
,
method
:
"GET"
,
...
...
src/types/dashboard.ts
View file @
5b5f2797
...
@@ -16,4 +16,11 @@ export interface AnalyticsResponse {
...
@@ -16,4 +16,11 @@ export interface AnalyticsResponse {
total_users
:
AnalyticsProps
,
total_users
:
AnalyticsProps
,
total_withdraw
:
AnalyticsProps
,
total_withdraw
:
AnalyticsProps
,
}
}
}
export
interface
AdminTrasactionResponse
{
data
:
{
label
:
string
,
data
:
number
}[],
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment