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;
|
||||
|
||||
export const showPremiumRequiredAlert = () =>
|
||||
alert(
|
||||
"Accès premium requis",
|
||||
"Vous devez payer pour créer une nouvelle musique."
|
||||
// [{ text: "OK", style: "cancel" }]
|
||||
);
|
||||
|
||||
export default alert;
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user