Skip to content

Instantly share code, notes, and snippets.

View App.js
import React, {Component} from 'react';
import 'react-dates/initialize';
import {DateRangePicker, initialStartDate, isInclusivelyAfterDay} from 'react-dates';
import {START_DATE, END_DATE} from 'react-dates/constants';
import ReactDOM from 'react-dom';
import isSameDay from './utils/isSameDay';
import moment from "moment/moment";
import checkStatus from "./utils/checkFetchStatus";
import swal from 'sweetalert';
import 'whatwg-fetch';
View app.js
import React, {Component} from 'react';
import 'react-dates/initialize';
import {DateRangePicker, initialStartDate, isInclusivelyAfterDay} from 'react-dates';
import {START_DATE, END_DATE} from 'react-dates/constants';
import ReactDOM from 'react-dom';
import isSameDay from './utils/isSameDay';
import moment from "moment/moment";
import fetchPrices from './utils/fetchPrices';
let disabledDates = [];
View webpack.config.js
const Encore = require('@symfony/webpack-encore');
Encore
.setOutputPath('public/build')
.setPublicPath('/build')
.setManifestKeyPrefix('')
.splitEntryChunks()
.addEntry('js/test', './public/assets/js/test.js')// JAVASCRIPT
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
View Router.js
(function (root, factory) {
var routing = factory();
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], routing.Routing);
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = routing.Routing;
View datepicker.vue
<template>
<datepicker
:startDate="startDate"
@check-in-changed="setCheckInDate"
@check-out-changed="setCheckOutDate"
:maxNights="21"
:minNights="minNights"
:checkIn="checkIn"
:checkOut="checkOut"
:disabledDates="bookedDates"
View datePicker.vue
<template>
<datepicker
:startDate="startDate"
@checkInChanged="setCheckinDate"
:maxNights="30"
:disabledDates="bookedDates"
:firstDayOfWeek="1"
:i18n="lang"
:showYear="true"
>
@heleneshaikh
heleneshaikh / Fetch
Last active Oct 29, 2018
Fetch with polyfill and error wrapper
View Fetch
import 'whatwg-fetch'; //polyfill
window.fetch(Routing.generate('booking_data'), { //window.fetch -> polyfill
method: 'post',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
checkin: event.start.toDateString(),