Commit 66625cf1 authored by TJHeeringa's avatar TJHeeringa

Calendar Prelimenary

parent 99106b36
import {Alert} from "reactstrap";
import PropTypes from "prop-types";
import React from "react";
import {Alert} from "reactstrap";
export const AlertHandler = (props) => {
const {color, message, visible} = props;
......
......@@ -49,8 +49,8 @@ DateTimeField.propTypes = {
};
DateTimeField.defaultProps = {
apiFormat: "YYYY/MM/DD HH:mm",
format: "YYYY/MM/DD HH:mm"
apiFormat: "YYYY-MM-DD HH:mm",
format: "YYYY-MM-DD HH:mm"
};
export default DateTimeField;
\ No newline at end of file
import cx from "clsx";
import makeStyles from "@material-ui/core/styles/makeStyles";
import useTheme from "@material-ui/core/styles/useTheme";
import PropTypes from "prop-types";
import React from "react";
const useStyles = makeStyles(theme=>({
......@@ -10,22 +12,20 @@ const useStyles = makeStyles(theme=>({
},
}));
const Wrapper = (props) => {
const Wrapper = ({ children, className }) => {
const theme = useTheme();
const classes = useStyles(theme);
// eslint-disable-next-line react/prop-types
const { children } = props;
return (
<div className={classes.wrapper}>
<div className={className ? cx(classes.wrapper, className) : classes.wrapper}>
{ children }
</div>
);
};
Wrapper.propTypes = {
className: PropTypes.string,
children: PropTypes.node
};
export default Wrapper;
\ No newline at end of file
......@@ -29,9 +29,9 @@ const useStyles = makeStyles(theme => ({
}));
const ConfirmationModal = (props) => {
const { onConfirm, onCancel, title, description, open} = props;
const ConfirmationModal = ({ onConfirm, onCancel, title, description, open }) => {
const classes = useStyles();
return (
<Modal
open={open}
......
......@@ -2,8 +2,7 @@ import Button from "@material-ui/core/Button";
import Dialog from "@material-ui/core/Dialog";
import DialogTitle from "@material-ui/core/DialogTitle";
import Divider from "@material-ui/core/Divider";
import Modal from "@material-ui/core/Modal";
import { makeStyles, useTheme,withStyles } from "@material-ui/core/styles";
import { makeStyles } from "@material-ui/core/styles";
import Typography from "@material-ui/core/Typography";
import PropTypes from "prop-types";
import React from "react";
......@@ -38,8 +37,7 @@ const useStyles = makeStyles(theme => ({
}));
const FormModal = (props) => {
const { onSubmit, onCancel, title, open, size, cancelButtonText, submitButtonText} = props;
const FormModal = ({ onSubmit, onCancel, title, open, size, cancelButtonText, submitButtonText, children}) => {
const classes = useStyles();
return (
<Dialog
......@@ -56,7 +54,7 @@ const FormModal = (props) => {
<div className={classes.paper}>
<Typography variant={"h5"}>{ title }</Typography>
<Divider className={classes.divider}/>
{ props.children }
{ children }
<Divider className={classes.divider}/>
<div className={classes.buttonGroup}>
<Button variant={"contained"} onClick={onCancel}>{ cancelButtonText }</Button>
......@@ -76,6 +74,7 @@ FormModal.propTypes = {
size: PropTypes.string,
cancelButtonText: PropTypes.string,
submitButtonText: PropTypes.string,
children: PropTypes.node
};
FormModal.defaultProps = {
......
......@@ -17,8 +17,8 @@ export const APIContext = createContext({
refetch: ()=>{},
call: ()=>{},
callv2: ()=>{},
callv3: ()=>{}
callv3: ()=>{},
callv4: ()=>{},
});
export function useAuth() {
......@@ -172,7 +172,7 @@ const API = ({ children }) => {
};
const api_callv2 = ({url, method, object = undefined, json_or_form_data = "json", on_succes = undefined, on_failure = undefined, external = false}={}) => {
api_call(url, method, object, json_or_form_data, on_succes, on_failure, !external);
return api_call(url, method, object, json_or_form_data, on_succes, on_failure, !external);
};
const api_callv3 = ({url, method, object = undefined, json_or_form_data = "json", on_succes = undefined, on_failure = undefined, external = false}={}) => {
......@@ -180,7 +180,16 @@ const API = ({ children }) => {
if (url[0] === "/") {
url = process.env.REACT_APP_API_URL + url;
}
api_call(url, method, object, json_or_form_data, on_succes, on_failure, !external);
return api_call(url, method, object, json_or_form_data, on_succes, on_failure, !external);
};
const api_callv4 = ({url, method, queryParams = {}, object = undefined, json_or_form_data = "json", on_succes = undefined, on_failure = undefined, external = false}={}) => {
url += Object.entries(queryParams).reduce((queryParamString, queryParam)=>(
queryParamString
? queryParams + "&" + queryParam.join("=")
: "?" + queryParam.join("=")),
"");
return api_callv3({url, method, object, json_or_form_data, on_succes, on_failure, external});
};
const contextValue = {
......@@ -193,7 +202,8 @@ const API = ({ children }) => {
logout: handleLogout,
call: api_call,
callv2: api_callv2,
callv3: api_callv3
callv3: api_callv3,
callv4: api_callv4
};
let requestOptions;
......@@ -209,7 +219,6 @@ const API = ({ children }) => {
<RestfulProvider
base={process.env.REACT_APP_API_URL}
onError={(err, retry, response)=> {
console.log("error triggered");
console.log(err);
handleLogout();
return null;
......
This diff is collapsed.
This diff is collapsed.
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