import { QuestionCircleOutlined } from '@ant-design/icons';
import { SelectLang as UmiSelectLang } from '@umijs/max';
import React from 'react';
import { Select } from 'antd';
import {useModel} from "@@/exports";
export type SiderTheme = 'light' | 'dark';
import {postUserSetUserRole} from "@/services/system/User";

export const SelectLang = () => {
  return (
    <UmiSelectLang
      style={{
        padding: 4,
      }}
    />
  );
};

export const Question = () => {
  return (
    <div
      style={{
        display: 'flex',
        height: 26,
      }}
      onClick={() => {
        window.open('https://pro.ant.design/docs/getting-started');
      }}
    >
      <QuestionCircleOutlined />
    </div>
  );
};

export const SelectRole = () => {

  const { initialState } = useModel('@@initialState');
  const { currentUser } = initialState || {};

  return (
    <>
      {
        currentUser && (
          <Select
            defaultValue={currentUser.roleId}
            options={currentUser?.roles || []}
            onSelect={value => {
              postUserSetUserRole({roleId: value}).then((resp) => {
                console.log(resp)
              })
            }}
          />
        )
      }
    </>

  );
};
