|
1 | | -import {Link} from "react-router-dom"; |
2 | | -import React from "react"; |
| 1 | +import { Link } from 'react-router-dom'; |
| 2 | +import React from 'react'; |
3 | 3 |
|
4 | 4 | interface HeaderProps { |
5 | 5 | title: string; |
6 | 6 | button?: string; |
7 | 7 | navTo?: string; |
8 | 8 | } |
9 | 9 |
|
10 | | -const Header: React.FC<HeaderProps> = ({ title, button, navTo}) => { |
11 | | - const isButtonNeeded = button !== undefined && navTo !== undefined; |
| 10 | +const Header: React.FC<HeaderProps> = ({ title, button, navTo }) => { |
| 11 | + const isButtonNeeded = button !== undefined && navTo !== undefined; |
12 | 12 |
|
13 | | - return ( |
| 13 | + return ( |
14 | 14 | <header className="bg-white shadow"> |
15 | | - <div className="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8 flex justify-between"> |
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'} |
| 15 | + {button === 'back' ? ( |
| 16 | + <div className="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8 flex "> |
| 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 | + <svg |
| 23 | + xmlns="http://www.w3.org/2000/svg" |
| 24 | + className="h-6 w-6" |
| 25 | + fill="none" |
| 26 | + viewBox="0 0 24 24" |
| 27 | + stroke="currentColor" |
21 | 28 | > |
22 | | - {button} |
23 | | - </Link> |
24 | | - : <></>} |
25 | | - </div> |
26 | | - |
| 29 | + <path |
| 30 | + strokeLinecap="round" |
| 31 | + strokeLinejoin="round" |
| 32 | + strokeWidth="2" |
| 33 | + d="M10 19l-7-7m0 0l7-7m-7 7h18" |
| 34 | + /> |
| 35 | + </svg> |
| 36 | + </Link> |
| 37 | + ) : ( |
| 38 | + <></> |
| 39 | + )} |
| 40 | + <h1 className="text-3xl font-bold text-gray-900 ml-2">{title}</h1> |
| 41 | + </div> |
| 42 | + ) : ( |
| 43 | + <div className="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8 flex justify-between"> |
| 44 | + <h1 className="text-3xl font-bold text-gray-900">{title}</h1> |
| 45 | + {isButtonNeeded ? ( |
| 46 | + <Link |
| 47 | + className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full" |
| 48 | + to={navTo !== undefined ? navTo : '/500'} |
| 49 | + > |
| 50 | + {button} |
| 51 | + </Link> |
| 52 | + ) : ( |
| 53 | + <></> |
| 54 | + )} |
| 55 | + </div> |
| 56 | + )} |
27 | 57 | </header> |
28 | | - |
29 | 58 | ); |
30 | 59 | }; |
31 | 60 |
|
|
0 commit comments