-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #380 from BinaryStudioAcademy/task/OV-349-add-logi…
…c-to-modal-warning OV-349: Add warning modal when the scenes exceed the scripts
- Loading branch information
Showing
3 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
frontend/src/bundles/studio/helpers/scenes-exceed-scripts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { type Scene, type Script } from '../types/types.js'; | ||
|
||
const INITIAL_DURATION = 0; | ||
|
||
const scenesExceedScripts = (scenes: Scene[], scripts: Script[]): boolean => { | ||
const totalScenesDuration = scenes.reduce( | ||
(accumulator, scene) => accumulator + scene.duration, | ||
INITIAL_DURATION, | ||
); | ||
const totalScriptsDuration = scripts.reduce( | ||
(accumulator, script) => accumulator + script.duration, | ||
INITIAL_DURATION, | ||
); | ||
|
||
return totalScenesDuration > totalScriptsDuration; | ||
}; | ||
|
||
export { scenesExceedScripts }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters