"use client";
import React, {
  useState,
  useRef,
  useEffect,
  useMemo,
  useCallback,
  Fragment,
  RefObject,
} from "react";

import { UserSwitchOutlined } from '@ant-design/icons';
import {  Modal } from "antd";
import {replaceUrl} from '@/app/utils/index'

export function UserOut(props: { globalStore: any; chatStore: any }) {
  const {globalStore,chatStore} = props;
  return <UserSwitchOutlined className="cursor-pointer" onClick={() => {
    Modal.confirm({
      title: '确认退出当前用户吗？',
      onOk() {
        localStorage.clear();
        window.sessionStorage.clear();
        // globalStore.setSelectedAppId('1881234567890');
        globalStore.setSelectedAppId('');
        chatStore.clearSessions();
        
        window.location.replace(`${replaceUrl}?redirectUrl=${encodeURIComponent(window.location.href)}`);
        // const originUrl = window.location.origin;
        // window.open(originUrl + '/#/login', '_self');
      },
    });
    }} />
}