feat: Introduce course marketing features with dedicated metadata, image generation, and UI in both studio and experience apps.
This commit is contained in:
@@ -53,16 +53,36 @@ export default function BackgroundTasksPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const getStatusBadge = (status?: string) => {
|
||||
const getStatusBadge = (task: BackgroundTask) => {
|
||||
const status = task.video_generation_status || task.transcription_status;
|
||||
const progress = task.generation_progress || 0;
|
||||
|
||||
switch (status) {
|
||||
case 'processing':
|
||||
return <span className="bg-blue-100 text-blue-800 px-2 py-1 rounded-full text-xs font-semibold flex items-center gap-1"><Loader2 className="w-3 h-3 animate-spin" /> Processing</span>;
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className="bg-blue-100 text-blue-800 px-2 py-1 rounded-full text-xs font-semibold flex items-center gap-1 w-fit">
|
||||
<Loader2 className="w-3 h-3 animate-spin" /> Processing
|
||||
</span>
|
||||
{task.video_generation_status === 'processing' && (
|
||||
<div className="w-full bg-gray-200 rounded-full h-1.5 mt-1 max-w-[150px]">
|
||||
<div
|
||||
className="bg-blue-600 h-1.5 rounded-full transition-all duration-500 ease-out"
|
||||
style={{ width: `${progress}%` }}
|
||||
></div>
|
||||
<div className="text-[10px] text-gray-400 mt-1 font-medium">{progress}% completo</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
case 'queued':
|
||||
return <span className="bg-yellow-100 text-yellow-800 px-2 py-1 rounded-full text-xs font-semibold">Queued</span>;
|
||||
return <span className="bg-yellow-100 text-yellow-800 px-2 py-1 rounded-full text-xs font-semibold w-fit">Queued</span>;
|
||||
case 'failed':
|
||||
return <span className="bg-red-100 text-red-800 px-2 py-1 rounded-full text-xs font-semibold">Failed</span>;
|
||||
return <span className="bg-red-100 text-red-800 px-2 py-1 rounded-full text-xs font-semibold w-fit">Failed</span>;
|
||||
case 'completed':
|
||||
return <span className="bg-green-100 text-green-800 px-2 py-1 rounded-full text-xs font-semibold w-fit">Completed</span>;
|
||||
default:
|
||||
return <span className="bg-gray-100 text-gray-800 px-2 py-1 rounded-full text-xs font-semibold">{status}</span>;
|
||||
return <span className="bg-gray-100 text-gray-800 px-2 py-1 rounded-full text-xs font-semibold w-fit">{status}</span>;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -109,7 +129,7 @@ export default function BackgroundTasksPage() {
|
||||
<div className="text-xs text-gray-400 font-mono mt-1">{task.id}</div>
|
||||
</td>
|
||||
<td className="px-6 py-4 whitespace-nowrap">
|
||||
{getStatusBadge(task.transcription_status)}
|
||||
{getStatusBadge(task)}
|
||||
</td>
|
||||
<td className="px-6 py-4 text-sm text-gray-500">
|
||||
{format(new Date(task.updated_at), 'MMM d, h:mm a')}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import Link from 'next/link';
|
||||
import { useParams, useRouter } from 'next/navigation';
|
||||
import { cmsApi, Lesson, Block, GradingCategory, LibraryBlock, Rubric, RubricLevel, RubricCriterion, LessonDependency } from '@/lib/api';
|
||||
import { cmsApi, Lesson, Block, GradingCategory, LibraryBlock, Rubric, RubricLevel, RubricCriterion, LessonDependency, getImageUrl } from '@/lib/api';
|
||||
import {
|
||||
Layout,
|
||||
CheckCircle2,
|
||||
@@ -40,6 +40,7 @@ import PeerReviewBlock from "@/components/blocks/PeerReviewBlock";
|
||||
import SaveToLibraryModal from "@/components/modals/SaveToLibraryModal";
|
||||
import LibraryPanel from "@/components/LibraryPanel";
|
||||
import Modal from "@/components/Modal";
|
||||
import MediaPlayer from "@/components/MediaPlayer";
|
||||
|
||||
export default function LessonEditor({ params }: { params: { id: string; lessonId: string } }) {
|
||||
const [lesson, setLesson] = useState<Lesson | null>(null);
|
||||
@@ -1152,6 +1153,21 @@ export default function LessonEditor({ params }: { params: { id: string; lessonI
|
||||
</div>
|
||||
))}
|
||||
|
||||
{!editMode && blocks.length === 0 && lesson.content_url && (
|
||||
<div className="animate-in fade-in slide-in-from-bottom-6 duration-700 delay-100 mb-12">
|
||||
<MediaPlayer
|
||||
src={getImageUrl(lesson.content_url)}
|
||||
type={lesson.content_type || 'video'}
|
||||
transcription={lesson.transcription}
|
||||
/>
|
||||
<div className="mt-6 p-6 glass-card bg-blue-500/5 border-blue-500/10 text-center rounded-[2rem]">
|
||||
<p className="text-[10px] font-black uppercase tracking-widest text-blue-600 dark:text-blue-400">
|
||||
AI Generated Content Preview
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{editMode && (
|
||||
<div className="pt-20 border-t border-slate-100 dark:border-white/5">
|
||||
<div className="flex flex-col items-center gap-12">
|
||||
|
||||
@@ -0,0 +1,363 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import {
|
||||
cmsApi,
|
||||
Course,
|
||||
getImageUrl
|
||||
} from "@/lib/api";
|
||||
import {
|
||||
Save,
|
||||
Sparkles,
|
||||
Image as ImageIcon,
|
||||
Type,
|
||||
Target,
|
||||
AlertCircle,
|
||||
CheckCircle2,
|
||||
Clock,
|
||||
Award,
|
||||
Zap,
|
||||
Maximize,
|
||||
Monitor,
|
||||
Square,
|
||||
Smartphone
|
||||
} from "lucide-react";
|
||||
|
||||
interface MarketingTabProps {
|
||||
courseId: string;
|
||||
}
|
||||
|
||||
const RESOLUTIONS = [
|
||||
{ label: "16:9 Landscape", width: 1024, height: 576, icon: Monitor },
|
||||
{ label: "1:1 Square", width: 1024, height: 1024, icon: Square },
|
||||
{ label: "4:3 Classic", width: 1024, height: 768, icon: Maximize },
|
||||
{ label: "9:16 Portrait", width: 576, height: 1024, icon: Smartphone },
|
||||
];
|
||||
|
||||
export default function MarketingTab({ courseId }: MarketingTabProps) {
|
||||
const [course, setCourse] = useState<Course | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [prompt, setPrompt] = useState("");
|
||||
const [selectedRes, setSelectedRes] = useState(RESOLUTIONS[0]);
|
||||
const [isGenerating, setIsGenerating] = useState(false);
|
||||
|
||||
// Form states
|
||||
const [objectives, setObjectives] = useState("");
|
||||
const [requirements, setRequirements] = useState("");
|
||||
const [duration, setDuration] = useState("");
|
||||
const [modulesSummary, setModulesSummary] = useState("");
|
||||
const [certificationInfo, setCertificationInfo] = useState("");
|
||||
|
||||
const loadCourse = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const data = await cmsApi.getCourse(courseId);
|
||||
setCourse(data);
|
||||
|
||||
// Initialize form from metadata
|
||||
const meta = data.marketing_metadata || {};
|
||||
setObjectives(meta.objectives || "");
|
||||
setRequirements(meta.requirements || "");
|
||||
setDuration(meta.duration || "");
|
||||
setModulesSummary(meta.modules_summary || "");
|
||||
setCertificationInfo(meta.certification_info || "");
|
||||
|
||||
if (data.generation_status === 'processing' || data.generation_status === 'queued') {
|
||||
setIsGenerating(true);
|
||||
} else {
|
||||
setIsGenerating(false);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to load course", err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
loadCourse();
|
||||
}, [courseId]);
|
||||
|
||||
// Polling for generation status
|
||||
useEffect(() => {
|
||||
let interval: NodeJS.Timeout;
|
||||
if (isGenerating) {
|
||||
interval = setInterval(async () => {
|
||||
const updated = await cmsApi.getCourse(courseId);
|
||||
setCourse(updated);
|
||||
if (updated.generation_status === 'completed' || updated.generation_status === 'error') {
|
||||
setIsGenerating(false);
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
return () => clearInterval(interval);
|
||||
}, [isGenerating, courseId]);
|
||||
|
||||
const handleSaveMetadata = async () => {
|
||||
try {
|
||||
setSaving(true);
|
||||
await cmsApi.updateCourse(courseId, {
|
||||
marketing_metadata: {
|
||||
objectives,
|
||||
requirements,
|
||||
duration,
|
||||
modules_summary: modulesSummary,
|
||||
certification_info: certificationInfo
|
||||
}
|
||||
});
|
||||
alert("Marketing metadata saved successfully!");
|
||||
} catch (err) {
|
||||
console.error("Save failed", err);
|
||||
alert("Failed to save changes.");
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleGenerateImage = async () => {
|
||||
try {
|
||||
setIsGenerating(true);
|
||||
await cmsApi.generateCourseImage(courseId, {
|
||||
prompt: prompt || course?.title,
|
||||
width: selectedRes.width,
|
||||
height: selectedRes.height
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("Generation failed", err);
|
||||
alert("Failed to start generation.");
|
||||
setIsGenerating(false);
|
||||
}
|
||||
};
|
||||
|
||||
if (loading) return (
|
||||
<div className="flex items-center justify-center py-20">
|
||||
<div className="w-12 h-12 border-4 border-blue-500/20 border-t-blue-500 rounded-full animate-spin" />
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="space-y-12 animate-in fade-in slide-in-from-bottom-4 duration-700">
|
||||
|
||||
{/* ── SECTION: COURSE IMAGE AI ── */}
|
||||
<div className="bg-white dark:bg-white/5 border border-slate-200 dark:border-white/10 rounded-[3rem] overflow-hidden shadow-sm hover:shadow-xl transition-all duration-500">
|
||||
<div className="p-10 lg:p-14 flex flex-col lg:flex-row gap-12">
|
||||
|
||||
{/* Left: Preview */}
|
||||
<div className="lg:w-1/2 space-y-6">
|
||||
<div className="group relative aspect-video rounded-[2.5rem] bg-slate-100 dark:bg-black/20 overflow-hidden border border-slate-200 dark:border-white/5 shadow-inner">
|
||||
{course?.course_image_url ? (
|
||||
<img
|
||||
src={getImageUrl(course.course_image_url)}
|
||||
className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-[2s]"
|
||||
alt="Course Preview"
|
||||
/>
|
||||
) : (
|
||||
<div className="absolute inset-0 flex flex-col items-center justify-center text-slate-400 gap-4">
|
||||
<ImageIcon size={64} className="opacity-20 stroke-[1]" />
|
||||
<p className="text-[10px] font-black uppercase tracking-[0.3em] opacity-40">No preview generated</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isGenerating && (
|
||||
<div className="absolute inset-0 bg-white/60 dark:bg-black/80 backdrop-blur-md flex flex-col items-center justify-center p-12 text-center">
|
||||
<Zap size={48} className="text-blue-500 animate-pulse mb-6" />
|
||||
<h4 className="text-xl font-black uppercase tracking-tight text-slate-900 dark:text-white mb-4">Generating Visual Intelligence...</h4>
|
||||
|
||||
<div className="w-full h-3 bg-slate-200 dark:bg-white/10 rounded-full overflow-hidden mb-4 border border-white/10">
|
||||
<div
|
||||
className="h-full bg-gradient-to-r from-blue-600 to-indigo-500 transition-all duration-500 ease-out"
|
||||
style={{ width: `${course?.generation_progress || 0}%` }}
|
||||
/>
|
||||
</div>
|
||||
<p className="text-[10px] font-black uppercase tracking-[0.2em] text-blue-600 dark:text-blue-400">
|
||||
Analysis Phase: {course?.generation_progress || 0}% Complete
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{course?.generation_error && (
|
||||
<div className="p-6 bg-red-50 dark:bg-red-500/10 border border-red-200 dark:border-red-500/20 rounded-3xl flex items-center gap-4 text-red-600 dark:text-red-400">
|
||||
<AlertCircle size={24} />
|
||||
<div className="flex-1">
|
||||
<p className="text-[10px] font-black uppercase tracking-widest mb-1">Neural Engine Error</p>
|
||||
<p className="text-sm font-medium">{course.generation_error}</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Right: Controls */}
|
||||
<div className="lg:w-1/2 space-y-10">
|
||||
<div>
|
||||
<h3 className="text-3xl font-black uppercase tracking-tighter text-slate-900 dark:text-white flex items-center gap-4">
|
||||
<Sparkles className="text-blue-500" />
|
||||
AI Visual Identity
|
||||
</h3>
|
||||
<p className="text-slate-500 dark:text-gray-500 mt-2 font-medium">Generate a cinematic landing page image using Stable Diffusion.</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
<label className="text-[10px] font-black uppercase tracking-[0.2em] text-slate-400 dark:text-gray-500 ml-2">Creative Prompt</label>
|
||||
<textarea
|
||||
value={prompt}
|
||||
onChange={(e) => setPrompt(e.target.value)}
|
||||
placeholder={course?.title || "Describe the visual mood of your course..."}
|
||||
className="w-full h-32 bg-slate-50 dark:bg-white/5 border border-slate-200 dark:border-white/10 rounded-[2rem] p-6 text-slate-900 dark:text-white focus:outline-none focus:ring-4 focus:ring-blue-500/10 transition-all resize-none font-medium shadow-inner"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
<label className="text-[10px] font-black uppercase tracking-[0.2em] text-slate-400 dark:text-gray-500 ml-2">Resolution Matrix</label>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
{RESOLUTIONS.map((res) => {
|
||||
const Icon = res.icon;
|
||||
const isSelected = selectedRes.label === res.label;
|
||||
return (
|
||||
<button
|
||||
key={res.label}
|
||||
onClick={() => setSelectedRes(res)}
|
||||
className={`p-5 rounded-3xl border transition-all flex items-center gap-4 group ${isSelected
|
||||
? "bg-blue-600 border-blue-500 text-white shadow-xl shadow-blue-500/20 active:scale-95"
|
||||
: "bg-white dark:bg-white/5 border-slate-200 dark:border-white/10 text-slate-600 dark:text-gray-400 hover:bg-slate-50 dark:hover:bg-white/10 active:scale-95 shadow-sm"
|
||||
}`}
|
||||
>
|
||||
<div className={`p-2 rounded-xl ${isSelected ? "bg-white/20" : "bg-slate-100 dark:bg-white/10 group-hover:scale-110 transition-transform"}`}>
|
||||
<Icon size={20} />
|
||||
</div>
|
||||
<div className="text-left">
|
||||
<p className="text-xs font-black uppercase tracking-tight">{res.label}</p>
|
||||
<p className={`text-[10px] font-black opacity-60 ${isSelected ? "text-white" : "text-slate-400"}`}>{res.width}x{res.height}</p>
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={handleGenerateImage}
|
||||
disabled={isGenerating}
|
||||
className={`w-full py-5 bg-slate-900 dark:bg-white text-white dark:text-slate-900 rounded-[2rem] font-black text-[10px] uppercase tracking-[0.3em] shadow-2xl transition-all active:scale-[0.98] flex items-center justify-center gap-4 group ${isGenerating ? 'opacity-50 cursor-not-allowed' : 'hover:scale-[1.02]'}`}
|
||||
>
|
||||
{isGenerating ? (
|
||||
<>
|
||||
<div className="w-5 h-5 border-2 border-slate-300 border-t-blue-500 rounded-full animate-spin" />
|
||||
Synthesizing...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Sparkles size={20} className="group-hover:rotate-12 transition-transform" />
|
||||
Energize Neural Engine
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ── SECTION: CORE MARKETING DATA ── */}
|
||||
<div className="bg-white dark:bg-white/5 border border-slate-200 dark:border-white/10 rounded-[3rem] p-10 lg:p-14 space-y-12 shadow-sm">
|
||||
<div className="flex items-center justify-between gap-6 flex-wrap">
|
||||
<div>
|
||||
<h3 className="text-3xl font-black uppercase tracking-tighter text-slate-900 dark:text-white flex items-center gap-4">
|
||||
<Megaphone className="text-indigo-500" />
|
||||
Marketing Manifesto
|
||||
</h3>
|
||||
<p className="text-slate-500 dark:text-gray-500 mt-2 font-medium">Define the core value proposition and educational objectives.</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={handleSaveMetadata}
|
||||
disabled={saving}
|
||||
className="flex items-center gap-3 px-10 py-4 bg-indigo-600 hover:bg-indigo-500 text-white rounded-[1.5rem] font-black text-[10px] uppercase tracking-[0.2em] shadow-xl shadow-indigo-500/30 transition-all active:scale-95 disabled:opacity-50"
|
||||
>
|
||||
{saving ? <div className="w-4 h-4 border-2 border-white/20 border-t-white rounded-full animate-spin" /> : <Save size={18} />}
|
||||
{saving ? 'Saving Manifest...' : 'Update Manifesto'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-10">
|
||||
<div className="space-y-6">
|
||||
<div className="space-y-3">
|
||||
<label className="text-[10px] font-black uppercase tracking-[0.2em] text-indigo-500 dark:text-indigo-400 ml-2 flex items-center gap-2">
|
||||
<Target size={14} /> Learning Objectives
|
||||
</label>
|
||||
<textarea
|
||||
value={objectives}
|
||||
onChange={(e) => setObjectives(e.target.value)}
|
||||
placeholder="What will the student achieve?"
|
||||
className="w-full h-40 bg-slate-50 dark:bg-black/20 border border-slate-200 dark:border-white/5 rounded-[2rem] p-6 text-slate-800 dark:text-white focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all resize-none font-medium shadow-inner"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3">
|
||||
<label className="text-[10px] font-black uppercase tracking-[0.2em] text-amber-500 ml-2 flex items-center gap-2">
|
||||
<Zap size={14} /> Requirements & Prerequisites
|
||||
</label>
|
||||
<textarea
|
||||
value={requirements}
|
||||
onChange={(e) => setRequirements(e.target.value)}
|
||||
placeholder="What should they know before starting?"
|
||||
className="w-full h-40 bg-slate-50 dark:bg-black/20 border border-slate-200 dark:border-white/5 rounded-[2rem] p-6 text-slate-800 dark:text-white focus:outline-none focus:ring-4 focus:ring-amber-500/10 transition-all resize-none font-medium shadow-inner"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-8">
|
||||
<div className="space-y-3">
|
||||
<label className="text-[10px] font-black uppercase tracking-[0.2em] text-slate-400 dark:text-gray-500 ml-2 flex items-center gap-2">
|
||||
<Clock size={14} /> Estimated Duration
|
||||
</label>
|
||||
<input
|
||||
value={duration}
|
||||
onChange={(e) => setDuration(e.target.value)}
|
||||
placeholder="e.g. 10 weeks, 40 hours"
|
||||
className="w-full bg-slate-50 dark:bg-black/20 border border-slate-200 dark:border-white/5 rounded-[1.5rem] px-6 py-4 text-slate-800 dark:text-white focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all font-black uppercase tracking-tight shadow-inner"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3">
|
||||
<label className="text-[10px] font-black uppercase tracking-[0.2em] text-slate-400 dark:text-gray-500 ml-2 flex items-center gap-2">
|
||||
<Award size={14} /> Certification Info
|
||||
</label>
|
||||
<textarea
|
||||
value={certificationInfo}
|
||||
onChange={(e) => setCertificationInfo(e.target.value)}
|
||||
placeholder="Details about the final certificate or credential."
|
||||
className="w-full h-32 bg-slate-50 dark:bg-black/20 border border-slate-200 dark:border-white/5 rounded-[2rem] p-6 text-slate-800 dark:text-white focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all resize-none font-medium shadow-inner"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="p-8 bg-blue-50 dark:bg-blue-500/5 rounded-[2.5rem] border border-blue-100 dark:border-blue-500/10">
|
||||
<div className="flex items-center gap-4 mb-4">
|
||||
<div className="w-10 h-10 rounded-xl bg-blue-600 text-white flex items-center justify-center shadow-lg shadow-blue-500/30">
|
||||
<AlertCircle size={20} />
|
||||
</div>
|
||||
<h4 className="font-black uppercase tracking-tight text-blue-900 dark:text-blue-300">Public Preview</h4>
|
||||
</div>
|
||||
<p className="text-sm text-blue-700/70 dark:text-blue-400/70 font-medium leading-relaxed">
|
||||
This information will be displayed on the public landing page. Use compelling language to increase student enrollment.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4 pt-6">
|
||||
<label className="text-[10px] font-black uppercase tracking-[0.2em] text-slate-400 dark:text-gray-500 ml-2 flex items-center gap-2">
|
||||
<Type size={14} /> Modules Deep-Dive (Sales Summary)
|
||||
</label>
|
||||
<textarea
|
||||
value={modulesSummary}
|
||||
onChange={(e) => setModulesSummary(e.target.value)}
|
||||
placeholder="Highlight the key modules and what's unique about them."
|
||||
className="w-full h-40 bg-slate-50 dark:bg-black/20 border border-slate-200 dark:border-white/5 rounded-[2rem] p-8 text-slate-800 dark:text-white focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all resize-none font-medium shadow-inner"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
import { Megaphone } from "lucide-react";
|
||||
@@ -0,0 +1,16 @@
|
||||
"use client";
|
||||
|
||||
import CourseEditorLayout from "@/components/CourseEditorLayout";
|
||||
import MarketingTab from "./MarketingTab";
|
||||
|
||||
export default function MarketingPage({ params }: { params: { id: string } }) {
|
||||
return (
|
||||
<CourseEditorLayout
|
||||
activeTab="marketing"
|
||||
pageTitle="Marketing del Curso"
|
||||
pageDescription="Configura la landing page y genera activos visuales con IA."
|
||||
>
|
||||
<MarketingTab courseId={params.id} />
|
||||
</CourseEditorLayout>
|
||||
);
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import { cmsApi, Course } from "@/lib/api";
|
||||
|
||||
type TabKey =
|
||||
| "outline"
|
||||
| "marketing"
|
||||
| "grading"
|
||||
| "rubrics"
|
||||
| "calendar"
|
||||
@@ -73,6 +74,7 @@ export default function CourseEditorLayout({
|
||||
icon: BookOpen,
|
||||
tabs: [
|
||||
{ key: "outline", label: "Outline", icon: Layout, href: `/courses/${id}` },
|
||||
{ key: "marketing", label: "Marketing", icon: Megaphone, href: `/courses/${id}/marketing` },
|
||||
{ key: "files", label: "Archivos", icon: Folder, href: `/courses/${id}/files` },
|
||||
{ key: "sessions", label: "Sesiones en Vivo", icon: Video, href: `/courses/${id}/sessions` },
|
||||
],
|
||||
|
||||
@@ -151,6 +151,18 @@ export default function MediaPlayer({ src, type, transcription, locked, onEnded,
|
||||
);
|
||||
}
|
||||
|
||||
if (type === "image") {
|
||||
return (
|
||||
<div className={`relative glass overflow-hidden border border-white/10 ${locked ? 'blur-xl grayscale' : ''}`}>
|
||||
<img
|
||||
src={src}
|
||||
alt="Lesson Content"
|
||||
className="w-full aspect-video object-contain"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={`relative glass overflow-hidden border border-white/10 ${locked ? 'blur-xl grayscale' : ''}`}>
|
||||
{type === "video" ? (
|
||||
|
||||
@@ -16,7 +16,7 @@ interface MediaBlockProps {
|
||||
id: string;
|
||||
title?: string;
|
||||
url: string;
|
||||
type: 'video' | 'audio';
|
||||
type: 'video' | 'audio' | 'image';
|
||||
config: {
|
||||
maxPlays?: number;
|
||||
currentPlays?: number;
|
||||
@@ -44,7 +44,9 @@ interface MediaBlockProps {
|
||||
|
||||
export default function MediaBlock({ title, url, type, config, editMode, onChange, transcription, isGraded }: MediaBlockProps) {
|
||||
const [localPlays, setLocalPlays] = useState(config.currentPlays || 0);
|
||||
const [sourceType, setSourceType] = useState<"url" | "upload">(url.startsWith("/assets/") ? "upload" : "url");
|
||||
const [sourceType, setSourceType] = useState<"url" | "upload">(
|
||||
(url.startsWith("/assets/") || url.includes("/assets/")) ? "upload" : "url"
|
||||
);
|
||||
const maxPlays = config.maxPlays || 0;
|
||||
const isLocked = maxPlays > 0 && localPlays >= maxPlays;
|
||||
|
||||
|
||||
@@ -14,9 +14,12 @@ export const LMS_API_BASE_URL = getApiBaseUrl("3002", process.env.NEXT_PUBLIC_LM
|
||||
export const getImageUrl = (path?: string) => {
|
||||
if (!path) return '';
|
||||
if (path.startsWith('http')) return path;
|
||||
// Map /uploads to /assets if backend stores relative paths
|
||||
// Map uploads to assets if backend stores relative paths
|
||||
// The main.rs serves "uploads" dir at "/assets" route
|
||||
const cleanPath = path.startsWith('/uploads') ? path.replace('/uploads', '/assets') : path;
|
||||
let cleanPath = path;
|
||||
if (cleanPath.startsWith('uploads/')) cleanPath = '/' + cleanPath.replace('uploads/', 'assets/');
|
||||
if (cleanPath.startsWith('/uploads/')) cleanPath = cleanPath.replace('/uploads/', '/assets/');
|
||||
|
||||
const finalPath = cleanPath.startsWith('/') ? cleanPath : `/${cleanPath}`;
|
||||
return `${API_BASE_URL}${finalPath}`;
|
||||
};
|
||||
@@ -34,6 +37,17 @@ export interface Course {
|
||||
certificate_template?: string;
|
||||
price: number;
|
||||
currency: string;
|
||||
marketing_metadata?: {
|
||||
objectives?: string;
|
||||
requirements?: string;
|
||||
duration?: string;
|
||||
modules_summary?: string;
|
||||
certification_info?: string;
|
||||
};
|
||||
course_image_url?: string;
|
||||
generation_status?: 'idle' | 'queued' | 'processing' | 'completed' | 'error';
|
||||
generation_progress?: number;
|
||||
generation_error?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
modules?: Module[];
|
||||
@@ -632,7 +646,8 @@ export const cmsApi = {
|
||||
updateLesson: (id: string, payload: Partial<Lesson>): Promise<Lesson> => apiFetch(`/lessons/${id}`, { method: 'PUT', body: JSON.stringify(payload) }),
|
||||
summarizeLesson: (id: string): Promise<Lesson> => apiFetch(`/lessons/${id}/summarize`, { method: 'POST' }),
|
||||
generateQuiz: (id: string, payload: { context?: string, quiz_type?: string }): Promise<Block[]> => apiFetch(`/lessons/${id}/generate-quiz`, { method: 'POST', body: JSON.stringify(payload) }),
|
||||
generateImage: (id: string, payload: { prompt?: string } = {}): Promise<Lesson> => apiFetch(`/lessons/${id}/generate-image`, { method: 'POST', body: JSON.stringify(payload) }),
|
||||
generateImage: (id: string, payload: { prompt?: string, width?: number, height?: number } = {}): Promise<Lesson> => apiFetch(`/lessons/${id}/generate-image`, { method: 'POST', body: JSON.stringify(payload) }),
|
||||
generateCourseImage: (id: string, payload: { prompt?: string, width?: number, height?: number } = {}): Promise<Course> => apiFetch(`/courses/${id}/generate-image`, { method: 'POST', body: JSON.stringify(payload) }),
|
||||
reviewText: (text: string): Promise<{ suggestion: string, comments: string }> => apiFetch('/api/ai/review-text', { method: 'POST', body: JSON.stringify({ text }) }),
|
||||
deleteModule: (id: string): Promise<void> => apiFetch(`/modules/${id}`, { method: 'DELETE' }),
|
||||
deleteLesson: (id: string): Promise<void> => apiFetch(`/lessons/${id}`, { method: 'DELETE' }),
|
||||
@@ -961,5 +976,6 @@ export interface BackgroundTask {
|
||||
course_title?: string;
|
||||
transcription_status?: 'idle' | 'queued' | 'processing' | 'failed' | 'completed';
|
||||
video_generation_status?: 'idle' | 'queued' | 'processing' | 'failed' | 'completed';
|
||||
generation_progress?: number;
|
||||
updated_at: string;
|
||||
}
|
||||
Reference in New Issue
Block a user