File tree Expand file tree Collapse file tree 4 files changed +29
-31
lines changed Expand file tree Collapse file tree 4 files changed +29
-31
lines changed Original file line number Diff line number Diff line change 1
1
import React , { useEffect , useState } from 'react' ;
2
- import { Link , Redirect } from 'react-router-dom' ;
2
+ import { Redirect } from 'react-router-dom' ;
3
3
import { BenchmarkServices } from '../../api/BenchmarkServices' ;
4
4
import Header from '../Page/Header' ;
5
5
import Page from '../Page/Page' ;
@@ -27,29 +27,17 @@ const BenchmarkDetail = (props) => {
27
27
} ) ;
28
28
} , [ setBenchmark , props . match . params . id ] ) ;
29
29
30
- if ( benchmark === '' ) {
30
+ if ( benchmark === '' || undefined ) {
31
31
return < Redirect to = "/404" /> ;
32
32
}
33
33
34
34
return (
35
35
< Page >
36
- < Header title = "Dashboard" />
37
- < header className = "bg-white shadow" >
38
- < div className = "max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8 flex justify-between" >
39
- < h1 className = "text-3xl font-bold text-gray-900" >
40
- {
41
- // @ts -ignore
42
- benchmark === undefined ? '' : benchmark . title
43
- }
44
- </ h1 >
45
- < Link
46
- className = "bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full"
47
- to = "/benchmarks"
48
- >
49
- Back
50
- </ Link >
51
- </ div >
52
- </ header >
36
+ < Header title = {
37
+ // @ts -ignore
38
+ benchmark === undefined ? '' : benchmark . title }
39
+ button = 'Back' navTo = '/benchmarks'
40
+ />
53
41
< div className = "flex p-4" >
54
42
< div className = "flex-1 mx-auto border-4 border-dashed border-gray-200 rounded-lg h-96" >
55
43
< div className = "pl-8 pr-8" >
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ export class Benchmarks extends React.Component<
103
103
render ( ) {
104
104
return (
105
105
< Page >
106
- < Header title = "Benchmarks" />
106
+ < Header title = "Benchmarks" button = "Create" navTo = "/benchmarks/create" />
107
107
< div className = "max-w-7xl mx-auto py-6 sm:px-6 lg:px-8" >
108
108
< div className = "flex flex-col" >
109
109
< div className = "-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8" >
Original file line number Diff line number Diff line change @@ -45,14 +45,7 @@ export class CreateBenchmark extends React.Component<
45
45
render ( ) {
46
46
return (
47
47
< Page >
48
- < Header title = "Dashboard" />
49
- < header className = "bg-white shadow" >
50
- < div className = "max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8 flex justify-between" >
51
- < h1 className = "text-3xl font-bold text-gray-900" >
52
- Create benchmark
53
- </ h1 >
54
- </ div >
55
- </ header >
48
+ < Header title = "Create benchmark" />
56
49
< div className = "max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8" >
57
50
< form className = "w-full max-w-lg" onSubmit = { this . onSubmit } >
58
51
< div className = "flex flex-wrap -mx-3 mb-6" >
Original file line number Diff line number Diff line change
1
+ import { Link } from "react-router-dom" ;
2
+ import React from "react" ;
3
+
1
4
interface HeaderProps {
2
5
title : string ;
6
+ button ?: string ;
7
+ navTo ?: string ;
3
8
}
4
9
5
- const Header : React . FC < HeaderProps > = ( { title } ) => {
6
- return (
10
+ const Header : React . FC < HeaderProps > = ( { title, button, navTo} ) => {
11
+ const isButtonNeeded = button !== undefined && navTo !== undefined ;
12
+
13
+ return (
7
14
< header className = "bg-white shadow" >
8
- < div className = "max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8" >
15
+ < div className = "max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8 flex justify-between " >
9
16
< h1 className = "text-3xl font-bold text-gray-900" > { title } </ h1 >
17
+ { isButtonNeeded ?
18
+ < Link
19
+ className = "bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full"
20
+ to = { navTo !== undefined ? navTo : '/500' }
21
+ >
22
+ { button }
23
+ </ Link >
24
+ : < > </ > }
10
25
</ div >
26
+
11
27
</ header >
28
+
12
29
) ;
13
30
} ;
14
31
You can’t perform that action at this time.
0 commit comments