<file_sep>import React from 'react'

export const Page404 = ({id}) => {
    return (
        <>Page not found.</>
    )
}<file_sep>import React, {useEffect, useState} from 'react'
import {Button, Card, Form, Input, notification, Popover} from "antd";
import { FileSearchOutlined, EditOutlined, DownloadOutlined, DeleteOutlined } from '@ant-design/icons';
import API from "../../services/api";

export const RemDisplay = (props) => {
    const [rem, setRem] = useState('')
    const [pres, setPres] = useState('')

    function moreInfo() {
        return(
            <>
                <b>Date:</b> {pres.date}<br/>
                <b>Keywords:</b> {pres.keywords}<br/>
                <b>Authors:</b> {pres.authors}<br/>
                <b>Session:</b> {pres.session}<br/>
            </>
        )
    }

    function download() {
        API.get(`/abstracts/${pres.filename}`,{responseType: 'arraybuffer'})
            .then(response => {
                const url = window.URL.createObjectURL(new Blob([response.data]));
                const link = document.createElement('a');
                link.href = url;
                link.setAttribute('download',`${pres.filename.split('/')[1]}`);
                document.body.appendChild(link);
                link.click();
                window.URL.revokeObjectURL(url);
            })
            .catch(errInfo => {
                notification['error']({
                    message: 'Error!',
                    description: 'File has not been found!'
                })
            });
    }

    function remNoteEdit() {
            return <>
                <Form name="basic" onFinish={remPut} style={{width: 300}}>
                    <Form.Item label="Note" name="note">
                        <Input placeholder="..."/>
                    </Form.Item>
                    <Form.Item>
                        <Button type="primary" htmlType="submit">
                            Submit
                        </Button>
                    </Form.Item>
                </Form>
            </>
    }

    function remPut(attr) {
        API.put(`/reminders/${rem.id}`,{ "presentationId": `${pres.id}`, "notes": attr.note,
            "enabled": true }, {headers:{Authorization:`Bearer ${props.token}`}})
            .then(response=>{
                notification.open({
                    message: 'Saved',
                    description: 'Note edited!',
                    duration: 3,
                });
                setRem({"id": rem.id, "presentationId": rem.presentationId, "notes": attr.note, "enabled": true})
            })
            .catch(err=>{
                notification['error']({
                    message: 'Error!',
                    description: 'Edit error!'
                })
            })
    }

    function remDelete() {
        API.delete(`/reminders/${rem.id}`, {headers:{Authorization:`Bearer ${props.token}`}})
            .then(response=>{
                notification.open({
                    message: 'Deleted',
                    description: 'Reminder deleted!',
                    duration: 3,
                });
                window.location.reload();
            })
            .catch(err=>{
                notification['error']({
                    message: 'Error!',
                    description: 'Delete error!'
                })
            })
    }

    useEffect( () => {
        API.get(`/reminders/${props.remId}`, {headers:{Authorization:`Bearer ${props.token}`}})
            .then(response => {
                console.log('Reminder claimed.');
                setRem(response.data);
            })
            .catch(errInfo => {
                console.log('Reminder error: ', errInfo)
            });

        API.get(`/presentations/${props.presId}`, {headers:{Authorization:`Bearer ${props.token}`}})
            .then(response => {
                console.log('Presentation claimed.');
                setPres(response.data);
            })
            .catch(errInfo => {
                console.log('Presentation error: ', errInfo)
            });
        }, //eslint-disable-next-line
        []);

    return (
        <Card title={pres.title} actions={[
            <Popover title={pres.title} content={moreInfo(pres)} trigger="click">
                <FileSearchOutlined key="moreInfo" />
            </Popover>,
            <Popover title="Edit Note" content={remNoteEdit()} trigger="click">
                <EditOutlined key="edit" />
            </Popover>,
            <DownloadOutlined key="download" onClick={()=>download()} />,
            <DeleteOutlined key="delete" onClick={()=>remDelete()} />
        ]}>
            <h3>
                <b>Starts at:</b> {pres.date}<br/>
                <b>Notes:</b> {rem.notes}<br/>
            </h3>
        </Card>
    )
};<file_sep>import React, {useEffect, useState} from 'react'
import Cookies from "js-cookie";
import API from "../../services/api";
import {Col, Row} from "antd";
import {RemDisplay} from "./RemDisplay";

