import { getCurrentInstance } from "@tarojs/runtime";
import { useEffect, useState } from "react";
import { business } from "@/services";
import { RichText } from "@tarojs/components";

export default function Page() {
  const router = getCurrentInstance()?.router;
  const agreementId = router?.params
    ?.agreementId as BusinessAPI.AgreementVO["agreementId"];

  const [agreementVO, setAgreementVO] = useState<BusinessAPI.AgreementVO>();

  useEffect(() => {
    if (agreementId) {
      business.agreement
        .showAgreement({ agreementShowQry: { agreementId } })
        .then((res) => {
          setAgreementVO(res.data.data);
        });
    }
  }, [agreementId]);

  return <RichText nodes={agreementVO?.content}></RichText>;
}
