import { useEffect, useState } from 'react'; import { track } from '../lib/analytics'; import { getCustomerServicePhone, loadCustomerServicePhone, openWecomCustomerService, } from '../lib/customer-service'; type ContactCustomerSheetProps = { orderId?: string; orderNo?: string; onClose: () => void; }; export default function ContactCustomerSheet({ orderId, onClose }: ContactCustomerSheetProps) { const [phone, setPhone] = useState(getCustomerServicePhone); useEffect(() => { void loadCustomerServicePhone().then(setPhone); }, []); const tel = phone.replace(/-/g, ''); function openPhone() { track('cs_contact', { type: 'phone', orderId }); window.location.href = `tel:${tel}`; onClose(); } function openOnline() { track('cs_contact', { type: 'wecom_kf', orderId }); if (openWecomCustomerService()) { onClose(); } } return (