Commit c641d8e2 authored by Andrew Hrdy's avatar Andrew Hrdy

Fix webpack, change some imports

parent 869e5b34
......@@ -33,22 +33,6 @@
</head>
<body>
<script type="text/javascript">
// /*
// The following code is generated by matomo to use for analytics.
// */
// var _paq = _paq || [];
// _paq.push(['trackPageView']);
// _paq.push(['enableLinkTracking']);
// (function () {
// var u = "//matomo.srct.gmu.edu/";
// _paq.push(['setTrackerUrl', u + 'piwik.php']);
// _paq.push(['setSiteId', '2']);
// var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
// g.type = 'text/javascript'; g.async = true; g.defer = true; g.src = u + 'piwik.js'; s.parentNode.insertBefore(g, s);
// })();
</script>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
......
import * as React from 'react';
import * as classNames from 'classnames';
import { findLink } from '../utils/nameUtils';
import { findLink } from '../utils/name.util';
import { IAlert } from '../models/alert.model';
import ArrowForwardIcon from '@material-ui/icons/ArrowForward';
import { Chip, Button } from '@material-ui/core';
......
import * as React from 'react';
import * as classNames from 'classnames';
import FacilityUtils from '../utils/facilityUtils';
import { isFacilityOpen } from '../utils/facility.util';
import { IFacility } from '../models/facility.model';
import { Typography } from '@material-ui/core';
......@@ -18,7 +18,7 @@ export default ({facility}: FacilityStatusProps) => {
let label;
let isOpen;
if (FacilityUtils.isFacilityOpen(facility)) {
if (isFacilityOpen(facility)) {
label = 'OPEN';
isOpen = true;
} else {
......
import * as React from 'react';
import { removeBrackets } from '../utils/nameUtils';
import { removeBrackets } from '../utils/name.util';
import * as phoneFormatter from 'phone-formatter';
import { IFacility } from '../models/facility.model';
import TextwTitle from './TextwTitle';
......
import * as React from 'react';
import facilityUtils from '../utils/facilityUtils';
import { getHoursByDay } from '../utils/facility.util';
import { IFacility } from '../models/facility.model';
import { Grid, Typography } from '@material-ui/core';
......@@ -28,7 +28,7 @@ export default ({facility}: WeekHoursProps) => {
let index = 0;
for (let dayOfWeek = 0; dayOfWeek < 7; dayOfWeek++) {
const todaysHours = facilityUtils.getHoursByDay(facility, dayOfWeek);
const todaysHours = getHoursByDay(facility, dayOfWeek);
for (let i = 0; i < todaysHours.length; i++) {
output[index] = (
......
......@@ -4,7 +4,7 @@ import { IFacility } from '../models/facility.model';
import { ApplicationState } from '../store';
import { fetchFacilitiesAction } from '../store/facility/facility.actions';
import { fetchAlertsAction } from '../store/alert/alert.actions';
import facilityUtils from '../utils/facilityUtils';
import { filterFacilities } from '../utils/facility.util';
import CardContainer from '../components/CardContainer';
import AppBar from '../components/AppBar';
......@@ -54,7 +54,7 @@ export default () => {
<div className={'layout-container'}>
<div className={'layout-main-content'}>
<div className={'layout-card-container'}>
<CardContainer facilities={facilityUtils.filterFacilities(facilities, searchTerm.searchTerm, searchTerm.campusRegion)} showFavoriteIcons={true} />
<CardContainer facilities={filterFacilities(facilities, searchTerm.searchTerm, searchTerm.campusRegion)} showFavoriteIcons={true} />
</div>
</div>
......
import * as React from 'react';
import * as classNames from 'classnames';
import { useSelector, useDispatch } from 'react-redux';
import { removeBrackets } from '../utils/nameUtils';
import FacilityUtils from '../utils/facilityUtils';
import { removeBrackets } from '../utils/name.util';
import { getHoursByDay } from '../utils/facility.util';
import { IFacility } from '../models/facility.model';
import { ApplicationState } from '../store';
import { addFavoriteFacilityAction, removeFavoriteFacilityAction, setSelectedFacilityAction } from '../store/ui/ui.actions';
......@@ -34,7 +34,7 @@ export default React.memo(({facility, showFavoriteIcon}: FacilityCardProps) => {
const getDisplayHours = () => {
const currentHour = new Date().getHours();
const todaysHours = FacilityUtils.getHoursByDay(facility, dayOfWeek);
const todaysHours = getHoursByDay(facility, dayOfWeek);
if (todaysHours.length > 1) {
for (let i = 0; i < todaysHours.length; i++) {
......
......@@ -2,7 +2,7 @@ import * as React from 'react';
import { IFacility } from '../models/facility.model';
import { Paper, Typography, IconButton } from '@material-ui/core';
import CloseIcon from '@material-ui/icons/Close';
import { removeBrackets } from '../utils/nameUtils';
import { removeBrackets } from '../utils/name.util';
import * as phoneFormatter from 'phone-formatter';
import WeekHours from '../components/WeekHours';
import { ApplicationState } from '../store';
......
......@@ -4,7 +4,7 @@ import { ApplicationState } from '../store';
import { fetchFacilitiesAction } from '../store/facility/facility.actions';
import { fetchAlertsAction } from '../store/alert/alert.actions';
import { useDispatch, useSelector } from 'react-redux';
import facilityUtils from '../utils/facilityUtils';
import { filterFacilities } from '../utils/facility.util';
import AppBar from '../components/AppBar';
import CardContainer from '../components/CardContainer';
import FacilityDetail from './FacilityDetail';
......@@ -57,7 +57,7 @@ export default () => {
{showSpinner && <LoadingSpinner />}
<CardContainer facilities={facilityUtils.filterFacilities(facilities, searchTerm.searchTerm, searchTerm.campusRegion)} showFavoriteIcons={false} />
<CardContainer facilities={filterFacilities(facilities, searchTerm.searchTerm, searchTerm.campusRegion)} showFavoriteIcons={false} />
<Drawer {...handlers} anchor={'bottom'} open={selectedFacilitySlug !== ''} onClose={closeDrawer} transitionDuration={250}>
<FacilityDetail facility={drawerFacility} onClose={closeDrawer} />
......
......@@ -3,7 +3,7 @@ import { callApi } from '../../utils/api.util';
import { setFacilitiesAction } from './facility.actions';
import { FacilityActionTypes } from './facility.action-types';
import { IFacility } from '../../models/facility.model';
import facilityUtils from '../../utils/facilityUtils';
import { isFacilityOpen } from '../../utils/facility.util';
import { ApplicationState, LOCAL_STORAGE_FACILITIES_KEY } from '..';
const API_GET_FACILITIES = process.env.API_GET_FACILITIES || 'https://api.srct.gmu.edu/whatsopen/v2/facilities/';
......@@ -15,7 +15,7 @@ const facilitySort = (favorites: string[]) => (a: IFacility, b: IFacility) => {
return favoriteCheck;
}
const openCheck = Number(facilityUtils.isFacilityOpen(b)) - Number(facilityUtils.isFacilityOpen(a));
const openCheck = Number(isFacilityOpen(b)) - Number(isFacilityOpen(a));
if (openCheck !== 0) {
return openCheck;
......
......@@ -6,7 +6,7 @@ import { IFacility, IFacilitySchedule, IFacilityScheduleEntry, CampusRegion } fr
* @param facility The facility to find the active schedule for.
* @returns {IFacilitySchedule} The active schedule.
*/
const getFacilityActiveSchedule = (facility: IFacility): IFacilitySchedule => {
export const getFacilityActiveSchedule = (facility: IFacility): IFacilitySchedule => {
const curDateTime = new Date();
for (let i = 0; i < facility.special_schedules.length; i++) {
......@@ -30,7 +30,7 @@ const getFacilityActiveSchedule = (facility: IFacility): IFacilitySchedule => {
* @param facility The facility to find the status for.
* @returns {boolean} True if the facility is open, otherwise false.
*/
const isFacilityOpen = (facility: IFacility): boolean => {
export const isFacilityOpen = (facility: IFacility): boolean => {
const schedule = getFacilityActiveSchedule(facility);
return isScheduleOpen(schedule);
......@@ -44,7 +44,7 @@ const isFacilityOpen = (facility: IFacility): boolean => {
* @param schedule The active schedule for the facility.
* @return {number} The time (in minutes) until the facility opens.
*/
const calcTimeTillOpen = (schedule: IFacilitySchedule): number => {
export const calcTimeTillOpen = (schedule: IFacilitySchedule): number => {
const curDateTime = new Date();
// Converts the JS day of week (0 is sunday), to the API day of week (0 is monday).
......@@ -85,7 +85,7 @@ const calcTimeTillOpen = (schedule: IFacilitySchedule): number => {
* @param schedule The active schedule for the facility.
* @returns {number} The time (in minutes) until the facility closes. Returns -1 is the facility is open 24/7
*/
const calcTimeTillClose = (schedule: IFacilitySchedule): number => {
export const calcTimeTillClose = (schedule: IFacilitySchedule): number => {
if (schedule.twenty_four_hours) {
return -1;
}
......@@ -249,7 +249,7 @@ const getEntriesByDay = (schedule: IFacilitySchedule, dayOfWeek: number): IFacil
* @param dayOfWeek The day of the week
* @returns {array} array of objects with text,start,end,allDayOrClosed properties.
*/
const getHoursByDay = (facility: IFacility, dayOfWeek: number): {text: string, start: number | string, end: number | string, allDayOrClosed: boolean}[] => {
export const getHoursByDay = (facility: IFacility, dayOfWeek: number): {text: string, start: number | string, end: number | string, allDayOrClosed: boolean}[] => {
const schedule = getFacilityActiveSchedule(facility);
if (schedule.twenty_four_hours) {
......@@ -354,7 +354,7 @@ const daysTill = (dayFrom: number, dayTo: number) => {
* @param {CampusRegion} campusRegion
* @returns
*/
const filterFacilities = (facilities: IFacility[], searchTerm: string, campusRegion: CampusRegion) => {
export const filterFacilities = (facilities: IFacility[], searchTerm: string, campusRegion: CampusRegion) => {
return facilities.filter((facility: IFacility) => {
if (facility.facility_location.campus_region.toLowerCase() !== campusRegion.toLowerCase()) {
return false;
......@@ -380,13 +380,4 @@ const filterFacilities = (facilities: IFacility[], searchTerm: string, campusReg
return facilityName.includes(lSearchTerm) || facilityLocation.includes(lSearchTerm) ||
facilityCategory.includes(lSearchTerm) || hasTag || friendlyName.includes(lSearchTerm);
});
};
export default {
getFacilityActiveSchedule: getFacilityActiveSchedule,
isFacilityOpen: isFacilityOpen,
getHoursByDay: getHoursByDay,
calcTimeTillOpen: calcTimeTillOpen,
calcTimeTillClose: calcTimeTillClose,
filterFacilities: filterFacilities
};
\ No newline at end of file
......@@ -2,7 +2,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const paths = require('./paths');
......@@ -46,9 +46,7 @@ module.exports = {
]
},
plugins: [
new CleanWebpackPlugin([paths.appBuild], {
root: paths.appRoot
}),
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
inject: true,
template: paths.appHtml,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment