File tree Expand file tree Collapse file tree 2 files changed +14
-21
lines changed Expand file tree Collapse file tree 2 files changed +14
-21
lines changed Original file line number Diff line number Diff line change @@ -4,12 +4,12 @@ import { FunctionComponent } from "react";
4
4
import AppMargin from "../AppMargin" ;
5
5
import { useNavigate } from "react-router-dom" ;
6
6
7
- type NavbarItems = { label : string ; link : string } ;
7
+ type NavbarItem = { label : string ; link : string } ;
8
8
9
- const Navbar : FunctionComponent = ( ) => {
10
- const navbarItems : Array < NavbarItems > = [
11
- { label : "Questions" , link : "/questions" } ,
12
- ] ;
9
+ type NavbarProps = { navbarItems ?: Array < NavbarItem > } ;
10
+
11
+ const Navbar : FunctionComponent < NavbarProps > = ( props : NavbarProps ) => {
12
+ const { navbarItems = [ { label : "Questions" , link : "/" } ] } = props ;
13
13
const navigate = useNavigate ( ) ;
14
14
15
15
return (
@@ -29,7 +29,7 @@ const Navbar: FunctionComponent = () => {
29
29
< Typography
30
30
component = { Box }
31
31
variant = "h5"
32
- sx = { [ { flexGrow : 1 } , { "&:hover" : { cursor : "pointer" } } ] }
32
+ sx = { [ { flexGrow : 1 , "&:hover" : { cursor : "pointer" } } ] }
33
33
onClick = { ( ) => navigate ( "/" ) }
34
34
>
35
35
PeerPrep
Original file line number Diff line number Diff line change 1
1
import { Dispatch } from "react" ;
2
2
// import { questionClient } from "../utils/api";
3
3
4
- type QuestionInfo = {
5
- questionId : string ;
6
- title : string ;
7
- complexity : string ;
8
- categories : Array < string > ;
9
- } ;
10
-
11
4
type QuestionDetail = {
12
5
questionId : string ;
13
6
title : string ;
@@ -22,15 +15,21 @@ enum QuestionActionTypes {
22
15
23
16
type QuestionActions = {
24
17
type : QuestionActionTypes ;
25
- payload : QuestionDetail ;
18
+ payload : Array < QuestionDetail > | QuestionDetail ;
26
19
} ;
27
20
28
21
type QuestionsState = {
29
- questions : Array < QuestionInfo > ;
22
+ questions : Array < QuestionDetail > ;
30
23
selectedQuestion : QuestionDetail | null ;
31
24
selectedQuestionError : string | null ;
32
25
} ;
33
26
27
+ const isQuestionList = (
28
+ questionsList : Array < QuestionDetail > | QuestionDetail
29
+ ) : questionsList is Array < QuestionDetail > => {
30
+ return Array . isArray ( questionsList ) ;
31
+ } ;
32
+
34
33
export const initialState : QuestionsState = {
35
34
questions : [ ] ,
36
35
selectedQuestion : null ,
@@ -67,12 +66,6 @@ export const getQuestionById = (
67
66
} ) ;
68
67
} ;
69
68
70
- const isQuestionList = (
71
- questionsList : Array < QuestionInfo > | QuestionDetail
72
- ) : questionsList is Array < QuestionInfo > => {
73
- return Array . isArray ( questionsList ) ;
74
- } ;
75
-
76
69
const reducer = (
77
70
state : QuestionsState ,
78
71
action : QuestionActions
You can’t perform that action at this time.
0 commit comments