diff --git a/src/app/(dashboard)/assign-zone-project/AffectationsFilter.jsx b/src/app/(dashboard)/assign-zone-project/AffectationsFilter.jsx index 9d9c2224804cc518671a6e7fa659f59b3d89bbba..0fe90257abd8ec687345b3033229257446c0f713 100644 --- a/src/app/(dashboard)/assign-zone-project/AffectationsFilter.jsx +++ b/src/app/(dashboard)/assign-zone-project/AffectationsFilter.jsx @@ -13,7 +13,7 @@ const AffectationsFilter = memo(function Page({ setFilter, filter, zones, projec // "nom": "weleaf", // "id": 1 // } - + console.log("filterr", filter) const handleResetFilters = (event) => { const value = event.target.value setFilter({ semaines: [], jours: [], projects: [], zones: [] }) @@ -168,7 +168,7 @@ const AffectationsFilter = memo(function Page({ setFilter, filter, zones, projec isSearchable={true} value={filter.zones || ""} isMulti - name="jours" + name="zones" onChange={handleZoneChange} options={zones.map((element) => ({ label: 'Zone:'+ element.nomZone +' - '+ 'Étage:' +element.numeroEtage , value: element.id }))} styles={ diff --git a/src/app/(dashboard)/assign-zone-project/page.jsx b/src/app/(dashboard)/assign-zone-project/page.jsx index e7a343c4c6250fde953bf70a2a9b2505e258a558..c9484c0ff1068b79421a715815236496f82448af 100644 --- a/src/app/(dashboard)/assign-zone-project/page.jsx +++ b/src/app/(dashboard)/assign-zone-project/page.jsx @@ -39,7 +39,6 @@ const AffectingZoneProject = () => { await fetchRequest(`/zoaning/distinct-projects-zones/` ,{ method: 'GET' } ) if (isSuccess) { - console.log("getDistinctsProjectsAndZones", data) setProjects(data.projects) setZones(data.zones) } else { @@ -61,7 +60,6 @@ const AffectingZoneProject = () => { }, []) - useEffect(() => { // this function is to detect if there is a project that is not fully affected and return the corresponding data to use @@ -251,7 +249,6 @@ const AffectingZoneProject = () => { } - console.log("listProjectsAffected", listProjectsAffected) return ( <> @@ -277,8 +274,8 @@ const AffectingZoneProject = () => { Plateau Projet Places occupées + Nb des personnes Places disponible - Places occupées Actions {(listProjectsAffected.map((element, index) => diff --git a/src/app/(dashboard)/etage/CreateEtage.jsx b/src/app/(dashboard)/etage/CreateEtage.jsx index 2d16cebac618d8f66a40d831cfda4d2e19dca3e3..5259b4902664544db649bf3f4f390aced4825e2b 100644 --- a/src/app/(dashboard)/etage/CreateEtage.jsx +++ b/src/app/(dashboard)/etage/CreateEtage.jsx @@ -1,3 +1,4 @@ +/* eslint-disable @next/next/no-img-element */ 'use client' import Loader from '@/components/Loader/Loader' import React, { useRef, useState, useEffect } from 'react' @@ -5,7 +6,9 @@ import fetchRequest from '../../lib/fetchRequest' import { useNotification } from "@/context/NotificationContext"; import CancelIcon from "@/static/image/svg/cancel.svg" import CheckIcon from "@/static/image/svg/check.svg" - +import ImageIcon from "@/static/image/svg/image.svg" +import ColoredImageIcon from "@/static/image/svg/image2.svg" +import CrossIcon from "@/static/image/svg/cancel.svg" const CreateEtage = ({ appendEtage, cancelCreate }) => { const [isLoading, setIsLoading] = useState(false) @@ -15,12 +18,17 @@ const CreateEtage = ({ appendEtage, cancelCreate }) => { setNumeroEtage(event.target.value) } const inputRef = useRef(null) + const imageInput = useRef(null) + const [image, setImage] = useState(null) const handleSubmit = async (event) => { event.preventDefault() setIsLoading(true) + const formData = new FormData() + formData.append("numero", numeroEtage) + formData.append("image", image) const { data, errors, isSuccess } = await fetchRequest("/zoaning/etages/", { method: "POST", - body: JSON.stringify({ numero: numeroEtage }) + body: formData, }) if (isSuccess) { setIsLoading(false) @@ -36,6 +44,13 @@ const CreateEtage = ({ appendEtage, cancelCreate }) => { } else { setIsLoading(false) if (errors.type === "ValidationError") { + if (errors.detail.image) { + toggleNotification({ + type: "warning", + message: "Le type de l'image n'est pas supporté", + visible: true, + }) + } if (errors.detail.name) { toggleNotification({ type: "warning", @@ -93,9 +108,88 @@ const CreateEtage = ({ appendEtage, cancelCreate }) => { } }, []) + + const removeImage = () => { + imageInput.current.value = ""; + setImage(null); + setIsDisplayingImage(false) + }; + + const handleChangeImage = (e) => { + if (imageInput.current.value !== "") { + const supportedType = ["image/jpg", "image/jpeg", "image/png"]; + if (supportedType.includes(imageInput.current.files[0].type)) { + setImage(imageInput.current.files[0]); + } else { + removeImage(); + setIsDisplayingImage(false) + toggleNotification({ + type: "warning", + message: "Le type de l'image n'est pas supporté", + visible: true + }) + } + } else { + setImage(null); + setIsDisplayingImage(false) + } + }; + const [isDisplayingImage, setIsDisplayingImage] = useState(false) + const viewImage = () => { + setIsDisplayingImage(true) + } + return - + + + + {(!image) && <> + + } + + + + {(image) && <> +
+
+
+ +
+
+

{image.name}

+

{Math.round((image.size / (1024 * 1024)) * 100) / 100}Mo

+
+
+

Voir l'image

+
+ {(isDisplayingImage) &&
+
+
setIsDisplayingImage(false)} className='ml-auto relative bottom-3'> + +
+
+ User uploaded +
+
+
} +
+
+ +
+
+
+
+ }
diff --git a/src/app/(dashboard)/etage/EtageTableRow.jsx b/src/app/(dashboard)/etage/EtageTableRow.jsx index ff162b580369800b60cdeb49623f554d924fce04..0cc0af12b1223920ff1f2a5ae24fa82c30988ab1 100644 --- a/src/app/(dashboard)/etage/EtageTableRow.jsx +++ b/src/app/(dashboard)/etage/EtageTableRow.jsx @@ -1,3 +1,4 @@ +/* eslint-disable @next/next/no-img-element */ 'use client' import React, { useEffect, useRef, useState } from 'react' import fetchRequest from '../../lib/fetchRequest' @@ -8,7 +9,9 @@ import CancelIcon from "@/static/image/svg/cancel.svg" import CheckIcon from "@/static/image/svg/check.svg" import { useNotification } from '@/context/NotificationContext' import ConfirmationModal from '../../ui/ConfirmationModal' -const EtageTableRow = ({ id, numero, setEtages }) => { +import CrossIcon from "@/static/image/svg/cancel.svg" + +const EtageTableRow = ({ id, numero, setEtages, image }) => { const [numeroEtage, setNumeroEtage] = useState(numero) const [loadingStatus, setLoadingStatus] = useState(false) const { toggleNotification } = useNotification() @@ -68,11 +71,33 @@ const EtageTableRow = ({ id, numero, setEtages }) => { document.removeEventListener("click", handleUpdateBlur); } } + const [isDisplayingImage, setIsDisplayingImage] = useState(false) + const viewImage = () => { + setIsDisplayingImage(true) + } return ( <> - setNumeroEtage(event.target.value)} defaultValue={numero} type='text' className='w-full border-0 rounded-md px-2 enabled:drop-shadow border-none enabled:bg-gray-100 disabled:bg-transparent duration-100 h-10 outline-none' /> + setNumeroEtage(event.target.value)} defaultValue={numero} type='text' className='w-full min-w-80 border-0 rounded-md px-2 enabled:drop-shadow border-none enabled:bg-gray-100 disabled:bg-transparent duration-100 h-10 outline-none' /> + + + {(isDisplayingImage && image) &&
+
+
setIsDisplayingImage(false)} className='ml-auto relative bottom-3'> + +
+
+ User uploaded +
+
+
} + {!image &&

+ Aucune image n'est associée à cet étage. +

} + {(image) &&
+

Voir l'image

+
}
diff --git a/src/app/(dashboard)/etage/page.jsx b/src/app/(dashboard)/etage/page.jsx index 8deae510305aed6510cf98a804356ea6650668fe..c4dc6c726a9c501f76d55e480dc3723e1625271e 100644 --- a/src/app/(dashboard)/etage/page.jsx +++ b/src/app/(dashboard)/etage/page.jsx @@ -47,6 +47,7 @@ const Etage = () => { + {(isCreating) && setIsCreating(false)} appendEtage={appendEtage} />} diff --git a/src/app/(dashboard)/place/PlacesFilter.jsx b/src/app/(dashboard)/place/PlacesFilter.jsx index 2c23693535f98767b929ac83f713f8b91d4dbddc..01a903856145191aad8dce8431a88524111e6373 100644 --- a/src/app/(dashboard)/place/PlacesFilter.jsx +++ b/src/app/(dashboard)/place/PlacesFilter.jsx @@ -21,16 +21,19 @@ const PlacesFilter = memo(function Page({ setFilter, filter, etages, zones, tabl const handleResetFilters = () => { setFilter({ place: "", etage: "", zone: "", tables: [] }) } - + console.log("filter", filter) + + console.log("zones", zones) + console.log("etages", etages) return (

Recherche

- +
-
+
setSelectedWeek(e.target.value)} className='rounded-md px-3 duration-150 delay-75 focus:ring ring-offset-1 ring-sushi-200 border h-10 border-neutral-500 outline-none'> - - - - - - - -
- -
+
+ + table.zone.id === filter.zone).map((table) => ({ label: table.numero, value: table.id }))} + styles={ + { + menu: (provided) => ({ + ...provided, + maxHeight: '170px', + overflowY: 'auto' + }), + menuList: (provided) => ({ + ...provided, + maxHeight: '170px', + overflowY: 'auto' + }), + control: (provided, state) => ({ + ...provided, + borderColor: state.isFocused ? '#93a84c' : 'rgb(212 212 212)', + borderWidth: "1px", + boxShadow: 'none', + borderRadius: "0.375rem", + minHeight: "2.5rem", + }), + option: (provided, state) => ({ + ...provided, + backgroundColor: state.isSelected ? '#D3E193' : state.isFocused ? '#d9e1b5' : 'white', + color: state.isSelected ? 'black' : 'inherit', + '&:hover': { + backgroundColor: '#d9e1b5', // Tailwind's blue-200 + }, + }), + } + } + />
diff --git a/src/app/(dashboard)/place/page.jsx b/src/app/(dashboard)/place/page.jsx index 120a0ac121257463e3703e4d3a143408cafbc0ae..08c1014fbc4cb4d318103c60db2fde98dd97f708 100644 --- a/src/app/(dashboard)/place/page.jsx +++ b/src/app/(dashboard)/place/page.jsx @@ -19,7 +19,6 @@ const Place = () => { const [filter, setFilter] = useState({ place: "", etage: "", zone: "", tables: [] }); - console.log(filter) useEffect(() => { const getPlaces = async () => { var tablesIdString = filter.tables.map((element) => element.value).toString() diff --git a/src/app/(dashboard)/reservation/page.jsx b/src/app/(dashboard)/reservation/page.jsx index 0b82d13f3fe2d8704a69d36eda7945c42388da87..e75a1b401f35a3080e51f11db15a7e1e7d990ff4 100644 --- a/src/app/(dashboard)/reservation/page.jsx +++ b/src/app/(dashboard)/reservation/page.jsx @@ -9,6 +9,7 @@ import PresenceButton from './PresenceButton' import Cookies from 'js-cookie'; import { decrypt } from '@/app/lib/session'; import ReservationConfirmation from '@/app/ui/ReservationConfirmation' +import { dateDiffInDays, extractDate } from '@/app/lib/DateHelper' export const ReservationContext = React.createContext() @@ -174,10 +175,17 @@ const Reservation = () => { const currentMonth = new Date().getMonth() + 1 // filter dates from now to 2 weeks later + + // console.log("target date", datesData); + // const filteredDatesData = datesData?.filter((element) => { + // const date = new Date(element.date) + // const month = date.getMonth() + 1 + // return (month === currentMonth) && (date.getDate() >= new Date().getDate() && date.getDate() <= new Date().getDate() + 14) + // }) const filteredDatesData = datesData?.filter((element) => { - const date = new Date(element.date) - const month = date.getMonth() + 1 - return (month === currentMonth) && (date.getDate() >= new Date().getDate() && date.getDate() <= new Date().getDate() + 14) + const diff = dateDiffInDays(extractDate(new Date()), element.date) + return diff >= 0 && diff <= 14 + }) const selectedZoneData = floors.find((element) => element.id == selectedZone.floorId)?.zones.find((zone) => zone.id === selectedZone.zoneId) return ( diff --git a/src/app/(dashboard)/table/TablesFilter.jsx b/src/app/(dashboard)/table/TablesFilter.jsx index 53648ce6a83065f9c625e736258d77af60952eea..df099d97b1a102b3db17eb3b2e57f67ac503bfe6 100644 --- a/src/app/(dashboard)/table/TablesFilter.jsx +++ b/src/app/(dashboard)/table/TablesFilter.jsx @@ -25,7 +25,7 @@ const TablesFilter = memo(function Page({ setFilter, filter, etages, zones }) {
-
+
Nom de la zone
-
+
Numéro ÉtageImage Actions