add getGraphics

This commit is contained in:
Nastya 2024-06-24 22:58:06 +03:00
parent ce39371fe5
commit f62fd84b09
4 changed files with 27 additions and 11 deletions

@ -21,6 +21,7 @@ export type QuestionsResponse = {
Results: Record<string, number>; Results: Record<string, number>;
Questions: Record<string, Record<string, number>>; Questions: Record<string, Record<string, number>>;
}; };
export type GraphicsResponse = unknown;
type TRequest = { type TRequest = {
to: number; to: number;
@ -91,3 +92,24 @@ export const getQuestions = async (
return [null, `Не удалось получить статистику по результатам. ${error}`]; return [null, `Не удалось получить статистику по результатам. ${error}`];
} }
}; };
export const getGraphics = async (
quizId: string,
to: number,
from: number,
): Promise<[GraphicsResponse | null, string?]> => {
try {
const questionsResponse = await makeRequest<TRequest, QuestionsResponse>({
method: "get",
url: `${API_URL}/${quizId}/pipelines?from=${from}&to=${to}`,
withCredentials: true,
});
console.log(questionsResponse)
return [questionsResponse];
} catch (nativeError) {
const [error] = parseAxiosError(nativeError);
return [null, `Не удалось получить статистику по результатам. ${error}`];
}
};

@ -172,10 +172,7 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({ isModalOpen, handleClo
Customer: [{ QuestionID: {} }], Customer: [{ QuestionID: {} }],
}; };
console.log("selectedQuestions");
console.log(selectedQuestions);
for (let key in FieldsRule) { for (let key in FieldsRule) {
console.log("current key ", key);
selectedQuestions[key as QuestionKeys].forEach((id) => { selectedQuestions[key as QuestionKeys].forEach((id) => {
FieldsRule[key as QuestionKeys][0].QuestionID[id] = 0; FieldsRule[key as QuestionKeys][0].QuestionID[id] = 0;
}); });
@ -185,9 +182,6 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({ isModalOpen, handleClo
} }
body.FieldsRule = FieldsRule; body.FieldsRule = FieldsRule;
console.log("На отправку");
console.log(body);
if (firstRules) { if (firstRules) {
setIntegrationRules(quizID.toString(), body); setIntegrationRules(quizID.toString(), body);
} else { } else {

@ -46,6 +46,7 @@ export default function QuestionsPage({
if (!quiz) return null; if (!quiz) return null;
return ( return (
<> <>
<Box <Box

@ -4,6 +4,7 @@ import {
GeneralResponse, GeneralResponse,
getDevices, getDevices,
getGeneral, getGeneral,
getGraphics,
getQuestions, getQuestions,
QuestionsResponse, QuestionsResponse,
} from "@api/statistic"; } from "@api/statistic";
@ -35,11 +36,9 @@ export function useAnalytics({ ready, quizId, to, from }: useAnalyticsProps) {
const [gottenGeneral] = await getGeneral(quizId, formatTo, formatFrom); const [gottenGeneral] = await getGeneral(quizId, formatTo, formatFrom);
const [gottenDevices] = await getDevices(quizId, formatTo, formatFrom); const [gottenDevices] = await getDevices(quizId, formatTo, formatFrom);
const [gottenQuestions] = await getQuestions( const [gottenQuestions] = await getQuestions(quizId, formatTo, formatFrom);
quizId,
formatTo, getGraphics(quizId, formatTo, formatFrom)
formatFrom,
);
if (gottenGeneral) { if (gottenGeneral) {
setGeneral(gottenGeneral); setGeneral(gottenGeneral);