From 8fb7b5287b7305baf7b3cccb5329c200393c87b8 Mon Sep 17 00:00:00 2001 From: pikiou Date: Fri, 25 Mar 2022 01:37:11 +0100 Subject: [PATCH] Add /profil to notifications, improve responsiveness --- .../Form/IgnoreButton/IgnoreButton.tsx | 53 ++ .../Form/IgnoreButton/styles.module.scss | 30 ++ src/components/Navigation/MainMenu.tsx | 4 + src/components/Navigation/styles.module.scss | 3 + src/components/Notifications/index.tsx | 456 +++++++++++------- .../Notifications/styles.module.scss | 8 +- src/components/VolunteerBoard/Board.tsx | 14 +- .../VolunteerBoard/DayWishes/DayWishes.tsx | 9 +- .../DayWishes/styles.module.scss | 1 - .../DayWishesForm/DayWishesForm.tsx | 34 +- .../DayWishesForm/styles.module.scss | 5 +- .../ParticipationDetails.tsx | 22 +- .../ParticipationDetails/styles.module.scss | 5 + .../ParticipationDetailsForm.tsx | 56 ++- .../styles.module.scss | 25 +- .../TeamWishesForm/TeamWishesForm.tsx | 32 +- .../TeamWishesForm/styles.module.scss | 15 +- src/components/index.ts | 15 +- src/pages/Board/Board.tsx | 11 +- src/pages/Home/Home.tsx | 11 +- src/theme/mixins.scss | 9 +- 21 files changed, 538 insertions(+), 280 deletions(-) create mode 100644 src/components/Form/IgnoreButton/IgnoreButton.tsx create mode 100644 src/components/Form/IgnoreButton/styles.module.scss diff --git a/src/components/Form/IgnoreButton/IgnoreButton.tsx b/src/components/Form/IgnoreButton/IgnoreButton.tsx new file mode 100644 index 0000000..f42499a --- /dev/null +++ b/src/components/Form/IgnoreButton/IgnoreButton.tsx @@ -0,0 +1,53 @@ +import { FC, ReactNode, useState } from "react" +import styles from "./styles.module.scss" + +type Props = { + children?: ReactNode | undefined + text: string + onClick?: () => void +} + +const FormButton: FC = ({ children, text, onClick }): JSX.Element => { + const [doShowMessage, setDoShowMessage] = useState(false) + + const showMessage = () => { + setDoShowMessage(true) + } + const onIgnore = () => { + setDoShowMessage(true) + onClick?.() + } + const onCloseIgnore = () => { + setDoShowMessage(false) + } + + return ( + <> + + {doShowMessage && ( +
+ +
{children}
+ +
+ )} + + ) +} + +FormButton.defaultProps = { + children: undefined, + onClick: undefined, +} + +export default FormButton diff --git a/src/components/Form/IgnoreButton/styles.module.scss b/src/components/Form/IgnoreButton/styles.module.scss new file mode 100644 index 0000000..9e5fae4 --- /dev/null +++ b/src/components/Form/IgnoreButton/styles.module.scss @@ -0,0 +1,30 @@ +@import "../../../theme/mixins"; + +.greyButton { + @include form-grey-button; + + margin-top: 10px; +} + +.infoBeforeIgnore { + margin-top: 15px; + position: relative; + padding: 15px; + outline: 0; + background-color: $color-white; +} +.closeButton { + position: absolute; + padding: 0; + z-index: 10; + top: 10px; + right: 10px; + width: 20px; + height: 20px; + border-radius: 0; + line-height: 20px; + color: $color-grey-dark; + text-align: center; + background: none; + cursor: pointer; +} diff --git a/src/components/Navigation/MainMenu.tsx b/src/components/Navigation/MainMenu.tsx index 740e843..971996f 100644 --- a/src/components/Navigation/MainMenu.tsx +++ b/src/components/Navigation/MainMenu.tsx @@ -6,6 +6,7 @@ import styles from "./styles.module.scss" const MainMenu: FC = (): JSX.Element | null => { const connected = useSelector(isUserConnected) + const [opened, setOpened] = useState(false) const onOpen = useCallback(() => { @@ -24,6 +25,9 @@ const MainMenu: FC = (): JSX.Element | null => { ☰
    +
  • + Page d'accueil +
  • Annonces
  • diff --git a/src/components/Navigation/styles.module.scss b/src/components/Navigation/styles.module.scss index e7517e3..48a537d 100644 --- a/src/components/Navigation/styles.module.scss +++ b/src/components/Navigation/styles.module.scss @@ -57,6 +57,9 @@ text-align: center; font-size: 22px; color: $color-black; + background-color: $color-white; + border-radius: 4px; + box-shadow: 1px 1px 2px $color-black; } } diff --git a/src/components/Notifications/index.tsx b/src/components/Notifications/index.tsx index dff993d..48e1332 100644 --- a/src/components/Notifications/index.tsx +++ b/src/components/Notifications/index.tsx @@ -1,16 +1,25 @@ -import _ from "lodash" +import _, { get } from "lodash" import React, { memo, useCallback, useEffect, useRef, useState } from "react" import isNode from "detect-node" import { shallowEqual, useDispatch, useSelector } from "react-redux" -import classnames from "classnames" import { fetchVolunteerNotifsSet } from "../../store/volunteerNotifsSet" import styles from "./styles.module.scss" import { selectUserJwtToken } from "../../store/auth" import { VolunteerNotifs } from "../../services/volunteers" -// import { TeamWishesForm } from ".." -import { fetchFor as fetchForTeamWishesForm } from "../VolunteerBoard/TeamWishesForm/TeamWishesForm" +import TeamWishesForm, { + fetchFor as fetchForTeamWishesForm, +} from "../VolunteerBoard/TeamWishesForm/TeamWishesForm" import { AppState } from "../../store" -import Block from "../ui/Content/ContentBlock" +import { useUserTeamWishes } from "../VolunteerBoard/teamWishes.utils" +import { useUserDayWishes } from "../VolunteerBoard/daysWishes.utils" +import ParticipationDetailsForm, { + fetchFor as fetchForarticipationDetailsForm, +} from "../VolunteerBoard/ParticipationDetailsForm/ParticipationDetailsForm" +import DayWishesForm, { + fetchFor as fetchForDayWishesForm, +} from "../VolunteerBoard/DayWishesForm/DayWishesForm" +import { useUserParticipationDetails } from "../VolunteerBoard/participationDetails.utils" +import FormButton from "../Form/FormButton/FormButton" let prevNotifs: VolunteerNotifs | undefined @@ -28,118 +37,28 @@ const Notifications = (): JSX.Element | null => { const hidden = volunteerNotifs?.hiddenNotifs || [] const notifs: JSX.Element[] = [] - const onSubmit1 = useCallback( - (event: React.SyntheticEvent): void => { - event.preventDefault() - dispatch( - fetchVolunteerNotifsSet(jwtToken, 0, { - hiddenNotifs: [...(volunteerNotifs?.hiddenNotifs || []), 1], - }) - ) - }, - [dispatch, jwtToken, volunteerNotifs] - ) + const onSubmit1 = useCallback((): void => { + dispatch( + fetchVolunteerNotifsSet(jwtToken, 0, { + hiddenNotifs: [...(volunteerNotifs?.hiddenNotifs || []), 1], + }) + ) + }, [dispatch, jwtToken, volunteerNotifs]) if (!_.includes(hidden, 1)) { notifs.push(
    -
    -
    - Salut {volunteerNotifs?.firstname} ! -
    - Ici tu seras notifié(e) des nouvelles importantes et des questions pour - lesquelles il nous faudrait absolument ta réponse. -
    - -
    -
    -
    -
    -
    - ) - } - - const [participation, setParticipation] = useState(volunteerNotifs?.active || "inconnu") - const [participationMessage, setParticipationMessage] = useState("") - const onChangeValue2 = (e: React.ChangeEvent) => - setParticipation(e.target.value) - - const onSubmit2 = useCallback( - (event: React.SyntheticEvent): void => { - event.preventDefault() - if (participation === "inconnu") { - setParticipationMessage("Il nous faudrait une réponse ^^") - return - } - - dispatch( - fetchVolunteerNotifsSet(jwtToken, 0, { - hiddenNotifs: [...(volunteerNotifs?.hiddenNotifs || []), 2], - active: participation, - }) - ) - }, - [dispatch, jwtToken, volunteerNotifs, participation] - ) - - if (!_.includes(hidden, 2)) { - notifs.push( -
    -
    -
    -
    - Si les conditions sanitaires te le permettent, souhaites-tu être - bénévole à PeL 2022 ?
    - - - - {participation === "peut-etre" ? ( -
    - On te le reproposera dans quelques temps. -
    - Si tu as besoin d'infos, viens nous en parler sur le - serveur Discord ! Pour le rejoindre,{" "} - - clique ici{" "} - - . +
    +
    + + Salut {volunteerNotifs?.firstname} ! +
    + Ici tu seras notifié(e) des nouvelles importantes et des questions + pour lesquelles il nous faudrait absolument ta réponse. +
    + Ok, continuer
    - ) : null} -
    -
    -
    {participationMessage}
    @@ -147,40 +66,94 @@ const Notifications = (): JSX.Element | null => { ) } - const onSubmit3 = useCallback((): void => { - dispatch( - fetchVolunteerNotifsSet(jwtToken, 0, { - hiddenNotifs: [...(volunteerNotifs?.hiddenNotifs || []), 3], - }) - ) - }, [dispatch, jwtToken, volunteerNotifs]) + // const [participation, setParticipation] = useState(volunteerNotifs?.active || "inconnu") + // const [participationMessage, setParticipationMessage] = useState("") + // const onChangeValue2 = (e: React.ChangeEvent) => + // setParticipation(e.target.value) - if (!_.includes(hidden, 3)) { - notifs.push( -
    -
    -
    -
    - La{" "} - - gazette de février - {" "} - est disponible !
    -
    - -
    -
    -
    -
    -
    - ) - } + // const onSubmit2 = useCallback( + // (): void => { + // if (participation === "inconnu") { + // setParticipationMessage("Il nous faudrait une réponse ^^") + // return + // } + + // dispatch( + // fetchVolunteerNotifsSet(jwtToken, 0, { + // hiddenNotifs: [...(volunteerNotifs?.hiddenNotifs || []), 2], + // active: participation, + // }) + // ) + // }, + // [dispatch, jwtToken, volunteerNotifs, participation] + // ) + + // if (!_.includes(hidden, 2)) { + // notifs.push( + //
    + //
    + //
    + //
    + //
    + // Si les conditions sanitaires te le permettent, souhaites-tu être + // bénévole à PeL 2022 ?
    + // + // + // + // {participation === "peut-etre" ? ( + //
    + // On te le reproposera dans quelques temps. + //
    + // Si tu as besoin d'infos, viens nous en parler sur le + // serveur Discord ! Pour le rejoindre,{" "} + // + // clique ici{" "} + // + // . + //
    + // ) : null} + //
    + // Confirmer + //
    + //
    {participationMessage}
    + //
    + //
    + //
    + //
    + //
    + // ) + // } // const onSubmit3 = useCallback((): void => { // dispatch( @@ -192,16 +165,121 @@ const Notifications = (): JSX.Element | null => { // if (!_.includes(hidden, 3)) { // notifs.push( - //
    + //
    //
    - //
    - // + //
    + //
    + //
    + // La{" "} + // + // gazette de février + // {" "} + // est disponible !
    + //
    + // Ok, masquer + //
    + //
    + //
    //
    //
    //
    // ) // } + const answerLaterOnProfile = ( + <> + Tu pourras y répondre plus tard sur la page Mon profil. + + ) + + const onSubmit10 = useCallback((): void => { + dispatch( + fetchVolunteerNotifsSet(jwtToken, 0, { + hiddenNotifs: [...(volunteerNotifs?.hiddenNotifs || []), 10], + }) + ) + }, [dispatch, jwtToken, volunteerNotifs]) + + const [userWishes] = useUserDayWishes() + const participation10 = get(userWishes, "active", "inconnu") + const newSelection = get(userWishes, "dayWishes", []) + const comment10 = get(userWishes, "dayWishesComment", "") + const needToShow10 = participation10 === "inconnu" || (newSelection.length === 0 && !comment10) + + if (!_.includes(hidden, 10) && needToShow10) { + notifs.push( +
    +
    +
    + + {answerLaterOnProfile} + +
    +
    +
    + ) + } + + const onSubmit11 = useCallback((): void => { + dispatch( + fetchVolunteerNotifsSet(jwtToken, 0, { + hiddenNotifs: [...(volunteerNotifs?.hiddenNotifs || []), 11], + }) + ) + }, [dispatch, jwtToken, volunteerNotifs]) + + const [teamWishesData] = useUserTeamWishes() + const teamWishesString = get(teamWishesData, "teamWishes", []) + const comment = get(teamWishesData, "teamWishesComment", "") + const needToShow11 = teamWishesString.length === 0 && !comment + + if (!_.includes(hidden, 11) && needToShow11) { + notifs.push( +
    +
    +
    + + {answerLaterOnProfile} + +
    +
    +
    + ) + } + + const onSubmit12 = useCallback((): void => { + dispatch( + fetchVolunteerNotifsSet(jwtToken, 0, { + hiddenNotifs: [...(volunteerNotifs?.hiddenNotifs || []), 12], + }) + ) + }, [dispatch, jwtToken, volunteerNotifs]) + + const [participationDetails] = useUserParticipationDetails() + const tshirtSize = get(participationDetails, "tshirtSize", "") + const food = get(participationDetails, "food", "") + const needToShow12 = !tshirtSize && !food + + if (!_.includes(hidden, 12) && needToShow12) { + notifs.push( +
    +
    +
    + + {answerLaterOnProfile} + +
    +
    +
    + ) + } + /* DISCORD Discord nous donne à tous la parole via nos téléphone ou navigateurs, pour organiser le meilleur des festivals ! Il permet de discuter sujet par sujet entre tous les bénévoles, entre les membres d'une même équipe, ou avec ton référent. @@ -382,47 +460,49 @@ Tu n'y es absolument pas obligé(e) ! C'est juste plus pratique. if (notifs.length === 0) { notifs.push(
    - -
    -
    ) } @@ -437,4 +517,8 @@ Tu n'y es absolument pas obligé(e) ! C'est juste plus pratique. export default memo(Notifications) // Fetch server-side data here -export const fetchFor = [...fetchForTeamWishesForm] +export const fetchFor = [ + ...fetchForTeamWishesForm, + ...fetchForarticipationDetailsForm, + ...fetchForDayWishesForm, +] diff --git a/src/components/Notifications/styles.module.scss b/src/components/Notifications/styles.module.scss index 2c68b21..3873975 100755 --- a/src/components/Notifications/styles.module.scss +++ b/src/components/Notifications/styles.module.scss @@ -6,7 +6,11 @@ } .notificationsContent { - @include inner-content-wrapper; + @include page-content-wrapper; +} + +.notificationsContentNarrow { + @include page-content-wrapper(520px); } .pushNotificationsPage { @@ -14,7 +18,7 @@ } .pushNotificationsContent { - @include inner-content-wrapper; + @include page-content-wrapper; } .notifIntro { diff --git a/src/components/VolunteerBoard/Board.tsx b/src/components/VolunteerBoard/Board.tsx index c351a89..7199a82 100644 --- a/src/components/VolunteerBoard/Board.tsx +++ b/src/components/VolunteerBoard/Board.tsx @@ -6,11 +6,10 @@ import ParticipationDetailsFormModal from "./ParticipationDetailsForm/Participat import TeamWishes from "./TeamWishes/TeamWishes" import TeamWishesFormModal from "./TeamWishesForm/TeamWishesFormModal" import withUserConnected from "../../utils/withUserConnected" -import { fetchVolunteerDayWishesSetIfNeed } from "../../store/volunteerDayWishesSet" -import { fetchVolunteerParticipationDetailsSetIfNeed } from "../../store/volunteerParticipationDetailsSet" -import { fetchTeamListIfNeed } from "../../store/teamList" -import { fetchVolunteerTeamWishesSetIfNeed } from "../../store/volunteerTeamWishesSet" import ContentTitle from "../ui/Content/ContentTitle" +import { fetchFor as fetchForDayWishesForm } from "./DayWishesForm/DayWishesForm" +import { fetchFor as fetchForParticipationDetailsForm } from "./ParticipationDetailsForm/ParticipationDetailsForm" +import { fetchFor as fetchForTeamWishesForm } from "./TeamWishesForm/TeamWishesForm" const Board: FC = (): JSX.Element => ( <> @@ -27,8 +26,7 @@ const Board: FC = (): JSX.Element => ( export default memo(withUserConnected(Board)) export const fetchFor = [ - fetchVolunteerDayWishesSetIfNeed, - fetchVolunteerParticipationDetailsSetIfNeed, - fetchTeamListIfNeed, - fetchVolunteerTeamWishesSetIfNeed, + ...fetchForDayWishesForm, + ...fetchForParticipationDetailsForm, + ...fetchForTeamWishesForm, ] diff --git a/src/components/VolunteerBoard/DayWishes/DayWishes.tsx b/src/components/VolunteerBoard/DayWishes/DayWishes.tsx index 1865e46..e7cf811 100644 --- a/src/components/VolunteerBoard/DayWishes/DayWishes.tsx +++ b/src/components/VolunteerBoard/DayWishes/DayWishes.tsx @@ -32,16 +32,17 @@ const DayWishes: FC = (): JSX.Element | null => {
    )} {participation === "inconnu" && ( -
    Participation à PeL 2022 non renseignée
    +
    + Participation à PeL 2022{" "} + non renseignées +
    )} {participation !== "non" && (
    Mes jours : {dayWishesString && {dayWishesString}} - {!dayWishesString && ( - Non renseignés - )} + {!dayWishesString && Non renseignés}
    )} {comment && ( diff --git a/src/components/VolunteerBoard/DayWishes/styles.module.scss b/src/components/VolunteerBoard/DayWishes/styles.module.scss index e5b6ef6..33a1d1e 100755 --- a/src/components/VolunteerBoard/DayWishes/styles.module.scss +++ b/src/components/VolunteerBoard/DayWishes/styles.module.scss @@ -36,7 +36,6 @@ } .lineEmpty { - margin: 0 5px 5px 0; color: $color-red; font-style: italic; } diff --git a/src/components/VolunteerBoard/DayWishesForm/DayWishesForm.tsx b/src/components/VolunteerBoard/DayWishesForm/DayWishesForm.tsx index 94e5447..56b9ceb 100644 --- a/src/components/VolunteerBoard/DayWishesForm/DayWishesForm.tsx +++ b/src/components/VolunteerBoard/DayWishesForm/DayWishesForm.tsx @@ -1,4 +1,4 @@ -import { FC, memo, useCallback, useEffect, useRef, useState } from "react" +import { FC, memo, ReactNode, useCallback, useEffect, useRef, useState } from "react" import classnames from "classnames" import get from "lodash/get" import set from "lodash/set" @@ -10,12 +10,15 @@ import { useUserDayWishes, } from "../daysWishes.utils" import FormButton from "../../Form/FormButton/FormButton" +import { fetchVolunteerDayWishesSetIfNeed } from "../../../store/volunteerDayWishesSet" +import IgnoreButton from "../../Form/IgnoreButton/IgnoreButton" type Props = { + children?: ReactNode | undefined afterSubmit?: () => void | undefined } -const DayWishesForm: FC = ({ afterSubmit }): JSX.Element => { +const DayWishesForm: FC = ({ children, afterSubmit }): JSX.Element => { const [participationState, setParticipation] = useState("inconnu") const [selection, setSelection] = useState(daysChoiceSelectionDefaultState) const commentRef = useRef(null) @@ -145,18 +148,35 @@ const DayWishesForm: FC = ({ afterSubmit }): JSX.Element => {