create flow
This commit is contained in:
@@ -30,7 +30,7 @@ const CreateLyricsWithAi = () => {
|
||||
const [selectedIndex, setSelectedIndex] = useState(hasLyrics ? 5 : 0);
|
||||
const [progress, setProgress] = useState(16);
|
||||
const [parentLayout, setparentLayout] = useState(null);
|
||||
const containerWidth = isWeb ? parentLayout?.width : windowWidth;
|
||||
const containerWidth = windowWidth;
|
||||
|
||||
// Collected state across steps
|
||||
const [objective, setObjective] = useState(null); // from Goals list
|
||||
@@ -50,11 +50,23 @@ const CreateLyricsWithAi = () => {
|
||||
const sel = selectedProject?.selections || {};
|
||||
const cfg = selectedProject?.config || {};
|
||||
|
||||
// Text inputs / choix simples
|
||||
if (objective == null && typeof sel.objective === "string" && sel.objective)
|
||||
setObjective(sel.objective);
|
||||
if (!otherObjective && typeof sel.otherObjective === "string")
|
||||
setOtherObjective(sel.otherObjective);
|
||||
const rawOtherObjective =
|
||||
typeof sel.otherObjective === "string" ? sel.otherObjective : "";
|
||||
const hasSavedOtherObjective = rawOtherObjective.trim().length > 0;
|
||||
const savedObjective =
|
||||
typeof sel.objective === "string" && sel.objective.trim().length > 0
|
||||
? sel.objective
|
||||
: null;
|
||||
|
||||
if (!otherObjective && hasSavedOtherObjective) {
|
||||
setOtherObjective(rawOtherObjective);
|
||||
if (objective !== null) {
|
||||
setObjective(null);
|
||||
}
|
||||
} else if (!hasSavedOtherObjective && objective == null && savedObjective) {
|
||||
setObjective(savedObjective);
|
||||
}
|
||||
|
||||
if (!context && typeof sel.context === "string") setContext(sel.context);
|
||||
|
||||
// Emotion: accepter objet {title, description} ou string "Titre : description"
|
||||
@@ -72,10 +84,22 @@ const CreateLyricsWithAi = () => {
|
||||
}
|
||||
}
|
||||
|
||||
if (style == null && typeof sel.style === "string" && sel.style)
|
||||
setStyle(sel.style);
|
||||
if (!otherStyle && typeof sel.otherStyle === "string")
|
||||
setOtherStyle(sel.otherStyle);
|
||||
const rawOtherStyle =
|
||||
typeof sel.otherStyle === "string" ? sel.otherStyle : "";
|
||||
const hasSavedOtherStyle = rawOtherStyle.trim().length > 0;
|
||||
const savedStyle =
|
||||
typeof sel.style === "string" && sel.style.trim().length > 0
|
||||
? sel.style
|
||||
: null;
|
||||
|
||||
if (!otherStyle && hasSavedOtherStyle) {
|
||||
setOtherStyle(rawOtherStyle);
|
||||
if (style !== null) {
|
||||
setStyle(null);
|
||||
}
|
||||
} else if (!hasSavedOtherStyle && style == null && savedStyle) {
|
||||
setStyle(savedStyle);
|
||||
}
|
||||
if (!audience && typeof sel.audience === "string")
|
||||
setAudience(sel.audience);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user