41 lines
1.6 KiB
React
41 lines
1.6 KiB
React
import { TemplatePage as FoodTemplatePage } from "../../../../../packages/template-acheng-campus-food/taro/index.tsx";
|
|
import { TemplatePage as EditorialTemplatePage } from "../../../../../packages/template-linjing-editorial/taro/index.tsx";
|
|
import React from "react";
|
|
import { Inquiry } from "../../../../taro/src/components/Inquiry.tsx";
|
|
import { Records } from "../../../../taro/src/components/Records.tsx";
|
|
import { Success } from "../../../../taro/src/components/Success.tsx";
|
|
import { TemplateAssetContext } from "./taro-web-components.jsx";
|
|
|
|
function pageContent({ workspace, page }) {
|
|
if (page === "inquiry") return <Inquiry workspace={workspace} preview />;
|
|
if (page === "records") return <Records workspace={workspace} preview />;
|
|
if (page === "success") return <Success workspace={workspace} preview />;
|
|
return null;
|
|
}
|
|
|
|
function FoodPreview(props) {
|
|
return (
|
|
<TemplateAssetContext.Provider value="acheng-campus-food">
|
|
<FoodTemplatePage {...props}>{pageContent(props)}</FoodTemplatePage>
|
|
</TemplateAssetContext.Provider>
|
|
);
|
|
}
|
|
function EditorialPreview(props) {
|
|
return (
|
|
<TemplateAssetContext.Provider value="linjing-editorial">
|
|
<EditorialTemplatePage {...props}>{pageContent(props)}</EditorialTemplatePage>
|
|
</TemplateAssetContext.Provider>
|
|
);
|
|
}
|
|
|
|
export function resolveTemplateRenderer(workspace) {
|
|
const config = workspace?.brand?.config;
|
|
const key =
|
|
config && typeof config === "object" && !Array.isArray(config)
|
|
? config.visualTemplateKey
|
|
: undefined;
|
|
if (key === "acheng-campus-food") return FoodPreview;
|
|
if (key === "linjing-editorial") return EditorialPreview;
|
|
return null;
|
|
}
|