Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"scripts": {
"start": "webpack serve --config webpack/webpack.dev",
"start:prod": "npm run build && serve -s build",
"build": "webpack --config webpack/webpack.prod",
"lint": "eslint --fix --ext .ts,.tsx ."
},
Expand All @@ -23,6 +24,7 @@
"react-hook-form": "^7.45.4",
"react-redux": "^8.1.2",
"react-router-dom": "^6.15.0",
"serve": "^14.2.0",
"yup": "^1.2.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/api/requests/getDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const getDescriptionByAddr = async (elementAddr: number) => {
// };

export const getDescriptionById = async (id: string, lang: TLanguage) => {
console.log("k");
const languageNode = await getLanguage(lang);
const action = new Action('action_reply_to_message');
const constr = new ScConstruction();
constr.createLink(ScType.LinkConst, new ScLinkContent(id, ScLinkContentType.String));
Expand All @@ -149,7 +149,7 @@ export const getDescriptionById = async (id: string, lang: TLanguage) => {

const res = await client.templateGenerate(textLinkTemplate);

await action.addArgs(linkAddr);
await action.addArgs(linkAddr, languageNode);

const answerAddr = await action.initiate();

Expand Down
55 changes: 32 additions & 23 deletions src/components/AskAnswer/AskAnswer.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import { useToast, useTranslate } from 'ostis-ui-lib';
import { useToast, useTranslate, Spinner, useLanguage } from 'ostis-ui-lib';

import { useLocation } from 'react-router-dom';
import { ChangeEvent, useEffect, useReducer, useState, useRef, useCallback } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useLocation } from 'react-router-dom';

import { Spinner, useLanguage } from 'ostis-ui-lib';
import { SPINER_COLOR } from '@constants';
import { AskElement } from './AskElement';
import { getDescriptionById } from '@api/requests/getDescription';
import { TextItem } from '@components/AskAnswer/AskElement/AnswerText';

import styles from './AskAnswer.module.scss';
import { AskInput } from '@components/AskInput';

import { getHintButtonHandler } from 'src/constants/hintButtons';
import { getDescriptionById } from '@api/requests/getDescription';
import { useDispatch, useSelector } from 'react-redux';
import { addInHistory, selectRequests } from '@store/requestDialogHistorySlice';
import { Notification } from '@components/Notification';
import { SPINER_COLOR } from '@constants';
import { addInHistory, selectRequests } from '@store/requestDialogHistorySlice';
import { getHintButtonHandler } from 'src/constants/hintButtons';
import styles from './AskAnswer.module.scss';
import { AskElement } from './AskElement';

interface NavigateState {
query?: string;
isHintButton: boolean;
}


export const AskAnswer = () => {
const state = useLocation().state as NavigateState;

Expand Down Expand Up @@ -59,17 +55,30 @@ export const AskAnswer = () => {
}

if (answer) {
dispatch(addInHistory({ query, answer }));
const items: TextItem[] = [
{
type: 'normal',
content: answer,
},
];
dispatch(addInHistory({ query, answer: items }));
} else {
dispatch(
addInHistory({
query,
answer: translate({
ru: 'К сожалению, в настоящее время нет информации, соответствующей вашему вопросу в базе знаний. Приносим извинения за неудобства.',
en: 'Unfortunately, there is currently no information corresponding to your question in the knowledge base. We apologize for the inconvenience.',
}),
}),
);
const items: TextItem[] = [];
items.push({
type: 'normal',
content:
'Unfortunately, there is currently no information corresponding to your question in the knowledge base. We apologize for the inconvenience.',
});
dispatch(addInHistory({ query, answer: items }));
// dispatch(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the commented-out translation code if it is no longer needed to keep the code clean.

// addInHistory({
// query,
// answer: translate({
// ru: 'К сожалению, в настоящее время нет информации, соответствующей вашему вопросу в базе знаний. Приносим извинения за неудобства.',
// en: 'Unfortunately, there is currently no information corresponding to your question in the knowledge base. We apologize for the inconvenience.',
// }),
// }),
// );
}

setIsLoading(false);
Expand Down
22 changes: 11 additions & 11 deletions src/components/AskAnswer/AskElement/AnswerText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ export interface TextItem {
content: string;
}

// export const AnswerText: React.FC<{
// items: TextItem[];
// }> = ({ items }) => {
// return (
// <div>
// {items.map((item, index) => (
// <CollapsibleText key={index} {...item} />
// ))}
// </div>
// );
// };
export const AnswerText: React.FC<{
items: TextItem[];
}> = ({ items }) => {
return (
<div>
{items.map((item, index) => (
<CollapsibleText key={index} {...item} />
))}
</div>
);
};
4 changes: 2 additions & 2 deletions src/components/AskAnswer/AskElement/AskElement.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC } from 'react';
import styles from './AskElement.module.scss';
//import { AnswerText } from '@components/AskAnswer/AskElement/AnswerText';
import { AnswerText } from '@components/AskAnswer/AskElement/AnswerText';

import AskAIMessageIcon from '@assets/images/AskAIMessageIcon.svg';

Expand All @@ -15,7 +15,7 @@ export const AskElement: FC<IProps> = ({ query, answer }) => {
<div className={styles.elementQuery}>{query}</div>
<div className={styles.elementAnswer}>
<div>{<AskAIMessageIcon />}</div>
{/* <div><AnswerText items={answer} /></div> */}
{ <div><AnswerText items={answer} /></div> }
</div>
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion src/store/requestDialogHistorySlice.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { TextItem } from '@components/AskAnswer/AskElement/AnswerText';
import { IRootState } from '@store/model';

export interface IRequest {
query: string;
answer: any;
answer: TextItem[];
}

interface IInitialState {
Expand Down