Skip to content

Commit 4515d58

Browse files
fix: tab navigation from practice tab to other tabs in interview prep page with type safety
1 parent 2e738ad commit 4515d58

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/pages/interview-prep/PracticeTab.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react";
22
import { useState, useEffect } from "react";
33
import { motion, AnimatePresence } from "framer-motion";
4+
import type { TabType } from "./index";
45

56
interface MockQuestion {
67
id: string;
@@ -44,7 +45,7 @@ interface PracticeStats {
4445

4546
interface PracticeTabProps {
4647
mockInterviewQuestions?: MockQuestion[];
47-
onTabChange?: (tab: string) => void;
48+
onTabChange?: (tab: TabType) => void;
4849
}
4950

5051
const fadeIn = {
@@ -220,7 +221,7 @@ const PracticeTab: React.FC<PracticeTabProps> = ({
220221
});
221222
};
222223

223-
const handleTabNavigation = (tab: string) => {
224+
const handleTabNavigation = (tab: TabType) => {
224225
if (onTabChange) {
225226
onTabChange(tab);
226227
}

src/pages/interview-prep/index.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,15 @@ const staggerContainer = {
2727
},
2828
};
2929

30+
type TabType =
31+
| "overview"
32+
| "technical"
33+
| "behavioral"
34+
| "companies"
35+
| "practice";
36+
3037
const InterviewPrepPage: React.FC = () => {
31-
const [activeTab, setActiveTab] = useState<
32-
"overview" | "technical" | "behavioral" | "companies" | "practice"
33-
>("overview");
38+
const [activeTab, setActiveTab] = useState<TabType>("overview");
3439
const [expandedCategories, setExpandedCategories] = useState<{
3540
[key: string]: boolean;
3641
}>({});
@@ -1501,11 +1506,7 @@ function InterviewPrepContent({
15011506
mockInterviewQuestions,
15021507
}: {
15031508
activeTab: string;
1504-
setActiveTab: React.Dispatch<
1505-
React.SetStateAction<
1506-
"overview" | "technical" | "behavioral" | "companies" | "practice"
1507-
>
1508-
>;
1509+
setActiveTab: React.Dispatch<React.SetStateAction<TabType>>;
15091510
expandedCategories: { [key: string]: boolean };
15101511
toggleCategory: (categoryIndex: number) => void;
15111512
showTips: { [key: number]: boolean };
@@ -1654,7 +1655,10 @@ function InterviewPrepContent({
16541655

16551656
{/* Practice Tab */}
16561657
{activeTab === "practice" && (
1657-
<PracticeTab mockInterviewQuestions={mockInterviewQuestions} />
1658+
<PracticeTab
1659+
mockInterviewQuestions={mockInterviewQuestions}
1660+
onTabChange={setActiveTab}
1661+
/>
16581662
)}
16591663
</div>
16601664

@@ -1702,3 +1706,4 @@ function InterviewPrepContent({
17021706
}
17031707

17041708
export default InterviewPrepPage;
1709+
export type { TabType };

0 commit comments

Comments
 (0)