firebase errors and continue profress
This commit is contained in:
@@ -38,37 +38,43 @@ export const formatPhoneNumber = ({ phoneNumber = null }) => {
|
|||||||
return newPhoneNumber;
|
return newPhoneNumber;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function handleFirebaseError(code) {
|
export function handleFirebaseError(code = "") {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case "auth/user-not-found":
|
case "auth/user-not-found":
|
||||||
return "Ce compte n'existe pas.";
|
return "Ce compte n'existe pas.";
|
||||||
|
case "auth/user-disabled":
|
||||||
|
return "Ce compte est désactivé. Contacte le support si besoin.";
|
||||||
case "auth/invalid-verification-code":
|
case "auth/invalid-verification-code":
|
||||||
return "Votre code de validation est incorrect.";
|
return "Ton code de validation est incorrect.";
|
||||||
case "auth/provider-already-linked":
|
case "auth/provider-already-linked":
|
||||||
return "Ce compte est déjà lié à un utilisateur.";
|
return "Ce compte est déjà lié à un utilisateur.";
|
||||||
case "auth/invalid-credential":
|
case "auth/invalid-credential":
|
||||||
return "Identifiants incorrects.";
|
case "auth/invalid-login-credential":
|
||||||
case "auth/invalid-login-credentials":
|
case "auth/invalid-login-credentials":
|
||||||
return "Identifiants incorrects.";
|
return "Identifiants incorrects.";
|
||||||
case "auth/credential-already-in-use":
|
case "auth/credential-already-in-use":
|
||||||
return "Ce compte existe déjà ou est déjà lié.";
|
return "Ce compte existe déjà ou est déjà lié.";
|
||||||
case "auth/operation-not-allowed":
|
case "auth/operation-not-allowed":
|
||||||
return "Le provider n'est pas activé.";
|
return "Le fournisseur d'identité n'est pas disponible.";
|
||||||
case "auth/invalid-email":
|
case "auth/invalid-email":
|
||||||
return "Email invalide.";
|
return "Adresse e-mail invalide.";
|
||||||
case "auth/wrong-password":
|
case "auth/wrong-password":
|
||||||
return "Mot de passe incorrect.";
|
return "Mot de passe incorrect.";
|
||||||
case "auth/invalid-verification-id":
|
case "auth/invalid-verification-id":
|
||||||
return "Impossible de vous authentifié, réessayez dans quelques secondes.";
|
return "Impossible de t'authentifier, réessaie dans quelques secondes.";
|
||||||
case "auth/invalid-phone-number":
|
case "auth/invalid-phone-number":
|
||||||
return "Numéro de téléphone incorrect.";
|
return "Numéro de téléphone incorrect.";
|
||||||
case "auth/too-many-requests":
|
case "auth/too-many-requests":
|
||||||
return "Nous avons détecté une activité inhabituelle et avons bloqué momentanément votre requête, réessayez dans quelques minutes.";
|
return "Trop de tentatives. Réessaie dans quelques minutes.";
|
||||||
case "auth/email-already-in-use":
|
case "auth/email-already-in-use":
|
||||||
return "Il y a déjà un compte avec cette adresse mail.";
|
return "Il existe déjà un compte avec cette adresse e-mail.";
|
||||||
case "auth/missing-password":
|
case "auth/missing-password":
|
||||||
return "Veuillez entrer un mot de passe.";
|
return "Renseigne ton mot de passe.";
|
||||||
|
case "auth/weak-password":
|
||||||
|
return "Ton mot de passe est trop faible.";
|
||||||
|
case "auth/network-request-failed":
|
||||||
|
return "Problème de connexion réseau. Vérifie ta connexion et réessaie.";
|
||||||
default:
|
default:
|
||||||
return code;
|
return "Une erreur est survenue. Réessaie dans quelques instants.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { background } from "../assets";
|
|||||||
import GradientButton from "../components/GradientButton";
|
import GradientButton from "../components/GradientButton";
|
||||||
import { Input } from "../components/Input";
|
import { Input } from "../components/Input";
|
||||||
import ItemContainer from "../components/ItemContainer/ItemContainer";
|
import ItemContainer from "../components/ItemContainer/ItemContainer";
|
||||||
|
import { handleFirebaseError } from "../actions/signupActions";
|
||||||
import firebase, { usersRef } from "../config/firebase";
|
import firebase, { usersRef } from "../config/firebase";
|
||||||
import Page from "../layouts/Page";
|
import Page from "../layouts/Page";
|
||||||
import { Routes } from "../navigation";
|
import { Routes } from "../navigation";
|
||||||
@@ -72,7 +73,11 @@ const CreatePassword = () => {
|
|||||||
navigate(Routes.CreatePseudo);
|
navigate(Routes.CreatePseudo);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Register error", e?.message);
|
console.log("Register error", e?.message);
|
||||||
setTooltip({ text: e?.message || "Création impossible", type: "error" });
|
const message =
|
||||||
|
e?.code && e.code.startsWith("auth/")
|
||||||
|
? handleFirebaseError(e.code)
|
||||||
|
: e?.message || "Création impossible";
|
||||||
|
setTooltip({ text: message, type: "error" });
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-10
@@ -75,12 +75,31 @@ const Home = () => {
|
|||||||
[currentProject]
|
[currentProject]
|
||||||
);
|
);
|
||||||
|
|
||||||
const firstUnlockedIndex = useMemo(() => {
|
const preferredStageIndex = useMemo(() => {
|
||||||
const index = stageStates.findIndex((stage) => !stage.isLocked);
|
if (!stageStates.length) {
|
||||||
return index === -1 ? 0 : index;
|
return 0;
|
||||||
|
}
|
||||||
|
const actionableIndex = stageStates.findIndex(
|
||||||
|
(stage) => !stage.isCompleted && !stage.isLocked
|
||||||
|
);
|
||||||
|
if (actionableIndex !== -1) {
|
||||||
|
return actionableIndex;
|
||||||
|
}
|
||||||
|
const firstIncomplete = stageStates.findIndex(
|
||||||
|
(stage) => !stage.isCompleted
|
||||||
|
);
|
||||||
|
if (firstIncomplete !== -1) {
|
||||||
|
return firstIncomplete;
|
||||||
|
}
|
||||||
|
const firstUnlocked = stageStates.findIndex((stage) => !stage.isLocked);
|
||||||
|
if (firstUnlocked !== -1) {
|
||||||
|
return firstUnlocked;
|
||||||
|
}
|
||||||
|
return stageStates.length - 1;
|
||||||
}, [stageStates]);
|
}, [stageStates]);
|
||||||
|
|
||||||
const [activeStageIndex, setActiveStageIndex] = useState(firstUnlockedIndex);
|
const [activeStageIndex, setActiveStageIndex] =
|
||||||
|
useState(preferredStageIndex);
|
||||||
const [menuVisible, setMenuVisible] = useState(false);
|
const [menuVisible, setMenuVisible] = useState(false);
|
||||||
const [menuAnchor, setMenuAnchor] = useState(null);
|
const [menuAnchor, setMenuAnchor] = useState(null);
|
||||||
const [menuProject, setMenuProject] = useState(null);
|
const [menuProject, setMenuProject] = useState(null);
|
||||||
@@ -89,17 +108,28 @@ const Home = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setActiveStageIndex((prev) => {
|
setActiveStageIndex((prev) => {
|
||||||
|
const fallbackIndex =
|
||||||
|
preferredStageIndex >= 0 && preferredStageIndex < stageStates.length
|
||||||
|
? preferredStageIndex
|
||||||
|
: 0;
|
||||||
|
|
||||||
if (prev == null || prev >= stageStates.length) {
|
if (prev == null || prev >= stageStates.length) {
|
||||||
return firstUnlockedIndex;
|
return fallbackIndex;
|
||||||
}
|
}
|
||||||
const current = stageStates[prev];
|
const current = stageStates[prev];
|
||||||
const fallback = stageStates[firstUnlockedIndex];
|
if (!current) {
|
||||||
if (current?.isLocked && fallback && !fallback.isLocked) {
|
return fallbackIndex;
|
||||||
return firstUnlockedIndex;
|
}
|
||||||
|
if (
|
||||||
|
(current.isLocked || current.isCompleted) &&
|
||||||
|
fallbackIndex !== prev &&
|
||||||
|
stageStates[fallbackIndex]
|
||||||
|
) {
|
||||||
|
return fallbackIndex;
|
||||||
}
|
}
|
||||||
return prev;
|
return prev;
|
||||||
});
|
});
|
||||||
}, [stageStates, firstUnlockedIndex]);
|
}, [stageStates, preferredStageIndex]);
|
||||||
|
|
||||||
const handleSelectProject = useCallback(
|
const handleSelectProject = useCallback(
|
||||||
(project) => {
|
(project) => {
|
||||||
@@ -182,7 +212,7 @@ const Home = () => {
|
|||||||
}, [handleDeleteProject, menuProject?.id]);
|
}, [handleDeleteProject, menuProject?.id]);
|
||||||
|
|
||||||
const activeStage =
|
const activeStage =
|
||||||
stageStates[activeStageIndex] || stageStates[firstUnlockedIndex];
|
stageStates[activeStageIndex] || stageStates[preferredStageIndex];
|
||||||
const stageAction = useMemo(() => {
|
const stageAction = useMemo(() => {
|
||||||
if (!activeStage) {
|
if (!activeStage) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
+17
-3
@@ -19,6 +19,7 @@ import { background } from "../assets";
|
|||||||
import GradientButton from "../components/GradientButton.js";
|
import GradientButton from "../components/GradientButton.js";
|
||||||
import { Input } from "../components/Input.js";
|
import { Input } from "../components/Input.js";
|
||||||
import ItemContainer from "../components/ItemContainer/ItemContainer";
|
import ItemContainer from "../components/ItemContainer/ItemContainer";
|
||||||
|
import { handleFirebaseError } from "../actions/signupActions.js";
|
||||||
import firebase, { usersRef } from "../config/firebase";
|
import firebase, { usersRef } from "../config/firebase";
|
||||||
import {
|
import {
|
||||||
GOOGLE_ANDROID_CLIENT_ID,
|
GOOGLE_ANDROID_CLIENT_ID,
|
||||||
@@ -78,7 +79,11 @@ export default ({ navigation }) => {
|
|||||||
await afterLoginNavigate();
|
await afterLoginNavigate();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Login error", e?.message);
|
console.log("Login error", e?.message);
|
||||||
setTooltip({ text: e?.message || "Connexion impossible", type: "error" });
|
const message =
|
||||||
|
e?.code && e.code.startsWith("auth/")
|
||||||
|
? handleFirebaseError(e.code)
|
||||||
|
: e?.message || "Connexion impossible";
|
||||||
|
setTooltip({ text: message, type: "error" });
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -104,8 +109,13 @@ export default ({ navigation }) => {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Google Login error", e?.message);
|
console.log("Google Login error", e?.message);
|
||||||
|
const message =
|
||||||
|
e?.code && e.code.startsWith("auth/")
|
||||||
|
? handleFirebaseError(e.code)
|
||||||
|
: e?.message;
|
||||||
setTooltip({
|
setTooltip({
|
||||||
text: e?.message || "Connexion Google impossible. Merci de réessayer.",
|
text:
|
||||||
|
message || "Connexion Google impossible. Merci de réessayer.",
|
||||||
type: "error",
|
type: "error",
|
||||||
});
|
});
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@@ -165,8 +175,12 @@ export default ({ navigation }) => {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Google native sign-in error", e?.message);
|
console.log("Google native sign-in error", e?.message);
|
||||||
|
const message =
|
||||||
|
e?.code && e.code.startsWith("auth/")
|
||||||
|
? handleFirebaseError(e.code)
|
||||||
|
: e?.message;
|
||||||
setTooltip({
|
setTooltip({
|
||||||
text: e?.message || "Connexion Google impossible",
|
text: message || "Connexion Google impossible",
|
||||||
type: "error",
|
type: "error",
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -147,6 +147,21 @@ const getStageLockedDescription = (key, metadata) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getStageCompletionState = (key, metadata) => {
|
||||||
|
switch (key) {
|
||||||
|
case "songwriter":
|
||||||
|
return metadata.hasLyrics;
|
||||||
|
case "beatmaker":
|
||||||
|
return metadata.hasSongUrl || metadata.musicStatus === "GENERATED";
|
||||||
|
case "designer":
|
||||||
|
return metadata.hasCover;
|
||||||
|
case "director":
|
||||||
|
return metadata.hasPlaybackAsset;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const getCreationStageStates = (project) => {
|
export const getCreationStageStates = (project) => {
|
||||||
const metadata = getStageMetadata(project);
|
const metadata = getStageMetadata(project);
|
||||||
return CREATION_STAGE_KEYS.map((key, index) => {
|
return CREATION_STAGE_KEYS.map((key, index) => {
|
||||||
@@ -158,6 +173,7 @@ export const getCreationStageStates = (project) => {
|
|||||||
key,
|
key,
|
||||||
index,
|
index,
|
||||||
isLocked,
|
isLocked,
|
||||||
|
isCompleted: getStageCompletionState(key, metadata),
|
||||||
description:
|
description:
|
||||||
isLocked && lockedDescription ? lockedDescription : description,
|
isLocked && lockedDescription ? lockedDescription : description,
|
||||||
lockedDescription,
|
lockedDescription,
|
||||||
@@ -198,6 +214,26 @@ export const getStageAction = (key, project) => {
|
|||||||
|
|
||||||
export const findFirstUnlockedStageIndex = (project) => {
|
export const findFirstUnlockedStageIndex = (project) => {
|
||||||
const stages = getCreationStageStates(project);
|
const stages = getCreationStageStates(project);
|
||||||
const index = stages.findIndex((stage) => !stage.isLocked);
|
if (!stages.length) {
|
||||||
return index === -1 ? 0 : index;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const actionableIndex = stages.findIndex(
|
||||||
|
(stage) => !stage.isCompleted && !stage.isLocked
|
||||||
|
);
|
||||||
|
if (actionableIndex !== -1) {
|
||||||
|
return actionableIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
const firstIncomplete = stages.findIndex((stage) => !stage.isCompleted);
|
||||||
|
if (firstIncomplete !== -1) {
|
||||||
|
return firstIncomplete;
|
||||||
|
}
|
||||||
|
|
||||||
|
const firstUnlocked = stages.findIndex((stage) => !stage.isLocked);
|
||||||
|
if (firstUnlocked !== -1) {
|
||||||
|
return firstUnlocked;
|
||||||
|
}
|
||||||
|
|
||||||
|
return stages.length - 1;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user