aboutsummaryrefslogtreecommitdiff
path: root/jb-ui/src/components/Profiling.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'jb-ui/src/components/Profiling.tsx')
-rw-r--r--jb-ui/src/components/Profiling.tsx38
1 files changed, 24 insertions, 14 deletions
diff --git a/jb-ui/src/components/Profiling.tsx b/jb-ui/src/components/Profiling.tsx
index 96b06b2..23b8457 100644
--- a/jb-ui/src/components/Profiling.tsx
+++ b/jb-ui/src/components/Profiling.tsx
@@ -1,4 +1,5 @@
import { UpkQuestionChoice } from "@/api_fsb";
+import { useGetMeQuery } from "@/models/authAPI";
import { ChevronRightIcon } from "lucide-react";
import { KeyboardEvent, MouseEvent, useEffect, useRef, useState } from "react";
@@ -46,7 +47,7 @@ const TextEntry = () => {
// const selectAnswer = useSelector(selectAnswerForQuestion(question));
const metadata = activeQuestion?._metadata;
const validation = activeQuestion?._validation;
- const bpuid = useAppSelector((state) => state.app.bpuid);
+ const { data: user, isLoading, isError } = useGetMeQuery();
if (!metadata) return null;
if (!validation) return null;
@@ -67,11 +68,14 @@ const TextEntry = () => {
const handleKeyPress = (event: KeyboardEvent<HTMLInputElement>) => {
if (!activeQuestion.question_id) return;
- if (!bpuid) return;
+ if (!user?.product_user_id) return;
if (event.key === "Enter") {
dispatch(
- saveAnswer({ questionId: activeQuestion.question_id!, bpuid: bpuid }),
+ saveAnswer({
+ questionId: activeQuestion.question_id!,
+ bpuid: user.product_user_id,
+ }),
);
}
};
@@ -109,14 +113,14 @@ export default function useKeyboardMode(rowModel: RowModel<UpkQuestionChoice>) {
const dispatch = useAppDispatch();
const activeQuestion = useSelector(selectActiveQuestion);
- const bpuid = useAppSelector((state) => state.app.bpuid);
+ const { data: user, isLoading, isError } = useGetMeQuery();
const keyboardSelectionIdxRef = useRef(0);
useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
if (!activeQuestion) return;
- if (!bpuid) return;
+ if (!user?.product_user_id) return;
// if (!keyboardEnabled) {
// return;
@@ -141,7 +145,10 @@ export default function useKeyboardMode(rowModel: RowModel<UpkQuestionChoice>) {
if (event.key === "Enter") {
dispatch(
- saveAnswer({ questionId: activeQuestion.question_id!, bpuid: bpuid }),
+ saveAnswer({
+ questionId: activeQuestion.question_id!,
+ bpuid: user.product_user_id,
+ }),
);
}
@@ -507,15 +514,18 @@ const ProfilingQuestionSubmitButton = () => {
const activeQuestion = useSelector(selectActiveQuestion);
const activeQuestionValidation = useSelector(selectActiveQuestionValidation);
- const bpuid = useAppSelector((state) => state.app.bpuid);
+ const { data: user, isLoading, isError } = useGetMeQuery();
const handleOnClick = () => {
if (!activeQuestion) return;
if (!activeQuestionValidation?.isComplete) return;
- if (!bpuid) return;
+ if (!user?.product_user_id) return;
dispatch(
- saveAnswer({ questionId: activeQuestion.question_id!, bpuid: bpuid }),
+ saveAnswer({
+ questionId: activeQuestion.question_id!,
+ bpuid: user.product_user_id,
+ }),
);
};
@@ -749,14 +759,14 @@ const Profiling = () => {
const [showProfiling, setShowProfiling] = useState(false);
const dispatch = useAppDispatch();
- const bpuid = useAppSelector((state) => state.app.bpuid);
+ const { data: user, isLoading, isError } = useGetMeQuery();
useEffect(() => {
- if (!bpuid) return;
- dispatch(fetchNewQuestions(bpuid));
- }, [bpid, bpuid]);
+ if (!user?.product_user_id) return;
+ dispatch(fetchNewQuestions(user.product_user_id));
+ }, [bpid, user?.product_user_id]);
- if (!bpuid) return null;
+ if (!user?.product_user_id) return null;
return (
<div