summaryrefslogtreecommitdiff
path: root/apps/web/src/types
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/src/types')
-rw-r--r--apps/web/src/types/project.ts15
-rw-r--r--apps/web/src/types/timeline.ts31
2 files changed, 39 insertions, 7 deletions
diff --git a/apps/web/src/types/project.ts b/apps/web/src/types/project.ts
index 8b1eff3f..e208be3a 100644
--- a/apps/web/src/types/project.ts
+++ b/apps/web/src/types/project.ts
@@ -1,7 +1,8 @@
-export interface TProject {
- id: string;
- name: string;
- thumbnail: string;
- createdAt: Date;
- updatedAt: Date;
-}
+export interface TProject {
+ id: string;
+ name: string;
+ thumbnail: string;
+ createdAt: Date;
+ updatedAt: Date;
+ mediaItems?: string[];
+}
diff --git a/apps/web/src/types/timeline.ts b/apps/web/src/types/timeline.ts
index 7079f091..a759de21 100644
--- a/apps/web/src/types/timeline.ts
+++ b/apps/web/src/types/timeline.ts
@@ -123,3 +123,34 @@ export function ensureMainTrack(tracks: TimelineTrack[]): TimelineTrack[] {
return tracks;
}
+
+// Timeline validation utilities
+export function canElementGoOnTrack(
+ elementType: "text" | "media",
+ trackType: TrackType
+): boolean {
+ if (elementType === "text") {
+ return trackType === "text";
+ } else if (elementType === "media") {
+ return trackType === "media" || trackType === "audio";
+ }
+ return false;
+}
+
+export function validateElementTrackCompatibility(
+ element: { type: "text" | "media" },
+ track: { type: TrackType }
+): { isValid: boolean; errorMessage?: string } {
+ const isValid = canElementGoOnTrack(element.type, track.type);
+
+ if (!isValid) {
+ const errorMessage =
+ element.type === "text"
+ ? "Text elements can only be placed on text tracks"
+ : "Media elements can only be placed on media or audio tracks";
+
+ return { isValid: false, errorMessage };
+ }
+
+ return { isValid: true };
+}