export const Reminder = () => {
    const [logged, setLogged] = useState(false);
    const [reminders, setReminders] = useState([]);
    const token=Cookies.get('token')

    useEffect( () => {
        if(token != null) {
            setLogged(true);
            API.get('/reminders', {headers:{Authorization:`Bearer ${token}`}})
                .then(response => {
                    console.log('Reminders claimed.');
                    setReminders(response.data);
                })
                .catch(errInfo => {
                    console.log('Reminders error: ', errInfo)
                });
        }
        }, //eslint-disable-next-line
        []);

    if(logged)
        return (
            <div className="site-card-border-less-wrapper">
                <Row>
                    {reminders.map(rem =>
                        <Col span={6} key={rem.id}>
                            <div className="card-content">
                                <RemDisplay presId={rem.presentationId} remId={rem.id} token={token}/>
                            </div>
                        </Col>

                    )}
                </Row>
            </div>
        );
    else
        return (
            <>The user is not logged.</>
        );
};<file_sep>import React from 'react'
import {Collapse, Divider, Tabs} from 'antd';
import {Presentation} from "./Presentation";
import {Session} from "./Session";
import {Room} from "./Room";
const {Panel} = Collapse;

export const Home = () => {
    const { TabPane } = Tabs;

    return (
        <>
            <Collapse>
                <Panel header='Sessions' key='1'>
                    <Session/>
                </Panel>
                <Panel header='Rooms' key='2'>
                    <Room/>
                </Panel>
            </Collapse>
            <Divider/>
            <Tabs defaultActiveKey="1">
                <TabPane tab="Monday" key="1">
                    <Presentation date='2019-09-02'/>
                </TabPane>
                <TabPane tab="Tuesday" key="2">
                    <Presentation date='2019-09-03'/>
                </TabPane>
                <TabPane tab="Wednesday" key="3">
                    <Presentation date='2019-09-04'/>
                </TabPane>
                <TabPane tab="Thursday" key="4">
                    <Presentation date='2019-09-05'/>
                </TabPane>
                <TabPane tab="Friday" key="5">
                    <Presentation date='2019-09-06'/>
                </TabPane>
            </Tabs>
        </>
    )
};<file_sep>import React, {useEffect} from 'react'
import API from "../../services/api";
import Cookies from "js-cookie";

export const RemPost = (props) => {
    const token=Cookies.get('token')

    useEffect( () => {
        if(token != null) {
            API.post(`/reminders`, {
                    "presenationId": props.presId,
                    "notes": '',
                    "enabled": true
                },
                {headers: {Authorization: `Bearer ${token}`}})
                .then(response => {
                    console.log('Reminder posted.');
                })
                .catch(errInfo => {
                    console.log('Reminder post error: ', errInfo)
                });
            }
        }, //eslint-disable-next-line
        []);

    return (
        <></>
    )
};<file_sep>import React from 'react'
import API from "../../services/api";
import {Button, Form, Input, notification} from "antd";
import {Link, useHistory} from "react-router-dom";

const layout = {
    labelCol: {
        span: 2,
    },
    wrapperCol: {
        span: 6,
    },
};
const tailLayout = {
    wrapperCol: {
        offset: 2,
        span: 6,
    },
};

