From b37837d7c2f895536af933be1c6d09dc9385b3ef Mon Sep 17 00:00:00 2001 From: Alexandre-27 Date: Thu, 8 Feb 2024 01:47:02 +0100 Subject: [PATCH 1/9] fixed css in the component FilterUsersAdmin.jsx --- frontend/src/components/FilterUsersAdmin.scss | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/FilterUsersAdmin.scss b/frontend/src/components/FilterUsersAdmin.scss index 651b677..61f9e39 100644 --- a/frontend/src/components/FilterUsersAdmin.scss +++ b/frontend/src/components/FilterUsersAdmin.scss @@ -19,12 +19,14 @@ justify-content: end; .cross-filter-button { + padding: 0; margin-top: 4%; margin-right: 4%; + margin-bottom: 0; width: 8%; - height: 0; border: none; cursor: pointer; + background-color: $deep-purple; img { width: 100%; @@ -49,6 +51,7 @@ border: 3px solid $red; border-left: none; border-right: none; + border-radius: 0; padding: 3%; margin-bottom: 0; cursor: pointer; From a98694008ee4e78fa5662415eee367342c5a3ae0 Mon Sep 17 00:00:00 2001 From: Alexandre-27 Date: Thu, 8 Feb 2024 01:56:53 +0100 Subject: [PATCH 2/9] fixed css in the component ValidateCaptureAdmin.jsx --- frontend/src/components/ValidateCaptureAdmin.scss | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/src/components/ValidateCaptureAdmin.scss b/frontend/src/components/ValidateCaptureAdmin.scss index 264c9ee..a09bfaa 100644 --- a/frontend/src/components/ValidateCaptureAdmin.scss +++ b/frontend/src/components/ValidateCaptureAdmin.scss @@ -17,12 +17,15 @@ justify-content: end; button { + padding: 0; margin-top: 4%; margin-right: 4%; + margin-bottom: 0; width: 6%; height: 0; border: none; cursor: pointer; + background-color: $deep-purple; img { width: 100%; From c0a9fc9b9f40457d91e84e324e3ea472a114b425 Mon Sep 17 00:00:00 2001 From: Alexandre-27 Date: Thu, 8 Feb 2024 02:02:12 +0100 Subject: [PATCH 3/9] Deleted of section Artistes. --- frontend/src/pages/Admin.jsx | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/frontend/src/pages/Admin.jsx b/frontend/src/pages/Admin.jsx index 036f6dc..e714baf 100644 --- a/frontend/src/pages/Admin.jsx +++ b/frontend/src/pages/Admin.jsx @@ -13,7 +13,6 @@ import Avatar from "../assets/panel-admin/avatar-svgrepo-com.svg"; import Hourglass from "../assets/panel-admin/hourglass-not-done-svgrepo-com.svg"; import badge from "../assets/panel-admin/badge-award-svgrepo-com.svg"; import light from "../assets/panel-admin/light-bulb-idea-svgrepo-com.svg"; -import download from "../assets/panel-admin/download-svgrepo-com.svg"; import CaptureAdmin from "../components/CaptureAdmin"; import FilterUsersAdmin from "../components/FilterUsersAdmin"; import NewArtAdmin from "../components/NewArtAdmin"; @@ -42,7 +41,6 @@ function admin() { const dashboardRef = useRef(null); const usersRef = useRef(null); const streetArtRef = useRef(null); - const artistsRef = useRef(null); const { user, handleAuth, userMode } = useContext(AuthContext); @@ -64,13 +62,8 @@ function admin() { offset < streetArtRef.current.offsetTop ) { setActiveSection("users"); - } else if ( - offset >= streetArtRef.current.offsetTop && - offset < artistsRef.current.offsetTop - ) { + } else if (offset >= streetArtRef.current.offsetTop) { setActiveSection("streetArt"); - } else if (offset >= artistsRef.current.offsetTop) { - setActiveSection("artists"); } }; @@ -384,33 +377,6 @@ function admin() { /> )} -
-

- Ajouter un artiste -

- download -

Télécharger une photo

-
-
-

- Nom de l'artiste{" "} - * -

- -
-
-

A propos de l'artiste

- -
-
- -
) : (

From c9fea1756f365484c171d6d181790845ecb98336 Mon Sep 17 00:00:00 2001 From: Alexandre-27 Date: Thu, 8 Feb 2024 02:03:38 +0100 Subject: [PATCH 4/9] Deleted of section Artistes. --- frontend/src/components/NavBarAdmin.jsx | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/frontend/src/components/NavBarAdmin.jsx b/frontend/src/components/NavBarAdmin.jsx index d523f05..d37fd77 100644 --- a/frontend/src/components/NavBarAdmin.jsx +++ b/frontend/src/components/NavBarAdmin.jsx @@ -56,16 +56,6 @@ function NavBarAdmin({ activeSection }) {

-
  • -

    - - Artistes - -

    -
  • ); From c04b7d3c50c9a7d44e4dd6bfe8ef506ffbb7ccc3 Mon Sep 17 00:00:00 2001 From: Alexandre-27 Date: Thu, 8 Feb 2024 02:09:54 +0100 Subject: [PATCH 5/9] fixed css in the component CaptureAdmin.scss. --- frontend/src/components/CaptureAdmin.scss | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/CaptureAdmin.scss b/frontend/src/components/CaptureAdmin.scss index c42ef87..544da81 100644 --- a/frontend/src/components/CaptureAdmin.scss +++ b/frontend/src/components/CaptureAdmin.scss @@ -50,9 +50,11 @@ .original-img-grid { grid-area: 1 / 3 / 2 / 4; - width: 50%; + width: 40%; + height: 29vh; + object-fit: cover; margin: auto; - margin-left: 0; + margin-left: 2%; margin-bottom: 0; border-radius: 0.5rem; } From 784a8005cfa8193070291f3ff71fd3820abb3598 Mon Sep 17 00:00:00 2001 From: Alexandre-27 Date: Thu, 8 Feb 2024 02:28:20 +0100 Subject: [PATCH 6/9] fixed css in the component NavBar.jsx. --- frontend/src/components/MainNavBars/NavBar.jsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/MainNavBars/NavBar.jsx b/frontend/src/components/MainNavBars/NavBar.jsx index 23741a8..8e1f539 100644 --- a/frontend/src/components/MainNavBars/NavBar.jsx +++ b/frontend/src/components/MainNavBars/NavBar.jsx @@ -56,7 +56,9 @@ function NavBar({ { handleChangePage("user/profil"); }} @@ -66,7 +68,12 @@ function NavBar({ { + handleChangePage("connexionOuDéconnexion"); + }} >

    {user.is_administrator === 3 ? "Connexion" : "Déconnexion"}

    From 9f374e4433bbdc6ce543f7b10d49ef7fe7199922 Mon Sep 17 00:00:00 2001 From: Alexandre-27 Date: Thu, 8 Feb 2024 03:14:52 +0100 Subject: [PATCH 7/9] Setting up notification of captures awaiting validation. --- backend/src/models/CaptureManager.js | 2 +- frontend/src/components/CaptureAdmin.jsx | 33 +++++++----------------- frontend/src/pages/Admin.jsx | 26 ++++++++++++++++++- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/backend/src/models/CaptureManager.js b/backend/src/models/CaptureManager.js index 0a6dc45..d57b5af 100644 --- a/backend/src/models/CaptureManager.js +++ b/backend/src/models/CaptureManager.js @@ -25,7 +25,7 @@ class CaptureManager extends AbstractManager { async readAll() { const [rows] = await this.database.query(` - SELECT c.id, c.user_id, c.artwork_id, c.capture, a.picture AS artwork_url + SELECT c.id, c.user_id, c.artwork_id, c.capture, a.picture AS artwork_url, a.reported FROM ${this.table} c LEFT JOIN artworks a ON c.artwork_id = a.id `); diff --git a/frontend/src/components/CaptureAdmin.jsx b/frontend/src/components/CaptureAdmin.jsx index 743dc91..182835c 100644 --- a/frontend/src/components/CaptureAdmin.jsx +++ b/frontend/src/components/CaptureAdmin.jsx @@ -1,29 +1,7 @@ -import { useState, useEffect } from "react"; import PropTypes from "prop-types"; -import axios from "axios"; import "./CaptureAdmin.scss"; -function CaptureAdmin({ setToggleModalCapture, userId }) { - const [artCapture, setArtCapture] = useState([]); - - useEffect(() => { - axios - .get(`${import.meta.env.VITE_BACKEND_URL}/api/captures`, { - params: { - general_gallery: true, - }, - }) - .then((response) => { - setArtCapture(response.data); - }) - .catch((error) => { - console.error( - "Erreur lors de la récupération des utilisateurs:", - error - ); - }); - }, []); - +function CaptureAdmin({ artCapture, setToggleModalCapture, userId }) { const getCaptureURL = (artwork) => { const capturePath = artwork.capture.replace("public/", ""); return `${import.meta.env.VITE_BACKEND_URL}/${capturePath}`; @@ -68,6 +46,15 @@ function CaptureAdmin({ setToggleModalCapture, userId }) { } CaptureAdmin.propTypes = { + artCapture: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.number.isRequired, + user_pseudo: PropTypes.string.isRequired, + capture: PropTypes.string.isRequired, + artwork_url: PropTypes.string.isRequired, + user_id: PropTypes.number.isRequired, + }) + ).isRequired, setToggleModalCapture: PropTypes.func.isRequired, userId: PropTypes.func.isRequired, }; diff --git a/frontend/src/pages/Admin.jsx b/frontend/src/pages/Admin.jsx index e714baf..adb6a61 100644 --- a/frontend/src/pages/Admin.jsx +++ b/frontend/src/pages/Admin.jsx @@ -31,12 +31,14 @@ function admin() { const [toggleUserFilter, setToggleUserFilter] = useState(false); const [initialOffset, setInitialOffset] = useState(null); const [sortOrder, setSortOrder] = useState(null); + const [artCapture, setArtCapture] = useState([]); const [toggleModalCapture, setToggleModalCapture] = useState(false); const [points, setPoints] = useState(0); const [isNewArtwork, setIsNewArtwork] = useState(false); const [isHardToFind, setIsHardToFind] = useState(false); const [isAllFieldsFilled, setIsAllFieldsFilled] = useState(false); const [pointsUserId, setPointsUserId] = useState([]); + const [notifCaptureCount, setNotifCaptureCount] = useState(0); const dashboardRef = useRef(null); const usersRef = useRef(null); @@ -180,6 +182,25 @@ function admin() { }; }, [initialOffset]); + useEffect(() => { + axios + .get(`${import.meta.env.VITE_BACKEND_URL}/api/captures`, { + params: { + general_gallery: true, + }, + }) + .then((response) => { + const filteredCaptures = response.data.filter( + (capture) => capture.artwork?.reported !== true + ); + setArtCapture(filteredCaptures); + setNotifCaptureCount(filteredCaptures.length); + }) + .catch((error) => { + console.error("Erreur lors de la récupération des captures:", error); + }); + }, []); + const handleNewArtworkCheck = () => { setIsNewArtwork(!isNewArtwork); setPoints((prevPoints) => @@ -238,7 +259,9 @@ function admin() {
    -

    12 Street Art en attente de validation

    +

    + {notifCaptureCount} Street Art en attente de validation +

    Sablier
    @@ -357,6 +380,7 @@ function admin() { /> {activeComponent === "captures" && ( From e39051ed8632e325f851404abf2d7cfaed1dcc6d Mon Sep 17 00:00:00 2001 From: Alexandre-27 Date: Thu, 8 Feb 2024 04:07:19 +0100 Subject: [PATCH 8/9] Setting up the deletion of the work in the back and front once it has been validated. --- frontend/src/components/CaptureAdmin.jsx | 9 ++- .../src/components/ValidateCaptureAdmin.jsx | 12 ++-- frontend/src/pages/Admin.jsx | 59 +++++++++++++------ 3 files changed, 55 insertions(+), 25 deletions(-) diff --git a/frontend/src/components/CaptureAdmin.jsx b/frontend/src/components/CaptureAdmin.jsx index 182835c..d6acb66 100644 --- a/frontend/src/components/CaptureAdmin.jsx +++ b/frontend/src/components/CaptureAdmin.jsx @@ -1,7 +1,12 @@ import PropTypes from "prop-types"; import "./CaptureAdmin.scss"; -function CaptureAdmin({ artCapture, setToggleModalCapture, userId }) { +function CaptureAdmin({ + artCapture, + setToggleModalCapture, + userId, + captureId, +}) { const getCaptureURL = (artwork) => { const capturePath = artwork.capture.replace("public/", ""); return `${import.meta.env.VITE_BACKEND_URL}/${capturePath}`; @@ -26,6 +31,7 @@ function CaptureAdmin({ artCapture, setToggleModalCapture, userId }) { onClick={() => { setToggleModalCapture(true); userId(artwork.user_id); + captureId(artwork.id); }} > Valider @@ -57,6 +63,7 @@ CaptureAdmin.propTypes = { ).isRequired, setToggleModalCapture: PropTypes.func.isRequired, userId: PropTypes.func.isRequired, + captureId: PropTypes.func.isRequired, }; export default CaptureAdmin; diff --git a/frontend/src/components/ValidateCaptureAdmin.jsx b/frontend/src/components/ValidateCaptureAdmin.jsx index c83b579..93f3c37 100644 --- a/frontend/src/components/ValidateCaptureAdmin.jsx +++ b/frontend/src/components/ValidateCaptureAdmin.jsx @@ -12,6 +12,7 @@ function ValidateCaptureAdmin({ isHardToFind, isAllFieldsFilled, pointsUserId, + deleteCaptureId, }) { return (
    @@ -60,7 +61,7 @@ function ValidateCaptureAdmin({ type="button" className="button-red" onClick={() => { - handleValidateButtonClick(pointsUserId); + handleValidateButtonClick(pointsUserId, deleteCaptureId); }} > Valider l'oeuvre @@ -75,10 +76,11 @@ ValidateCaptureAdmin.propTypes = { handleHardToFindCheck: PropTypes.func.isRequired, handleAllFieldsFilledCheck: PropTypes.func.isRequired, handleValidateButtonClick: PropTypes.func.isRequired, - isNewArtwork: PropTypes.func.isRequired, - isHardToFind: PropTypes.func.isRequired, - isAllFieldsFilled: PropTypes.func.isRequired, - pointsUserId: PropTypes.func.isRequired, + isNewArtwork: PropTypes.bool.isRequired, + isHardToFind: PropTypes.bool.isRequired, + isAllFieldsFilled: PropTypes.bool.isRequired, + pointsUserId: PropTypes.number.isRequired, + deleteCaptureId: PropTypes.number.isRequired, }; export default ValidateCaptureAdmin; diff --git a/frontend/src/pages/Admin.jsx b/frontend/src/pages/Admin.jsx index adb6a61..f9be7ee 100644 --- a/frontend/src/pages/Admin.jsx +++ b/frontend/src/pages/Admin.jsx @@ -38,6 +38,7 @@ function admin() { const [isHardToFind, setIsHardToFind] = useState(false); const [isAllFieldsFilled, setIsAllFieldsFilled] = useState(false); const [pointsUserId, setPointsUserId] = useState([]); + const [deleteCaptureId, setDeleteCaptureId] = useState([]); const [notifCaptureCount, setNotifCaptureCount] = useState(0); const dashboardRef = useRef(null); @@ -182,25 +183,6 @@ function admin() { }; }, [initialOffset]); - useEffect(() => { - axios - .get(`${import.meta.env.VITE_BACKEND_URL}/api/captures`, { - params: { - general_gallery: true, - }, - }) - .then((response) => { - const filteredCaptures = response.data.filter( - (capture) => capture.artwork?.reported !== true - ); - setArtCapture(filteredCaptures); - setNotifCaptureCount(filteredCaptures.length); - }) - .catch((error) => { - console.error("Erreur lors de la récupération des captures:", error); - }); - }, []); - const handleNewArtworkCheck = () => { setIsNewArtwork(!isNewArtwork); setPoints((prevPoints) => @@ -226,6 +208,10 @@ function admin() { setPointsUserId(id); }; + const captureId = (id) => { + setDeleteCaptureId(id); + }; + const handleValidateButtonClick = () => { setPoints((prevPoints) => prevPoints + 100); const totalPoints = @@ -242,8 +228,41 @@ function admin() { .catch((error) => { console.error("Erreur lors de l'envoi des points:", error); }); + + axios + .delete( + `${import.meta.env.VITE_BACKEND_URL}/api/captures/${deleteCaptureId}` + ) + .then((response) => { + console.info( + "Suppression de l'œuvre effectuée avec succès !", + response + ); + }) + .catch((error) => { + console.error("Erreur lors de la suppression de l'œuvre:", error); + }); }; + useEffect(() => { + axios + .get(`${import.meta.env.VITE_BACKEND_URL}/api/captures`, { + params: { + general_gallery: true, + }, + }) + .then((response) => { + const filteredCaptures = response.data.filter( + (capture) => capture.artwork?.reported !== true + ); + setArtCapture(filteredCaptures); + setNotifCaptureCount(filteredCaptures.length); + }) + .catch((error) => { + console.error("Erreur lors de la récupération des captures:", error); + }); + }, [handleValidateButtonClick]); + const handleReturn = () => { switch (user.is_administrator) { case 1: { @@ -383,6 +402,7 @@ function admin() { artCapture={artCapture} setToggleModalCapture={setToggleModalCapture} userId={userId} + captureId={captureId} /> )} {activeComponent === "newWork" && } @@ -398,6 +418,7 @@ function admin() { isHardToFind={isHardToFind} isAllFieldsFilled={isAllFieldsFilled} pointsUserId={pointsUserId} + deleteCaptureId={deleteCaptureId} /> )}
    From a6117d64a1e6b37c35f714d67e96ef18706102fd Mon Sep 17 00:00:00 2001 From: Alexandre-27 Date: Thu, 8 Feb 2024 04:42:57 +0100 Subject: [PATCH 9/9] Updating multiple items. --- frontend/src/pages/Admin.jsx | 45 ++++++++---- frontend/src/pages/Admin.scss | 125 ++++++++++------------------------ 2 files changed, 67 insertions(+), 103 deletions(-) diff --git a/frontend/src/pages/Admin.jsx b/frontend/src/pages/Admin.jsx index f9be7ee..0d2f57f 100644 --- a/frontend/src/pages/Admin.jsx +++ b/frontend/src/pages/Admin.jsx @@ -276,16 +276,23 @@ function admin() {

    Notifications

    ampoule
    -
    -
    -

    - {notifCaptureCount} Street Art en attente de validation -

    - Sablier +
    +
    + {notifCaptureCount > 0 && ( +
    +

    + {notifCaptureCount} Street Art en attente de + validation +

    + Sablier +
    + )}
    -
    -

    3 Street Art sont portés disparus

    - Carte +
    +
    +

    3 Street Art sont portés disparus

    + Carte +
    @@ -398,12 +405,20 @@ function admin() { handleActive={handleActive} /> {activeComponent === "captures" && ( - +
    + {artCapture.length === 0 ? ( +

    + Aucune capture à valider. +

    + ) : ( + + )} +
    )} {activeComponent === "newWork" && } {activeComponent === "reported" && } diff --git a/frontend/src/pages/Admin.scss b/frontend/src/pages/Admin.scss index 97d5ec8..8d79cb8 100644 --- a/frontend/src/pages/Admin.scss +++ b/frontend/src/pages/Admin.scss @@ -28,39 +28,47 @@ } } - .notif-parent-div { + .notif-prev-parent-div { display: flex; - gap: 8rem; - .notif-grid-div { - border-radius: 0.5rem; - display: grid; - grid-template-columns: repeat(2, 1fr); - grid-template-rows: 100px 150px; - padding: 1rem 1rem 5rem 1rem; - p { - grid-area: 2 / 1 / 3 / 3; - margin: auto; - } + flex-direction: row; + justify-content: center; + gap: 10%; + width: 100%; + + .notif-parent-div { + width: 40%; + + .notif-grid-div { + border-radius: 0.5rem; + display: grid; + grid-template-columns: repeat(2, 1fr); + grid-template-rows: 100px 150px; + padding: 1rem 1rem 5rem 1rem; + p { + grid-area: 2 / 1 / 3 / 3; + margin: auto; + } - img { - grid-area: 1 / 2 / 2 / 3; + img { + grid-area: 1 / 2 / 2 / 3; + } } - } - .notif-child-div-yellow { - border: 3px solid $light-yellow; + .notif-child-div-yellow { + border: 3px solid $light-yellow; - img { - width: 30%; - margin-left: 70%; + img { + width: 30%; + margin-left: 70%; + } } - } - .notif-child-div-cyan { - border: 3px solid $light-cyan; + .notif-child-div-cyan { + border: 3px solid $light-cyan; - img { - width: 30%; - margin-left: 65%; + img { + width: 30%; + margin-left: 65%; + } } } } @@ -193,68 +201,9 @@ } } - .download-art-img { - width: 5%; - margin-top: 2%; - margin-bottom: 1%; - padding: 0.5rem; - transform: rotate(180deg); - background-color: $extra-light-yellow; - border-radius: 30%; - } - - .add-art-form-grid { - margin-top: 3rem; - display: grid; - grid-template-columns: repeat(2, 1fr); - grid-template-rows: repeat(2, 1fr); - - div { - display: flex; - flex-direction: column; - align-items: start; - margin: auto; - - input { - font-style: oblique; - padding: 6px 100px; - border-radius: 2px; - margin-top: 5px; - margin-bottom: 20px; - background-color: $extra-light-yellow; - border-color: $extra-light-yellow; - border-radius: 0.3rem; - color: $deep-purple; - } - } - - .name-art-grid { - grid-area: 1 / 1 / 2 / 2; - .name-red-span { - color: $red; - } - } - - .about-art-grid { - grid-area: 1 / 2 / 3 / 3; - - .about-art-pad { - padding: 0px 10px 0px 10px; - font-size: calc(2.5rem - 1.2vw); - width: 130%; - height: 150px; - } - } - } - - .add-art-button { - background-color: $light-red; - border: $light-cyan; - border-radius: 0.3rem; - padding: 10px 60px; - margin-top: 3rem; - margin-bottom: 2rem; - color: $deep-purple; + .street-art-p { + margin-top: 8%; + margin-bottom: 8%; } .admin-mobile-h2 {