diff --git a/client/.env.development b/client/.env.development index b23305d..ab28adf 100644 --- a/client/.env.development +++ b/client/.env.development @@ -1,2 +1,3 @@ REACT_APP_GOOGLE_MAPS_API_KEY=AIzaSyCxttBHhvoDHLXbUgnMtjO3OVDw46iFSQw REACT_APP_SERVER_URL=http://localhost:4000/graphql +REACT_APP_GOOGLE_OAUTH=962299963873-vfn6gg5ig0ilop0v70fgi7bonovplopr.apps.googleusercontent.com diff --git a/client/.eslintrc.js b/client/.eslintrc.js index e254df4..06edd8a 100644 --- a/client/.eslintrc.js +++ b/client/.eslintrc.js @@ -18,4 +18,10 @@ module.exports = { "plugin:react/recommended", "plugin:prettier/recommended", ], + rules: { + 'prettier/prettier': [ + 'error', + {endOfLine: 'auto'} + ] + }, }; diff --git a/client/package.json b/client/package.json index d98e8d6..a871b07 100644 --- a/client/package.json +++ b/client/package.json @@ -27,6 +27,7 @@ "react": "^17.0.2", "react-datetime": "2.16.3", "react-dom": "^17.0.2", + "react-google-login": "^5.2.2", "react-router-dom": "5.2.0", "react-scripts": "4.0.3", "react-slick": "0.26.1", diff --git a/client/src/CoviSource/Components/Pages/CreateProvider/CreateProvider.js b/client/src/CoviSource/Components/Pages/CreateProvider/CreateProvider.js index ad9b2bb..9703981 100644 --- a/client/src/CoviSource/Components/Pages/CreateProvider/CreateProvider.js +++ b/client/src/CoviSource/Components/Pages/CreateProvider/CreateProvider.js @@ -4,7 +4,6 @@ import { makeStyles } from "@material-ui/core/styles"; import InputAdornment from "@material-ui/core/InputAdornment"; // @material-ui/icons import LocationCity from "@material-ui/icons/LocationCity"; -// import People from "@material-ui/icons/People"; import Hospital from "@material-ui/icons/LocalHospital"; // core components import GridContainer from "components/Grid/GridContainer.js"; @@ -23,10 +22,10 @@ import "./CreateProvider.scss"; import image from "assets/img/bg7.jpg"; import CreateContact from "./CreateContact"; -import { useMutation } from "@apollo/client"; +import { useMutation, useQuery } from "@apollo/client"; import { CREATE_PROVIDER } from "CoviSource/graphql/mutations/Provider/CreateProvider"; import CreateResource from "./CreateResource"; -// import Map from "CoviSource/Components/UtilityComponents/Map/Map"; +import { GET_USER } from "CoviSource/graphql/queries/User/GetUser"; const useStyles = makeStyles(styles); @@ -40,6 +39,16 @@ const formReducer = (state, event) => { export default function CreateProvider(props) { const [formData, setFormData] = useReducer(formReducer, {}); const [resourceData, setresourceData] = useState({}); + const { + data: queryData, + error: queryError, + loading: queryLoading, + } = useQuery(GET_USER); + if (queryLoading) return <>Loading...; + if (queryError) return <>Error; + if (queryData.me === null) { + window.location.assign("/login"); + } const [cardAnimaton, setCardAnimation] = useState("cardHidden"); const [numberContact, setNumberContact] = useState(0); const [createProvider, { loading, data, error }] = useMutation( @@ -62,7 +71,6 @@ export default function CreateProvider(props) { name: event.target.name, value: event.target.value, }); - console.log(formData); }; const handleSubmit = (event) => { event.preventDefault(); diff --git a/client/src/CoviSource/Components/Pages/LandingPage/LandingPage.js b/client/src/CoviSource/Components/Pages/LandingPage/LandingPage.js index 517606c..f22365a 100644 --- a/client/src/CoviSource/Components/Pages/LandingPage/LandingPage.js +++ b/client/src/CoviSource/Components/Pages/LandingPage/LandingPage.js @@ -6,11 +6,8 @@ import classNames from "classnames"; // core components import Header from "CoviSource/Components/UtilityComponents/Header/Header"; - -// import Footer from "components/Footer/Footer.js"; import GridContainer from "components/Grid/GridContainer.js"; import GridItem from "components/Grid/GridItem.js"; -// import Button from "components/CustomButtons/Button.js"; import Parallax from "components/Parallax/Parallax.js"; // sections for the page @@ -34,174 +31,11 @@ export default function LandingPage(props) { const { loading, data, error } = useQuery(GET_ALL_PROVIDERS); if (loading) return <>Loading...; if (error) return <>Error; - if (data) console.log(data); - - // const [data, setData] = useState([ - // { - // username: "someUsername", - // resourceProviderName: "Resource Provider Name", - // availability: "UNUPDATED", - // resources: [ - // { - // resource: "Oxygen refilling", - // quantity: 32, - // updated: "06:00 PM, 27 APRIL", - // }, - // { - // resource: "Hospital Beds", - // quantity: 23, - // updated: "06:00 PM, 27 APRIL", - // }, - // { - // resource: "Remdesivir Vials", - // quantity: 65, - // updated: "06:00 PM, 27 APRIL", - // }, - // ], - // address: "Provider Address", - // contactPersonName: "Contact Person's Name", - // phoneNumber: "9821095754", - // serviceName: "Service Provided", - // }, - // { - // username: "anotherUsername", - // resourceProviderName: "Free oxygen seva vijaya nagar", - // availability: "AVAILABLE", - // resources: [ - // { - // resource: "Oxygen refilling", - // quantity: 32, - // updated: "06:00 PM, 27 APRIL", - // }, - // { - // resource: "Hospital Beds", - // quantity: 23, - // updated: "06:00 PM, 27 APRIL", - // }, - // { - // resource: "Remdesivir Vials", - // quantity: 65, - // updated: "06:00 PM, 27 APRIL", - // }, - // ], - // address: "Free oxygen seva, near gurudwara, delhi", - // contactPersonName: "Jaspal Singh", - // phoneNumber: "9821095754", - // serviceName: "Oxygen refilling", - // }, - // { - // username: "anotherUsername2", - // resourceProviderName: "Apex Hospital", - // availability: "UNAVAILABLE", - // resources: [ - // { - // resource: "Oxygen Cylinders", - // quantity: 0, - // updated: "06:00 PM, 27 APRIL", - // }, - // { - // resource: "Hospital Beds", - // quantity: 0, - // updated: "06:00 PM, 27 APRIL", - // }, - // { - // resource: "Remdesivir Vials", - // quantity: 0, - // updated: "06:00 PM, 27 APRIL", - // }, - // ], - // address: "Apex Hospital, Kalyan West, Mumbai", - // contactPersonName: "Dr. D P Goel", - // phoneNumber: "9789965234", - // serviceName: "Hospital", - // }, - // ]); const onSearchButtonClick = function () { console.log("Search Button Clicked"); - - // a fetch operation will be made here which will then update the state -> data; - // setData([ - // { - // username: "someUsername", - // resourceProviderName: "Resource Provider Name", - // availability: "UNUPDATED", - // resources: [ - // { - // resource: "Oxygen refilling", - // quantity: 32, - // updated: "06:00 PM, 27 APRIL", - // }, - // { - // resource: "Hospital Beds", - // quantity: 23, - // updated: "06:00 PM, 27 APRIL", - // }, - // { - // resource: "Remdesivir Vials", - // quantity: 65, - // updated: "06:00 PM, 27 APRIL", - // }, - // ], - // address: "Provider Address", - // contactPersonName: "Contact Person's Name", - // phoneNumber: "9821095754", - // serviceName: "Service Provided", - // }, - // { - // username: "anotherUsername", - // resourceProviderName: "Free oxygen seva vijaya nagar", - // availability: "AVAILABLE", - // resources: [ - // { - // resource: "Oxygen refilling", - // quantity: 32, - // updated: "06:00 PM, 27 APRIL", - // }, - // { - // resource: "Hospital Beds", - // quantity: 23, - // updated: "06:00 PM, 27 APRIL", - // }, - // { - // resource: "Remdesivir Vials", - // quantity: 65, - // updated: "06:00 PM, 27 APRIL", - // }, - // ], - // address: "Free oxygen seva, near gurudwara, delhi", - // contactPersonName: "Jaspal Singh", - // phoneNumber: "9821095754", - // serviceName: "Oxygen refilling", - // }, - // { - // username: "anotherUsername2", - // resourceProviderName: "Apex Hospital", - // availability: "UNAVAILABLE", - // resources: [ - // { - // resource: "Oxygen Cylinders", - // quantity: 0, - // updated: "06:00 PM, 27 APRIL", - // }, - // { - // resource: "Hospital Beds", - // quantity: 0, - // updated: "06:00 PM, 27 APRIL", - // }, - // { - // resource: "Remdesivir Vials", - // quantity: 0, - // updated: "06:00 PM, 27 APRIL", - // }, - // ], - // address: "Apex Hospital, Kalyan West, Mumbai", - // contactPersonName: "Dr. D P Goel", - // phoneNumber: "9789965234", - // serviceName: "Hospital", - // }, - // ]); }; + const renderResourcesCards = () => { return (
Loading...; + if (queryError) return <>Error; + if (queryData.me) { + window.location.assign("/"); + } const handleChange = (event) => { setFormData({ @@ -62,14 +75,17 @@ export default function Login(props) { }, }, }); - if (!loading) { - if (data) { - if (data.login.errors) { - alert(data.login.errors[0].message); - } else { - alert("Logged In!"); - window.location.assign("/"); - } + if (loading); + if (error) { + alert(error); + return; + } + if (data) { + if (data.login.errors) { + alert(data.login.errors[0].message); + } else { + alert("Logged In!"); + window.location.assign("/"); } } }; @@ -79,6 +95,33 @@ export default function Login(props) { color: "white", }; + const googleSuccess = async (res) => { + await login({ + variables: { + input: { + email: res.profileObj.email, + password: res.qc.login_hint, + }, + }, + }); + if (loading); + if (error) { + alert(error); + return; + } + if (data) { + if (data.login.errors) { + alert(data.login.errors[0].message); + } else { + alert("Logged In!"); + window.location.assign("/"); + } + } + }; + const googleFailure = () => { + alert("Google Signin was unsucessfull."); + }; + return (

Login

- + ( + + )} + onSuccess={googleSuccess} + onFailure={googleFailure} + cookiePolicy="single_host_origin" + />

Or Be Classical

diff --git a/client/src/CoviSource/Components/Pages/OrganisationPage/OrganisationPage.js b/client/src/CoviSource/Components/Pages/OrganisationPage/OrganisationPage.js index 3435998..291326e 100644 --- a/client/src/CoviSource/Components/Pages/OrganisationPage/OrganisationPage.js +++ b/client/src/CoviSource/Components/Pages/OrganisationPage/OrganisationPage.js @@ -31,9 +31,6 @@ export default function OrganisationPage() { console.log(error); return <>Error; } - if (data) { - console.log(data); - } const getBannerClass = function () { return "banner banner" + status[data.availability]; diff --git a/client/src/CoviSource/Components/Pages/RegistrationPage/RegistrationPage.js b/client/src/CoviSource/Components/Pages/RegistrationPage/RegistrationPage.js index 51d8e57..2c4151b 100644 --- a/client/src/CoviSource/Components/Pages/RegistrationPage/RegistrationPage.js +++ b/client/src/CoviSource/Components/Pages/RegistrationPage/RegistrationPage.js @@ -5,7 +5,6 @@ import InputAdornment from "@material-ui/core/InputAdornment"; // @material-ui/icons import Email from "@material-ui/icons/Email"; import People from "@material-ui/icons/People"; -// import Hospital from "@material-ui/icons/LocalHospital"; import Password from "@material-ui/icons/Lock"; // core components import GridContainer from "components/Grid/GridContainer.js"; @@ -25,11 +24,14 @@ import "./RegistrationPage.scss"; import image from "assets/img/bg2.jpg"; import Phone from "@material-ui/icons/Phone"; -import { useMutation } from "@apollo/client"; +import { useMutation, useQuery } from "@apollo/client"; import { ADD_USER } from "CoviSource/graphql/mutations/User/AddUser"; +import { GET_USER } from "CoviSource/graphql/queries/User/GetUser"; +import GoogleLogin from "react-google-login"; const useStyles = makeStyles(styles); +// To map each entry field to its value const formReducer = (state, event) => { return { ...state, @@ -46,6 +48,19 @@ export default function RegistrationPage(props) { const classes = useStyles(); const { ...rest } = props; + const { + data: queryData, + error: queryError, + loading: queryLoading, + } = useQuery(GET_USER); + + if (queryLoading) return <>Loading...; + if (queryError) return <>Error; + if (queryData.me) { + window.location.assign("/"); + } + + // addUser mutation const [addUser, { data, loading, error }] = useMutation(ADD_USER); const scrollChangeData = { @@ -53,6 +68,7 @@ export default function RegistrationPage(props) { color: "white", }; + // Handling change for individual entries of form data const handleChange = (event) => { setFormData({ name: event.target.name, @@ -60,6 +76,7 @@ export default function RegistrationPage(props) { }); }; + // Submit function to call the mutation const handleSubmit = (event) => { event.preventDefault(); addUser({ @@ -72,6 +89,38 @@ export default function RegistrationPage(props) { }, }, }); + // If loading then do nothing + if (loading); + // If error, alert the user + if (error) { + alert(error); + } + if (data) { + // If backend sends an error, alert the user + if (data.register.errors) { + alert(data.register.errors[0].message); + } + // Success + if (data.register.user) { + alert("Registration sucessful!"); + // Send to homepage + window.location.assign("/"); + } + } + }; + + // On obtaining valid Google OAuth tokens + const googleSuccess = async (res) => { + await addUser({ + variables: { + input: { + name: `${res.profileObj.givenName} ${res.profileObj.familyName}`, + email: res.profileObj.email, + phoneNumber: `${res.profileObj.googleId}`.substring(0, 10), + password: res.qc.login_hint, + }, + }, + }); if (loading); if (error) { alert(error); @@ -87,6 +136,11 @@ export default function RegistrationPage(props) { } }; + // On invalid Google OAuth + const googleFailure = () => { + alert("Google Signup was unsucessfull"); + }; + return (

Register Yourself

- + ( + + )} + onSuccess={googleSuccess} + onFailure={googleFailure} + cookiePolicy="single_host_origin" + />

Or Be Classical

diff --git a/client/src/components/Badge/Badge.js b/client/src/components/Badge/Badge.js deleted file mode 100755 index 3d29d5a..0000000 --- a/client/src/components/Badge/Badge.js +++ /dev/null @@ -1,35 +0,0 @@ -import React from "react"; -// nodejs library to set properties for components -import PropTypes from "prop-types"; - -// @material-ui/core components -import { makeStyles } from "@material-ui/core/styles"; - -import styles from "assets/jss/material-kit-react/components/badgeStyle.js"; - -const useStyles = makeStyles(styles); - -export default function Badge(props) { - const classes = useStyles(); - const { color, children } = props; - return ( - {children} - ); -} - -Badge.defaultProps = { - color: "gray", -}; - -Badge.propTypes = { - color: PropTypes.oneOf([ - "primary", - "warning", - "danger", - "success", - "info", - "rose", - "gray", - ]), - children: PropTypes.node, -}; diff --git a/client/src/components/Clearfix/Clearfix.js b/client/src/components/Clearfix/Clearfix.js deleted file mode 100755 index c95a1bc..0000000 --- a/client/src/components/Clearfix/Clearfix.js +++ /dev/null @@ -1,25 +0,0 @@ -import React from "react"; - -// mterial-ui components -import { makeStyles } from "@material-ui/core/styles"; - -const styles = { - clearfix: { - "&:after,&:before": { - display: "table", - content: '" "', - }, - "&:after": { - clear: "both", - }, - }, -}; - -const useStyles = makeStyles(styles); - -export default function Clearfix() { - const classes = useStyles(); - return
; -} - -Clearfix.propTypes = {}; diff --git a/client/src/components/CustomDropdown/CustomDropdown.js b/client/src/components/CustomDropdown/CustomDropdown.js deleted file mode 100755 index 6c176db..0000000 --- a/client/src/components/CustomDropdown/CustomDropdown.js +++ /dev/null @@ -1,195 +0,0 @@ -import React from "react"; -// nodejs library that concatenates classes -import classNames from "classnames"; -// nodejs library to set properties for components -import PropTypes from "prop-types"; - -// @material-ui/core components -import { makeStyles } from "@material-ui/core/styles"; -import MenuItem from "@material-ui/core/MenuItem"; -import MenuList from "@material-ui/core/MenuList"; -import ClickAwayListener from "@material-ui/core/ClickAwayListener"; -import Paper from "@material-ui/core/Paper"; -import Grow from "@material-ui/core/Grow"; -import Divider from "@material-ui/core/Divider"; -import Icon from "@material-ui/core/Icon"; -import Popper from "@material-ui/core/Popper"; - -// core components -import Button from "components/CustomButtons/Button.js"; - -import styles from "assets/jss/material-kit-react/components/customDropdownStyle.js"; - -const useStyles = makeStyles(styles); - -export default function CustomDropdown(props) { - const [anchorEl, setAnchorEl] = React.useState(null); - const handleClick = (event) => { - if (anchorEl && anchorEl.contains(event.target)) { - setAnchorEl(null); - } else { - setAnchorEl(event.currentTarget); - } - }; - const handleClose = (param) => { - setAnchorEl(null); - if (props && props.onClick) { - props.onClick(param); - } - }; - const handleCloseAway = (event) => { - if (anchorEl.contains(event.target)) { - return; - } - setAnchorEl(null); - }; - const classes = useStyles(); - const { - buttonText, - buttonIcon, - dropdownList, - buttonProps, - dropup, - dropdownHeader, - caret, - hoverColor, - left, - rtlActive, - noLiPadding, - } = props; - const caretClasses = classNames({ - [classes.caret]: true, - [classes.caretActive]: Boolean(anchorEl), - [classes.caretRTL]: rtlActive, - }); - const dropdownItem = classNames({ - [classes.dropdownItem]: true, - [classes[hoverColor + "Hover"]]: true, - [classes.noLiPadding]: noLiPadding, - [classes.dropdownItemRTL]: rtlActive, - }); - let icon = null; - switch (typeof buttonIcon) { - case "object": - icon = ; - break; - case "string": - icon = {props.buttonIcon}; - break; - default: - icon = null; - break; - } - return ( -
-
- -
- - {() => ( - - - - - {dropdownHeader !== undefined ? ( - handleClose(dropdownHeader)} - className={classes.dropdownHeader} - > - {dropdownHeader} - - ) : null} - {dropdownList.map((prop, key) => { - if (prop.divider) { - return ( - handleClose("divider")} - className={classes.dropdownDividerItem} - /> - ); - } - return ( - handleClose(prop)} - className={dropdownItem} - > - {prop} - - ); - })} - - - - - )} - -
- ); -} - -CustomDropdown.defaultProps = { - caret: true, - hoverColor: "primary", -}; - -CustomDropdown.propTypes = { - hoverColor: PropTypes.oneOf([ - "black", - "primary", - "info", - "success", - "warning", - "danger", - "rose", - ]), - buttonText: PropTypes.node, - buttonIcon: PropTypes.oneOfType([PropTypes.object, PropTypes.string]), - dropdownList: PropTypes.array, - buttonProps: PropTypes.object, - dropup: PropTypes.bool, - dropdownHeader: PropTypes.node, - rtlActive: PropTypes.bool, - caret: PropTypes.bool, - left: PropTypes.bool, - noLiPadding: PropTypes.bool, - // function that retuns the selected item - onClick: PropTypes.func, -}; diff --git a/client/src/components/CustomDropdown/CustomDropdown.jsx b/client/src/components/CustomDropdown/CustomDropdown.jsx deleted file mode 100755 index d7c1719..0000000 --- a/client/src/components/CustomDropdown/CustomDropdown.jsx +++ /dev/null @@ -1,214 +0,0 @@ -import React from "react"; -// nodejs library that concatenates classes -import classNames from "classnames"; -// nodejs library to set properties for components -import PropTypes from "prop-types"; - -// @material-ui/core components -import withStyles from "@material-ui/core/styles/withStyles"; -import MenuItem from "@material-ui/core/MenuItem"; -import MenuList from "@material-ui/core/MenuList"; -import ClickAwayListener from "@material-ui/core/ClickAwayListener"; -import Paper from "@material-ui/core/Paper"; -import Grow from "@material-ui/core/Grow"; -import Divider from "@material-ui/core/Divider"; -import Icon from "@material-ui/core/Icon"; -import Popper from "@material-ui/core/Popper"; - -// core components -import Button from "components/CustomButtons/Button.jsx"; - -import customDropdownStyle from "assets/jss/material-kit-react/components/customDropdownStyle.jsx"; - -class CustomDropdown extends React.Component { - constructor(props) { - super(props); - this.state = { - open: false, - }; - } - handleClick = () => { - this.setState((state) => ({ open: !state.open })); - }; - handleClose = (param) => { - this.setState({ open: false }); - if (this.props && this.props.onClick) { - this.props.onClick(param); - } - }; - handleCloseAway = (event) => { - if (this.anchorEl.contains(event.target)) { - return; - } - this.setState({ open: false }); - }; - render() { - const { open } = this.state; - const { - classes, - buttonText, - buttonIcon, - dropdownList, - buttonProps, - dropup, - dropdownHeader, - caret, - hoverColor, - left, - rtlActive, - noLiPadding, - } = this.props; - const caretClasses = classNames({ - [classes.caret]: true, - [classes.caretActive]: open, - [classes.caretRTL]: rtlActive, - }); - const dropdownItem = classNames({ - [classes.dropdownItem]: true, - [classes[hoverColor + "Hover"]]: true, - [classes.noLiPadding]: noLiPadding, - [classes.dropdownItemRTL]: rtlActive, - }); - let icon = null; - switch (typeof buttonIcon) { - case "function": - icon = ; - break; - case "object": - if (buttonIcon.type.muiName === "Icon") { - icon = this.props.buttonIcon; - } - break; - case "string": - icon = ( - {this.props.buttonIcon} - ); - break; - default: - icon = null; - break; - } - return ( -
-
- -
- - {({ TransitionProps, placement }) => ( - - - - - {dropdownHeader !== undefined ? ( - this.handleClose(dropdownHeader)} - className={classes.dropdownHeader} - > - {dropdownHeader} - - ) : null} - {dropdownList.map((prop, key) => { - if (prop.divider) { - return ( - this.handleClose("divider")} - className={classes.dropdownDividerItem} - /> - ); - } - return ( - this.handleClose(prop)} - className={dropdownItem} - > - {prop} - - ); - })} - - - - - )} - -
- ); - } -} - -CustomDropdown.defaultProps = { - caret: true, - hoverColor: "primary", -}; - -CustomDropdown.propTypes = { - classes: PropTypes.object.isRequired, - hoverColor: PropTypes.oneOf([ - "black", - "primary", - "info", - "success", - "warning", - "danger", - "rose", - ]), - buttonText: PropTypes.node, - buttonIcon: PropTypes.oneOfType([ - PropTypes.func, - PropTypes.object, - PropTypes.string, - ]), - dropdownList: PropTypes.array, - buttonProps: PropTypes.object, - dropup: PropTypes.bool, - dropdownHeader: PropTypes.node, - rtlActive: PropTypes.bool, - caret: PropTypes.bool, - left: PropTypes.bool, - noLiPadding: PropTypes.bool, - // function that retuns the selected item - onClick: PropTypes.func, -}; - -export default withStyles(customDropdownStyle)(CustomDropdown); diff --git a/client/src/components/CustomLinearProgress/CustomLinearProgress.js b/client/src/components/CustomLinearProgress/CustomLinearProgress.js deleted file mode 100755 index 78ecb4c..0000000 --- a/client/src/components/CustomLinearProgress/CustomLinearProgress.js +++ /dev/null @@ -1,41 +0,0 @@ -import React from "react"; -// nodejs library to set properties for components -import PropTypes from "prop-types"; - -// @material-ui/core components -import { makeStyles } from "@material-ui/core/styles"; -import LinearProgress from "@material-ui/core/LinearProgress"; -// core components -import styles from "assets/jss/material-kit-react/components/customLinearProgressStyle.js"; - -const useStyles = makeStyles(styles); - -export default function CustomLinearProgress(props) { - const classes = useStyles(); - const { color, ...rest } = props; - return ( - - ); -} - -CustomLinearProgress.defaultProps = { - color: "gray", -}; - -CustomLinearProgress.propTypes = { - color: PropTypes.oneOf([ - "primary", - "warning", - "danger", - "success", - "info", - "rose", - "gray", - ]), -}; diff --git a/client/src/components/CustomTabs/CustomTabs.js b/client/src/components/CustomTabs/CustomTabs.js deleted file mode 100755 index 31190b5..0000000 --- a/client/src/components/CustomTabs/CustomTabs.js +++ /dev/null @@ -1,104 +0,0 @@ -import React from "react"; -// nodejs library that concatenates classes -import classNames from "classnames"; -// nodejs library to set properties for components -import PropTypes from "prop-types"; - -// material-ui components -import { makeStyles } from "@material-ui/core/styles"; -import Tabs from "@material-ui/core/Tabs"; -import Tab from "@material-ui/core/Tab"; -import Icon from "@material-ui/core/Icon"; -// core components -import Card from "components/Card/Card.js"; -import CardBody from "components/Card/CardBody.js"; -import CardHeader from "components/Card/CardHeader.js"; - -import styles from "assets/jss/material-kit-react/components/customTabsStyle.js"; - -const useStyles = makeStyles(styles); - -export default function CustomTabs(props) { - const [value, setValue] = React.useState(0); - - const handleChange = (event, value) => { - setValue(value); - }; - const classes = useStyles(); - const { headerColor, plainTabs, tabs, title, rtlActive } = props; - const cardTitle = classNames({ - [classes.cardTitle]: true, - [classes.cardTitleRTL]: rtlActive, - }); - return ( - - - {title !== undefined ?
{title}
: null} - - {tabs.map((prop, key) => { - var icon = {}; - if (prop.tabIcon) { - icon = { - icon: - typeof prop.tabIcon === "string" ? ( - {prop.tabIcon} - ) : ( - - ), - }; - } - return ( - - ); - })} - -
- - {tabs.map((prop, key) => { - if (key === value) { - return
{prop.tabContent}
; - } - return null; - })} -
-
- ); -} - -CustomTabs.propTypes = { - headerColor: PropTypes.oneOf([ - "warning", - "success", - "danger", - "info", - "primary", - "rose", - ]), - title: PropTypes.string, - tabs: PropTypes.arrayOf( - PropTypes.shape({ - tabName: PropTypes.string.isRequired, - tabIcon: PropTypes.object, - tabContent: PropTypes.node.isRequired, - }) - ), - rtlActive: PropTypes.bool, - plainTabs: PropTypes.bool, -}; diff --git a/client/src/components/InfoArea/InfoArea.js b/client/src/components/InfoArea/InfoArea.js deleted file mode 100755 index 82a7f4b..0000000 --- a/client/src/components/InfoArea/InfoArea.js +++ /dev/null @@ -1,56 +0,0 @@ -import React from "react"; -// nodejs library to set properties for components -import PropTypes from "prop-types"; -// nodejs library that concatenates classes -import classNames from "classnames"; -// @material-ui/core components -import { makeStyles } from "@material-ui/core/styles"; - -import styles from "assets/jss/material-kit-react/components/infoStyle.js"; - -const useStyles = makeStyles(styles); - -export default function InfoArea(props) { - const classes = useStyles(); - const { title, description, iconColor, vertical } = props; - const iconWrapper = classNames({ - [classes.iconWrapper]: true, - [classes[iconColor]]: true, - [classes.iconWrapperVertical]: vertical, - }); - const iconClasses = classNames({ - [classes.icon]: true, - [classes.iconVertical]: vertical, - }); - return ( -
-
- -
-
-

