Skip to content

Commit b8a8615

Browse files
committed
progress with chart data
1 parent 8c7ff74 commit b8a8615

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/actions/statistics/get-stats-chart-data.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ export const getStatsChartData = async (opts: {
2626
userUid,
2727
createdAt: {
2828
gte: new Date(from),
29-
lte: new Date(to)
29+
lte: new Date('2024-12-31')
3030
}
3131
},
3232
include: {
3333
question: {
3434
select: {
35-
createdAt: true,
3635
tags: {
3736
include: {
3837
tag: true
@@ -46,7 +45,8 @@ export const getStatsChartData = async (opts: {
4645
const data: StatsChartData = {};
4746

4847
questions.forEach((answer) => {
49-
const month = answer.question.createdAt.toISOString().slice(0, 7);
48+
console.log(answer.createdAt);
49+
const month = answer.createdAt.toISOString().slice(0, 7);
5050
const tags = answer.question.tags.map((tag) => tag.tag.name);
5151

5252
if (data[month]) {
@@ -63,6 +63,8 @@ export const getStatsChartData = async (opts: {
6363
}
6464
});
6565

66+
console.log(data['2024-12']);
67+
6668
revalidateTag('statistics');
6769

6870
return data;

src/app/(dashboard)/(default_layout)/statistics/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export default async function StatisticsPage() {
5252
<div className="grid grid-cols-12 gap-y-4 gap-x-8">
5353
{totalQuestions ? (
5454
<TotalStatsCard
55+
className="-left-3 relative"
5556
header={Number(totalQuestions)}
5657
description="Total Questions Answered"
5758
/>

src/components/statistics/total-stats-card.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default function TotalStatsCard({
3838
<CardHeader className="p-3">
3939
<CardTitle className="text-white">
4040
<div className="flex items-center justify-between">
41-
<span className="text-2xl lg:text-4xl font-bold text-white">
41+
<span className="text-2xl lg:text-4xl font-bold">
4242
{typeof header === 'number' ? (
4343
<NumberFlow
4444
className="p-0"
@@ -51,7 +51,12 @@ export default function TotalStatsCard({
5151
</div>
5252
</CardTitle>
5353
</CardHeader>
54-
<CardContent className="text-white text-sm p-3 pt-0">
54+
<CardContent
55+
className={cn(
56+
'relative text-gray-400 text-sm p-3 pt-0',
57+
typeof header === 'number' ? '-top-3' : ''
58+
)}
59+
>
5560
{description}
5661
</CardContent>
5762
</Card>

0 commit comments

Comments
 (0)