// components/GlobalModal.tsx
import { useModalStore } from '@/store/modalStore';
import WemetaModal from '@/components/WemetaModal'
import { RootPortal } from '@tarojs/components';
export function GlobalModal() {
  const { isVisible, config } = useModalStore((state) => ({ isVisible: state.isVisible, config: state.config }));
  const { onConfirm, onCancel } = useModalStore((state) => state.actions);


  if(!config?.content){
    return <></>
  }

  return (
    <RootPortal className={`taro-portal-container taro-portal-container-ztop`}>
      <WemetaModal show={isVisible} cancelText={config.cancelText} confirmText={config.confirmText}  showCancelButton={config.showCancelButton} onConfirm={()=> onConfirm() } onCancel={()=> onCancel()} >
        <>{config.content}</>
      </WemetaModal>
      </RootPortal>
  );
}
