Files
persionalBrand/apps/taro/src/components/Success.tsx
T

37 lines
1.3 KiB
TypeScript

import { View, Text, Button } from "@tarojs/components";
import Taro from "@tarojs/taro";
import type { RuntimeWorkspace } from "@personal-brand/types";
import { presentation, object, text } from "../runtime/content";
import { brandSlug } from "../runtime/api";
import { navigate } from "../runtime/navigation";
export function Success({
workspace,
preview = false,
}: {
workspace: RuntimeWorkspace;
preview?: boolean;
}) {
const p = presentation(workspace, "success");
const submitted =
preview ||
Boolean(text(object(Taro.getStorageSync<unknown>(`latestInquiry:${brandSlug()}`)).id));
if (!submitted)
return (
<View className="runtime-state">
尚未提交咨询<Button onClick={() => navigate("inquiry")}>填写需求</Button>
</View>
);
return (
<View className="success-page">
<Text className="success-symbol">✓</Text>
<Text className="eyebrow">{p.eyebrow}</Text>
<Text className="form-title">{p.title || "已收到你的需求"}</Text>
<Text className="form-subtitle">{p.intro}</Text>
<Button className="submit-button" onClick={() => navigate("records")}>
{p.recordsAction || "查看咨询记录"}
</Button>
<Button onClick={() => navigate("home")}>{p.homeAction || "返回首页"}</Button>
</View>
);
}