import React from "react";
import Taro from "@tarojs/taro";
import Page from "@/layouts/index";
import { View, RichText } from "@tarojs/components";
import { getTaCheckStandById } from "@/services/tacheckstand";

export default (props) => {
  const router = Taro.useRouter();
  const { id } = router.params;
  const [loading, setLoading] = React.useState(false);
  const [detail, setDetail] = React.useState();

  React.useEffect(() => {
    setLoading(true);

    // ID 固定是 1
    getTaCheckStandById(id)
      .then((res) => {
        setDetail(res);
        setLoading(false);
      })
      .catch(() => {
        setLoading(false);
      });
  }, []);

  return (
    <Page loading={loading}>
      <View style={{ padding: "var(--main-space)" }}>
        <RichText style={{ lineHeight: "2em" }} nodes={detail?.content} />
      </View>
    </Page>
  );
};
