firebase errors and continue profress
This commit is contained in:
@@ -147,6 +147,21 @@ const getStageLockedDescription = (key, metadata) => {
|
||||
}
|
||||
};
|
||||
|
||||
const getStageCompletionState = (key, metadata) => {
|
||||
switch (key) {
|
||||
case "songwriter":
|
||||
return metadata.hasLyrics;
|
||||
case "beatmaker":
|
||||
return metadata.hasSongUrl || metadata.musicStatus === "GENERATED";
|
||||
case "designer":
|
||||
return metadata.hasCover;
|
||||
case "director":
|
||||
return metadata.hasPlaybackAsset;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
export const getCreationStageStates = (project) => {
|
||||
const metadata = getStageMetadata(project);
|
||||
return CREATION_STAGE_KEYS.map((key, index) => {
|
||||
@@ -158,6 +173,7 @@ export const getCreationStageStates = (project) => {
|
||||
key,
|
||||
index,
|
||||
isLocked,
|
||||
isCompleted: getStageCompletionState(key, metadata),
|
||||
description:
|
||||
isLocked && lockedDescription ? lockedDescription : description,
|
||||
lockedDescription,
|
||||
@@ -198,6 +214,26 @@ export const getStageAction = (key, project) => {
|
||||
|
||||
export const findFirstUnlockedStageIndex = (project) => {
|
||||
const stages = getCreationStageStates(project);
|
||||
const index = stages.findIndex((stage) => !stage.isLocked);
|
||||
return index === -1 ? 0 : index;
|
||||
if (!stages.length) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const actionableIndex = stages.findIndex(
|
||||
(stage) => !stage.isCompleted && !stage.isLocked
|
||||
);
|
||||
if (actionableIndex !== -1) {
|
||||
return actionableIndex;
|
||||
}
|
||||
|
||||
const firstIncomplete = stages.findIndex((stage) => !stage.isCompleted);
|
||||
if (firstIncomplete !== -1) {
|
||||
return firstIncomplete;
|
||||
}
|
||||
|
||||
const firstUnlocked = stages.findIndex((stage) => !stage.isLocked);
|
||||
if (firstUnlocked !== -1) {
|
||||
return firstUnlocked;
|
||||
}
|
||||
|
||||
return stages.length - 1;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user