Skip to content

Commit

Permalink
🔧 update(room_types): Add room types TP Automatisme, TP Electronique,…
Browse files Browse the repository at this point in the history
… Bureau

GitOrigin-RevId: 02c25de406990768e3545cb3a566ef85c7eac7d2
  • Loading branch information
petitbenjamin authored and p-bizouard committed Sep 11, 2023
1 parent 3580e32 commit ced696a
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 54 deletions.
4 changes: 2 additions & 2 deletions back/src/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ module.exports = {
secret: secrets.jwtSecret,
},
cypher: {
salt: secrets.cypherSalt,
tokenSecret: secrets.tokenSalt,
salt: secrets.cypher.salt,
tokenSecret: secrets.cypher.tokenSecret,
},
smtp: {
host: secrets.smtp.host,
Expand Down
5 changes: 0 additions & 5 deletions back/src/webservice/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const { promisify } = require("util");
const _ = require("lodash");
const kleur = require("kleur");
// src
const { CAMPUS_SACLAY } = require("../config/constants");
const config = require("./translatorConfig").room;
const wsEventStapler = require("./eventStapler");
const roomParser = require("./utils/roomParser");
Expand Down Expand Up @@ -157,10 +156,6 @@ async function getAvailableRooms(
room.allowBookings ||
(!room.allowBookings && room.belongsTo.length > 0),
)
.filter(
(room) =>
(diffInHours > 2 && room.campus !== CAMPUS_SACLAY) || diffInHours <= 2,
)
.map((room) => ({
...room,
videoProviders: room.videoProviders.map((vp) => vp.label),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
"CodPro": "45",
"ValPro": {
"102": "TP numérique",
"199": "TP Automatisme",
"205": "TP Electronique",
"198": "Bureau",
"27": "Amphithéâtre",
"28": "Auditorium",
"100": "Enseignement",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
"CodPro": "45",
"ValPro": {
"102": "TP numérique",
"199": "TP Automatisme",
"205": "TP Electronique",
"198": "Bureau",
"27": "Amphithéâtre",
"28": "Auditorium",
"100": "Enseignement",
Expand Down
19 changes: 9 additions & 10 deletions front/src/components/scenes/Search/Filters/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// lib
import React from "react";
import PropTypes from "prop-types";
import throttle from "lodash/throttle";
import React from 'react';
import PropTypes from 'prop-types';
import throttle from 'lodash/throttle';
// src
import { CAMPUSES, BUILDINGS } from "config";
import Checkbox from "components/partials/Checkbox";
import roomTypes from "reducers/search/roomTypes.data";
import SearchBar from "./SearchBar";
import TypeSelector from "./TypeSelector";
import CapacitySelector from "./CapacitySelector";
import { CAMPUSES, BUILDINGS } from 'config';
import Checkbox from 'components/partials/Checkbox';
import roomTypes from 'reducers/search/roomTypes.data';
import SearchBar from './SearchBar';
import TypeSelector from './TypeSelector';
import CapacitySelector from './CapacitySelector';

class Filters extends React.Component {
static propTypes = {
Expand Down Expand Up @@ -102,7 +102,6 @@ class Filters extends React.Component {
name={c}
/>
))}
<div>Bâtiments :</div>
{BUILDINGS.map((b) => (
<Checkbox
key={b}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// lib
import React, { useState, useEffect, useCallback } from "react";
import PropTypes from "prop-types";
import OptionalImage from "react-image";
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import OptionalImage from 'react-image';
// src
import config from "config";
import ConfirmModal from "components/partials/Modals/ConfirmModal";
import EventList from "components/partials/EventList";
import BookingSummary from "components/partials/BookingSummary";
import EventNameInput from "./EventNameInput";
import VideoProviderInput from "./VideoProviderInput";
import config from 'config';
import ConfirmModal from 'components/partials/Modals/ConfirmModal';
import EventList from 'components/partials/EventList';
import BookingSummary from 'components/partials/BookingSummary';
import EventNameInput from './EventNameInput';
import VideoProviderInput from './VideoProviderInput';

const imageExtension = "jpg";
const { CAMPUS_SACLAY } = require('../../../../../config/index');

const imageExtension = 'jpg';

const ConfirmBooking = ({
room,
Expand All @@ -27,15 +29,15 @@ const ConfirmBooking = ({
}) => {
const [tooLongTimes, setTooLongTimes] = useState(false);

const checkTimeCoherence = useCallback(() => {
const diffTime = endTime - startTime;

const checkTimeCoherence = () => {
setTooLongTimes(false);

if (diffTime / 3600000 > 2) {
setTooLongTimes(true);
if (room.campus === CAMPUS_SACLAY) {
const diffTime = endTime - startTime;
if (diffTime / 3600000 > 2) {
setTooLongTimes(true);
}
}
}, [endTime, startTime]);
};

useEffect(() => {
// Appel de la méthode checkTimeCoherence lors du montage du composant
Expand Down Expand Up @@ -67,6 +69,14 @@ const ConfirmBooking = ({
ATTENTION, cette salle sera décloisonnée
</div>
) : null,
tooLongTimes === true ? (
<div className="alert alert-danger" role="alert">
Pour un créneau supérieur à 2h, contacter{' '}
<a href="mailto:[email protected]">
[email protected]
</a>
</div>
) : null,
<EventNameInput
available={room.available}
eventName={eventName}
Expand All @@ -87,25 +97,21 @@ const ConfirmBooking = ({
];

return (
<ConfirmModal
title={`Réservation de ${room.name}`}
body={body}
confirmButtonText={
<span>
Confirmer
<span className="d-none d-sm-inline"> la réservation</span>
</span>
}
confirmButtonFunction={!tooLongTimes ? confirmBooking : null}
showConfirmButton={room.available && !tooLongTimes}
cancelActionText={
tooLongTimes
? "Le créneau demandé est de 2h max pour Paris Saclay"
: room.available
? "Annuler"
: "OK"
}
/>
<>
<ConfirmModal
title={`Réservation de ${room.name}`}
body={body}
confirmButtonText={
<span>
Confirmer
<span className="d-none d-sm-inline"> la réservation</span>
</span>
}
confirmButtonFunction={confirmBooking}
showConfirmButton={room.available && !tooLongTimes}
cancelActionText={room.available ? 'Annuler' : 'OK'}
/>
</>
);
};

Expand Down
3 changes: 2 additions & 1 deletion front/src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const loginQuery = querystring.stringify({

export const loginRequest = `${config.cas.loginUrl}?${loginQuery}`;
export const CAMPUSES = ['Saclay', 'Metz', 'Rennes'];
export const BUILDINGS = ["Lumen"];
export const CAMPUS_SACLAY = 'Saclay';
export const BUILDINGS = ['Lumen'];

export default config;
8 changes: 8 additions & 0 deletions front/src/reducers/search/roomTypes.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ const roomTypes = [
value: 'TP numérique',
fullName: 'TP numériques',
},
{
value: 'TP Automatisme',
fullName: 'TP Automatisme',
},
{
value: 'TP Electronique',
fullName: 'TP Electronique',
},
{
value: 'Plateau projet',
fullName: 'Espaces projets',
Expand Down

0 comments on commit ced696a

Please sign in to comment.