feat: better error message
This commit is contained in:
@@ -80,6 +80,14 @@ function Root() {
|
||||
check_validity(data => dispatch({type: 'init', val: data}))
|
||||
}, []);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
check_validity(data => dispatch({type: 'update', val: data}))
|
||||
}, 1000 * 60 * 9)
|
||||
return () => clearInterval(interval)
|
||||
}, []);
|
||||
|
||||
return <>
|
||||
<header>
|
||||
<Nav/>
|
||||
|
||||
@@ -32,6 +32,8 @@ function authReducer(auth, action) {
|
||||
case 'update': {
|
||||
return {
|
||||
...auth,
|
||||
is_authenticated: action.val.state,
|
||||
userinfo: action.val.userinfo
|
||||
// data: {realm_access: {roles: ["federation_admin"]}}
|
||||
// data: JSON.parse(atob(action.token.split('.')[1]))
|
||||
}
|
||||
|
||||
@@ -8,9 +8,7 @@ export function useCountries(country = 'fr') {
|
||||
|
||||
useEffect(() => {
|
||||
if (countries[country] === undefined) {
|
||||
console.log('fetch')
|
||||
apiAxios.get(`/countries/${country}/${country}`).then(data => {
|
||||
console.log(data.data)
|
||||
countries[country] = data.data
|
||||
setOut(data.data)
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {useEffect, useState} from "react";
|
||||
import {apiAxios, getSaison} from "../utils/Tools.js";
|
||||
import {apiAxios, errFormater, getSaison} from "../utils/Tools.js";
|
||||
import {toast} from "react-toastify";
|
||||
import {useLocation, useNavigate} from "react-router-dom";
|
||||
|
||||
@@ -89,7 +89,11 @@ export function DemandeAff() {
|
||||
{
|
||||
pending: "Annulation de la demande d'affiliation en cours",
|
||||
success: "Demande d'affiliation annulée avec succès 🎉",
|
||||
error: "Échec de l'annulation de la demande d'affiliation 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de l'annulation de la demande d'affiliation")
|
||||
}
|
||||
}
|
||||
}
|
||||
).then(_ => {
|
||||
navigate("/club/me")
|
||||
@@ -102,7 +106,11 @@ export function DemandeAff() {
|
||||
{
|
||||
pending: "Enregistrement des modifications en cours",
|
||||
success: "Modifications enregistrées avec succès 🎉",
|
||||
error: "Échec de l'enregistrement des modifications 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de l'enregistrement des modifications")
|
||||
}
|
||||
}
|
||||
}
|
||||
).then(_ => {
|
||||
navigate("/club/me")
|
||||
@@ -115,7 +123,11 @@ export function DemandeAff() {
|
||||
{
|
||||
pending: "Enregistrement de la demande d'affiliation en cours",
|
||||
success: "Demande d'affiliation enregistrée avec succès 🎉",
|
||||
error: "Échec de la demande d'affiliation 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de la demande d'affiliation")
|
||||
}
|
||||
}
|
||||
}
|
||||
).then(_ => {
|
||||
navigate("/affiliation/ok")
|
||||
@@ -208,7 +220,11 @@ function AssoInfo({initData, needFile}) {
|
||||
{
|
||||
pending: "Recherche de l'association en cours",
|
||||
success: "Association trouvée avec succès 🎉",
|
||||
error: "Échec de la recherche de l'association 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de la recherche de l'association")
|
||||
}
|
||||
}
|
||||
}
|
||||
).then(data => {
|
||||
const data2 = data.data.unite_legale
|
||||
|
||||
@@ -7,7 +7,7 @@ import {Input} from "../components/Input.jsx";
|
||||
import {useLocation, useNavigate} from "react-router-dom";
|
||||
import {Checkbox} from "../components/MemberCustomFiels.jsx";
|
||||
import axios from "axios";
|
||||
import {apiAxios} from "../utils/Tools.js";
|
||||
import {apiAxios, errFormater} from "../utils/Tools.js";
|
||||
import {toast} from "react-toastify";
|
||||
import {SearchBar} from "../components/SearchBar.jsx";
|
||||
|
||||
@@ -58,7 +58,11 @@ export function MemberList({source}) {
|
||||
{
|
||||
pending: "Chargement des licences...",
|
||||
success: "Licences chargées",
|
||||
error: "Impossible de charger les licences"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Impossible de charger les licences")
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(data => {
|
||||
setLicenceData(data.data);
|
||||
|
||||
@@ -3,7 +3,7 @@ import {LoadingProvider, useLoadingSwitcher} from "../../../hooks/useLoading.jsx
|
||||
import {useFetch} from "../../../hooks/useFetch.js";
|
||||
import {AxiosError} from "../../../components/AxiosError.jsx";
|
||||
import {toast} from "react-toastify";
|
||||
import {apiAxios} from "../../../utils/Tools.js";
|
||||
import {apiAxios, errFormater} from "../../../utils/Tools.js";
|
||||
import {RoleList, TextField} from "../../../components/MemberCustomFiels.jsx";
|
||||
import {useEffect, useRef, useState} from "react";
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
@@ -44,7 +44,11 @@ function Content({data, refresh}) {
|
||||
{
|
||||
pending: "Suppression de la demande d'affiliation en cours",
|
||||
success: "Demande d'affiliation supprimée avec succès 🎉",
|
||||
error: "Échec de la suppression de la demande d'affiliation 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de la suppression de la demande d'affiliation")
|
||||
}
|
||||
}
|
||||
}
|
||||
).then(_ => {
|
||||
navigate("/admin/affiliation/request")
|
||||
@@ -128,7 +132,11 @@ function Content({data, refresh}) {
|
||||
{
|
||||
pending: "Enregistrement de la demande d'affiliation en cours",
|
||||
success: "Demande d'affiliation enregistrée avec succès 🎉",
|
||||
error: "Échec de l'enregistrement de la demande d'affiliation 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de l'enregistrement de la demande d'affiliation")
|
||||
}
|
||||
}
|
||||
}
|
||||
).then(_ => {
|
||||
refresh(`/affiliation/request/${data.id}`)
|
||||
@@ -139,7 +147,11 @@ function Content({data, refresh}) {
|
||||
{
|
||||
pending: "Acceptation de l'affiliation en cours",
|
||||
success: "Affiliation acceptée avec succès 🎉",
|
||||
error: "Échec de l'acceptation de l'affiliation 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de l'acceptation de l'affiliation")
|
||||
}
|
||||
}
|
||||
}
|
||||
).then(_ => {
|
||||
navigate("/admin/affiliation/request")
|
||||
|
||||
@@ -4,7 +4,7 @@ import {useEffect, useReducer, useState} from "react";
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
import {faEye, faPen} from "@fortawesome/free-solid-svg-icons";
|
||||
import {AxiosError} from "../../../components/AxiosError.jsx";
|
||||
import {apiAxios, getSaison} from "../../../utils/Tools.js";
|
||||
import {apiAxios, errFormater, getSaison} from "../../../utils/Tools.js";
|
||||
import {toast} from "react-toastify";
|
||||
import {SimpleReducer} from "../../../utils/SimpleReducer.jsx";
|
||||
import {useNavigate} from "react-router-dom";
|
||||
@@ -71,7 +71,11 @@ function sendAffiliation(event, dispatch) {
|
||||
{
|
||||
pending: "Enregistrement de l'affiliation en cours",
|
||||
success: "Affiliation enregistrée avec succès 🎉",
|
||||
error: "Échec de l'enregistrement de l'affiliation 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de l'enregistrement de l'affiliation")
|
||||
}
|
||||
}
|
||||
}
|
||||
).then(data => {
|
||||
dispatch({type: 'UPDATE_OR_ADD', payload: data.data})
|
||||
@@ -87,7 +91,11 @@ function removeAffiliation(id, dispatch) {
|
||||
{
|
||||
pending: "Suppression de l'affiliation en cours",
|
||||
success: "Affiliation supprimée avec succès 🎉",
|
||||
error: "Échec de la suppression de l'affiliation 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de la suppression de l'affiliation")
|
||||
}
|
||||
}
|
||||
}
|
||||
).then(_ => {
|
||||
dispatch({type: 'REMOVE', payload: id})
|
||||
|
||||
@@ -3,7 +3,7 @@ import {useEffect, useState} from "react";
|
||||
import {useLoadingSwitcher} from "../../../hooks/useLoading.jsx";
|
||||
import {useFetch} from "../../../hooks/useFetch.js";
|
||||
import {toast} from "react-toastify";
|
||||
import {apiAxios} from "../../../utils/Tools.js";
|
||||
import {apiAxios, errFormater} from "../../../utils/Tools.js";
|
||||
import {AxiosError} from "../../../components/AxiosError.jsx";
|
||||
import {Checkbox} from "../../../components/MemberCustomFiels.jsx";
|
||||
import {ThreeDots} from "react-loader-spinner";
|
||||
@@ -55,7 +55,11 @@ export function ClubList() {
|
||||
{
|
||||
pending: "Chargement des affiliation...",
|
||||
success: "Affiliation chargées",
|
||||
error: "Impossible de charger les affiliations"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Impossible de charger les affiliations")
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(data => {
|
||||
setAffiliationData(data.data);
|
||||
|
||||
@@ -2,7 +2,7 @@ import {useNavigate, useParams} from "react-router-dom";
|
||||
import {LoadingProvider, useLoadingSwitcher} from "../../../hooks/useLoading.jsx";
|
||||
import {useFetch} from "../../../hooks/useFetch.js";
|
||||
import {toast} from "react-toastify";
|
||||
import {apiAxios} from "../../../utils/Tools.js";
|
||||
import {apiAxios, errFormater} from "../../../utils/Tools.js";
|
||||
import {ConfirmDialog} from "../../../components/ConfirmDialog.jsx";
|
||||
import {AxiosError} from "../../../components/AxiosError.jsx";
|
||||
import {AffiliationCard} from "./AffiliationCard.jsx";
|
||||
@@ -30,7 +30,11 @@ export function ClubPage() {
|
||||
{
|
||||
pending: "Suppression du club en cours...",
|
||||
success: "Club supprimé avec succès 🎉",
|
||||
error: "Échec de la suppression du club 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de la suppression du club")
|
||||
}
|
||||
},
|
||||
}
|
||||
).then(_ => {
|
||||
navigate("/admin/club")
|
||||
@@ -85,7 +89,11 @@ function InformationForm({data}) {
|
||||
{
|
||||
pending: "Enregistrement du club en cours",
|
||||
success: "Club enregistrée avec succès 🎉",
|
||||
error: "Échec de l'enregistrement du club 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de l'enregistrement du club")
|
||||
}
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import {useNavigate} from "react-router-dom";
|
||||
import {LoadingProvider} from "../../../hooks/useLoading.jsx";
|
||||
import {useFetch} from "../../../hooks/useFetch.js";
|
||||
import {toast} from "react-toastify";
|
||||
import {apiAxios} from "../../../utils/Tools.js";
|
||||
import {apiAxios, errFormater} from "../../../utils/Tools.js";
|
||||
import {CountryList, TextField} from "../../../components/MemberCustomFiels.jsx";
|
||||
|
||||
import {useRef, useState} from "react";
|
||||
@@ -48,7 +48,11 @@ function InformationForm() {
|
||||
{
|
||||
pending: "Création du club en cours",
|
||||
success: "Club créé avec succès 🎉",
|
||||
error: "Échec de la création du club 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de la création du club")
|
||||
}
|
||||
}
|
||||
}
|
||||
).then(data => {
|
||||
navigate(`/admin/club/${data.data}`);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {toast} from "react-toastify";
|
||||
import {apiAxios} from "../../../utils/Tools.js";
|
||||
import {apiAxios, errFormater} from "../../../utils/Tools.js";
|
||||
import {useLoadingSwitcher} from "../../../hooks/useLoading.jsx";
|
||||
import {useFetch} from "../../../hooks/useFetch.js";
|
||||
import {ColoredCircle} from "../../../components/ColoredCircle.jsx";
|
||||
@@ -8,15 +8,16 @@ import {AxiosError} from "../../../components/AxiosError.jsx";
|
||||
export function CompteInfo({userData}) {
|
||||
|
||||
const creatAccount = () => {
|
||||
let err = {};
|
||||
toast.promise(
|
||||
apiAxios.put(`/compte/${userData.id}/init`).catch(e => {
|
||||
err = e
|
||||
}),
|
||||
apiAxios.put(`/compte/${userData.id}/init`),
|
||||
{
|
||||
pending: 'Création du compte en cours',
|
||||
success: 'Compte créé avec succès 🎉',
|
||||
error: 'Échec de la création du compte 😕 (code: ' + err.response.status + ')'
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de la création du compte")
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -28,7 +29,11 @@ export function CompteInfo({userData}) {
|
||||
{
|
||||
pending: "Définition de l'identifient en cours",
|
||||
success: "Identifient défini avec succès 🎉",
|
||||
error: "Échec de la définition de l'identifient 😕 "
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de la définition de l'identifient")
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
import {faPen} from "@fortawesome/free-solid-svg-icons";
|
||||
import {AxiosError} from "../../../components/AxiosError.jsx";
|
||||
import {CheckField, TextField} from "../../../components/MemberCustomFiels.jsx";
|
||||
import {apiAxios, getSaison} from "../../../utils/Tools.js";
|
||||
import {apiAxios, errFormater, getSaison} from "../../../utils/Tools.js";
|
||||
import {Input} from "../../../components/Input.jsx";
|
||||
import {toast} from "react-toastify";
|
||||
|
||||
@@ -98,7 +98,11 @@ function sendLicence(event, dispatch) {
|
||||
{
|
||||
pending: "Enregistrement de la licence en cours",
|
||||
success: "Licence enregistrée avec succès 🎉",
|
||||
error: "Échec de l'enregistrement de la licence 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de l'enregistrement de la licence")
|
||||
}
|
||||
}
|
||||
}
|
||||
).then(data => {
|
||||
dispatch({type: 'UPDATE_OR_ADD', payload: data.data})
|
||||
@@ -113,7 +117,11 @@ function removeLicence(id, dispatch) {
|
||||
{
|
||||
pending: "Suppression de la licence en cours",
|
||||
success: "Licence supprimée avec succès 🎉",
|
||||
error: "Échec de la suppression de la licence 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de la suppression de la licence")
|
||||
}
|
||||
}
|
||||
}
|
||||
).then(_ => {
|
||||
dispatch({type: 'REMOVE', payload: id})
|
||||
|
||||
@@ -7,7 +7,7 @@ import {PremForm} from "./PremForm.jsx";
|
||||
import {InformationForm} from "./InformationForm.jsx";
|
||||
import {LicenceCard} from "./LicenceCard.jsx";
|
||||
import {toast} from "react-toastify";
|
||||
import {apiAxios} from "../../../utils/Tools.js";
|
||||
import {apiAxios, errFormater} from "../../../utils/Tools.js";
|
||||
import {ConfirmDialog} from "../../../components/ConfirmDialog.jsx";
|
||||
|
||||
const vite_url = import.meta.env.VITE_URL;
|
||||
@@ -25,7 +25,11 @@ export function MemberPage() {
|
||||
{
|
||||
pending: "Suppression du compte en cours...",
|
||||
success: "Compte supprimé avec succès 🎉",
|
||||
error: "Échec de la suppression du compte 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de la suppression du compte")
|
||||
}
|
||||
}
|
||||
}
|
||||
).then(_ => {
|
||||
navigate("/admin/member")
|
||||
|
||||
@@ -2,7 +2,7 @@ import {useNavigate, useParams} from "react-router-dom";
|
||||
import {LoadingProvider, useLoadingSwitcher} from "../../../hooks/useLoading.jsx";
|
||||
import {useFetch} from "../../../hooks/useFetch.js";
|
||||
import {toast} from "react-toastify";
|
||||
import {apiAxios} from "../../../utils/Tools.js";
|
||||
import {apiAxios, errFormater} from "../../../utils/Tools.js";
|
||||
import {ConfirmDialog} from "../../../components/ConfirmDialog.jsx";
|
||||
import {AxiosError} from "../../../components/AxiosError.jsx";
|
||||
import {AffiliationCard, BureauCard} from "./AffiliationCard.jsx";
|
||||
@@ -58,7 +58,11 @@ function InformationForm({data}) {
|
||||
{
|
||||
pending: "Enregistrement des modifications en cours",
|
||||
success: "Modifications enregistrées avec succès 🎉",
|
||||
error: "Échec de l'enregistrement des modifications 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de l'enregistrement des modifications")
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import {useEffect, useReducer, useState} from "react";
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
import {faInfo, faPen} from "@fortawesome/free-solid-svg-icons";
|
||||
import {AxiosError} from "../../../components/AxiosError.jsx";
|
||||
import {apiAxios, getSaison} from "../../../utils/Tools.js";
|
||||
import {apiAxios, errFormater, getSaison} from "../../../utils/Tools.js";
|
||||
import {toast} from "react-toastify";
|
||||
import {ColoredText} from "../../../components/ColoredCircle.jsx";
|
||||
|
||||
@@ -95,7 +95,11 @@ function sendLicence(event, dispatch) {
|
||||
{
|
||||
pending: "Enregistrement de la demande de licence en cours",
|
||||
success: "Demande de licence enregistrée avec succès 🎉",
|
||||
error: "Échec de la demande de licence 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de la demande de licence")
|
||||
}
|
||||
}
|
||||
}
|
||||
).then(data => {
|
||||
dispatch({type: 'UPDATE_OR_ADD', payload: data.data})
|
||||
@@ -110,7 +114,11 @@ function removeLicence(id, dispatch) {
|
||||
{
|
||||
pending: "Suppression de la demande en cours",
|
||||
success: "Demande supprimée avec succès 🎉",
|
||||
error: "Échec de la suppression de la demande de licence 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de la suppression de la demande de licence")
|
||||
}
|
||||
}
|
||||
}
|
||||
).then(_ => {
|
||||
dispatch({type: 'REMOVE', payload: id})
|
||||
|
||||
@@ -6,7 +6,7 @@ import {CompteInfo} from "./CompteInfo.jsx";
|
||||
import {InformationForm} from "./InformationForm.jsx";
|
||||
import {LicenceCard} from "./LicenceCard.jsx";
|
||||
import {ConfirmDialog} from "../../../components/ConfirmDialog.jsx";
|
||||
import {apiAxios} from "../../../utils/Tools.js";
|
||||
import {apiAxios, errFormater} from "../../../utils/Tools.js";
|
||||
import {toast} from "react-toastify";
|
||||
|
||||
const vite_url = import.meta.env.VITE_URL;
|
||||
@@ -24,7 +24,11 @@ export function MemberPage() {
|
||||
{
|
||||
pending: "Suppression du compte en cours...",
|
||||
success: "Compte supprimé avec succès 🎉",
|
||||
error: "Échec de la suppression du compte 😕"
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de la suppression du compte")
|
||||
}
|
||||
}
|
||||
}
|
||||
).then(_ => {
|
||||
navigate("/club/member")
|
||||
|
||||
@@ -7,6 +7,11 @@ export const apiAxios = axios.create({
|
||||
});
|
||||
apiAxios.defaults.headers.post['Accept'] = 'application/json; charset=UTF-8';
|
||||
|
||||
|
||||
export const errFormater = (data, msg) => {
|
||||
return `${msg} (${data.response.statusText}: ${data.response.data}) 😕`
|
||||
}
|
||||
|
||||
export function getCategoryFormBirthDate(birth_date, currentDate = new Date()) {
|
||||
const currentSaison = getSaison(currentDate)
|
||||
const birthYear = birth_date.getFullYear()
|
||||
|
||||
Reference in New Issue
Block a user