"use client"; import { useState, useEffect } from 'react' import PageTitle from '@/components/ui/PageTitle'; import { Input, Typography, Select, Switch, Upload, Form, Button, Tag, Col, Row, Flex } from 'antd' import AltLayout from '@/components/layout/AltLayout'; import { UploadOutlined } from '@ant-design/icons'; import type { SelectProps } from 'antd'; import TextArea from 'antd/es/input/TextArea'; import { useQuery } from '@tanstack/react-query'; import { getPersonaStyle } from '@/app/api/user/personaService'; import type { RcFile } from 'antd/es/upload'; import PhoneInput from 'react-phone-input-2'; import 'react-phone-input-2/lib/style.css'; const CreatePersona: React.FC = () => { const [name, setName] = useState("") const [phone, setPhone] = useState(''); const [options, setOptions] = useState() const [imageUrl, setImageUrl] = useState(null); const [fileList, setFileList] = useState([]); const [enabled, setEnabled] = useState({ isManualKnowledgeEntry: false, isUploadTextDocument: false, isImportWebLink: false, isDallEImageGen: false, isSOPAutoLearn: false }); const { data: personaStyleList, error, isLoading } = useQuery({ queryKey: ["personaStyle"], queryFn: () => getPersonaStyle() }) useEffect(() => { const latestData: SelectProps[] | undefined = personaStyleList?.map(persona => { return { label: persona.name, value: persona.id } }) setOptions(latestData) }, [personaStyleList]) const handleBeforeUpload = (file: RcFile) => { const isImage = file.type.startsWith('image/'); if (!isImage) { // message.error('Only image files are allowed!'); } const isLt2M = file.size / 1024 / 1024 < 2; if (!isLt2M) { //message.error('Image must be smaller than 2MB!'); } if (isImage && isLt2M) { const reader = new FileReader(); reader.onload = () => setImageUrl(reader.result as string); reader.readAsDataURL(file); } // prevent automatic upload return false; }; return ( Create Persona}>
Persona Name

}> setName(e.target.value)} />
Avatar Upload

}> { setFileList([]); setImageUrl(null); }} onChange={({ fileList }) => setFileList(fileList)} maxCount={1} accept="image/*" listType="picture" > {imageUrl && ( Uploaded Preview )}
Role / Department

}> setName(e.target.value)} />
Description

}>