-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathScheduleNode.tsx
More file actions
53 lines (50 loc) · 1.73 KB
/
ScheduleNode.tsx
File metadata and controls
53 lines (50 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { type ComponentType } from 'react'
import cronstrue from 'cronstrue'
import type { Schedule } from '@/types'
import type { NodeProps } from 'reactflow'
import NodeBase, { type NodeBaseData } from './NodeBase'
export type ScheduleNodeData = NodeBaseData<Schedule>
export const ScheduleNode: ComponentType<NodeProps<ScheduleNodeData>> = (
props,
) => {
const { data } = props
return (
<NodeBase
{...props}
drawerOptions={{
title: `Schedule - ${data.title}`,
description: data.description,
icon: data.icon,
nodeType: 'schedule',
testHref: `/schedules`, // TODO add url param to switch to resource
services: data.resource.requestingServices,
address: `http://${data.address}`,
children: (
<>
{data.resource.expression ? (
<>
<div className="flex flex-col">
<span className="font-bold text-foreground">Cron:</span>
<span className="text-foreground">{data.resource.expression}</span>
</div>
<div className="flex flex-col">
<span className="font-bold text-foreground">Description:</span>
<span className="text-foreground">
{cronstrue.toString(data.resource.expression, {
verbose: true,
})}
</span>
</div>
</>
) : (
<div className="flex flex-col">
<span className="font-bold text-foreground">Rate:</span>
<span className="text-foreground">Every {data.resource.rate}</span>
</div>
)}
</>
),
}}
/>
)
}