Skip to content

Commit

Permalink
refactor: updated how teachme/ask_question and instagraph works when …
Browse files Browse the repository at this point in the history
…paying lsat
  • Loading branch information
tobi-bams committed Oct 17, 2023
1 parent f8adb33 commit 31f2a83
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
10 changes: 9 additions & 1 deletion src/components/App/Helper/TeachMe/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<ToastMessage message="We started preparing tutorial for you" />, {
type: 'success',
})
Expand All @@ -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)
Expand Down
18 changes: 12 additions & 6 deletions src/network/fetchGraphData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const postInstagraph = async (data: TeachData): Promise<void> => {
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) {
Expand All @@ -177,7 +177,9 @@ export const postInstagraph = async (data: TeachData): Promise<void> => {

await payLsat(lsat)

return postInstagraph(data)
await postInstagraph(data)

return
}

throw error
Expand All @@ -188,7 +190,7 @@ export const postTeachMe = async (data: TeachData): Promise<void> => {
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) {
Expand All @@ -197,7 +199,9 @@ export const postTeachMe = async (data: TeachData): Promise<void> => {

await payLsat(lsat)

return postTeachMe(data)
await postTeachMe(data)

return
}

throw error
Expand All @@ -208,7 +212,7 @@ export const postAskQuestion = async (data: QuestionData): Promise<void> => {
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) {
Expand All @@ -217,7 +221,9 @@ export const postAskQuestion = async (data: QuestionData): Promise<void> => {

await payLsat(lsat)

return postAskQuestion(data)
await postAskQuestion(data)

return
}

throw error
Expand Down

0 comments on commit 31f2a83

Please sign in to comment.