From 31f2a83c48d8c02e7c2d76569ef84897631d5e6b Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Tue, 17 Oct 2023 03:37:14 +0100 Subject: [PATCH] refactor: updated how teachme/ask_question and instagraph works when paying lsat --- src/components/App/Helper/TeachMe/index.tsx | 10 +++++++++- src/network/fetchGraphData/index.ts | 18 ++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/components/App/Helper/TeachMe/index.tsx b/src/components/App/Helper/TeachMe/index.tsx index d981f7430..e509d82fc 100644 --- a/src/components/App/Helper/TeachMe/index.tsx +++ b/src/components/App/Helper/TeachMe/index.tsx @@ -106,6 +106,14 @@ export const TeachMe = () => { transcripts, }) + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + let budget = await sphinx.getBudget() + + if (budget.budget) { + setBudget(budget.budget) + } + toast(, { type: 'success', }) @@ -117,7 +125,7 @@ export const TeachMe = () => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - const budget = await sphinx.getBudget() + budget = await sphinx.getBudget() if (budget.budget) { setBudget(budget.budget) diff --git a/src/network/fetchGraphData/index.ts b/src/network/fetchGraphData/index.ts index 823715fd5..fae8a46d7 100644 --- a/src/network/fetchGraphData/index.ts +++ b/src/network/fetchGraphData/index.ts @@ -168,7 +168,7 @@ export const postInstagraph = async (data: TeachData): Promise => { const lsatToken = await getLSat() try { - return api.post(`/instagraph`, JSON.stringify(data), { Authorization: lsatToken }) + await api.post(`/instagraph`, JSON.stringify(data), { Authorization: lsatToken }) // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (error: any) { @@ -177,7 +177,9 @@ export const postInstagraph = async (data: TeachData): Promise => { await payLsat(lsat) - return postInstagraph(data) + await postInstagraph(data) + + return } throw error @@ -188,7 +190,7 @@ export const postTeachMe = async (data: TeachData): Promise => { const lsatToken = await getLSat() try { - return api.post(`/teachme`, JSON.stringify(data), { Authorization: lsatToken }) + await api.post(`/teachme`, JSON.stringify(data), { Authorization: lsatToken }) // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (error: any) { @@ -197,7 +199,9 @@ export const postTeachMe = async (data: TeachData): Promise => { await payLsat(lsat) - return postTeachMe(data) + await postTeachMe(data) + + return } throw error @@ -208,7 +212,7 @@ export const postAskQuestion = async (data: QuestionData): Promise => { const lsatToken = await getLSat() try { - return api.post(`/ask_question`, JSON.stringify(data), { Authorization: lsatToken }) + await api.post(`/ask_question`, JSON.stringify(data), { Authorization: lsatToken }) // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (error: any) { @@ -217,7 +221,9 @@ export const postAskQuestion = async (data: QuestionData): Promise => { await payLsat(lsat) - return postAskQuestion(data) + await postAskQuestion(data) + + return } throw error