diff --git a/src/api/deck/createAnswer.ts b/src/api/deck/createAnswer.ts index 1eec40c..8d5340e 100644 --- a/src/api/deck/createAnswer.ts +++ b/src/api/deck/createAnswer.ts @@ -9,6 +9,8 @@ export type CreateAnswerDTO = { deckId: number; questionId: number; answer: any; + isFile?: boolean; + file?: File; }; export type CreateAnswerResponse = Answer; @@ -18,7 +20,29 @@ export const createAnswer = (data: CreateAnswerDTO): Promise + + + + \ No newline at end of file diff --git a/src/components/UploadButton/UploadButton.module.scss b/src/components/UploadButton/UploadButton.module.scss new file mode 100644 index 0000000..8bc57f5 --- /dev/null +++ b/src/components/UploadButton/UploadButton.module.scss @@ -0,0 +1,17 @@ +@import 'src/app/styles/vars'; + +.UploadButton { + width: 100%; + height: 80px !important; + //background-color: $color-on-surface-dark-400; +} + +.UploadButton__icon { + width: 24px; + height: 24px; + color: white; +} + +.UploadButton__input { + display: none; +} \ No newline at end of file diff --git a/src/components/UploadButton/UploadButton.tsx b/src/components/UploadButton/UploadButton.tsx new file mode 100644 index 0000000..425e969 --- /dev/null +++ b/src/components/UploadButton/UploadButton.tsx @@ -0,0 +1,35 @@ +import clsx from 'clsx'; +import s from './UploadButton.module.scss'; +import {ReactFCC} from '../../utils/ReactFCC'; +import {Button, ButtonVariant} from '../Button'; +import { ReactComponent as UploadIcon } from '../../assets/icons/upload.svg'; +import {useId} from 'react'; + +export interface UploadButtonProps { + /** + * Дополнительный css-класс + */ + className?: string; + onChange?: (e: any) => void; + multiple?: boolean; +} + +export const UploadButton: ReactFCC = (props) => { + const {className, onChange, multiple} = props; + + const id = useId(); + + return ( + + ); +}; + diff --git a/src/components/UploadButton/index.ts b/src/components/UploadButton/index.ts new file mode 100644 index 0000000..52f301f --- /dev/null +++ b/src/components/UploadButton/index.ts @@ -0,0 +1 @@ +export * from './UploadButton'; \ No newline at end of file diff --git a/src/pages/chat/ChatPage.tsx b/src/pages/chat/ChatPage.tsx index e993349..6f34e7f 100644 --- a/src/pages/chat/ChatPage.tsx +++ b/src/pages/chat/ChatPage.tsx @@ -18,6 +18,7 @@ import {generateTextFromAnswer} from './utils/generateTextFromAnswer'; import {Button, ButtonVariant} from '../../components/Button'; import {useNavigate} from 'react-router-dom'; import {DECK_PAGE_PARAM, DECK_PAGE_ROUTE} from '../../app/routes'; +import {generateFieldsForFileAnswers} from './utils/generateFieldsForFileAnswers'; export interface ChatPageProps { /** @@ -28,8 +29,8 @@ export interface ChatPageProps { const QUESTION_POLLING_MS = 1000; -const DEFAULT_DECK_ID = 0; -const DEFAULT_QUESTION_ID = 0; +const DEFAULT_DECK_ID = 80; +const DEFAULT_QUESTION_ID = 25; export const ChatPage: ReactFCC = (props) => { const {className} = props; @@ -127,16 +128,19 @@ export const ChatPage: ReactFCC = (props) => { timeout.clear(); const answerValue = generateAnswerFromData(question, data); + const additionalFields = generateFieldsForFileAnswers(question, data); const answer = await createAnswer({ deckId, questionId, - answer: answerValue + answer: answerValue, + ...additionalFields, + isFile: !!additionalFields && Object.keys(additionalFields).length !== 0 }); pushHistory({ type: ChatItemType.send, - text: generateTextFromAnswer(question.type, answer) + text: generateTextFromAnswer(question.type, answer, additionalFields) }); if (question.next_id) { diff --git a/src/pages/chat/components/ChatForm/QuestionFactory.tsx b/src/pages/chat/components/ChatForm/QuestionFactory.tsx index c0490b8..aebba77 100644 --- a/src/pages/chat/components/ChatForm/QuestionFactory.tsx +++ b/src/pages/chat/components/ChatForm/QuestionFactory.tsx @@ -1,12 +1,15 @@ import {ReactFCC} from '../../../../utils/ReactFCC'; -import {EntityType, Hint, Question} from '../../../../api/deck'; +import {EntityType, Question} from '../../../../api/deck'; import {Form} from '../../../../components/Form'; -import {ChatFormText} from './components/ChatFormText/ChatFormText'; +import {ChatFormText} from './components/ChatFormText'; import {ChatFormSelect} from './components/ChatFormSelect'; import {ChatFormMultipleRange, RangeType} from './components/ChatFormMultipleRange'; import {ChatFormMultipleDateDescription} from './components/ChatFormMultipleDateDescription'; import {ChatFormRange} from './components/ChatFormRange'; import {ChatFormMultipleLinkDescription} from './components/ChatFormMultipleLinkDescription'; +import {ChatFormPhotoDescription} from './components/ChatFormPhotoDescription'; +import {ChatFormMultiplePhoto} from './components/ChatFormMultiplePhoto'; +import {ChatFormMultiplePhotoDescription} from './components/ChatFormMultiplePhotoDescription'; export interface QuestionFactoryProps { type: EntityType; @@ -183,6 +186,57 @@ export const QuestionFactory: ReactFCC = (props) => { )} ) + case EntityType.photo_description: + return ( +
+ {({ handleSubmit, register, control }) => ( + + )} + + ); + case EntityType.multiple_photo: + return ( +
+ {({ handleSubmit, register, control }) => ( + + )} + + ); + case EntityType.multiple_photo_description: + return ( +
+ {({ handleSubmit, register, control }) => ( + + )} + + ); default: return null; } diff --git a/src/pages/chat/components/ChatForm/components/ChatFormMultipleDateDescription/ChatFormMultipleDateDescription.module.scss b/src/pages/chat/components/ChatForm/components/ChatFormMultipleDateDescription/ChatFormMultipleDateDescription.module.scss index 124e380..f6331b5 100644 --- a/src/pages/chat/components/ChatForm/components/ChatFormMultipleDateDescription/ChatFormMultipleDateDescription.module.scss +++ b/src/pages/chat/components/ChatForm/components/ChatFormMultipleDateDescription/ChatFormMultipleDateDescription.module.scss @@ -31,4 +31,8 @@ .ChatFormMultipleDateDescription__hint { white-space: pre-wrap; +} + +.ChatFormMultipleDateDescription__itemName { + align-self: flex-start; } \ No newline at end of file diff --git a/src/pages/chat/components/ChatForm/components/ChatFormMultipleDateDescription/ChatFormMultipleDateDescription.tsx b/src/pages/chat/components/ChatForm/components/ChatFormMultipleDateDescription/ChatFormMultipleDateDescription.tsx index 3c1e468..b8082d2 100644 --- a/src/pages/chat/components/ChatForm/components/ChatFormMultipleDateDescription/ChatFormMultipleDateDescription.tsx +++ b/src/pages/chat/components/ChatForm/components/ChatFormMultipleDateDescription/ChatFormMultipleDateDescription.tsx @@ -58,7 +58,11 @@ export const ChatFormMultipleDateDescription: ReactFCC -