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>;
Questions: Record<string, Record<string, number>>;
};
export type GraphicsResponse = unknown;
type TRequest = {
to: number;
@ -91,3 +92,24 @@ export const getQuestions = async (
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: {} }],
};
console.log("selectedQuestions");
console.log(selectedQuestions);
for (let key in FieldsRule) {
console.log("current key ", key);
selectedQuestions[key as QuestionKeys].forEach((id) => {
FieldsRule[key as QuestionKeys][0].QuestionID[id] = 0;
});
@ -185,9 +182,6 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({ isModalOpen, handleClo
}
body.FieldsRule = FieldsRule;
console.log("На отправку");
console.log(body);
if (firstRules) {
setIntegrationRules(quizID.toString(), body);
} else {

@ -45,6 +45,7 @@ export default function QuestionsPage({
}, []);
if (!quiz) return null;
return (
<>

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