mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-06-10 01:24:20 +02:00
Fix api url in prod
This commit is contained in:
parent
c7941aefc3
commit
15c6cc0be7
@ -34,12 +34,12 @@ const ForgotForm = ({ dispatch, error, message }: Props): JSX.Element => {
|
|||||||
<input type="email" id="email" name="utilisateur" />
|
<input type="email" id="email" name="utilisateur" />
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.formButtons}>
|
<div className={styles.formButtons}>
|
||||||
<button type="submit">Connexion</button>
|
<button type="submit">Envoyer</button>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.error}>{error}</div>
|
<div className={styles.error}>{error}</div>
|
||||||
<div className={styles.message}>{message}</div>
|
<div className={styles.message}>{message}</div>
|
||||||
<div className={styles.link}>
|
<div className={styles.link}>
|
||||||
<Link to="/login"> S'identifier </Link>
|
<Link to="/"> S'identifier </Link>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
)
|
)
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import _ from "lodash"
|
import _ from "lodash"
|
||||||
import React, { memo, useCallback, useEffect, useRef, useState } from "react"
|
import React, { memo, useCallback, useEffect, useRef, useState } from "react"
|
||||||
import isNode from "detect-node"
|
import isNode from "detect-node"
|
||||||
import { shallowEqual, useSelector } from "react-redux"
|
import { AppDispatch } from "../../store"
|
||||||
import { AppDispatch, AppState } from "../../store"
|
|
||||||
import { fetchVolunteerNotifsSet } from "../../store/volunteerNotifsSet"
|
import { fetchVolunteerNotifsSet } from "../../store/volunteerNotifsSet"
|
||||||
import styles from "./styles.module.scss"
|
import styles from "./styles.module.scss"
|
||||||
import { logoutUser } from "../../store/auth"
|
import { logoutUser } from "../../store/auth"
|
||||||
@ -12,19 +11,11 @@ import { VolunteerNotifs } from "../../services/volunteers"
|
|||||||
interface Props {
|
interface Props {
|
||||||
dispatch: AppDispatch
|
dispatch: AppDispatch
|
||||||
jwt: string
|
jwt: string
|
||||||
|
// eslint-disable-next-line react/require-default-props
|
||||||
|
volunteerNotifs?: VolunteerNotifs
|
||||||
}
|
}
|
||||||
let prevNotifs: VolunteerNotifs | undefined
|
|
||||||
|
|
||||||
const Notifications = ({ dispatch, jwt }: Props): JSX.Element | null => {
|
|
||||||
const volunteerNotifs = useSelector((state: AppState) => {
|
|
||||||
const notifs = state.volunteerNotifsSet.entity
|
|
||||||
if (notifs) {
|
|
||||||
prevNotifs = notifs
|
|
||||||
return notifs
|
|
||||||
}
|
|
||||||
return prevNotifs
|
|
||||||
}, shallowEqual)
|
|
||||||
|
|
||||||
|
const Notifications = ({ dispatch, jwt, volunteerNotifs }: Props): JSX.Element | null => {
|
||||||
const hidden = volunteerNotifs?.hiddenNotifs || []
|
const hidden = volunteerNotifs?.hiddenNotifs || []
|
||||||
const notifs: JSX.Element[] = []
|
const notifs: JSX.Element[] = []
|
||||||
|
|
||||||
@ -62,12 +53,17 @@ const Notifications = ({ dispatch, jwt }: Props): JSX.Element | null => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const [participation, setParticipation] = useState(volunteerNotifs?.active || "inconnu")
|
const [participation, setParticipation] = useState(volunteerNotifs?.active || "inconnu")
|
||||||
|
const [participationMessage, setParticipationMessage] = useState("")
|
||||||
const onChangeValue2 = (e: React.ChangeEvent<HTMLInputElement>) =>
|
const onChangeValue2 = (e: React.ChangeEvent<HTMLInputElement>) =>
|
||||||
setParticipation(e.target.value)
|
setParticipation(e.target.value)
|
||||||
|
|
||||||
const onSubmit2 = useCallback(
|
const onSubmit2 = useCallback(
|
||||||
(event: React.SyntheticEvent): void => {
|
(event: React.SyntheticEvent): void => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
if (participation === "inconnu") {
|
||||||
|
setParticipationMessage("Il nous faudrait une réponse ^^")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
fetchVolunteerNotifsSet(jwt, 0, {
|
fetchVolunteerNotifsSet(jwt, 0, {
|
||||||
@ -88,16 +84,6 @@ const Notifications = ({ dispatch, jwt }: Props): JSX.Element | null => {
|
|||||||
<form onSubmit={onSubmit2}>
|
<form onSubmit={onSubmit2}>
|
||||||
Si les conditions sanitaires te le permettent, souhaites-tu être
|
Si les conditions sanitaires te le permettent, souhaites-tu être
|
||||||
bénévole à PeL 2022 ?<br />
|
bénévole à PeL 2022 ?<br />
|
||||||
<label>
|
|
||||||
<input
|
|
||||||
type="radio"
|
|
||||||
value="inconnu"
|
|
||||||
name="gender"
|
|
||||||
checked={participation === "inconnu"}
|
|
||||||
onChange={onChangeValue2}
|
|
||||||
/>{" "}
|
|
||||||
-
|
|
||||||
</label>
|
|
||||||
<label>
|
<label>
|
||||||
<input
|
<input
|
||||||
type="radio"
|
type="radio"
|
||||||
@ -147,6 +133,7 @@ const Notifications = ({ dispatch, jwt }: Props): JSX.Element | null => {
|
|||||||
<div className={styles.formButtons}>
|
<div className={styles.formButtons}>
|
||||||
<button type="submit">Confirmer</button>
|
<button type="submit">Confirmer</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div className={styles.message}>{participationMessage}</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -271,7 +258,7 @@ Tu n'y es absolument pas obligé(e) ! C'est juste plus pratique.
|
|||||||
"Un autre navigateur était notifié, mais c'est maintenant celui-ci qui le sera."
|
"Un autre navigateur était notifié, mais c'est maintenant celui-ci qui le sera."
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
setNotifMessage("C'est enregistré !")
|
setNotifMessage("C'est mémorisé !")
|
||||||
}
|
}
|
||||||
|
|
||||||
setAcceptsNotifs("oui")
|
setAcceptsNotifs("oui")
|
||||||
@ -284,7 +271,7 @@ Tu n'y es absolument pas obligé(e) ! C'est juste plus pratique.
|
|||||||
} catch (_e) {
|
} catch (_e) {
|
||||||
if (Notification.permission !== "granted") {
|
if (Notification.permission !== "granted") {
|
||||||
setNotifMessage(
|
setNotifMessage(
|
||||||
"Mince tu as bloqué toutes notifications pour le site des bénévoles, l'exact opposé de ce qu'il fallait :) Pour annuler ça, les instructions sont ici : https://support.pushcrew.com/support/solutions/articles/9000098467-how-to-unblock-notifications-from-a-website-that-you-once-blocked-"
|
"Mince tu as bloqué les notifications pour le site des bénévoles ! En haut juste à gauche de la barre d'adresse, il y a une icone de cadenas ou de message barré sur lequel cliquer pour annuler ce blocage."
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
setNotifMessage(
|
setNotifMessage(
|
||||||
@ -305,7 +292,7 @@ Tu n'y es absolument pas obligé(e) ! C'est juste plus pratique.
|
|||||||
"Un autre navigateur était notifié, mais c'est maintenant celui-ci qui le sera."
|
"Un autre navigateur était notifié, mais c'est maintenant celui-ci qui le sera."
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
setNotifMessage("C'est enregistré !")
|
setNotifMessage("C'est mémorisé !")
|
||||||
}
|
}
|
||||||
|
|
||||||
setAcceptsNotifs("oui")
|
setAcceptsNotifs("oui")
|
||||||
@ -335,12 +322,15 @@ Tu n'y es absolument pas obligé(e) ! C'est juste plus pratique.
|
|||||||
if (notifs.length === 0) {
|
if (notifs.length === 0) {
|
||||||
notifs.push(
|
notifs.push(
|
||||||
<div key="pushNotifs">
|
<div key="pushNotifs">
|
||||||
<div className={styles.notificationsPage}>
|
<div className={styles.pushNotificationsPage}>
|
||||||
<div className={styles.notificationsContent}>
|
<div className={styles.pushNotificationsContent}>
|
||||||
<div className={styles.formLine} key="line-participation">
|
<div className={styles.formLine} key="line-participation">
|
||||||
<label>
|
<label>
|
||||||
Acceptes-tu d'être notifié(e) ici quand on aura des questions
|
Acceptes-tu de recevoir une alerte dans ton navigateur quand on aura
|
||||||
ou informations importantes pour toi ?
|
une info ou question importante à te poser ici sur le site ?<br />
|
||||||
|
<span className={styles.sousMessage}>
|
||||||
|
(Ça simplifierait grandement notre organisation !!)
|
||||||
|
</span>
|
||||||
<label>
|
<label>
|
||||||
<input
|
<input
|
||||||
type="radio"
|
type="radio"
|
||||||
|
@ -7,6 +7,14 @@
|
|||||||
|
|
||||||
.notificationsContent {
|
.notificationsContent {
|
||||||
@include page-content-wrapper;
|
@include page-content-wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pushNotificationsPage {
|
||||||
|
@include page-wrapper-center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pushNotificationsContent {
|
||||||
|
@include page-content-wrapper;
|
||||||
|
|
||||||
background-color: #ece3df;
|
background-color: #ece3df;
|
||||||
}
|
}
|
||||||
@ -23,6 +31,10 @@
|
|||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
margin-top: 7px;
|
margin-top: 7px;
|
||||||
}
|
}
|
||||||
|
.sousMessage {
|
||||||
|
font-size: 95%;
|
||||||
|
}
|
||||||
|
|
||||||
select,
|
select,
|
||||||
input {
|
input {
|
||||||
width: 10%;
|
width: 10%;
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
|
import isNode from "detect-node"
|
||||||
|
|
||||||
const PROTOCOL = (typeof window !== "undefined" && window?.location?.protocol) || "http:"
|
const PROTOCOL = (typeof window !== "undefined" && window?.location?.protocol) || "http:"
|
||||||
const PORT = 4000 + (PROTOCOL === "https:" ? 2 : 0)
|
const PORT = 4000 + (PROTOCOL === "https:" ? 2 : 0)
|
||||||
const API_URL =
|
const API_URL =
|
||||||
__DEV__ || __LOCAL__ ? `${PROTOCOL}//localhost:${PORT}` : `${PROTOCOL}//fo.parisestludique.fr`
|
__DEV__ || __LOCAL__ || isNode
|
||||||
|
? `${PROTOCOL}//localhost:${PORT}`
|
||||||
|
: `${PROTOCOL}//fo.parisestludique.fr`
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
PORT,
|
PORT,
|
||||||
|
@ -7,19 +7,31 @@ import { AppState, AppThunk } from "../../store"
|
|||||||
import { LoginForm, Notifications } from "../../components"
|
import { LoginForm, Notifications } from "../../components"
|
||||||
import styles from "./styles.module.scss"
|
import styles from "./styles.module.scss"
|
||||||
import { fetchVolunteerNotifsSetIfNeed } from "../../store/volunteerNotifsSet"
|
import { fetchVolunteerNotifsSetIfNeed } from "../../store/volunteerNotifsSet"
|
||||||
|
import { VolunteerNotifs } from "../../services/volunteers"
|
||||||
|
|
||||||
export type Props = RouteComponentProps
|
export type Props = RouteComponentProps
|
||||||
|
|
||||||
|
let prevNotifs: VolunteerNotifs | undefined
|
||||||
|
|
||||||
const HomePage: FC<Props> = (): JSX.Element => {
|
const HomePage: FC<Props> = (): JSX.Element => {
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
|
|
||||||
|
const volunteerNotifs = useSelector((state: AppState) => {
|
||||||
|
const notifs = state.volunteerNotifsSet?.entity
|
||||||
|
if (notifs) {
|
||||||
|
prevNotifs = notifs
|
||||||
|
return notifs
|
||||||
|
}
|
||||||
|
return prevNotifs
|
||||||
|
}, shallowEqual)
|
||||||
|
|
||||||
const loginError = useSelector((state: AppState) => state.volunteerLogin.error, shallowEqual)
|
const loginError = useSelector((state: AppState) => state.volunteerLogin.error, shallowEqual)
|
||||||
const jwt = useSelector((state: AppState) => state.auth.jwt, shallowEqual)
|
const jwt = useSelector((state: AppState) => state.auth.jwt, shallowEqual)
|
||||||
|
|
||||||
if (jwt === undefined) return <p>Loading...</p>
|
if (jwt === undefined) return <p>Loading...</p>
|
||||||
|
|
||||||
if (jwt) {
|
if (jwt) {
|
||||||
return <Notifications dispatch={dispatch} jwt={jwt} />
|
return <Notifications dispatch={dispatch} jwt={jwt} volunteerNotifs={volunteerNotifs} />
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@ -30,7 +42,7 @@ const HomePage: FC<Props> = (): JSX.Element => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.homePage}>
|
<div className={styles.homePage}>
|
||||||
<div className={styles.preRegisterContent}>
|
<div className={styles.navigationLink}>
|
||||||
<Link to="/preRegister"> S'informer sur le bénévolat </Link>
|
<Link to="/preRegister"> S'informer sur le bénévolat </Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -15,3 +15,9 @@
|
|||||||
.preRegisterContent {
|
.preRegisterContent {
|
||||||
@include page-content-wrapper;
|
@include page-content-wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.navigationLink {
|
||||||
|
@include page-content-wrapper;
|
||||||
|
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
@ -83,7 +83,7 @@ export const volunteerForgot = expressAccessor.set(
|
|||||||
return {
|
return {
|
||||||
toDatabase: newVolunteer,
|
toDatabase: newVolunteer,
|
||||||
toCaller: {
|
toCaller: {
|
||||||
message: `Un nouveau mot de passe t'a été envoyé par email. Regarde bien dans tes spams, ils pourrait y être :/`,
|
message: `Un nouveau mot de passe t'a été envoyé par email. Regarde bien dans les spams, il pourrait y être :/`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ export default async (req: Request, res: Response, next: NextFunction): Promise<
|
|||||||
const loadBranchData = (): Promise<any> => {
|
const loadBranchData = (): Promise<any> => {
|
||||||
const branch = matchRoutes(routes, req.path)
|
const branch = matchRoutes(routes, req.path)
|
||||||
const promises = branch.map(({ route, match }) => {
|
const promises = branch.map(({ route, match }) => {
|
||||||
if (route.loadData)
|
if (route.loadData) {
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
route
|
route
|
||||||
.loadData({
|
.loadData({
|
||||||
@ -33,6 +33,7 @@ export default async (req: Request, res: Response, next: NextFunction): Promise<
|
|||||||
})
|
})
|
||||||
.map((item: Action) => store.dispatch(item))
|
.map((item: Action) => store.dispatch(item))
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return Promise.resolve(null)
|
return Promise.resolve(null)
|
||||||
})
|
})
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
import { ActionCreatorWithoutPayload, ActionCreatorWithPayload } from "@reduxjs/toolkit"
|
import {
|
||||||
|
Action,
|
||||||
|
ActionCreatorWithoutPayload,
|
||||||
|
ActionCreatorWithPayload,
|
||||||
|
ThunkDispatch,
|
||||||
|
} from "@reduxjs/toolkit"
|
||||||
import { toast } from "react-toastify"
|
import { toast } from "react-toastify"
|
||||||
|
|
||||||
import { AppThunk, AppDispatch } from "."
|
import { AppState, AppThunk } from "."
|
||||||
|
|
||||||
export interface StateRequest {
|
export interface StateRequest {
|
||||||
readyStatus: "idle" | "request" | "success" | "failure"
|
readyStatus: "idle" | "request" | "success" | "failure"
|
||||||
@ -41,10 +46,10 @@ export function elementFetch<Element, ServiceInput extends Array<any>>(
|
|||||||
getSuccess: ActionCreatorWithPayload<Element, string>,
|
getSuccess: ActionCreatorWithPayload<Element, string>,
|
||||||
getFailure: ActionCreatorWithPayload<string, string>,
|
getFailure: ActionCreatorWithPayload<string, string>,
|
||||||
errorMessage?: (error: Error) => void,
|
errorMessage?: (error: Error) => void,
|
||||||
successMessage?: (data: Element, dispatch: AppDispatch) => void
|
successMessage?: (data: Element, dispatch: ThunkDispatch<AppState, any, Action>) => void
|
||||||
): (...idArgs: ServiceInput) => AppThunk {
|
): (...idArgs: ServiceInput) => AppThunk {
|
||||||
return (...idArgs: ServiceInput): AppThunk =>
|
return (...idArgs: ServiceInput): AppThunk =>
|
||||||
async (dispatch) => {
|
async (dispatch: ThunkDispatch<AppState, any, Action>) => {
|
||||||
dispatch(getRequesting())
|
dispatch(getRequesting())
|
||||||
|
|
||||||
const { error, data } = await elementService(...idArgs)
|
const { error, data } = await elementService(...idArgs)
|
||||||
|
@ -40,13 +40,14 @@ export const fetchVolunteerNotifsSet = elementFetch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
const shouldFetchVolunteerNotifsSet = (state: AppState, id: number) =>
|
const shouldFetchVolunteerNotifsSet = (state: AppState, id: number) =>
|
||||||
state.volunteerNotifsSet.readyStatus !== "success" ||
|
state.volunteerNotifsSet?.readyStatus !== "success" ||
|
||||||
(state.volunteerNotifsSet.entity && state.volunteerNotifsSet.entity.id !== id)
|
(state.volunteerNotifsSet?.entity && state.volunteerNotifsSet?.entity?.id !== id)
|
||||||
|
|
||||||
export const fetchVolunteerNotifsSetIfNeed =
|
export const fetchVolunteerNotifsSetIfNeed =
|
||||||
(id = 0, notif: Partial<VolunteerNotifs> = {}): AppThunk =>
|
(id = 0, notif: Partial<VolunteerNotifs> = {}): AppThunk =>
|
||||||
(dispatch, getState) => {
|
(dispatch, getState) => {
|
||||||
let jwt = ""
|
let jwt = ""
|
||||||
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
;({ id, jwt } = getState().auth)
|
;({ id, jwt } = getState().auth)
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ const config = (isWeb = false): Configuration => ({
|
|||||||
minimizer: [
|
minimizer: [
|
||||||
new TerserPlugin({
|
new TerserPlugin({
|
||||||
// See more options: https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
|
// See more options: https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
|
||||||
terserOptions: { compress: { drop_console: true } },
|
terserOptions: { compress: { drop_console: false } },
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user