Skip to content

Commit 604a16f

Browse files
committed
create dashboard mock folder
1 parent 66dbb0b commit 604a16f

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

src/components/Dashboard.tsx

+1-18
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
1-
import { format, formatDistance } from "date-fns";
1+
import { generateRandomDate, generateRandomUptime } from "../mock/dashboard";
22
import { Prompt } from "../types";
33
import { PieChart } from "../viz/PieChart";
44

5-
function generateRandomUptime() {
6-
const now = new Date();
7-
const randomPastTime = new Date(
8-
now.getTime() - Math.random() * 48 * 60 * 60 * 1000
9-
);
10-
11-
return formatDistance(randomPastTime, now, { includeSeconds: true });
12-
}
13-
14-
function generateRandomDate(): string {
15-
const randomPastDate = new Date(
16-
Date.now() - Math.random() * 30 * 24 * 60 * 60 * 1000
17-
);
18-
19-
return format(randomPastDate, "MM/dd/yyyy");
20-
}
21-
225
export function Dashboard({ prompts }: { prompts: Prompt[] }) {
236
const tagCounts = prompts.reduce<Record<string, number>>((acc, prompt) => {
247
prompt.tags.forEach((tag) => {

src/mock/dashboard.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { format, formatDistance } from "date-fns";
2+
3+
export function generateRandomUptime() {
4+
const now = new Date();
5+
const randomPastTime = new Date(
6+
now.getTime() - Math.random() * 48 * 60 * 60 * 1000
7+
);
8+
9+
return formatDistance(randomPastTime, now, { includeSeconds: true });
10+
}
11+
12+
export function generateRandomDate(): string {
13+
const randomPastDate = new Date(
14+
Date.now() - Math.random() * 30 * 24 * 60 * 60 * 1000
15+
);
16+
17+
return format(randomPastDate, "MM/dd/yyyy");
18+
}

0 commit comments

Comments
 (0)