blob: 5100f3dc79845942170ac5276fbbcf7c47a5fd23 (
plain)
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
54
55
56
|
import { formatDistance } from 'date-fns';
import * as React from 'react';
import { Activity, Database, RefreshCw } from '~/components/shared/FeatherIcons';
import Button from '~/components/Button';
import { useUpdateRuleProviderItem } from '~/modules/rules/hooks';
import s from './RuleProviderItem.module.scss';
export function RuleProviderItem({
idx,
name,
vehicleType,
behavior,
updatedAt,
ruleCount,
apiConfig,
}) {
const [onClickRefreshButton, isRefreshing] = useUpdateRuleProviderItem(name, apiConfig);
const timeAgo = formatDistance(new Date(updatedAt), new Date());
return (
<div className={s.RuleProviderItem}>
<div className={s.left}>{idx}</div>
<div className={s.middle}>
<div className={s.nameRow}>
<span className={s.name}>{name}</span>
<div className={s.badgeGroup}>
<span className={s.badge}>
<Database size={12} />
{vehicleType}
</span>
<span className={s.badge}>
<Activity size={12} />
{behavior}
</span>
</div>
</div>
<div className={s.infoRow}>
<span className={s.count}>{ruleCount} rules</span>
<span className={s.dot}>•</span>
<span className={s.time}>Updated {timeAgo} ago</span>
</div>
</div>
<div className={s.right}>
<Button
kind="minimal"
onClick={onClickRefreshButton}
disabled={isRefreshing}
className={s.refreshButton}
>
<RefreshCw size={18} className={isRefreshing ? s.rotating : ''} />
</Button>
</div>
</div>
);
}
|