From 8b6d712c1c0daac334fd891477eccbbe45ba1295 Mon Sep 17 00:00:00 2001 From: sannidhi-s-shetty Date: Tue, 21 Mar 2023 13:12:52 +0530 Subject: [PATCH 01/15] added new execom form --- src/components/AddExecomDialog.js | 356 ++++++++++++++++++++++++++++++ src/components/Avatar.js | 2 +- src/pages/CSSocietyPage.js | 32 ++- 3 files changed, 388 insertions(+), 2 deletions(-) create mode 100644 src/components/AddExecomDialog.js diff --git a/src/components/AddExecomDialog.js b/src/components/AddExecomDialog.js new file mode 100644 index 0000000..ecad0be --- /dev/null +++ b/src/components/AddExecomDialog.js @@ -0,0 +1,356 @@ +import { + Button, + Dialog, + DialogActions, + DialogContent, + DialogContentText, + DialogTitle, + FormControl, + FormControlLabel, + InputLabel, + makeStyles, + MenuItem, + Select, + Snackbar, + TextField, + Grid, + Checkbox, + OutlinedInput, + // Typography, + } from '@material-ui/core'; + import axios from 'axios'; + import React, { useState, useEffect } from 'react'; + + import { ecats, hostname} from '../links'; + + 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:'', + tenureStart:new Date().toDatetimeLocal(), + tenureEnd: '', + imagepath:'', + }); + + const [loading, setLoading] = useState(false); + + useEffect(() => { + if (props.data !== undefined) { + console.log("data") + setValues({ + ...props.data, + tenureStart: props.data.tenureStart.toDatetimeLocal(), + tenureEnd: props.data.tenureEnd.toDatetimeLocal(), + }); + } + }, [props.data]); + + + const handleFileInput = async file => { + const data = new FormData(); + data.append('image', file); + try { + const res = await axios.post(`https://api.imgbb.com/1/upload?key=${process.env.REACT_APP_IMGBB_API_KEY}`, data); + setValues({ + ...values, + imagepath: res.data.data.display_url, + }); + setLoading(v => !v); + } catch (err) { + console.log(err); + setLoading(v => !v); + } + }; + + 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 { + // axios + // .post(hostname + '/api/execom', 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 }); + // }); + // } + }; + + // 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); + }; + + return ( + <> + + Add Execom + + + Add execom details. Abide by the datatypes used in the form and use + submit button to add the execom. + + + + + + + + + + + + Society or Affinity + + + + + + + Designation + + + + + + + + } + label="Is the member currently serving in the Execom?" + /> + {!isCurrent && ( + + + + )} + {!loading ? ( + + + {values.imagepath !== '' ? ( +
+ execomimage +
+ ) : null} +
+ ) : ( +
+ +
+ )} +
+
+ + + +
+ + + {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'} + + + + ); + }; + \ No newline at end of file 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/pages/CSSocietyPage.js b/src/pages/CSSocietyPage.js index d3d5a36..03974d4 100644 --- a/src/pages/CSSocietyPage.js +++ b/src/pages/CSSocietyPage.js @@ -1,6 +1,12 @@ import React, { useState, useEffect } from 'react'; import axios from 'axios'; -import { Container, Grid, Typography, Paper } from '@material-ui/core'; +import { Container, + Grid, + Typography, + Paper, + Fab, + Tooltip } from '@material-ui/core'; + import { Add } from '@material-ui/icons'; import { Link } from 'react-router-dom'; import { makeStyles } from '@material-ui/core/styles'; import Avatar from '../components/Avatar'; @@ -8,6 +14,7 @@ import EventCard from '../components/EventCard'; import { hostname, ecats, images, execom, alumni } from '../links'; import AlumniAccordions from '../components/AlumniAccordions'; import SpacyDivider from '../components/SpacyDivider'; +import { AddExecomDialog } from '../components/AddExecomDialog'; const useStyles = makeStyles(theme => ({ root: theme.root, @@ -26,13 +33,26 @@ const useStyles = makeStyles(theme => ({ paddingTop: theme.spacing(4), }, grid: theme.grid, + fab: { + color:"green", + } })); export default function CSSocietyPage(props) { const classes = useStyles(); + let loggedIn = localStorage.getItem('isAuthenticated') === 'true'; const [events, setEvents] = useState([]); + //Dialog stuff + const [dialog, setDialog] = useState(false); + const handleDialogClose = () => { + setDialog(false); + }; + const handleDialogOpen = () => { + setDialog(true); + }; + useEffect(() => { axios.get(hostname + '/api/event/cat/' + ecats.compsoc).then(response => { setEvents( @@ -117,6 +137,16 @@ export default function CSSocietyPage(props) { ))} + {loggedIn && ( + <> + + + + + + + + )}
From 31041d57099a28119215439f2ca066d3a5814fa1 Mon Sep 17 00:00:00 2001 From: sannidhi-s-shetty Date: Tue, 28 Mar 2023 19:36:26 +0530 Subject: [PATCH 02/15] form changes made --- src/components/AddExecomDialog.js | 73 ++++++++++++++++++++++++++++--- src/pages/CSSocietyPage.js | 2 +- 2 files changed, 69 insertions(+), 6 deletions(-) diff --git a/src/components/AddExecomDialog.js b/src/components/AddExecomDialog.js index ecad0be..e6b8d78 100644 --- a/src/components/AddExecomDialog.js +++ b/src/components/AddExecomDialog.js @@ -14,6 +14,9 @@ import { Snackbar, TextField, Grid, + InputAdornment, + Input, + IconButton, Checkbox, OutlinedInput, // Typography, @@ -74,7 +77,7 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { firstname: '', lastname: '', position:'', - sid:'', + sid:props.sid, tenureStart:new Date().toDatetimeLocal(), tenureEnd: '', imagepath:'', @@ -176,6 +179,11 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { const [isCurrent,setIsCurrent] = useState(true); const handleEndTenure = event => { setIsCurrent(event.target.checked); + if(event.target.checked) + setValues({ + ...values, + tenureEnd: "", + }); }; return ( @@ -223,7 +231,7 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { /> - + {/* Society or Affinity - + */} @@ -301,7 +309,7 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { /> )} - {!loading ? ( + {/* {!loading ? ( + diff --git a/src/pages/CSSocietyPage.js b/src/pages/CSSocietyPage.js index 03974d4..9210572 100644 --- a/src/pages/CSSocietyPage.js +++ b/src/pages/CSSocietyPage.js @@ -144,7 +144,7 @@ export default function CSSocietyPage(props) { - + )} From 444c6576cc562a57fcdfb4c50f7081d7845ce9d0 Mon Sep 17 00:00:00 2001 From: sannidhi-s-shetty Date: Wed, 29 Mar 2023 00:45:00 +0530 Subject: [PATCH 03/15] added delete execom feature --- src/pages/CSSocietyPage.js | 54 +++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/src/pages/CSSocietyPage.js b/src/pages/CSSocietyPage.js index 9210572..b3e48e2 100644 --- a/src/pages/CSSocietyPage.js +++ b/src/pages/CSSocietyPage.js @@ -5,6 +5,8 @@ import { Container, Typography, Paper, Fab, + IconButton, + Snackbar, Tooltip } from '@material-ui/core'; import { Add } from '@material-ui/icons'; import { Link } from 'react-router-dom'; @@ -15,6 +17,7 @@ import { hostname, ecats, images, execom, alumni } from '../links'; import AlumniAccordions from '../components/AlumniAccordions'; import SpacyDivider from '../components/SpacyDivider'; import { AddExecomDialog } from '../components/AddExecomDialog'; +import Alert from '@material-ui/lab/Alert'; const useStyles = makeStyles(theme => ({ root: theme.root, @@ -63,6 +66,38 @@ export default function CSSocietyPage(props) { }); }, []); + const [del, setDel] = useState({ + error: false, + success: false, + }); + + const handleClose = prop => (event, reason) => { + if (reason === 'clickaway') return; + setDel({ ...del, [prop]: false }); + }; + + const deleteExecom = () => { + // console.log(hostname + '/api/execom/end/'+ ecats.compsoc); + axios + .post(hostname + '/api/execom/end/', ecats.compsoc, { + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer ' + localStorage.getItem('atoken'), + }, + }) + .then(response => { + if (response.data.ok === true) setDel({ ...del, success: true }); + else setDel({ ...del, error: true }); + }) + .then(() => { + window.location.reload(); + }) + .catch(error => { + console.error(error.response); + setDel({ ...del, error: true }); + }); + } + return (
)} - Executive Committee + Executive Committee + + + + + + +
{execom.compsoc.map(member => ( @@ -150,6 +192,16 @@ export default function CSSocietyPage(props) {
+ + + An error occurred while deleting, please try again + + + + + Successfully ended tenure of current execom + +
); } From 36eaa771b24a061cef8c082a0f46cc93d1dc3482 Mon Sep 17 00:00:00 2001 From: sannidhi-s-shetty Date: Wed, 29 Mar 2023 09:52:04 +0530 Subject: [PATCH 04/15] minor change to delete execom --- src/pages/CSSocietyPage.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pages/CSSocietyPage.js b/src/pages/CSSocietyPage.js index b3e48e2..4106c7e 100644 --- a/src/pages/CSSocietyPage.js +++ b/src/pages/CSSocietyPage.js @@ -163,12 +163,16 @@ export default function CSSocietyPage(props) { )} Executive Committee + {loggedIn && ( + <> + + )}
From c61d3bf9207272e9242c8f19ca975c1473118ca2 Mon Sep 17 00:00:00 2001 From: sannidhi-s-shetty Date: Thu, 30 Mar 2023 12:52:33 +0530 Subject: [PATCH 05/15] added handleFileInput to utils --- src/components/AddExecomDialog.js | 90 ++++--------------------------- src/utils.js | 45 ++++++++++++++++ 2 files changed, 55 insertions(+), 80 deletions(-) diff --git a/src/components/AddExecomDialog.js b/src/components/AddExecomDialog.js index e6b8d78..817d78a 100644 --- a/src/components/AddExecomDialog.js +++ b/src/components/AddExecomDialog.js @@ -16,15 +16,14 @@ import { Grid, InputAdornment, Input, - IconButton, Checkbox, OutlinedInput, // Typography, } from '@material-ui/core'; import axios from 'axios'; import React, { useState, useEffect } from 'react'; - import { ecats, hostname} from '../links'; + import { useImageUploader,FileUploadButton } from '../utils'; import Alert from '@material-ui/lab/Alert'; import { CircularProgress } from '@material-ui/core'; @@ -83,7 +82,6 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { imagepath:'', }); - const [loading, setLoading] = useState(false); useEffect(() => { if (props.data !== undefined) { @@ -96,23 +94,12 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { } }, [props.data]); - - const handleFileInput = async file => { - const data = new FormData(); - data.append('image', file); - try { - const res = await axios.post(`https://api.imgbb.com/1/upload?key=${process.env.REACT_APP_IMGBB_API_KEY}`, data); - setValues({ - ...values, - imagepath: res.data.data.display_url, - }); - setLoading(v => !v); - } catch (err) { - console.log(err); - setLoading(v => !v); - } + const {isLoading, error, uploadImage } = useImageUploader(); + const handleFileInputChange = async file => { + uploadImage(file); + if(error) console.log(error.message); }; - + const handleChange = prop => event => { setValues({ ...values, @@ -230,25 +217,6 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { fullWidth /> - - {/* - - Society or Affinity - - - */} @@ -273,7 +241,7 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { variant="outlined" fullWidth required - defaultValue={new Date().toDatetimeLocal} + //defaultValue={new Date().toDatetimeLocal} value={values.tenureStart} onChange={handleChange('tenureStart')} InputLabelProps={{ @@ -309,38 +277,6 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { /> )} - {/* {!loading ? ( - - - {values.imagepath !== '' ? ( -
- execomimage -
- ) : null} -
- ) : ( -
- -
- )} */} - Image Link @@ -358,18 +294,12 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { id="image-file" type="file" onChange={async e => { - setLoading(v => !v); const file = e.target.files[0]; - await handleFileInput(file); + await handleFileInputChange(file); }} /> } @@ -386,7 +316,7 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { execomimage ) : null} - {loading && ( + {isLoading && (
diff --git a/src/utils.js b/src/utils.js index a48bf69..97506bc 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,3 +1,9 @@ +import {useState} from 'react'; +import axios from 'axios'; +import { IconButton } from '@material-ui/core'; + + + /** * Converts date values in an object to UTC, based on list of keys provided * @template T @@ -14,3 +20,42 @@ export function convertDatesinValuestoUTC(object, keys) { }); return result; } + +export const useImageUploader = () => { + const [imageUrl, setImageUrl] = useState(""); + const [isLoading, setIsLoading] = useState(false); + const [error, setError] = useState(null); + + const uploadImage = async (file) => { + const data = new FormData(); + data.append("image", file); + + setIsLoading(true); + + try { + const res = await axios.post( + `https://api.imgbb.com/1/upload?key=${process.env.REACT_APP_IMGBB_API_KEY}`, + data + ); + setImageUrl(res.data.data.display_url); + setIsLoading(false); + } catch (err) { + setError(err); + setIsLoading(false); + } + }; + + return { imageUrl, isLoading, error, uploadImage }; +}; + + +export function FileUploadButton() { + return( + + + + + + + ); +} From 384818656bc79e2894b8c760d24cc7cb8bd71f97 Mon Sep 17 00:00:00 2001 From: sannidhi-s-shetty Date: Fri, 31 Mar 2023 12:51:14 +0530 Subject: [PATCH 06/15] minor change to uploadImage --- src/components/AddExecomDialog.js | 10 +++++++--- src/utils.js | 5 ++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/AddExecomDialog.js b/src/components/AddExecomDialog.js index 817d78a..89f9f9d 100644 --- a/src/components/AddExecomDialog.js +++ b/src/components/AddExecomDialog.js @@ -94,10 +94,13 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { } }, [props.data]); - const {isLoading, error, uploadImage } = useImageUploader(); + const {isLoading,error,uploadImage } = useImageUploader(); const handleFileInputChange = async file => { - uploadImage(file); - if(error) console.log(error.message); + const url = await uploadImage(file); + setValues({ + ...values, + imagepath:url, + }); }; const handleChange = prop => event => { @@ -305,6 +308,7 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { } />
+ {error &&

Error: {error.message}

} {values.imagepath !== '' ? (
{ - const [imageUrl, setImageUrl] = useState(""); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); @@ -37,15 +36,15 @@ export const useImageUploader = () => { `https://api.imgbb.com/1/upload?key=${process.env.REACT_APP_IMGBB_API_KEY}`, data ); - setImageUrl(res.data.data.display_url); setIsLoading(false); + return res.data.data.display_url; } catch (err) { setError(err); setIsLoading(false); } }; - return { imageUrl, isLoading, error, uploadImage }; + return {isLoading, error, uploadImage }; }; From 3e1be666e199da133264d98ff8f95a6c220ba7be Mon Sep 17 00:00:00 2001 From: sannidhi-s-shetty Date: Fri, 31 Mar 2023 13:09:01 +0530 Subject: [PATCH 07/15] heading of form changed --- src/components/AddExecomDialog.js | 42 +++++++++++++++---------------- src/links.js | 14 +++++++++++ 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/components/AddExecomDialog.js b/src/components/AddExecomDialog.js index 89f9f9d..3e17f96 100644 --- a/src/components/AddExecomDialog.js +++ b/src/components/AddExecomDialog.js @@ -22,7 +22,7 @@ import { } from '@material-ui/core'; import axios from 'axios'; import React, { useState, useEffect } from 'react'; - import { ecats, hostname} from '../links'; + import {hostname,societyNames} from '../links'; import { useImageUploader,FileUploadButton } from '../utils'; import Alert from '@material-ui/lab/Alert'; @@ -118,7 +118,7 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { const submitData = (e) => { e.preventDefault(); props.onClose(); - console.log(values); + // console.log(values); // if (props.edit === true) { // axios // .put(hostname + '/api/event/' + props.data.eid, values, { @@ -139,24 +139,24 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { // setMeta({ ...meta, error: true }); // }); // } else { - // axios - // .post(hostname + '/api/execom', 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 }); - // }); + axios + .post(hostname + '/api/execom', 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 }); + }); // } }; @@ -179,7 +179,7 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { return ( <> - Add Execom + Add Execom Member for {societyNames[props.sid]} Add execom details. Abide by the datatypes used in the form and use diff --git a/src/links.js b/src/links.js index 258339f..c3c0e33 100644 --- a/src/links.js +++ b/src/links.js @@ -169,6 +169,20 @@ export const ecats = { sc: 10, }; +export const societyNames = { + 0 : 'Main Execom', + 1 : 'Computer Society', + 2 : 'Communications Society', + 3 : 'Power and Energy Society', + 4 : 'Antennas and Propagation Society', + 5 : 'Signal Processing Society', + 6 : 'Robotics and Automation Society', + 7 : 'WIE', + 8 : 'Sight', + 9 : 'Circuits and Systems Society', + 10 : 'Sensor Council', +}; + /** Execom details */ export const execom = { main: [ From b62a174cfbac1ad21c6b13ba37f344b45814c5c3 Mon Sep 17 00:00:00 2001 From: sannidhi-s-shetty Date: Fri, 31 Mar 2023 16:37:40 +0530 Subject: [PATCH 08/15] moved repetitive code --- src/components/SocietyExecom.js | 131 ++++++++++++++++++++++++++++++++ src/pages/CSSocietyPage.js | 102 ++----------------------- 2 files changed, 138 insertions(+), 95 deletions(-) create mode 100644 src/components/SocietyExecom.js diff --git a/src/components/SocietyExecom.js b/src/components/SocietyExecom.js new file mode 100644 index 0000000..ff9a6a2 --- /dev/null +++ b/src/components/SocietyExecom.js @@ -0,0 +1,131 @@ +import axios from 'axios'; +import { hostname, ecats} from '../links'; +import React, {useState} from 'react'; +import Alert from '@material-ui/lab/Alert'; +import { Snackbar, + Grid, + Tooltip, + Fab } from '@material-ui/core'; +import { Add,School}from '@material-ui/icons'; +import { makeStyles } from '@material-ui/core/styles'; +import Avatar from '../components/Avatar'; +import { AddExecomDialog } from './AddExecomDialog'; + +const useStyles = makeStyles(theme => ({ + root: theme.root, + container: theme.page, + paper: { + ...theme.paper, + padding: theme.spacing(4), + }, + link: { + ...theme.link, + float: 'right', + textDecoration: 'none', + }, + carousel: { + margin: 'auto', + paddingTop: theme.spacing(4), + }, + grid: theme.grid, + fab: { + color:"green", + } + })); + +export default function SocietyExecom(props) { + const exelist = props.exelist; + const sid = props.sid; + + let loggedIn = localStorage.getItem('isAuthenticated') === 'true'; + const classes = useStyles(); + + //Dialog stuff + const [dialog, setDialog] = useState(false); + const handleDialogClose = () => { + setDialog(false); + }; + const handleDialogOpen = () => { + setDialog(true); + }; + + const [del, setDel] = useState({ + error: false, + success: false, + }); + + const handleClose = prop => (event, reason) => { + if (reason === 'clickaway') return; + setDel({ ...del, [prop]: false }); + }; + + const deleteExecom = () => { + console.log(hostname + '/api/execom/end/'+ ecats.compsoc); + axios + .post(hostname + '/api/execom/end/', sid, { + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer ' + localStorage.getItem('atoken'), + }, + }) + .then(response => { + if (response.data.ok === true) setDel({ ...del, success: true }); + else setDel({ ...del, error: true }); + }) + .then(() => { + window.location.reload(); + }) + .catch(error => { + console.error(error.response); + setDel({ ...del, error: true }); + }); + } + + return( + <> + + {exelist.map(member => ( + + + + ))} + {loggedIn && ( + <> + + + + + + + + + + + + + + + + + + + + + )} + + + + An error occurred , please try again + + + + + Successfully ended tenure of current execom + + + + ); + +}; \ No newline at end of file diff --git a/src/pages/CSSocietyPage.js b/src/pages/CSSocietyPage.js index 4106c7e..4d87015 100644 --- a/src/pages/CSSocietyPage.js +++ b/src/pages/CSSocietyPage.js @@ -3,21 +3,16 @@ import axios from 'axios'; import { Container, Grid, Typography, - Paper, - Fab, - IconButton, - Snackbar, - Tooltip } from '@material-ui/core'; - import { Add } from '@material-ui/icons'; + Paper} from '@material-ui/core'; import { Link } from 'react-router-dom'; import { makeStyles } from '@material-ui/core/styles'; -import Avatar from '../components/Avatar'; + import EventCard from '../components/EventCard'; -import { hostname, ecats, images, execom, alumni } from '../links'; +import { hostname, ecats, images,execom, alumni } from '../links'; import AlumniAccordions from '../components/AlumniAccordions'; import SpacyDivider from '../components/SpacyDivider'; -import { AddExecomDialog } from '../components/AddExecomDialog'; -import Alert from '@material-ui/lab/Alert'; +import SocietyExecom from '../components/SocietyExecom'; + const useStyles = makeStyles(theme => ({ root: theme.root, @@ -36,26 +31,12 @@ const useStyles = makeStyles(theme => ({ paddingTop: theme.spacing(4), }, grid: theme.grid, - fab: { - color:"green", - } })); export default function CSSocietyPage(props) { const classes = useStyles(); - let loggedIn = localStorage.getItem('isAuthenticated') === 'true'; - const [events, setEvents] = useState([]); - //Dialog stuff - const [dialog, setDialog] = useState(false); - const handleDialogClose = () => { - setDialog(false); - }; - const handleDialogOpen = () => { - setDialog(true); - }; - useEffect(() => { axios.get(hostname + '/api/event/cat/' + ecats.compsoc).then(response => { setEvents( @@ -66,38 +47,6 @@ export default function CSSocietyPage(props) { }); }, []); - const [del, setDel] = useState({ - error: false, - success: false, - }); - - const handleClose = prop => (event, reason) => { - if (reason === 'clickaway') return; - setDel({ ...del, [prop]: false }); - }; - - const deleteExecom = () => { - // console.log(hostname + '/api/execom/end/'+ ecats.compsoc); - axios - .post(hostname + '/api/execom/end/', ecats.compsoc, { - headers: { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer ' + localStorage.getItem('atoken'), - }, - }) - .then(response => { - if (response.data.ok === true) setDel({ ...del, success: true }); - else setDel({ ...del, error: true }); - }) - .then(() => { - window.location.reload(); - }) - .catch(error => { - console.error(error.response); - setDel({ ...del, error: true }); - }); - } - return (
)} - Executive Committee - {loggedIn && ( - <> - - - - - - - - )} - + Executive Committee
- - {execom.compsoc.map(member => ( - - - - ))} - +
- {loggedIn && ( - <> - - - - - - - - )}
- - - An error occurred while deleting, please try again - - - - - Successfully ended tenure of current execom - -
); } From cef4b3f1bc001eba52d41db7c6fc04d57556ae69 Mon Sep 17 00:00:00 2001 From: sannidhi-s-shetty Date: Fri, 31 Mar 2023 20:15:19 +0530 Subject: [PATCH 09/15] added confirmation dialog --- src/components/AddExecomDialog.js | 2 +- src/components/ConfirmTenureEnd.js | 61 ++++++++++++++++++++++ src/components/SocietyExecom.js | 83 ++++++++++++++++++++---------- src/pages/CSSocietyPage.js | 1 - src/pages/RASSocietyPage.js | 10 +--- 5 files changed, 121 insertions(+), 36 deletions(-) create mode 100644 src/components/ConfirmTenureEnd.js diff --git a/src/components/AddExecomDialog.js b/src/components/AddExecomDialog.js index 3e17f96..ae6188c 100644 --- a/src/components/AddExecomDialog.js +++ b/src/components/AddExecomDialog.js @@ -118,7 +118,7 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { const submitData = (e) => { e.preventDefault(); props.onClose(); - // console.log(values); + console.log(values); // if (props.edit === true) { // axios // .put(hostname + '/api/event/' + props.data.eid, values, { diff --git a/src/components/ConfirmTenureEnd.js b/src/components/ConfirmTenureEnd.js new file mode 100644 index 0000000..8c5ec17 --- /dev/null +++ b/src/components/ConfirmTenureEnd.js @@ -0,0 +1,61 @@ +import React from 'react'; +import { + Button, + Dialog, + DialogActions, + DialogContent, + DialogContentText, + DialogTitle, + TextField, +} from '@material-ui/core'; + +export const ConfirmEndTenureDialog = props => { + + 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{ + console.log("no match"); + props.onClose(); + } + }; + 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. +
+ +
+ + + + +
+ + ); +} \ No newline at end of file diff --git a/src/components/SocietyExecom.js b/src/components/SocietyExecom.js index ff9a6a2..abd067b 100644 --- a/src/components/SocietyExecom.js +++ b/src/components/SocietyExecom.js @@ -1,5 +1,5 @@ import axios from 'axios'; -import { hostname, ecats} from '../links'; +import { hostname} from '../links'; import React, {useState} from 'react'; import Alert from '@material-ui/lab/Alert'; import { Snackbar, @@ -10,6 +10,7 @@ import { Add,School}from '@material-ui/icons'; import { makeStyles } from '@material-ui/core/styles'; import Avatar from '../components/Avatar'; import { AddExecomDialog } from './AddExecomDialog'; +import { ConfirmEndTenureDialog} from './ConfirmTenureEnd'; const useStyles = makeStyles(theme => ({ root: theme.root, @@ -48,6 +49,27 @@ export default function SocietyExecom(props) { const handleDialogOpen = () => { setDialog(true); }; + + //Dialog of end tenure + const [openEndTenureDialog, setOpen] = useState(false); + const [endTenureState, changeTenureState] = useState(false); + + const handleEndTenureStateChange = (newState) => { + // console.log(newState); + changeTenureState(newState); + } + + const handleEndTenureClickOpen = () => { + setOpen(true); + }; + const handleEndTenureClose = () => { + setOpen(false); + if(endTenureState) + { + deleteExecom(); + changeTenureState(false); + } + }; const [del, setDel] = useState({ error: false, @@ -58,29 +80,28 @@ export default function SocietyExecom(props) { if (reason === 'clickaway') return; setDel({ ...del, [prop]: false }); }; + const deleteExecom = () => { + console.log(hostname + '/api/execom/end/'+ sid); + axios + .post(hostname + '/api/execom/end/', sid, { + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer ' + localStorage.getItem('atoken'), + }, + }) + .then(response => { + if (response.data.ok === true) setDel({ ...del, success: true }); + else setDel({ ...del, error: true }); + }) + .then(() => { + window.location.reload(); + }) + .catch(error => { + console.error(error.response); + setDel({ ...del, error: true }); + }); + } - const deleteExecom = () => { - console.log(hostname + '/api/execom/end/'+ ecats.compsoc); - axios - .post(hostname + '/api/execom/end/', sid, { - headers: { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer ' + localStorage.getItem('atoken'), - }, - }) - .then(response => { - if (response.data.ok === true) setDel({ ...del, success: true }); - else setDel({ ...del, error: true }); - }) - .then(() => { - window.location.reload(); - }) - .catch(error => { - console.error(error.response); - setDel({ ...del, error: true }); - }); - } - return( <> @@ -91,8 +112,10 @@ export default function SocietyExecom(props) { src={member.image} /> ))} + {loggedIn && ( <> + @@ -101,20 +124,28 @@ export default function SocietyExecom(props) { - + - + + + )} - An error occurred , please try again diff --git a/src/pages/CSSocietyPage.js b/src/pages/CSSocietyPage.js index 4d87015..8b497cf 100644 --- a/src/pages/CSSocietyPage.js +++ b/src/pages/CSSocietyPage.js @@ -6,7 +6,6 @@ import { Container, Paper} from '@material-ui/core'; import { Link } from 'react-router-dom'; import { makeStyles } from '@material-ui/core/styles'; - import EventCard from '../components/EventCard'; import { hostname, ecats, images,execom, alumni } from '../links'; import AlumniAccordions from '../components/AlumniAccordions'; diff --git a/src/pages/RASSocietyPage.js b/src/pages/RASSocietyPage.js index 119b95f..76de06a 100644 --- a/src/pages/RASSocietyPage.js +++ b/src/pages/RASSocietyPage.js @@ -3,11 +3,11 @@ import axios from 'axios'; import { Container, Grid, Typography, Paper } from '@material-ui/core'; import { Link } from 'react-router-dom'; import { makeStyles } from '@material-ui/core/styles'; -import Avatar from '../components/Avatar'; import EventCard from '../components/EventCard'; import { hostname, ecats, images, execom, alumni } from '../links'; import AlumniAccordions from '../components/AlumniAccordions'; import SpacyDivider from '../components/SpacyDivider'; +import SocietyExecom from '../components/SocietyExecom'; const useStyles = makeStyles(theme => ({ root: theme.root, @@ -102,13 +102,7 @@ export default function RASSocietyPage(props) { Executive Committee
- - {execom.ras.map(member => ( - - - - ))} - +

From 5d4719e5a689cf93258f9c2d67082f31a722c977 Mon Sep 17 00:00:00 2001 From: sannidhi-s-shetty Date: Fri, 31 Mar 2023 22:44:14 +0530 Subject: [PATCH 10/15] execom list taken directly --- src/components/AddExecomDialog.js | 2 +- src/components/SocietyExecom.js | 4 ++-- src/links.js | 22 +++++++++++----------- src/pages/CSSocietyPage.js | 4 ++-- src/pages/RASSocietyPage.js | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/components/AddExecomDialog.js b/src/components/AddExecomDialog.js index ae6188c..0f840d3 100644 --- a/src/components/AddExecomDialog.js +++ b/src/components/AddExecomDialog.js @@ -179,7 +179,7 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { return ( <> - Add Execom Member for {societyNames[props.sid]} + Add Execom Member for {societyNames[props.sid]["name"]} Add execom details. Abide by the datatypes used in the form and use diff --git a/src/components/SocietyExecom.js b/src/components/SocietyExecom.js index abd067b..2e9a08b 100644 --- a/src/components/SocietyExecom.js +++ b/src/components/SocietyExecom.js @@ -1,5 +1,5 @@ import axios from 'axios'; -import { hostname} from '../links'; +import { hostname,societyNames,execom} from '../links'; import React, {useState} from 'react'; import Alert from '@material-ui/lab/Alert'; import { Snackbar, @@ -35,8 +35,8 @@ const useStyles = makeStyles(theme => ({ })); export default function SocietyExecom(props) { - const exelist = props.exelist; const sid = props.sid; + const exelist = execom[societyNames[sid]["sub"]]; let loggedIn = localStorage.getItem('isAuthenticated') === 'true'; const classes = useStyles(); diff --git a/src/links.js b/src/links.js index c3c0e33..8ff0310 100644 --- a/src/links.js +++ b/src/links.js @@ -170,17 +170,17 @@ export const ecats = { }; export const societyNames = { - 0 : 'Main Execom', - 1 : 'Computer Society', - 2 : 'Communications Society', - 3 : 'Power and Energy Society', - 4 : 'Antennas and Propagation Society', - 5 : 'Signal Processing Society', - 6 : 'Robotics and Automation Society', - 7 : 'WIE', - 8 : 'Sight', - 9 : 'Circuits and Systems Society', - 10 : 'Sensor Council', + 0 : {name :'Main Execom', sub : 'main'}, + 1 : {name :'Computer Society', sub : 'compsoc'}, + 2 : {name :'Communications Society', sub : 'comsoc'}, + 3 : {name : 'Power and Energy Society',sub : 'pes'}, + 4 : {name : 'Antennas and Propagation Society',sub : 'aps'}, + 5 : {name : 'Signal Processing Society',sub : 'sps'}, + 6 : {name : 'Robotics and Automation Society',sub : 'ras'}, + 7 : {name : 'WIE',sub : 'wie'}, + 8 : {name : 'Sight',sub : 'sight'}, + 9 : {name : 'Circuits and Systems Society',sub : 'cas'}, + 10 : {name : 'Sensor Council',sub : 'sc'}, }; /** Execom details */ diff --git a/src/pages/CSSocietyPage.js b/src/pages/CSSocietyPage.js index 8b497cf..4ac0ab8 100644 --- a/src/pages/CSSocietyPage.js +++ b/src/pages/CSSocietyPage.js @@ -7,7 +7,7 @@ import { Container, import { Link } from 'react-router-dom'; import { makeStyles } from '@material-ui/core/styles'; import EventCard from '../components/EventCard'; -import { hostname, ecats, images,execom, alumni } from '../links'; +import { hostname, ecats, images,alumni } from '../links'; import AlumniAccordions from '../components/AlumniAccordions'; import SpacyDivider from '../components/SpacyDivider'; import SocietyExecom from '../components/SocietyExecom'; @@ -112,7 +112,7 @@ export default function CSSocietyPage(props) { Executive Committee
- +

diff --git a/src/pages/RASSocietyPage.js b/src/pages/RASSocietyPage.js index 76de06a..6866fef 100644 --- a/src/pages/RASSocietyPage.js +++ b/src/pages/RASSocietyPage.js @@ -4,7 +4,7 @@ import { Container, Grid, Typography, Paper } from '@material-ui/core'; import { Link } from 'react-router-dom'; import { makeStyles } from '@material-ui/core/styles'; import EventCard from '../components/EventCard'; -import { hostname, ecats, images, execom, alumni } from '../links'; +import { hostname, ecats, images, alumni } from '../links'; import AlumniAccordions from '../components/AlumniAccordions'; import SpacyDivider from '../components/SpacyDivider'; import SocietyExecom from '../components/SocietyExecom'; @@ -102,7 +102,7 @@ export default function RASSocietyPage(props) { Executive Committee
- +

From 43d6c5e28d9ec45e2bbbf8742d0d96ea5ebaa008 Mon Sep 17 00:00:00 2001 From: Prajwal P Date: Fri, 31 Mar 2023 22:47:00 +0530 Subject: [PATCH 11/15] fix: minor fix for date type --- src/components/AddExecomDialog.js | 444 +++++++++++++++--------------- 1 file changed, 227 insertions(+), 217 deletions(-) diff --git a/src/components/AddExecomDialog.js b/src/components/AddExecomDialog.js index ae6188c..fe0b719 100644 --- a/src/components/AddExecomDialog.js +++ b/src/components/AddExecomDialog.js @@ -1,59 +1,59 @@ 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 } from '../utils'; + 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'; +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', - }, +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 +//Nice prototype to convert Date objects to datetime local strings // eslint-disable-next-line Date.prototype.toDatetimeLocal = function toDatetimeLocal() { var date = this, @@ -68,125 +68,125 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { 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: '', - imagepath:'', - }); +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); + 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, + imagepath: url, }); - }; + }; - const handleChange = prop => event => { - setValues({ - ...values, - [prop]: event.target.value, - }); - }; - - const [meta, setMeta] = useState({ - error: false, - success: false, + const handleChange = prop => event => { + setValues({ + ...values, + [prop]: event.target.value, }); + }; - 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 { - axios - .post(hostname + '/api/execom', 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 }); - }); - // } - }; - - // 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) + 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: "", + tenureEnd: '', }); - }; + }; - return ( - <> - - Add Execom Member for {societyNames[props.sid]} - - - Add execom details. Abide by the datatypes used in the form and use - submit button to add the execom. - - - + return ( + <> + + Add Execom Member for {societyNames[props.sid]} + + + Add execom details. Abide by the datatypes used in the form and use submit button to add the execom. + + + - + - + - + Designation - Faculty Advisor Chair Vice Chair @@ -240,11 +249,11 @@ Date.prototype.toDatetimeLocal = function toDatetimeLocal() { - } - label="Is the member currently serving in the Execom?" - /> - {!isCurrent && ( - + control={} + label="Is the member currently serving in the Execom?" + /> + {!isCurrent && ( + - - )} + id="tenureEnd" + label="Tenure end date" + type="date" + variant="outlined" + defaultValue={new Date().toDateString()} + value={values.tenureEnd} + fullWidth + onChange={handleChange('tenureEnd')} + InputLabelProps={{ + shrink: true, + }} + /> + + )} - + Image Link
)} - -
- - - - - - - - - {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'} - - - - ); - }; - \ No newline at end of file + + + + + + + + + + {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'} + + + + ); +}; From 33d97d95c0f18e57f997ceed122344f0d2b52fd0 Mon Sep 17 00:00:00 2001 From: sannidhi-s-shetty Date: Sat, 1 Apr 2023 00:20:12 +0530 Subject: [PATCH 12/15] no match error message --- src/components/ConfirmTenureEnd.js | 18 ++++++++++++++++-- src/components/SocietyExecom.js | 1 - 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/components/ConfirmTenureEnd.js b/src/components/ConfirmTenureEnd.js index 8c5ec17..f4adbdc 100644 --- a/src/components/ConfirmTenureEnd.js +++ b/src/components/ConfirmTenureEnd.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {useState,useEffect} from 'react'; import { Button, Dialog, @@ -10,7 +10,20 @@ import { } 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'); @@ -23,8 +36,8 @@ export const ConfirmEndTenureDialog = props => { props.onClose(); } else{ + setMatch(false); console.log("no match"); - props.onClose(); } }; return ( @@ -46,6 +59,7 @@ export const ConfirmEndTenureDialog = props => { fullWidth variant="standard" /> + {!match &&

Strings do not match.

}