@@ -4,6 +4,8 @@ import { Button } from "@aws-amplify/ui-react";
4
4
import styles from "./chat.module.scss" ;
5
5
import { ChatInputState } from "./types" ;
6
6
import { BACKEND_URL } from "../../tools/const" ;
7
+ import { useSelector } from "react-redux" ;
8
+ import { UserState } from "@/types/StoreTypes" ;
7
9
8
10
export interface RecommendQuestionsProps {
9
11
setTextValue : Dispatch < SetStateAction < ChatInputState > > ;
@@ -14,8 +16,10 @@ export default function CustomQuestions(props: RecommendQuestionsProps) {
14
16
const [ showMoreQuestions , setShowMoreQuestions ] = useState ( true ) ;
15
17
const [ questions , setQuestions ] = useState < string [ ] > ( [ ] ) ;
16
18
17
- const getRecommendQuestions = async ( ) => {
18
- const url = `${ BACKEND_URL } qa/get_custom_question?data_profile=shopping-demo` ;
19
+ const userInfo = useSelector < UserState > ( ( state ) => state ) as UserState ;
20
+
21
+ const getRecommendQuestions = async ( data_profile : string ) => {
22
+ const url = `${ BACKEND_URL } qa/get_custom_question?data_profile=${ data_profile } ` ;
19
23
try {
20
24
const response = await fetch ( url , {
21
25
method : "GET" ,
@@ -33,8 +37,11 @@ export default function CustomQuestions(props: RecommendQuestionsProps) {
33
37
}
34
38
35
39
useEffect ( ( ) => {
36
- getRecommendQuestions ( ) . then ( ) ;
37
- } , [ ] ) ;
40
+ const data_profile = userInfo . queryConfig . selectedDataPro ;
41
+ if ( data_profile ) {
42
+ getRecommendQuestions ( data_profile ) . then ( ) ;
43
+ }
44
+ } , [ userInfo ] ) ;
38
45
39
46
return (
40
47
< div >
0 commit comments