diff --git a/src/components/AIChat/AIChatCouse.tsx b/src/components/AIChat/AIChatCouse.tsx
index c998ff400..e7a48ff37 100644
--- a/src/components/AIChat/AIChatCouse.tsx
+++ b/src/components/AIChat/AIChatCouse.tsx
@@ -1,4 +1,4 @@
-import { SquareArrowOutUpRightIcon } from 'lucide-react';
+import { Book } from 'lucide-react';
type AIChatCourseType = {
keyword: string;
@@ -41,10 +41,10 @@ export function AIChatCourse(props: AIChatCourseProps) {
href={courseSearchUrl}
target="_blank"
key={course?.keyword}
- className="group flex items-center gap-2 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-left text-sm text-gray-700 transition-all hover:border-gray-300 hover:bg-gray-50 hover:text-gray-900 active:bg-gray-100"
+ className="group flex min-w-[120px] items-center gap-2 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-left text-sm text-gray-700 transition-all hover:border-gray-400 hover:text-black active:bg-gray-100"
>
+
{course?.keyword}
-
);
diff --git a/src/components/AIChat/ChatHistory.tsx b/src/components/AIChat/ChatHistory.tsx
index 1a60f1bf1..e16222301 100644
--- a/src/components/AIChat/ChatHistory.tsx
+++ b/src/components/AIChat/ChatHistory.tsx
@@ -99,7 +99,7 @@ export const AIChatCard = memo((props: AIChatCardProps) => {
{!!jsx && jsx}
diff --git a/src/components/AIChat/PersonalizedResponseForm.tsx b/src/components/AIChat/PersonalizedResponseForm.tsx
index a5cc2d471..ea36eac60 100644
--- a/src/components/AIChat/PersonalizedResponseForm.tsx
+++ b/src/components/AIChat/PersonalizedResponseForm.tsx
@@ -27,24 +27,14 @@ type PersonalizedResponseFormProps = {
export const PersonalizedResponseForm = memo(
(props: PersonalizedResponseFormProps) => {
const { defaultValues, onClose } = props;
-
const toast = useToast();
const [expertise, setExpertise] = useState(defaultValues?.expertise ?? '');
- const [hasInitialGoal, setHasInitialGoal] = useState(!!defaultValues?.goal);
- const [goal, setGoal] = useState(defaultValues?.goal ?? '');
const [about, setAbout] = useState(defaultValues?.about ?? '');
const [specialInstructions, setSpecialInstructions] = useState(
- defaultValues?.specialInstructions ?? '',
+ defaultValues?.specialInstructions ?? ''
);
- const expertiseFieldId = useId();
- const goalFieldId = useId();
- const aboutFieldId = useId();
- const specialInstructionsFieldId = useId();
-
- const goalRef = useRef(null);
-
const goalOptions = [
'Finding a job',
'Learning for fun',
@@ -52,9 +42,47 @@ export const PersonalizedResponseForm = memo(
'Switching careers',
'Getting a promotion',
'Filling knowledge gaps',
- 'Other (tell us more)',
+ 'Other',
];
+ const getInitialGoalSelection = () => {
+ if (!defaultValues?.goal) {
+ return '';
+ }
+
+ for (const option of goalOptions.slice(0, -1)) {
+ if (defaultValues.goal.startsWith(option)) {
+ return option;
+ }
+ }
+
+ return 'Other';
+ };
+
+ const [selectedGoal, setSelectedGoal] = useState(getInitialGoalSelection());
+ const [goal, setGoal] = useState(defaultValues?.goal ?? '');
+
+ const expertiseFieldId = useId();
+ const goalFieldId = useId();
+ const goalSelectId = useId();
+ const aboutFieldId = useId();
+ const specialInstructionsFieldId = useId();
+
+ const goalRef = useRef(null);
+
+ const handleGoalSelectionChange = (value: string) => {
+ setSelectedGoal(value);
+
+ if (value === 'Other') {
+ setGoal('');
+ setTimeout(() => {
+ goalRef.current?.focus();
+ }, 0);
+ } else {
+ setGoal(value);
+ }
+ };
+
const { mutate: setChatPreferences, isPending } = useMutation(
{
mutationFn: (data: ChatPreferencesFormData) => {
@@ -68,7 +96,7 @@ export const PersonalizedResponseForm = memo(
toast.error(error?.message ?? 'Something went wrong');
},
},
- queryClient,
+ queryClient
);
const handleSubmit = (e: React.FormEvent) => {
@@ -103,12 +131,11 @@ export const PersonalizedResponseForm = memo(
setExpertise(e.target.value)}
className="h-[40px] border-gray-300 text-sm focus:border-gray-500 focus:ring-1 focus:ring-gray-500"
>
-
+
{[
'No experience (just starting out)',
'Beginner (less than 1 year of experience)',
@@ -122,52 +149,39 @@ export const PersonalizedResponseForm = memo(
))}
+
- {!hasInitialGoal && (
-
- {goalOptions.map((goalTemplate) => (
-
- ))}
-
+ {selectedGoal === 'Other' && (
+
@@ -222,5 +236,5 @@ export const PersonalizedResponseForm = memo(
);
- },
+ }
);
diff --git a/src/components/RoadmapAIChat/RoadmapRecommendations.tsx b/src/components/RoadmapAIChat/RoadmapRecommendations.tsx
index f1e4a4a91..2208bad7c 100644
--- a/src/components/RoadmapAIChat/RoadmapRecommendations.tsx
+++ b/src/components/RoadmapAIChat/RoadmapRecommendations.tsx
@@ -66,10 +66,10 @@ export function RoadmapRecommendations(props: RoadmapRecommendationsProps) {
href={`/${item.roadmapSlug}/ai`}
target="_blank"
key={item.roadmapSlug}
- className="group flex items-center gap-2 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-left text-sm text-gray-700 transition-all hover:border-gray-300 hover:bg-gray-50 hover:text-gray-900 active:bg-gray-100"
+ className="group flex items-center gap-2 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-left text-sm text-gray-700 transition-all hover:border-gray-400 hover:text-black active:bg-gray-100"
>
{item.title}
-
+
))}