{title}

-

{description}

-
-
- ); -} - -InfoArea.defaultProps = { - iconColor: "gray", -}; - -InfoArea.propTypes = { - icon: PropTypes.object.isRequired, - title: PropTypes.string.isRequired, - description: PropTypes.string.isRequired, - iconColor: PropTypes.oneOf([ - "primary", - "warning", - "danger", - "success", - "info", - "rose", - "gray", - ]), - vertical: PropTypes.bool, -}; diff --git a/client/src/components/NavPills/NavPills.js b/client/src/components/NavPills/NavPills.js deleted file mode 100755 index 0014763..0000000 --- a/client/src/components/NavPills/NavPills.js +++ /dev/null @@ -1,131 +0,0 @@ -import React from "react"; -// nodejs library that concatenates classes -import classNames from "classnames"; -// nodejs library to set properties for components -import PropTypes from "prop-types"; -import SwipeableViews from "react-swipeable-views"; - -// @material-ui/core components -import { makeStyles } from "@material-ui/core/styles"; -import Tabs from "@material-ui/core/Tabs"; -import Tab from "@material-ui/core/Tab"; - -// core components -import GridContainer from "components/Grid/GridContainer.js"; -import GridItem from "components/Grid/GridItem.js"; - -import styles from "assets/jss/material-kit-react/components/navPillsStyle.js"; - -const useStyles = makeStyles(styles); - -export default function NavPills(props) { - const [active, setActive] = React.useState(props.active); - const handleChange = (event, active) => { - setActive(active); - }; - const handleChangeIndex = (index) => { - setActive(index); - }; - const classes = useStyles(); - const { tabs, direction, color, horizontal, alignCenter } = props; - const flexContainerClasses = classNames({ - [classes.flexContainer]: true, - [classes.horizontalDisplay]: horizontal !== undefined, - }); - const tabButtons = ( - - {tabs.map((prop, key) => { - var icon = {}; - if (prop.tabIcon !== undefined) { - icon["icon"] = ; - } - const pillsClasses = classNames({ - [classes.pills]: true, - [classes.horizontalPills]: horizontal !== undefined, - [classes.pillsWithIcons]: prop.tabIcon !== undefined, - }); - return ( - - ); - })} - - ); - const tabContent = ( -
- - {tabs.map((prop, key) => { - return ( -
- {prop.tabContent} -
- ); - })} -
-
- ); - return horizontal !== undefined ? ( - - {tabButtons} - {tabContent} - - ) : ( -
- {tabButtons} - {tabContent} -
- ); -} - -NavPills.defaultProps = { - active: 0, - color: "primary", -}; - -NavPills.propTypes = { - // index of the default active pill - active: PropTypes.number, - tabs: PropTypes.arrayOf( - PropTypes.shape({ - tabButton: PropTypes.string, - tabIcon: PropTypes.object, - tabContent: PropTypes.node, - }) - ).isRequired, - color: PropTypes.oneOf([ - "primary", - "warning", - "danger", - "success", - "info", - "rose", - ]), - direction: PropTypes.string, - horizontal: PropTypes.shape({ - tabsGrid: PropTypes.object, - contentGrid: PropTypes.object, - }), - alignCenter: PropTypes.bool, -}; diff --git a/client/src/components/Pagination/Pagination.js b/client/src/components/Pagination/Pagination.js deleted file mode 100755 index 728e720..0000000 --- a/client/src/components/Pagination/Pagination.js +++ /dev/null @@ -1,64 +0,0 @@ -import React from "react"; -// nodejs library to set properties for components -import PropTypes from "prop-types"; -// nodejs library that concatenates classes -import classNames from "classnames"; - -// @material-ui/core components -import { makeStyles } from "@material-ui/core/styles"; -import Button from "@material-ui/core/Button"; - -import styles from "assets/jss/material-kit-react/components/paginationStyle.js"; - -const useStyles = makeStyles(styles); - -export default function Pagination(props) { - const classes = useStyles(); - const { pages, color } = props; - return ( -
    - {pages.map((prop, key) => { - const paginationLink = classNames({ - [classes.paginationLink]: true, - [classes[color]]: prop.active, - [classes.disabled]: prop.disabled, - }); - return ( -
  • - {prop.onClick !== undefined ? ( - - ) : ( - - )} -
  • - ); - })} -
- ); -} - -Pagination.defaultProps = { - color: "primary", -}; - -Pagination.propTypes = { - pages: PropTypes.arrayOf( - PropTypes.shape({ - active: PropTypes.bool, - disabled: PropTypes.bool, - text: PropTypes.oneOfType([ - PropTypes.number, - PropTypes.oneOf(["PREV", "NEXT", "..."]), - ]).isRequired, - onClick: PropTypes.func, - }) - ).isRequired, - color: PropTypes.oneOf(["primary", "info", "success", "warning", "danger"]), -}; diff --git a/client/src/components/Snackbar/SnackbarContent.js b/client/src/components/Snackbar/SnackbarContent.js deleted file mode 100755 index d1c4d45..0000000 --- a/client/src/components/Snackbar/SnackbarContent.js +++ /dev/null @@ -1,72 +0,0 @@ -import React from "react"; -// nodejs library to set properties for components -import PropTypes from "prop-types"; -// @material-ui/core components -import { makeStyles } from "@material-ui/core/styles"; -import Snack from "@material-ui/core/SnackbarContent"; -import IconButton from "@material-ui/core/IconButton"; -import Icon from "@material-ui/core/Icon"; -// @material-ui/icons -import Close from "@material-ui/icons/Close"; -// core components - -import styles from "assets/jss/material-kit-react/components/snackbarContentStyle.js"; - -const useStyles = makeStyles(styles); - -export default function SnackbarContent(props) { - const { message, color, close, icon } = props; - const classes = useStyles(); - var action = []; - const closeAlert = () => { - setAlert(null); - }; - if (close !== undefined) { - action = [ - - - , - ]; - } - let snackIcon = null; - switch (typeof icon) { - case "object": - snackIcon = ; - break; - case "string": - snackIcon = {props.icon}; - break; - default: - snackIcon = null; - break; - } - const [alert, setAlert] = React.useState( - - {snackIcon} - {message} - {close !== undefined ? action : null} -
- } - classes={{ - root: classes.root + " " + classes[color], - message: classes.message + " " + classes.container, - }} - /> - ); - return alert; -} - -SnackbarContent.propTypes = { - message: PropTypes.node.isRequired, - color: PropTypes.oneOf(["info", "success", "warning", "danger", "primary"]), - close: PropTypes.bool, - icon: PropTypes.oneOfType([PropTypes.object, PropTypes.string]), -}; diff --git a/client/src/components/Typography/Danger.js b/client/src/components/Typography/Danger.js deleted file mode 100755 index ec063e1..0000000 --- a/client/src/components/Typography/Danger.js +++ /dev/null @@ -1,23 +0,0 @@ -import React from "react"; -// nodejs library to set properties for components -import PropTypes from "prop-types"; -// @material-ui/core components -import { makeStyles } from "@material-ui/core/styles"; -// core components -import styles from "assets/jss/material-kit-react/components/typographyStyle.js"; - -const useStyles = makeStyles(styles); - -export default function Danger(props) { - const classes = useStyles(); - const { children } = props; - return ( -
- {children} -
- ); -} - -Danger.propTypes = { - children: PropTypes.node, -}; diff --git a/client/src/components/Typography/Info.js b/client/src/components/Typography/Info.js deleted file mode 100755 index bafaf7d..0000000 --- a/client/src/components/Typography/Info.js +++ /dev/null @@ -1,23 +0,0 @@ -import React from "react"; -// nodejs library to set properties for components -import PropTypes from "prop-types"; -// @material-ui/core components -import { makeStyles } from "@material-ui/core/styles"; -// core components -import styles from "assets/jss/material-kit-react/components/typographyStyle.js"; - -const useStyles = makeStyles(styles); - -export default function Info(props) { - const classes = useStyles(); - const { children } = props; - return ( -
- {children} -
- ); -} - -Info.propTypes = { - children: PropTypes.node, -}; diff --git a/client/src/components/Typography/Muted.js b/client/src/components/Typography/Muted.js deleted file mode 100755 index 2458a81..0000000 --- a/client/src/components/Typography/Muted.js +++ /dev/null @@ -1,23 +0,0 @@ -import React from "react"; -// nodejs library to set properties for components -import PropTypes from "prop-types"; -// @material-ui/core components -import { makeStyles } from "@material-ui/core/styles"; -// core components -import styles from "assets/jss/material-kit-react/components/typographyStyle.js"; - -const useStyles = makeStyles(styles); - -export default function Muted(props) { - const classes = useStyles(); - const { children } = props; - return ( -
- {children} -
- ); -} - -Muted.propTypes = { - children: PropTypes.node, -}; diff --git a/client/src/components/Typography/Primary.js b/client/src/components/Typography/Primary.js deleted file mode 100755 index 6564c9a..0000000 --- a/client/src/components/Typography/Primary.js +++ /dev/null @@ -1,23 +0,0 @@ -import React from "react"; -// nodejs library to set properties for components -import PropTypes from "prop-types"; -// @material-ui/core components -import { makeStyles } from "@material-ui/core/styles"; -// core components -import styles from "assets/jss/material-kit-react/components/typographyStyle.js"; - -const useStyles = makeStyles(styles); - -export default function Primary(props) { - const classes = useStyles(); - const { children } = props; - return ( -
- {children} -
- ); -} - -Primary.propTypes = { - children: PropTypes.node, -}; diff --git a/client/src/components/Typography/Quote.js b/client/src/components/Typography/Quote.js deleted file mode 100755 index b8f087e..0000000 --- a/client/src/components/Typography/Quote.js +++ /dev/null @@ -1,25 +0,0 @@ -import React from "react"; -// nodejs library to set properties for components -import PropTypes from "prop-types"; -// @material-ui/core components -import { makeStyles } from "@material-ui/core/styles"; -// core components -import styles from "assets/jss/material-kit-react/components/typographyStyle.js"; - -const useStyles = makeStyles(styles); - -export default function Quote(props) { - const { text, author } = props; - const classes = useStyles(); - return ( -
-

