first music free

This commit is contained in:
2025-10-21 15:29:20 +02:00
parent 59952efc1c
commit 90ad4be673
3 changed files with 25 additions and 2 deletions
+7
View File
@@ -118,4 +118,11 @@ const customAlert = (title, description, options, extra) => {
const alert = Platform.OS === "web" ? alertPolyfill : customAlert;
export const showPremiumRequiredAlert = () =>
alert(
"Accès premium requis",
"Vous devez payer pour créer une nouvelle musique."
// [{ text: "OK", style: "cancel" }]
);
export default alert;
+12
View File
@@ -5,6 +5,7 @@ import { createContext, useContext, useGlobal } from "reactn";
import { useCallback, useEffect, useState } from "react";
import { checkIfEmailIsValid } from "../actions/signupActions";
import { showPremiumRequiredAlert } from "../components/Alert";
import firebase, {
arrayRemove,
arrayUnion,
@@ -168,6 +169,17 @@ export default ({ children }) => {
};
const createNewProject = async ({ hasLyrics = false } = {}) => {
const existingProjectsCount = Array.isArray(userProjects)
? userProjects.length
: 0;
const hasUnlimitedCreation = true;
// currentUserDoc?.isPremium; mettre en place en prod
if (!hasUnlimitedCreation && existingProjectsCount >= 1) {
showPremiumRequiredAlert();
return null;
}
try {
await setIsLoading(true);
const payload = {
+6 -2
View File
@@ -22,8 +22,12 @@ const WritingLyrics = () => {
await setIsLoading(true);
if (selectedProject) {
updateProjectData({ hasLyrics });
} else {
await createNewProject({ hasLyrics });
setTimeout(() => navigate(Routes.CreateLyricsWithAi), 500);
return;
}
const newProjectId = await createNewProject({ hasLyrics });
if (!newProjectId) {
return;
}
setTimeout(() => navigate(Routes.CreateLyricsWithAi), 500);
} catch (e) {