end of tickets

This commit is contained in:
Thomas Demirdjian
2025-11-17 15:54:54 +01:00
parent c7cbd85088
commit 016f7c27ac
8 changed files with 159 additions and 71 deletions
+24 -4
View File
@@ -14,6 +14,13 @@ exports.generatePicturePrompt = (project = {}) => {
.replace(/[<>]/g, "")
.trim();
};
const normalizeForMatching = (value = "") => {
if (typeof value !== "string") return "";
return value
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.toLowerCase();
};
const titleForPrompt = sanitizeInline(title) || "Sans titre";
const artistName =
@@ -63,11 +70,23 @@ exports.generatePicturePrompt = (project = {}) => {
? "Palette vive et contrastée (magenta, cyan, jaune, bleu électrique)"
: "Palette harmonieuse et douce (bleu nuit, violet, corail, or pâle)";
const coverStyle = String(coverStyleRaw || "").trim();
const tagsLine = tags.join(" ; ") || "Non spécifié";
const coverStyleInput = String(coverStyleRaw || "").trim();
const coverStyle = sanitizeInline(coverStyleInput);
const normalizedStyle = normalizeForMatching(coverStyle);
let coverStyleGuidance = coverStyle;
if (normalizedStyle.includes("realist")) {
coverStyleGuidance =
"Style réaliste photographique hyper détaillé, textures fidèles, lumière naturelle, profondeur de champ crédible, aucun effet cartoon, fantastique ou peint";
}
const hasTags = tags.length > 0;
const tagsLine = hasTags
? `${tags.join(
" ; ",
)}. Utilise ces indications pour guider uniquement la palette, l'énergie et l'émotion, sans représenter littéralement les instruments, objets ou mots cités.`
: "Ambiance sonore non précisée : crée une atmosphère abstraite sans instrument ni objet musical apparent.";
const lyricsLine = lyricsSample || "Pas d'extraits fournis";
const styleLine = coverStyle
? `${coverStyle}. ${paletteHint}`
const styleLine = coverStyleGuidance
? `${coverStyleGuidance}. ${paletteHint}`
: `${paletteHint}. Style libre, artistique et lumineux.`;
const typographyLine = hasArtistName
? `Reproduis strictement le titre de la chanson ${titleForPrompt} sans modification, sans traduction et sans ajout ou suppression de caractères. Ajoute également le nom de l'artiste ${artistName} de manière artistique, parfaitement lisible et hiérarchisée, en harmonie avec le style abstrait et lumineux de la pochette.`
@@ -95,6 +114,7 @@ ${artistLine} <STYLE_MUSICAL>${tagsLine}</STYLE_MUSICAL>
<INTERDIT>Personnes, visages ou silhouettes reconnaissables.</INTERDIT>
<INTERDIT>Fonds blancs ou bordures délimitant l'image.</INTERDIT>
<INTERDIT>Texte illisible ou trop petit.</INTERDIT>
<INTERDIT>Représenter des instruments ou objets évoqués dans STYLE_MUSICAL : ces informations servent uniquement au contexte audio.</INTERDIT>
</CONTRAINTES>
`.trim();
+3
View File
@@ -507,3 +507,6 @@ export const CHOOSE_DECOR = [
"Jardin",
"Neige",
];
export const defaultAvatar =
"https://firebasestorage.googleapis.com/v0/b/musicland-d33f9.firebasestorage.app/o/default%2FdefaultAvatar.png?alt=media&token=99b6231a-e594-421e-b6cd-0e3aab148be0";
+68 -8
View File
@@ -30,6 +30,49 @@ const stripePromise = loadStripe(
isStripeTesting ? STRIPE_PUBLISHABLE_KEY_TEST : STRIPE_PUBLISHABLE_KEY_LIVE,
);
const isSafariBrowser = () => {
if (
typeof navigator !== "object" ||
typeof navigator.userAgent !== "string"
) {
return false;
}
return (
/safari/i.test(navigator.userAgent) &&
!/(chrome|crios|android|fxios|edgios|opr|ucbrowser)/i.test(
navigator.userAgent,
)
);
};
const openSafariCheckoutWindow = () => {
if (!isWeb || typeof window === "undefined") {
return null;
}
if (!isSafariBrowser()) {
return null;
}
try {
const placeholder = window.open("", "_blank", "noopener,noreferrer");
if (!placeholder) {
return null;
}
try {
placeholder.document.write(
"<p style='font-family: sans-serif; color: #111; padding: 16px;'>Chargement du paiement Stripe...</p>",
);
placeholder.document.title = "Stripe Checkout";
} catch {
// Ignore failures when the window gets reused or is cross-domain.
}
placeholder.focus?.();
return placeholder;
} catch (error) {
console.warn("[StripeProvider] Safari window pre-open failed", error);
return null;
}
};
export const StripeContext = React.createContext(null);
export const useStripe = () => {
@@ -68,25 +111,36 @@ const StripeProvider = ({ children }) => {
setClientSecret(null);
}, []);
const redirectToCheckout = React.useCallback(async (checkoutUrl) => {
const redirectToCheckout = React.useCallback(
async (checkoutUrl, { safariWindow } = {}) => {
if (!checkoutUrl) {
throw new Error("Session Stripe introuvable.");
}
if (isWeb) {
if (safariWindow && !safariWindow.closed) {
try {
safariWindow.location.replace(checkoutUrl);
} catch (navigationError) {
safariWindow.location.href = checkoutUrl;
}
safariWindow.focus?.();
return;
}
if (typeof window !== "undefined") {
const openedTab = window.open(
checkoutUrl,
"_blank",
"noopener,noreferrer",
);
// Fallback to same-tab navigation if the popup is blocked.
if (!openedTab) {
window.location.assign(checkoutUrl);
}
if (openedTab) {
return;
}
throw new Error("Navigation Stripe impossible dans cet environnement.");
}
await Linking.openURL(checkoutUrl);
return;
}
const isMobileApp =
@@ -114,10 +168,13 @@ const StripeProvider = ({ children }) => {
throw new Error("Impossible d'ouvrir l'URL de paiement.");
}
await Linking.openURL(checkoutUrl);
}, []);
},
[],
);
const runCheckoutSession = React.useCallback(
async ({ callableName, payload, logTag }) => {
const safariWindow = openSafariCheckoutWindow();
try {
const callable = getFunctionsClient(FUNCTIONS_REGION).httpsCallable(
callableName,
@@ -127,8 +184,11 @@ const StripeProvider = ({ children }) => {
if (!checkoutUrl) {
throw new Error("Session Stripe introuvable.");
}
await redirectToCheckout(checkoutUrl);
await redirectToCheckout(checkoutUrl, { safariWindow });
} catch (error) {
if (safariWindow && !safariWindow.closed) {
safariWindow.close();
}
console.error(`[StripeProvider] ${logTag}`, error);
throw new Error(
error?.message ||
@@ -49,9 +49,6 @@ const ResearchHeader = ({
<BlurView
intensity={Platform.OS !== "ios" ? 10 : 20}
style={styles.blurView}
// experimentalBlurMethod={
// Platform.OS !== "ios" ? "dimezisBlurView" : "none"
// }
>
<Text style={styles.menu}>{item}</Text>
</BlurView>
@@ -10,6 +10,7 @@ import { FONT_FAMILY } from "../../../styles/Fonts";
import { getArtistDisplayName } from "../../../utils/artistName";
import CreateLyricsHeader from "../../Writing/components/CreateLyricsHeader";
import MusicCard from "./MusicCard";
import { defaultAvatar } from "../../../data/data";
const EmptyText = ({ text }) => (
<View style={{ flex: 1, alignItems: "center", paddingVertical: 16 }}>
@@ -80,13 +81,13 @@ const SearchResultsList = ({
...cover.options.flatMap((option) => [
option?.finalUrl,
option?.generatedUrl,
])
]),
);
}
return coverCandidates.find(isValid) || null;
},
[]
[],
);
const handleMusicPress = (project) => {
@@ -164,7 +165,7 @@ const SearchResultsList = ({
setShowMenu(
(previous) =>
!previous ||
positionTop?.top !== (menuPosition?.top ?? null)
positionTop?.top !== (menuPosition?.top ?? null),
);
}}
/>
@@ -210,7 +211,7 @@ const SearchResultsList = ({
setShowMenu(
(previous) =>
!previous ||
positionTop?.top !== (menuPosition?.top ?? null)
positionTop?.top !== (menuPosition?.top ?? null),
);
}}
/>
@@ -249,12 +250,7 @@ const SearchResultsList = ({
onPress={() => handleProfilePress(user.id)}
>
<ProfilePicture
uri={
user?.pictureUrl ||
user?.profilePictureURL ||
user?.photoURL ||
null
}
uri={user?.profilePictureURL || defaultAvatar}
size={60}
imageProps={{ priority: "high" }}
/>
+1 -1
View File
@@ -197,7 +197,7 @@ const SongReady = () => {
try {
await pauseAllPlayers();
} catch {}
navigate(Routes.ComposeSong, { isRegeneration: true });
navigate(Routes.Lyrics);
};
const handleRegeneratePress = () => {
+8 -8
View File
@@ -73,7 +73,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
});
const sanitizedStructure = sanitizeStructureList(
config?.structure,
CUSTOM_SANITIZE_OPTIONS
CUSTOM_SANITIZE_OPTIONS,
);
const callable = firebase
.functions()
@@ -136,7 +136,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
const rawMessage = typeof e?.message === "string" ? e.message : "";
const cleanedMessage = rawMessage.replace(
/^functions error: \w+-\w+:\s*/i,
""
"",
);
setError({
message:
@@ -166,7 +166,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
console.log("💾 [CreatingLyrics] Sauvegarde automatique des paroles");
const sanitizedStructure = sanitizeStructureList(
result?.structure || config?.structure,
CUSTOM_SANITIZE_OPTIONS
CUSTOM_SANITIZE_OPTIONS,
);
const baseConfig =
config && typeof config === "object" && !Array.isArray(config)
@@ -192,12 +192,12 @@ const CreatingLyrics = ({ active, config, selections }) => {
if ("customStructure" in persistedSelections) {
persistedSelections.customStructure = sanitizeStructureList(
persistedSelections.customStructure,
CUSTOM_SANITIZE_OPTIONS
CUSTOM_SANITIZE_OPTIONS,
);
}
if ("parsedStructure" in persistedSelections) {
persistedSelections.parsedStructure = sanitizeStructureList(
persistedSelections.parsedStructure
persistedSelections.parsedStructure,
);
}
}
@@ -250,7 +250,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
onPress: redirect,
},
],
{ cancelable: false }
{ cancelable: false },
);
if (Platform.OS === "web") {
@@ -322,7 +322,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
setSaved(true);
await setIsLoading(true);
console.log(
"📄 [CreatingLyrics] Consultation manuelle du texte"
"📄 [CreatingLyrics] Consultation manuelle du texte",
);
await updateProjectData({
title: result?.title || "",
@@ -337,7 +337,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
} catch (e) {
console.error(
"⚠️ [CreatingLyrics] Erreur lors de l'ouverture manuelle",
e
e,
);
} finally {
await setIsLoading(false);
+16 -4
View File
@@ -37,6 +37,12 @@ const Lyrics = ({ navigation }) => {
const [containerLayout, setContainerLayout] = useState(null);
const { setIsLoading } = useMinuit();
const { selectedProjectId, selectedProject } = useUser();
const hasExistingMusicDraft = useMemo(() => {
if (!Array.isArray(selectedProject?.musicUrls)) return false;
return selectedProject.musicUrls.some(
(url) => typeof url === "string" && url.trim()
);
}, [selectedProject?.musicUrls]);
const [isFocus, setIsFocus] = useState(null);
const [itemsContainerLayout, setItemsContainerLayout] = useState([]);
const [sensitiveContentModal, setSensitiveContentModal] = useState({
@@ -306,6 +312,14 @@ const Lyrics = ({ navigation }) => {
}
const beatmakerStage = getStageAction("beatmaker", projectForStage);
await setIsLoading(false);
if (hasExistingMusicDraft) {
navigate(Routes.ComposeSong, { isRegeneration: true });
return;
}
const handleNavigateToStudio = () => {
const targetRoute = beatmakerStage?.route || Routes.Compose;
navigate(targetRoute, beatmakerStage?.params);
};
alert(
"Céline",
"Bravo ! Vous venez de terminer de créer les paroles de votre musique ! Maintenant vous pouvez passer à la prochaine étape : le Studio pour donner vie à votre chanson !",
@@ -323,10 +337,7 @@ const Lyrics = ({ navigation }) => {
},
{
text: "Continuer vers le Studio",
onPress: () => {
const targetRoute = beatmakerStage?.route || Routes.Compose;
navigate(targetRoute, beatmakerStage?.params);
},
onPress: handleNavigateToStudio,
},
]
);
@@ -350,6 +361,7 @@ const Lyrics = ({ navigation }) => {
projectHasLyrics,
projectLyrics,
selectedProject,
hasExistingMusicDraft,
]);
const typeOccurrences = {};