-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/dev' into generating-password
- Loading branch information
Showing
26 changed files
with
970 additions
and
785 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"projects": { | ||
"default": "delib-v3-dev", | ||
"dev": "delib-v3-dev", | ||
"prod": "synthesistalyaron" | ||
}, | ||
"targets": {}, | ||
"etags": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 44 additions & 45 deletions
89
src/controllers/db/multiStageQuestion/getMultiStageStatements.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,57 @@ | ||
import { QuestionStage, Statement } from "delib-npm"; | ||
import { Dispatch } from "react"; | ||
import { Statement, StatementSchema } from "delib-npm"; | ||
import { z } from "zod"; | ||
import { isProduction } from "@/controllers/general/helpers"; | ||
import { setTempStatementsForPresentation } from "@/model/statements/statementsSlice"; | ||
import { setCurrentMultiStepOptions } from "@/model/statements/statementsSlice"; | ||
import { store } from "@/model/store"; | ||
|
||
export async function getMultiStageOptions( | ||
|
||
export async function getFirstEvaluationOptions( | ||
statement: Statement, | ||
|
||
): Promise<void> { | ||
const dispatch: Dispatch<unknown> = store.dispatch; | ||
|
||
try { | ||
|
||
const dispatch = store.dispatch; | ||
const urlBase = isProduction() ? "qeesi7aziq-uc.a.run.app" : "http://localhost:5001/synthesistalyaron/us-central1"; | ||
|
||
const url = isProduction() ? `https://getRandomStatements-${urlBase}` : "http://localhost:5001/synthesistalyaron/us-central1/getRandomStatements"; | ||
|
||
const response = await fetch( | ||
`${url}?parentId=${statement.statementId}&limit=6` | ||
); | ||
const { randomStatements, error } = await response.json(); | ||
if (error) throw new Error(error); | ||
z.array(StatementSchema).parse(randomStatements); | ||
|
||
|
||
dispatch(setCurrentMultiStepOptions(randomStatements)); | ||
|
||
|
||
} catch (error) { | ||
console.error(error); | ||
|
||
|
||
} | ||
} | ||
|
||
export async function getSecondEvaluationOptions(statement: Statement): Promise<void> { | ||
|
||
try { | ||
const dispatch = store.dispatch; | ||
const urlBase = isProduction() ? "qeesi7aziq-uc.a.run.app" : "http://localhost:5001/synthesistalyaron/us-central1"; | ||
|
||
if (statement.questionSettings?.currentStage === QuestionStage.suggestion) { | ||
const userId = store.getState().user.user?.uid; | ||
if (!userId) throw new Error("User not found"); | ||
|
||
const url = isProduction() ? `https://getUserOptions-${urlBase}` : "http://localhost:5001/synthesistalyaron/us-central1/getUserOptions"; | ||
|
||
const response = await fetch( | ||
`${url}?parentId=${statement.statementId}&userId=${userId}` | ||
); | ||
const { statements, error } = await response.json(); | ||
if (error) throw new Error(error); | ||
|
||
dispatch(setTempStatementsForPresentation(statements)); | ||
} else if ( | ||
statement.questionSettings?.currentStage === QuestionStage.firstEvaluation | ||
) { | ||
const url = isProduction() ? `https://getRandomStatements-${urlBase}` : "http://localhost:5001/synthesistalyaron/us-central1/getRandomStatements"; | ||
|
||
const response = await fetch( | ||
`${url}?parentId=${statement.statementId}&limit=6` | ||
); | ||
const { randomStatements, error } = await response.json(); | ||
if (error) throw new Error(error); | ||
dispatch(setTempStatementsForPresentation(randomStatements)); | ||
} else if ( | ||
statement.questionSettings?.currentStage === | ||
QuestionStage.secondEvaluation | ||
) { | ||
const url = isProduction() ? `https://getTopStatements-${urlBase}` : "http://localhost:5001/synthesistalyaron/us-central1/getTopStatements"; | ||
const response = await fetch( | ||
`${url}?parentId=${statement.statementId}&limit=6` | ||
); | ||
const { topSolutions, error } = await response.json(); | ||
if (error) throw new Error(error); | ||
dispatch(setTempStatementsForPresentation(topSolutions)); | ||
} else { | ||
dispatch(setTempStatementsForPresentation([])); | ||
} | ||
const url = isProduction() ? `https://getTopStatements-${urlBase}` : "http://localhost:5001/synthesistalyaron/us-central1/getTopStatements"; | ||
const response = await fetch( | ||
`${url}?parentId=${statement.statementId}&limit=10` | ||
); | ||
const { topSolutions, error } = await response.json(); | ||
if (error) throw new Error(error); | ||
|
||
z.array(StatementSchema).parse(topSolutions); | ||
dispatch(setCurrentMultiStepOptions(topSolutions)); | ||
} catch (error) { | ||
console.error(error); | ||
dispatch(setTempStatementsForPresentation([])); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.