File tree 2 files changed +19
-18
lines changed
2 files changed +19
-18
lines changed Original file line number Diff line number Diff line change 1
- import { format , formatDistance } from "date-fns " ;
1
+ import { generateRandomDate , generateRandomUptime } from "../mock/dashboard " ;
2
2
import { Prompt } from "../types" ;
3
3
import { PieChart } from "../viz/PieChart" ;
4
4
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
-
22
5
export function Dashboard ( { prompts } : { prompts : Prompt [ ] } ) {
23
6
const tagCounts = prompts . reduce < Record < string , number > > ( ( acc , prompt ) => {
24
7
prompt . tags . forEach ( ( tag ) => {
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments