diff --git a/src/components/AboutUsBox.js b/src/components/AboutUsBox.js index 9647755..9fb5c27 100644 --- a/src/components/AboutUsBox.js +++ b/src/components/AboutUsBox.js @@ -65,7 +65,7 @@ export default function AboutUsBox() { return ( <> - +

diff --git a/src/components/AddExecomDialog.js b/src/components/AddExecomDialog.js new file mode 100644 index 0000000..53ed4d8 --- /dev/null +++ b/src/components/AddExecomDialog.js @@ -0,0 +1,364 @@ +import { + Button, + Dialog, + DialogActions, + DialogContent, + DialogContentText, + DialogTitle, + FormControl, + FormControlLabel, + InputLabel, + makeStyles, + MenuItem, + Select, + Snackbar, + TextField, + Grid, + InputAdornment, + Input, + Checkbox, + OutlinedInput, + // Typography, +} from '@material-ui/core'; +import axios from 'axios'; +import React, { useState, useEffect } from 'react'; +import { hostname, societyNames } from '../links'; +import { useImageUploader, FileUploadButton, convertDatesinValuestoUTC } from '../utils'; + +import Alert from '@material-ui/lab/Alert'; +import { CircularProgress } from '@material-ui/core'; + +const useStyles = makeStyles(theme => ({ + root: { + position: 'absolute', + top: '30%', + }, + formControl: { + minWidth: 240, + }, + fields: { + 'padding': theme.spacing(1), + '& .MuiOutlinedInput-root': { + '& fieldset': { + borderColor: 'green', + }, + '&:hover fieldset': { + border: '2px solid', + borderColor: 'green', + }, + '&.Mui-focused fieldset': { + border: '2px solid green', + }, + }, + }, +})); + +//Nice prototype to convert Date objects to datetime local strings +// eslint-disable-next-line +Date.prototype.toDatetimeLocal = function toDatetimeLocal() { + var date = this, + ten = function (i) { + return (i < 10 ? '0' : '') + i; + }, + YYYY = date.getFullYear(), + MM = ten(date.getMonth() + 1), + DD = ten(date.getDate()), + HH = ten(date.getHours()), + II = ten(date.getMinutes()), + SS = ten(date.getSeconds()); + return YYYY + '-' + MM + '-' + DD + 'T' + HH + ':' + II + ':' + SS; +}; +export const AddExecomDialog = props => { + const classes = useStyles(); + + // Textfields related + const [values, setValues] = useState({ + firstname: '', + lastname: '', + position: '', + sid: props.sid, + tenureStart: new Date().toDatetimeLocal(), + tenureEnd: null, + imagepath: '', + }); + + useEffect(() => { + if (props.data !== undefined) { + console.log('data'); + setValues({ + ...props.data, + tenureStart: props.data.tenureStart.toDatetimeLocal(), + tenureEnd: props.data.tenureEnd.toDatetimeLocal(), + }); + } + }, [props.data]); + + const { isLoading, error, uploadImage } = useImageUploader(); + const handleFileInputChange = async file => { + const url = await uploadImage(file); + setValues({ + ...values, + imagepath: url, + }); + }; + + const handleChange = prop => event => { + setValues({ + ...values, + [prop]: event.target.value, + }); + }; + + const [meta, setMeta] = useState({ + error: false, + success: false, + }); + + const submitData = e => { + e.preventDefault(); + props.onClose(); + console.log(values); + // if (props.edit === true) { + // axios + // .put(hostname + '/api/event/' + props.data.eid, values, { + // headers: { + // 'Content-Type': 'application/json', + // 'Authorization': 'Bearer ' + localStorage.getItem('atoken'), + // }, + // }) + // .then(response => { + // if (response.data.ok === true) setMeta({ ...meta, success: true }); + // else setMeta({ ...meta, error: true }); + // }) + // .then(() => { + // window.location.reload(); + // }) + // .catch(error => { + // console.error(error.response); + // setMeta({ ...meta, error: true }); + // }); + // } else { + + const requestData = convertDatesinValuestoUTC(values, ['tenureStart', values.tenureEnd === '' ? '' : 'tenureEnd']); + axios + .post(hostname + '/api/execom', requestData, { + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer ' + localStorage.getItem('atoken'), + }, + }) + .then(response => { + if (response.data.ok === true) setMeta({ ...meta, success: true }); + else setMeta({ ...meta, error: true }); + }) + .then(() => { + window.location.reload(); + }) + .catch(error => { + console.error(error.response); + setMeta({ ...meta, error: true }); + }); + // } + }; + + // Handle closing of snackbars + const handleClose = prop => (event, reason) => { + if (reason === 'clickaway') return; + setMeta({ ...meta, [prop]: false }); + }; + + const [isCurrent, setIsCurrent] = useState(true); + const handleEndTenure = event => { + setIsCurrent(event.target.checked); + if (event.target.checked) + setValues({ + ...values, + tenureEnd: '', + }); + }; + + return ( + <> + + Add Execom Member for {societyNames[props.sid]["name"]} + + + Add execom details. Abide by the datatypes used in the form and use + submit button to add the execom. + + + + + + + + + + + + Designation + + + + + + + } + label="Is the member currently serving in the Execom?" + /> + {!isCurrent && ( + + + + )} + + + Image Link + + { + const file = e.target.files[0]; + await handleFileInputChange(file); + }} + /> + + + } + /> + + {error &&

Error: {error.message}

} + {values.imagepath !== '' ? ( +
+ execomimage +
+ ) : null} + {isLoading && ( +
+ +
+ )} +
+
+ + + + +
+ + + {props.edit ? 'An error occurred while editing an execom' : 'An error occurred while adding execom'} + + + + + {props.edit ? 'Execom details edited successfully' : 'Execom details added successfully'} + + + + ); +}; diff --git a/src/components/Aluminiapi.js b/src/components/Aluminiapi.js new file mode 100644 index 0000000..0ba8aff --- /dev/null +++ b/src/components/Aluminiapi.js @@ -0,0 +1,152 @@ +import React from 'react'; +import { makeStyles } from '@material-ui/core/styles'; +import { Paper, Typography, Accordion, AccordionSummary, AccordionDetails, Grid } from '@material-ui/core'; +import Avatar from './Avatar'; +import GiveMeABreak from './GiveMeABreak'; +import SpacyDivider from './SpacyDivider'; + +const useStyles = makeStyles(theme => ({ + paper: { + ...theme.paper, + padding: theme.spacing(4), + backgroundColor: '#00000000', + }, +})); + +export default function Aluminiapi(props) { + const { members } = props; + const classes = useStyles(); + + +// const[members,setMembers] = useState({ +// "2020": [ +// { +// "name": "Risha Dassi", +// "position": "Chair", +// "image": "https://ieee-rvce.org/assets/images/alumni/2020/compsoc/risha.jpg" +// }, +// { +// "name": "Nischal J", +// "position": "Vice Chair", +// "image": "https://ieee-rvce.org/assets/images/alumni/2020/compsoc/nischal.jpg" +// }, +// { +// "name": "Chirag Bapat", +// "position": "Treasurer", +// "image": "https://ieee-rvce.org/assets/images/alumni/2020/compsoc/chirag.jpg" +// }, +// { +// "name": "Nikitha Srikanth", +// "position": "Secretary", +// "image": "https://ieee-rvce.org/assets/images/alumni/2020/compsoc/niks.jpg" +// } +// ], +// "2021": [ +// { +// "name": "Dr. Ashok Kumar AR", +// "position": "Faculty Advisor", +// "image": "https://ieee-rvce.org/assets/images/alumni/2021/compsoc/ashok_sir.jpg" +// }, +// { +// "name": "Akshara Udupa", +// "position": "Chair", +// "image": "https://ieee-rvce.org/assets/images/alumni/2021/compsoc/akshara.jpg" +// }, +// { +// "name": "Vishal M", +// "position": "Vice Chair", +// "image": "https://ieee-rvce.org/assets/images/alumni/2021/compsoc/vishal.jpg" +// }, +// { +// "name": "Namya LG", +// "position": "Treasurer", +// "image": "https://ieee-rvce.org/assets/images/alumni/2021/compsoc/namya.jpg" +// }, +// { +// "name": "Shashank Dhavalla", +// "position": "Secretary", +// "image": "https://ieee-rvce.org/assets/images/alumni/2021/compsoc/shashank.jpg" +// } +// ], +// "2022": [ +// { +// "name": "Dr. Ashok Kumar AR", +// "position": "Faculty Advisor", +// "image": "https://ieee-rvce.org/assets/images/alumni/2022/compsoc/ashok_sir.jpg" +// }, +// { +// "name": "Shubhaprada K P", +// "position": "Chair", +// "image": "https://ieee-rvce.org/assets/images/alumni/2022/compsoc/ShubhaPrada.jpeg" +// }, +// { +// "name": "Prajwal P", +// "position": "Vice Chair", +// "image": "https://ieee-rvce.org/assets/images/alumni/2022/compsoc/prajwal.PNG" +// }, +// { +// "name": "Sonia Singh B", +// "position": "Treasurer", +// "image": "https://ieee-rvce.org/assets/images/alumni/2022/compsoc/Sonia_Singh.jpeg" +// }, +// { +// "name": "Malavika Hariprasad ", +// "position": "Secretary", +// "image": "https://ieee-rvce.org/assets/images/alumni/2022/compsoc/Malavika_HariPrasad.jpg" +// } +//        ] +//     } +// ); + // useEffect(() => { + // axios.get(hostname + `/api/execom/alumini/1`).then(response => { + // setMember(response.data.execom); + // console.log(member); + //    }); + + // }, []); + + let color = props.color ?? '#222222'; + return ( + <> + { + // Check if members is not empty + members !== undefined && Object.keys(members).length !== 0 && ( + <> + + + + Alumni + + + {Object.keys(members).map((batch,index) => ( + + + {batch} + + + + {members[batch].map(member => ( + + + + ))} + + + + ))} + +
+ + ) + } + + ); +} diff --git a/src/components/AlumniAccordions.js b/src/components/AlumniAccordions.js index a383eaf..c004deb 100644 --- a/src/components/AlumniAccordions.js +++ b/src/components/AlumniAccordions.js @@ -1,4 +1,7 @@ import React from 'react'; +import { useState,useEffect } from 'react'; +import axios from 'axios'; +import { hostname } from '../links'; import { makeStyles } from '@material-ui/core/styles'; import { Paper, Typography, Accordion, AccordionSummary, AccordionDetails, Grid } from '@material-ui/core'; import Avatar from './Avatar'; @@ -14,8 +17,20 @@ const useStyles = makeStyles(theme => ({ })); export default function AlumniAccordions(props) { - const { members } = props; + //const { members } = props; + + const [members, setMembers] = useState({}); + + useEffect(() => { + axios.get(hostname + '/api/execom/alumini/' + props.sid).then(response => { + setMembers(response.data.alumini); + console.log(response.data.alumini); + }); + }, [props.sid]); + + const classes = useStyles(); + // console.log(members); let color = props.color ?? '#222222'; return ( <> @@ -29,8 +44,9 @@ export default function AlumniAccordions(props) { Alumni - {Object.keys(members).map(batch => ( + {Object.keys(members).map((batch,index) => ( {batch} - - {members[batch].map(member => ( - + + {members[batch].map((member,index) => ( + ))} diff --git a/src/components/AppBarMenu.js b/src/components/AppBarMenu.js index 81a1367..e2a609a 100644 --- a/src/components/AppBarMenu.js +++ b/src/components/AppBarMenu.js @@ -101,7 +101,7 @@ export default function AppBarMenu(props) { let listitems = props.items; let items = listitems.map(item => { return ( - + handleDrawer(false)} button key={item.name} className={classes.nested}> diff --git a/src/components/ArticlesBox.js b/src/components/ArticlesBox.js index 4b86e39..254155f 100644 --- a/src/components/ArticlesBox.js +++ b/src/components/ArticlesBox.js @@ -66,7 +66,7 @@ export default function FrontBox() { return ( <> - +

diff --git a/src/components/Avatar.js b/src/components/Avatar.js index a28f442..4b35cc2 100644 --- a/src/components/Avatar.js +++ b/src/components/Avatar.js @@ -30,7 +30,7 @@ const useStyles = makeStyles(theme => { */ export default function AvatarCard(props) { const classes = useStyles(); - console.log('I', classes); + // console.log('I', classes); return ( diff --git a/src/components/ConfirmTenureEnd.js b/src/components/ConfirmTenureEnd.js new file mode 100644 index 0000000..f4adbdc --- /dev/null +++ b/src/components/ConfirmTenureEnd.js @@ -0,0 +1,75 @@ +import React, {useState,useEffect} from 'react'; +import { + Button, + Dialog, + DialogActions, + DialogContent, + DialogContentText, + DialogTitle, + TextField, +} from '@material-ui/core'; + +export const ConfirmEndTenureDialog = props => { + const [match, setMatch] = useState(true); + + useEffect(() => { + const nomatchElement = document.getElementById("nomatch"); + if (nomatchElement) { + nomatchElement.style.display = match ? "none" : "block"; + if (!match) { + setTimeout(() => { + nomatchElement.style.display = "none"; + setMatch(true); + }, 1500); + } + } + }, [match]); + const endTenure = async e => { + e.preventDefault(); + const inputField = document.getElementById('confirmationText'); + const inputValue = inputField.value; + const expectedValue = 'my life my choice'; + + if (inputValue === expectedValue) { + console.log("match"); + await props.onEndTenureStateChange(true); + props.onClose(); + } + else{ + setMatch(false); + console.log("no match"); + } + }; + return ( + <> + + Are you absolutely sure? + + + This action cannot be undone. This will permanently end tenure of current execoms. +
+ Please type my life my choice to confirm. +
+ + {!match &&

Strings do not match.

} +
+ + + + +
+ + ); +} \ No newline at end of file diff --git a/src/components/EventsBox.js b/src/components/EventsBox.js index af87ee5..c8e8fd3 100644 --- a/src/components/EventsBox.js +++ b/src/components/EventsBox.js @@ -66,7 +66,7 @@ export default function EventsBox() { return ( <> - +

diff --git a/src/components/Footer.js b/src/components/Footer.js index 34b775c..7625f77 100644 --- a/src/components/Footer.js +++ b/src/components/Footer.js @@ -59,7 +59,7 @@ export default function Footer(props) {