Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

fullcalendar edit event modal react


    import React from "react";
    import FullCalendar from "@fullcalendar/react";
    import dayGridPlugin from "@fullcalendar/daygrid";
    import timeGridPlugin from "@fullcalendar/timegrid";
    import interactionPlugin from "@fullcalendar/interaction";
    import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from "reactstrap";
    import axios from 'axios';
    import "../main.scss";

    import "@fullcalendar/core/main.css";
    import "@fullcalendar/daygrid/main.css";
    import "@fullcalendar/timegrid/main.css";


    export default class CalendarView extends React.Component {
      calendarComponentRef = React.createRef();

      state = {
        modal: false,
        calendarWeekends: true,
        event: []
      };

    componentDidMount() {
        axios.get('/events')
          .then(response => {
            this.setState({event: response.data})
            console.log({calendarEvents: response.data})
          })
          .catch(function (error) {
            console.log(error);
          })
      }

      toggle = () => {
        this.setState({ modal: !this.state.modal });
      };

      handleEventClick = ({ event, el }) => {
        this.toggle();
        this.setState({ event });
      };

      render() {
        return (
          <div className="cal-container">
            <div style={{marginTop: 30}}>
              <FullCalendar
                defaultView="timeGridDay"
                header={{
                  left: "prev,next today",
                  center: "title",
                  right: "dayGridMonth,timeGridWeek,timeGridDay,listWeek"
                }}
                plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin]}
                ref={this.calendarComponentRef}
                weekends={this.state.calendarWeekends}
                events={this.state.event}
                eventClick={this.handleEventClick}
                nowIndicator='true'
                height='parent'
              />
              <Modal
              isOpen={this.state.modal}
              toggle={this.toggle}
            >
              <ModalHeader toggle={this.toggle}>
                EVENT TITLE SHOULD GO HERE: {this.state.event.title}
              </ModalHeader>
              <ModalBody>
                <div>
                  EVENT INFO SHOULD GO HERE: {this.state.event.start}
                </div>
              </ModalBody>
              <ModalFooter>
                <Button color="primary">Do Something</Button>{" "}
                <Button color="secondary" onClick={this.toggle}>
                  Cancel
                </Button>
              </ModalFooter>
            </Modal>
            </div>
          </div>
        );
      }
    }
Comment

PREVIOUS NEXT
Code Example
Javascript :: date range picker react 
Javascript :: React Hook "useState" is called in function "app" which is neither a React function component or a custom React Hook function react-hooks/rules-of-hooks 
Javascript :: js push 
Javascript :: rails json schema validation 
Javascript :: switch19 dynamically update js 
Javascript :: javascript destructing 
Javascript :: trimend in javascript 
Javascript :: node js how to basic auth to specific urk 
Javascript :: amount into words 
Javascript :: linear search javascript 
Javascript :: Discord.js v13 / command handler 
Javascript :: js callback hell 
Javascript :: Progress bar loader angular 
Javascript :: dot notation vs bracket notation 
Javascript :: react router dom v6 navigate replace 
Javascript :: indexof javascript 
Javascript :: javascript Rename in the import file 
Javascript :: simple todo list javascript 
Javascript :: change form value dynamically angular 
Javascript :: nodemailer 
Javascript :: how to parse header in node.js lambda 
Javascript :: Uncaught TypeError: $(...).datatables is not a function 
Javascript :: what does return do in javascript 
Javascript :: check if jwt token is valid 
Javascript :: js value to boolean 
Javascript :: take a screenshot javascript of canvas 
Javascript :: javascript url replace 
Javascript :: mdn trimstart 
Javascript :: value js 
Javascript :: call two functions onpress react native 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =