first music free
This commit is contained in:
@@ -118,4 +118,11 @@ const customAlert = (title, description, options, extra) => {
|
|||||||
|
|
||||||
const alert = Platform.OS === "web" ? alertPolyfill : customAlert;
|
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;
|
export default alert;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { createContext, useContext, useGlobal } from "reactn";
|
|||||||
|
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import { checkIfEmailIsValid } from "../actions/signupActions";
|
import { checkIfEmailIsValid } from "../actions/signupActions";
|
||||||
|
import { showPremiumRequiredAlert } from "../components/Alert";
|
||||||
import firebase, {
|
import firebase, {
|
||||||
arrayRemove,
|
arrayRemove,
|
||||||
arrayUnion,
|
arrayUnion,
|
||||||
@@ -168,6 +169,17 @@ export default ({ children }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const createNewProject = async ({ hasLyrics = false } = {}) => {
|
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 {
|
try {
|
||||||
await setIsLoading(true);
|
await setIsLoading(true);
|
||||||
const payload = {
|
const payload = {
|
||||||
|
|||||||
@@ -22,8 +22,12 @@ const WritingLyrics = () => {
|
|||||||
await setIsLoading(true);
|
await setIsLoading(true);
|
||||||
if (selectedProject) {
|
if (selectedProject) {
|
||||||
updateProjectData({ hasLyrics });
|
updateProjectData({ hasLyrics });
|
||||||
} else {
|
setTimeout(() => navigate(Routes.CreateLyricsWithAi), 500);
|
||||||
await createNewProject({ hasLyrics });
|
return;
|
||||||
|
}
|
||||||
|
const newProjectId = await createNewProject({ hasLyrics });
|
||||||
|
if (!newProjectId) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
setTimeout(() => navigate(Routes.CreateLyricsWithAi), 500);
|
setTimeout(() => navigate(Routes.CreateLyricsWithAi), 500);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user