Skip to content
Commits on Source (3)
......@@ -11,6 +11,7 @@ import ReadEvent from '../pages/ReadEvent';
import EditEvent from '../pages/EditEvent';
import NotLoggedIn from '../pages/NotLoggedIn';
import Logout from '../pages/Logout';
import Login from '../pages/Login';
import ROUTES from './routes';
import Spinner from '../components/system/Spinner';
import { useAppContext } from '../contexts/context';
......@@ -44,9 +45,10 @@ const MainLayout = ({ userFailed, setUserFailed }) => {
<Spinner />
) : (
<>
<Calendar />
<Switch>
<Route exact path={ROUTES.HOME} component={Calendar} />
<Route exact path={ROUTES.LOGOUT} component={Logout} />
<Route exact path={ROUTES.LOGIN} component={Login} />
<Route exact path={ROUTES.ADD_EVENT} component={AddEvent} />
<Route exact path={ROUTES.EVENT} component={ReadEvent} />
<Route exact path={ROUTES.EVENT_EDIT} component={EditEvent} />
......@@ -57,6 +59,7 @@ const MainLayout = ({ userFailed, setUserFailed }) => {
) : (
<Switch>
<Route exact path={ROUTES.LOGOUT} component={Logout} />
<Route exact path={ROUTES.LOGIN} component={Login} />
<Route path={ROUTES.HOME} component={NotLoggedIn} />
<Redirect from="*" to={ROUTES.HOME} />
</Switch>
......@@ -64,6 +67,7 @@ const MainLayout = ({ userFailed, setUserFailed }) => {
) : (
<Switch>
<Route exact path={ROUTES.LOGOUT} component={Logout} />
<Route exact path={ROUTES.LOGIN} component={Login} />
<Route exact path="/" component={SiteInMaintenance} />
<Route component={SiteInMaintenance} />
</Switch>
......
......@@ -10,6 +10,7 @@ const queryStringMaker = (query) => {
const ROUTES = {
HOME: '/',
LOGIN: '/login',
LOGOUT: '/logout',
ADD_EVENT: '/add-event',
ADD_EVENT_TO_DATE: ({ date, start, end }) => `/add-event?${queryStringMaker({ date, start, end })}`,
......
......@@ -14,6 +14,7 @@ import InformationsForm from '../components/events/InformationsForm';
import { useAppContext } from '../contexts/context';
import ParticipantsSelector from '../components/events/ParticipantsSelector';
import GroupsSelector from '../components/events/GroupsSelector';
import Calendar from '../components/system/Calendar/Calendar';
const AddEvent = ({ history }) => {
const goHome = () => history.push(ROUTES.HOME);
......@@ -150,30 +151,33 @@ const AddEvent = ({ history }) => {
}
};
return (
<ModalWrapper
open
title={i18n.__('pages.AddEvent.title')}
onClose={goHome}
loading={loading}
buttons={[
{
text: i18n.__('pages.AddEvent.closeButton'),
onClick: goHome,
props: { color: 'default' },
key: 'first',
},
{
text: i18n.__('pages.AddEvent.validateButton'),
onClick: createEventCall,
props: { color: 'primary', disabled: !isValid },
key: 'second',
},
]}
>
<InformationsForm errors={errors} stateHook={[state, setState]} />
<GroupsSelector errors={errors} stateHook={[state, setState]} groupId={groupId} />
<ParticipantsSelector stateHook={[state, setState]} handleCheckBoxUser={handleCheckBoxUser} />
</ModalWrapper>
<>
<Calendar />
<ModalWrapper
open
title={i18n.__('pages.AddEvent.title')}
onClose={goHome}
loading={loading}
buttons={[
{
text: i18n.__('pages.AddEvent.closeButton'),
onClick: goHome,
props: { color: 'default' },
key: 'first',
},
{
text: i18n.__('pages.AddEvent.validateButton'),
onClick: createEventCall,
props: { color: 'primary', disabled: !isValid },
key: 'second',
},
]}
>
<InformationsForm errors={errors} stateHook={[state, setState]} />
<GroupsSelector errors={errors} stateHook={[state, setState]} groupId={groupId} />
<ParticipantsSelector stateHook={[state, setState]} handleCheckBoxUser={handleCheckBoxUser} />
</ModalWrapper>
</>
);
};
......
......@@ -15,6 +15,7 @@ import InformationsForm from '../components/events/InformationsForm';
import ParticipantsSelector from '../components/events/ParticipantsSelector';
import GroupsSelector from '../components/events/GroupsSelector';
import Spinner from '../components/system/Spinner';
import Calendar from '../components/system/Calendar/Calendar';
import { useAppContext } from '../contexts/context';
const useStyles = makeStyles((theme) => ({
......@@ -181,42 +182,45 @@ const EditEvent = ({ history, match: { params } }) => {
}
};
return (
<ModalWrapper
open
title={i18n.__('pages.EditEvent.title')}
onClose={goHome}
loading={loading}
buttons={[
{
text: i18n.__('pages.EditEvent.delete'),
onClick: deleteEventCall,
props: { className: classes.redButton },
key: 'first',
},
{
text: i18n.__('pages.EditEvent.closeButton'),
onClick: goHome,
props: { color: 'default' },
key: 'second',
},
{
text: i18n.__('pages.EditEvent.validateButton'),
onClick: editEventCall,
props: { color: 'primary', disabled: !isValid },
key: 'third',
},
]}
>
{loading ? (
<Spinner inside />
) : (
<>
<InformationsForm errors={errors} stateHook={[state, setState]} />
<GroupsSelector errors={errors} stateHook={[state, setState]} />
<ParticipantsSelector stateHook={[state, setState]} handleCheckBoxUser={handleCheckBoxUser} />
</>
)}
</ModalWrapper>
<>
<Calendar />
<ModalWrapper
open
title={i18n.__('pages.EditEvent.title')}
onClose={goHome}
loading={loading}
buttons={[
{
text: i18n.__('pages.EditEvent.delete'),
onClick: deleteEventCall,
props: { className: classes.redButton },
key: 'first',
},
{
text: i18n.__('pages.EditEvent.closeButton'),
onClick: goHome,
props: { color: 'default' },
key: 'second',
},
{
text: i18n.__('pages.EditEvent.validateButton'),
onClick: editEventCall,
props: { color: 'primary', disabled: !isValid },
key: 'third',
},
]}
>
{loading ? (
<Spinner inside />
) : (
<>
<InformationsForm errors={errors} stateHook={[state, setState]} />
<GroupsSelector errors={errors} stateHook={[state, setState]} />
<ParticipantsSelector stateHook={[state, setState]} handleCheckBoxUser={handleCheckBoxUser} />
</>
)}
</ModalWrapper>
</>
);
};
......
import React from 'react';
import { useHistory } from 'react-router-dom';
import i18n from 'meteor/universe:i18n';
import { makeStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import { useAppContext } from '../contexts/context';
import ROUTES from '../layouts/routes';
const useStyles = makeStyles(() => ({
wrapper: {
height: 'calc(100vh - 64px)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
}));
const Login = () => {
const classes = useStyles();
const [{ loggingIn }] = useAppContext();
const history = useHistory();
return (
<div className={classes.wrapper}>
<Button variant="contained" color="primary" onClick={() => history.replace(ROUTES.HOME)}>
{i18n.__(loggingIn ? 'system.loading' : 'system.login')}
</Button>
</div>
);
};
export default Login;
import React, { useEffect } from 'react';
import { useEffect } from 'react';
import { useHistory } from 'react-router-dom';
import i18n from 'meteor/universe:i18n';
import { makeStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import { useAppContext } from '../contexts/context';
import ROUTES from '../layouts/routes';
const useStyles = makeStyles(() => ({
wrapper: {
height: 'calc(100vh - 64px)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
}));
const Logout = () => {
const classes = useStyles();
const [{ userId, loggingIn }] = useAppContext();
const history = useHistory();
useEffect(() => {
if (userId) Meteor.logout();
Meteor.logout(() => {
history.replace(ROUTES.LOGIN);
});
}, []);
return (
<div className={classes.wrapper}>
<Button variant="contained" color="primary" onClick={() => history.replace(ROUTES.HOME)}>
{i18n.__(loggingIn ? 'system.loading' : 'system.login')}
</Button>
</div>
);
return null;
};
export default Logout;
......@@ -21,6 +21,7 @@ import Spinner from '../components/system/Spinner';
import ROUTES from '../layouts/routes';
import { descriptionWithLinks } from '../components/events/utils';
import SingleGroupDisplay from '../components/events/SingleGroupDisplay';
import Calendar from '../components/system/Calendar/Calendar';
const useStyles = makeStyles((theme) => ({
chip: {
......@@ -144,93 +145,96 @@ const ReadEvent = ({ history, match: { params } }) => {
});
};
return (
<ModalWrapper
open
title={i18n.__('pages.ReadEvent.title')}
loading={loading}
onClose={goHome}
buttons={[
{
text: state.userId !== userId ? i18n.__('pages.ReadEvent.closeButton') : null,
onClick: state.userId !== userId ? goHome : null,
props: { color: 'default' },
key: 'first',
},
{
text: state.userId !== userId ? i18n.__('pages.ReadEvent.refuse') : i18n.__('pages.ReadEvent.cancelButton'),
onClick: state.userId !== userId ? refuseEvent : goHome,
props: state.userId !== userId ? { className: classes.redButton } : {},
key: 'second',
},
{
text: state.userId !== userId ? i18n.__('pages.ReadEvent.accept') : i18n.__('pages.ReadEvent.editButton'),
onClick: state.userId !== userId ? acceptEvent : goEdit,
props: { color: 'primary' },
key: 'third',
},
]}
>
{loading ? (
<Spinner inside />
) : (
<Grid container spacing={2}>
<Grid item md={12} xs={12}>
<Divider />
<h2>{i18n.__('pages.ReadEvent.informations')}</h2>
</Grid>
{informations.map((item) =>
item.value ? (
<Grid item md={item.width || 6} xs={12} key={item.label}>
<Typography>
<b>{item.label}:</b> <span className={classes.value}>{item.value}</span>
</Typography>
</Grid>
) : null,
)}
<>
<Calendar />
<ModalWrapper
open
title={i18n.__('pages.ReadEvent.title')}
loading={loading}
onClose={goHome}
buttons={[
{
text: state.userId !== userId ? i18n.__('pages.ReadEvent.closeButton') : null,
onClick: state.userId !== userId ? goHome : null,
props: { color: 'default' },
key: 'first',
},
{
text: state.userId !== userId ? i18n.__('pages.ReadEvent.refuse') : i18n.__('pages.ReadEvent.cancelButton'),
onClick: state.userId !== userId ? refuseEvent : goHome,
props: state.userId !== userId ? { className: classes.redButton } : {},
key: 'second',
},
{
text: state.userId !== userId ? i18n.__('pages.ReadEvent.accept') : i18n.__('pages.ReadEvent.editButton'),
onClick: state.userId !== userId ? acceptEvent : goEdit,
props: { color: 'primary' },
key: 'third',
},
]}
>
{loading ? (
<Spinner inside />
) : (
<Grid container spacing={2}>
<Grid item md={12} xs={12}>
<Divider />
<h2>{i18n.__('pages.ReadEvent.informations')}</h2>
</Grid>
{informations.map((item) =>
item.value ? (
<Grid item md={item.width || 6} xs={12} key={item.label}>
<Typography>
<b>{item.label}:</b> <span className={classes.value}>{item.value}</span>
</Typography>
</Grid>
) : null,
)}
{!!state.groups && !!state.groups.length && (
<>
{!!state.groups && !!state.groups.length && (
<>
<Grid item md={12} xs={12}>
<Divider />
<h2>{i18n.__('pages.ReadEvent.groups')}</h2>
</Grid>
<Grid item md={12} xs={12}>
{state.groups.map((group) => (
<SingleGroupDisplay key={group._id} group={group} view event={state} />
))}
</Grid>
</>
)}
{((!!state.participants && !!state.participants.filter(({ groupId }) => !groupId).length) ||
(!!state.guests && !!state.guests.length)) && (
<Grid item md={12} xs={12}>
<Divider />
<h2>{i18n.__('pages.ReadEvent.groups')}</h2>
</Grid>
<Grid item md={12} xs={12}>
{state.groups.map((group) => (
<SingleGroupDisplay key={group._id} group={group} view event={state} />
<h2>{i18n.__('pages.ReadEvent.participants')}</h2>
{state.participants
.filter(({ groupId }) => !groupId)
.map((part) => {
const displayStatus = part.status !== 1;
return (
<Chip
key={part._id}
className={`${classes.chip} ${
displayStatus ? (part.status === 0 ? classes.errorChip : classes.successChip) : ''
}`}
color={displayStatus ? 'primary' : 'default'}
onDelete={displayStatus ? () => null : null}
deleteIcon={displayStatus ? part.status === 0 ? <RemoveIcon /> : <DoneIcon /> : null}
label={part.email}
/>
);
})}
{state.guests.map((guest) => (
<Chip key={guest} color="secondary" label={guest} className={classes.chip} />
))}
</Grid>
</>
)}
{((!!state.participants && !!state.participants.filter(({ groupId }) => !groupId).length) ||
(!!state.guests && !!state.guests.length)) && (
<Grid item md={12} xs={12}>
<Divider />
<h2>{i18n.__('pages.ReadEvent.participants')}</h2>
{state.participants
.filter(({ groupId }) => !groupId)
.map((part) => {
const displayStatus = part.status !== 1;
return (
<Chip
key={part._id}
className={`${classes.chip} ${
displayStatus ? (part.status === 0 ? classes.errorChip : classes.successChip) : ''
}`}
color={displayStatus ? 'primary' : 'default'}
onDelete={displayStatus ? () => null : null}
deleteIcon={displayStatus ? part.status === 0 ? <RemoveIcon /> : <DoneIcon /> : null}
label={part.email}
/>
);
})}
{state.guests.map((guest) => (
<Chip key={guest} color="secondary" label={guest} className={classes.chip} />
))}
</Grid>
)}
</Grid>
)}
</ModalWrapper>
)}
</Grid>
)}
</ModalWrapper>
</>
);
};
......
{
"name": "agenda3",
"version": "3.6.0-testing.1",
"version": "3.6.0-testing.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......
{
"name": "agenda3",
"version": "3.6.0-testing.1",
"version": "3.6.0-testing.2",
"license": "EUPL-1.2",
"description": "Online diary",
"author": "EOLE/PCLL <team@eole.education> - DINUM",
......