export const Register = () => {
    const history = useHistory();

    const onFinish = (values) => {
        API.post('/users', {email: values.email, password: values.password})
            .then(response => {
                console.log('success')
                console.log('id:', response.id)
                notification['success']({
                    message: 'Login has been registered.'
                })
                history.push('/user')
            })
            .catch(errInfo => {
                notification['error']({
                    message: 'Register error!',
                    description: 'Wrong input data.'
                })
            })
    };

    const onFinishFailed = errorInfo => {
        console.log('Failed:', errorInfo);
    };

    return (
        <Form
            {...layout}
            name="basic"

            onFinish={onFinish}
            onFinishFailed={onFinishFailed}
        >
            <Form.Item
                label="Email"
                name="email"
                rules={[
                    {
                        required: true,
                        message: 'Please input your email!',
                    },
                ]}
            >
                <Input placeholder="<EMAIL>"/>
            </Form.Item>

            <Form.Item
                label="Password"
                name="password"
                rules={[
                    {
                        required: true,
                        message: 'Please input your password!',
                    },
                ]}
            >
                <Input.Password type='password' placeholder='<PASSWORD>' />
            </Form.Item>

            <Form.Item {...tailLayout}>
                <Button type="primary" htmlType="submit">
                    Register
                </Button>
                <p> <br/> Already have an account? <Link to="/login">Sign in</Link>!</p>

            </Form.Item>
        </Form>
    );
}<file_sep>import React from 'react'
import {Card, Popover, notification, Form, Input, Button} from "antd";
import { FileSearchOutlined, BellOutlined, DownloadOutlined } from '@ant-design/icons';
import Cookies from "js-cookie";
import API from "../../services/api";

export const PresDisplay = (props) => {
    const token=Cookies.get('token');

    function moreInfo() {
        return(
            <>
                <b>Starts at:</b> {props.date.substr(11, 5)}<br/>
                <b>Date:</b> {props.date.substr(0, 10)}<br/>
                <b>Keywords:</b> {props.keywords.join(', ')}<br/>
                <b>Authors:</b> {props.authors.join(', ')}<br/>
                <b>Session:</b> {props.session}<br/>
            </>
        )
    }

    function remPost(attr) {
        console.log(props.id)
        API.post(`/reminders`,
            {   "presentationId": props.id,
                "notes": attr.note,
                "enabled": true},
            {headers: {Authorization: `Bearer ${token}`}})
            .then(response => {
                console.log('Reminder posted.');
                notification.open({
                    message: 'Saved!',
                    description: 'Reminder has been added to your list.',
                    duration: 3,
                })
            })
            .catch(errInfo => {
                console.log('Reminder post error: ', errInfo)
            });
    }

    function remNoteEnter() {
        if(token != null) {
            return <>
                <Form name="basic" onFinish={remPost} style={{width: 300}}>
                    <Form.Item label="Note" name="note">
                        <Input placeholder="..."/>
                    </Form.Item>
                    <Form.Item>
                        <Button type="primary" htmlType="submit">
                            Submit
                        </Button>
                    </Form.Item>
                </Form>
            </>
        }
        else {
            return <>
                The user is not logged.
            </>
        }
    }

    function download() {
        API.get(`/abstracts/${props.filename}`,{responseType: 'arraybuffer'})
            .then(response => {
                const url = window.URL.createObjectURL(new Blob([response.data]));
                const link = document.createElement('a');
                link.href = url;
                link.setAttribute('download',`${props.filename.split('/')[1]}`);
                document.body.appendChild(link);
                link.click();
                window.URL.revokeObjectURL(url);
            })
            .catch(errInfo => {
                notification['error']({
                    message: 'Error!',
                    description: 'File has not been found!'
                })
            });
    }

    return (
                    <Card title={props.title} actions={[
                        <Popover title={props.title} content={moreInfo()} trigger="click">
                            <FileSearchOutlined key="moreInfo" />
                        </Popover>,
                        <Popover title="Add reminder" content={remNoteEnter()} trigger="click">
                            <BellOutlined key="remind" />
                        </Popover>,
                        <DownloadOutlined key="download" onClick={()=>download()} />,
                    ]}>
                        <h3><b>Starts at:</b> {props.date.substr(11, 5)}</h3>
                    </Card>

    )
};