1
|
|
|
import React from 'react'; |
2
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; |
3
|
|
|
import { Button, Media, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap'; |
4
|
|
|
import Flex from '../common/Flex'; |
5
|
|
|
import moment from 'moment'; |
6
|
|
|
|
7
|
|
|
const getCircleStackIcon = (icon, transform) => ( |
8
|
|
|
<span className="fa-stack ml-n1 mr-3"> |
9
|
|
|
<FontAwesomeIcon icon="circle" className="text-200 fa-stack-2x" /> |
10
|
|
|
<FontAwesomeIcon icon={icon} transform={transform ?? ''} className="text-primary fa-stack-1x" inverse /> |
11
|
|
|
</span> |
12
|
|
|
); |
13
|
|
|
|
14
|
|
|
const EventModalMediaContent = ({ icon, heading, content, children }) => ( |
15
|
|
|
<Media className="mt-3"> |
16
|
|
|
{getCircleStackIcon(icon)} |
17
|
|
|
<Media body> |
18
|
|
|
<> |
19
|
|
|
<h6>{heading}</h6> |
20
|
|
|
{children || <p className="mb-0 text-justify">{content}</p>} |
21
|
|
|
</> |
22
|
|
|
</Media> |
23
|
|
|
</Media> |
24
|
|
|
); |
25
|
|
|
|
26
|
|
|
const CalendarEventModal = ({ isOpenModal, setIsOpenModal, modalEventContent }) => { |
27
|
|
|
const toggle = () => setIsOpenModal(!isOpenModal); |
28
|
|
|
|
29
|
|
|
const { title, end, start } = isOpenModal && modalEventContent.event; |
30
|
|
|
const { description, location, organizer, schedules } = isOpenModal && modalEventContent.event.extendedProps; |
31
|
|
|
|
32
|
|
|
const closeBtn = ( |
33
|
|
|
<button className="close font-weight-normal" onClick={toggle}> |
34
|
|
|
× |
35
|
|
|
</button> |
36
|
|
|
); |
37
|
|
|
|
38
|
|
|
return ( |
39
|
|
|
<Modal isOpen={isOpenModal} toggle={toggle} modalClassName="theme-modal" contentClassName="border" centered> |
40
|
|
|
<ModalHeader toggle={toggle} tag="div" className="px-card bg-light border-0 flex-between-center" close={closeBtn}> |
41
|
|
|
<h5 className="mb-0">{title}</h5> |
42
|
|
|
{organizer && ( |
43
|
|
|
<p className="mb-0 fs--1 mt-1"> |
44
|
|
|
by <a href="#!">{organizer}</a> |
45
|
|
|
</p> |
46
|
|
|
)} |
47
|
|
|
</ModalHeader> |
48
|
|
|
<ModalBody className="px-card pb-card pt-1 fs--1"> |
49
|
|
|
{description && <EventModalMediaContent icon="align-left" heading="Description" content={description} />} |
50
|
|
|
{(end || start) && ( |
51
|
|
|
<EventModalMediaContent icon="calendar-check" heading="Time and Date"> |
52
|
|
|
<span>{moment(start).format('LLLL')}</span> |
53
|
|
|
{end && ( |
54
|
|
|
<> |
55
|
|
|
{' '} |
56
|
|
|
– <br /> <span>{moment(end).format('LLLL')}</span> |
57
|
|
|
</> |
58
|
|
|
)} |
59
|
|
|
</EventModalMediaContent> |
60
|
|
|
)} |
61
|
|
|
{location && ( |
62
|
|
|
<EventModalMediaContent icon="map-marker-alt" heading="Location"> |
63
|
|
|
<div className="mb-1" dangerouslySetInnerHTML={{ __html: location }} /> |
64
|
|
|
</EventModalMediaContent> |
65
|
|
|
)} |
66
|
|
|
{schedules && ( |
67
|
|
|
<EventModalMediaContent icon="clock" heading="Schedule"> |
68
|
|
|
<ul className="list-unstyled timeline mb-0"> |
69
|
|
|
{schedules.map((schedule, index) => ( |
70
|
|
|
<li key={index}>{schedule.title}</li> |
71
|
|
|
))} |
72
|
|
|
</ul> |
73
|
|
|
</EventModalMediaContent> |
74
|
|
|
)} |
75
|
|
|
</ModalBody> |
76
|
|
|
<ModalFooter tag={Flex} justify="end" className="bg-light px-card border-top-0"> |
77
|
|
|
<Button tag="a" href="pages/event-create" color="falcon-default" size="sm"> |
78
|
|
|
<FontAwesomeIcon icon="pencil-alt" className="fs--2 mr-2" /> |
79
|
|
|
<span>Edit</span> |
80
|
|
|
</Button> |
81
|
|
|
<Button tag="a" href="pages/event-detail" color="falcon-primary" size="sm"> |
82
|
|
|
<span>See more details</span> |
83
|
|
|
<FontAwesomeIcon icon="angle-right" className="fs--2 ml-1" /> |
84
|
|
|
</Button> |
85
|
|
|
</ModalFooter> |
86
|
|
|
</Modal> |
87
|
|
|
); |
88
|
|
|
}; |
89
|
|
|
|
90
|
|
|
export default CalendarEventModal; |
91
|
|
|
|