diff --git a/components/FamousTemplate.tsx b/components/FamousTemplate.tsx index 3cb3b15..b96e2c8 100644 --- a/components/FamousTemplate.tsx +++ b/components/FamousTemplate.tsx @@ -6,6 +6,8 @@ import { X } from "lucide-react" import TemplatePreviewModal from "@/components/common/TemplatePreviewModal" import { PcTemplateModal } from "@/components/ChatInputBox/PcTemplateModal" import { useTemplateStoryServiceHook } from "@/app/service/Interaction/templateStoryService" +import { useAppDispatch } from "@/lib/store/hooks" +import { selectTemplateById } from "@/lib/store/creationTemplateSlice" /** * A compact template showcase with a header and link to all templates. @@ -14,6 +16,7 @@ import { useTemplateStoryServiceHook } from "@/app/service/Interaction/templateS */ const FamousTemplate: React.FC = () => { const { templateStoryList, getTemplateStoryList, isLoading } = useTemplateStoryServiceHook() + const dispatch = useAppDispatch() const [isModalOpen, setIsModalOpen] = useState(false) const [initialTemplateId, setInitialTemplateId] = useState(undefined) @@ -127,8 +130,8 @@ const FamousTemplate: React.FC = () => { title={active.name} description={active.generateText || active.name} onPrimaryAction={() => { - setInitialTemplateId(active.id || active.template_id) - setIsModalOpen(true) + const id = active.id || active.template_id + dispatch(selectTemplateById(id)) setActiveTemplateId(null) }} primaryLabel="Try it Free" diff --git a/components/HomeBanner.tsx b/components/HomeBanner.tsx index 7a6e41f..bdc998b 100644 --- a/components/HomeBanner.tsx +++ b/components/HomeBanner.tsx @@ -159,11 +159,13 @@ export default function HomeBanner() { } return ( -
+
{/* Banner overlay - stacked above */}
([]); @@ -83,6 +85,8 @@ export default function VideoCreationForm() { const propInputRef = useRef(null); const mainTextInputRef = useRef(null); const { uploadFile } = useUploadFile(); + const dispatch = useAppDispatch(); + const selectedTemplateId = useAppSelector(state => state.creationTemplate.selectedTemplateId); /** Clear current template related states */ const clearTemplateSelection = () => { @@ -111,6 +115,16 @@ export default function VideoCreationForm() { }, 0); }; + /** Apply template selected from global store (e.g., FamousTemplate) */ + useEffect(() => { + if (!selectedTemplateId) return; + const selected = templateStoryList.find(t => (t.id || t.template_id) === selectedTemplateId); + if (!selected) return; + clearTemplateSelection(); + applyTemplateSelection(selected as StoryTemplateEntity); + dispatch(clearSelection()); + }, [selectedTemplateId, templateStoryList]); + /** Handle file upload */ const handleFileUpload = (event: React.ChangeEvent, type: PhotoType) => { const files = event.target.files; @@ -387,7 +401,7 @@ export default function VideoCreationForm() { {shouldShowInput && (
{isTemplateSelected?.freeInput[0].input_name && ( -
{isTemplateSelected?.freeInput[0].input_name}
+
{isTemplateSelected?.freeInput[0].input_name}
)}