-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCalendarView.tsx
58 lines (56 loc) · 1.63 KB
/
CalendarView.tsx
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
57
58
import React from 'react';
import type { Calendar, New } from '../lib/dataModel';
import { replaceKey } from '../lib/helpers';
import { globalText } from '../localization/global';
import { Input, Label, Textarea } from './Basic';
import { ColorPicker } from './ColorPicker';
export function CalendarView({
calendar,
onChange: handleChange,
occurrenceCount = 0,
}: {
readonly calendar: New<Calendar>;
readonly onChange: (calendar: New<Calendar>) => void;
readonly occurrenceCount: string | number | undefined;
}): JSX.Element {
return (
<>
<h2>{calendar.name}</h2>
<Label.Generic>
{globalText('name')}
<Input.Text
value={calendar.name}
onValueChange={(name): void =>
handleChange(replaceKey(calendar, 'name', name))
}
/>
</Label.Generic>
<Label.Generic>
{globalText('description')}
<Textarea
value={calendar.description}
onValueChange={(description): void =>
handleChange(replaceKey(calendar, 'description', description))
}
/>
</Label.Generic>
<Label.Generic>
{globalText('eventCount')}
{typeof occurrenceCount === 'number' ? (
<Input.Number value={occurrenceCount} isReadOnly />
) : (
<Input.Text value={occurrenceCount} isReadOnly />
)}
</Label.Generic>
<Label.Generic>
{globalText('color')}
<ColorPicker
color={calendar.color}
onChange={(color): void =>
handleChange(replaceKey(calendar, 'color', color))
}
/>
</Label.Generic>
</>
);
}