index.tsx 937 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { ChatContext } from '@/app/chat-context';
  2. import { StarsSvg } from '@/components/icons';
  3. import Icon, { AppstoreFilled } from '@ant-design/icons';
  4. import { Radio } from 'antd';
  5. import { useContext } from 'react';
  6. import './index.css';
  7. export default function ModeTab() {
  8. const { isContract, setIsContract, scene } = useContext(ChatContext);
  9. const isShow = scene && ['chat_with_db_execute', 'chat_dashboard'].includes(scene as string);
  10. if (!isShow) {
  11. return null;
  12. }
  13. return (
  14. <Radio.Group
  15. value={isContract}
  16. defaultValue={true}
  17. buttonStyle='solid'
  18. onChange={() => {
  19. setIsContract(!isContract);
  20. }}
  21. >
  22. <Radio.Button value={false}>
  23. <Icon component={StarsSvg} className='mr-1' />
  24. Preview
  25. </Radio.Button>
  26. <Radio.Button value={true}>
  27. <AppstoreFilled className='mr-1' />
  28. Editor
  29. </Radio.Button>
  30. </Radio.Group>
  31. );
  32. }