{text}

- {author} -
- ); -} - -Quote.propTypes = { - text: PropTypes.node, - author: PropTypes.node, -}; diff --git a/client/src/components/Typography/Small.js b/client/src/components/Typography/Small.js deleted file mode 100755 index 54101ac..0000000 --- a/client/src/components/Typography/Small.js +++ /dev/null @@ -1,23 +0,0 @@ -import React from "react"; -// nodejs library to set properties for components -import PropTypes from "prop-types"; -// @material-ui/core components -import { makeStyles } from "@material-ui/core/styles"; -// core components -import styles from "assets/jss/material-kit-react/components/typographyStyle.js"; - -const useStyles = makeStyles(styles); - -export default function Small(props) { - const classes = useStyles(); - const { children } = props; - return ( -
- {children} -
- ); -} - -Small.propTypes = { - children: PropTypes.node, -}; diff --git a/client/src/components/Typography/Success.js b/client/src/components/Typography/Success.js deleted file mode 100755 index 2ae7c47..0000000 --- a/client/src/components/Typography/Success.js +++ /dev/null @@ -1,23 +0,0 @@ -import React from "react"; -// nodejs library to set properties for components -import PropTypes from "prop-types"; -// @material-ui/core components -import { makeStyles } from "@material-ui/core/styles"; -// core components -import styles from "assets/jss/material-kit-react/components/typographyStyle.js"; - -const useStyles = makeStyles(styles); - -export default function Success(props) { - const classes = useStyles(); - const { children } = props; - return ( -
- {children} -
- ); -} - -Success.propTypes = { - children: PropTypes.node, -}; diff --git a/client/src/components/Typography/Warning.js b/client/src/components/Typography/Warning.js deleted file mode 100755 index f7dc6d3..0000000 --- a/client/src/components/Typography/Warning.js +++ /dev/null @@ -1,23 +0,0 @@ -import React from "react"; -// nodejs library to set properties for components -import PropTypes from "prop-types"; -// @material-ui/core components -import { makeStyles } from "@material-ui/core/styles"; -// core components -import styles from "assets/jss/material-kit-react/components/typographyStyle.js"; - -const useStyles = makeStyles(styles); - -export default function Warning(props) { - const classes = useStyles(); - const { children } = props; - return ( -
- {children} -
- ); -} - -Warning.propTypes = { - children: PropTypes.node, -}; diff --git a/client/yarn.lock b/client/yarn.lock index dc67243..8655258 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -10839,6 +10839,14 @@ react-event-listener@^0.6.0, react-event-listener@^0.6.2: prop-types "^15.6.0" warning "^4.0.1" +react-google-login@^5.2.2: + version "5.2.2" + resolved "https://registry.yarnpkg.com/react-google-login/-/react-google-login-5.2.2.tgz#a20b46440c6c1610175ef75baf427118ff0e9859" + integrity sha512-JUngfvaSMcOuV0lFff7+SzJ2qviuNMQdqlsDJkUM145xkGPVIfqWXq9Ui+2Dr6jdJWH5KYdynz9+4CzKjI5u6g== + dependencies: + "@types/react" "*" + prop-types "^15.6.0" + react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" diff --git a/server/src/index.ts b/server/src/index.ts index 89d5b26..3ea63db 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -44,8 +44,8 @@ const main = async () => { maxAge: COOKIE_MAX_AGE, httpOnly: true, secure: __prod__, - sameSite: 'lax', - domain: __prod__ ? '.emperoryp.live' : undefined, + sameSite: 'lax', // CSRF + domain: __prod__ ? '.covisource.tech' : undefined, }, saveUninitialized: false, secret: process.env.SESSION_SECRET, diff --git a/server/src/resolvers/User.ts b/server/src/resolvers/User.ts index af7fe21..abc8967 100644 --- a/server/src/resolvers/User.ts +++ b/server/src/resolvers/User.ts @@ -67,6 +67,18 @@ export class UserResolver { return User.find(); } + @Mutation(() => Boolean) + async deleteUser( + @Arg('id') id: number, + ): Promise { + try { + await User.delete(id); + return true; + } catch (err) { + return false; + } + } + @Mutation(() => UserResponse) async register( @Arg('input') input: UserRegisterInput,