|
1 | | -import { FiSearch, FiGlobe, FiUpload, FiHash, FiInfo } from "react-icons/fi"; |
| 1 | +import { FiSearch, FiInfo } from "react-icons/fi"; |
2 | 2 | import { useEffect, useState } from "react"; |
3 | 3 | import { GenerateTheme } from "deweb-pages/src/hooks/GenerateTheme"; |
4 | 4 |
|
| 5 | +type QuickAccessItemProps = { |
| 6 | + path: string; |
| 7 | + title: string; |
| 8 | + description: string; |
| 9 | + href: string; |
| 10 | +}; |
| 11 | + |
| 12 | +const QuickAccessItem = ({ path, title, description, href }: QuickAccessItemProps) => ( |
| 13 | + <a |
| 14 | + href={href} |
| 15 | + target="_blank" |
| 16 | + rel="noopener noreferrer" |
| 17 | + className="bg-secondary text-primary p-6 rounded-lg shadow-lg cursor-pointer hover:bg-opacity-90 transition-all no-underline block" |
| 18 | + > |
| 19 | + <div className="flex items-center justify-center mb-4"> |
| 20 | + <span className="paragraph-lg text-4xl">{path}</span> |
| 21 | + </div> |
| 22 | + <h3 className="paragraph-lg text-xl font-bold mb-2">{title}</h3> |
| 23 | + <p className="paragraph-lg text-sm">{description}</p> |
| 24 | + </a> |
| 25 | +); |
| 26 | + |
5 | 27 | export default function App() { |
6 | 28 | const [searchQuery, setSearchQuery] = useState(""); |
7 | 29 | const [port, setPort] = useState(""); |
@@ -35,21 +57,42 @@ export default function App() { |
35 | 57 | }); |
36 | 58 | }, []); |
37 | 59 |
|
38 | | - const redirectTo = (service: string) => { |
| 60 | + const generateUrl = (service: string, path: string = '') => { |
39 | 61 | const { host } = new URL(window.location.href); |
40 | | - const url = host === "station.massa" && port |
41 | | - ? `http://${service}.localhost:${port}` |
42 | | - : `//${service}.${host}`; |
43 | | - window.open(url, '_blank'); |
| 62 | + return host === "station.massa" && port |
| 63 | + ? `http://${service}.localhost:${port}${path}` |
| 64 | + : `//${service}.${host}${path}`; |
44 | 65 | }; |
45 | 66 |
|
46 | 67 | const handleSearch = (e: React.FormEvent) => { |
47 | 68 | e.preventDefault(); |
48 | 69 | if (searchQuery.trim()) { |
49 | | - redirectTo(searchQuery); |
| 70 | + window.open(generateUrl(searchQuery), '_blank'); |
50 | 71 | } |
51 | 72 | }; |
52 | 73 |
|
| 74 | + const quickAccessItems = [ |
| 75 | + { |
| 76 | + path: "/explore", |
| 77 | + title: "Explore DeWeb", |
| 78 | + description: "Browse the list of all websites available in the decentralized web ecosystem", |
| 79 | + service: "deweb", |
| 80 | + pathUrl: "/explore" |
| 81 | + }, |
| 82 | + { |
| 83 | + path: "/mns", |
| 84 | + title: "Massa Name System", |
| 85 | + description: "Decentralized naming service for users and smart contracts on the Massa blockchain", |
| 86 | + service: "mns" |
| 87 | + }, |
| 88 | + { |
| 89 | + path: "/upload", |
| 90 | + title: "DeWeb Uploader", |
| 91 | + description: "Upload and manage your websites on DeWeb", |
| 92 | + service: "dws" |
| 93 | + } |
| 94 | + ]; |
| 95 | + |
53 | 96 | const theme = GenerateTheme(); |
54 | 97 |
|
55 | 98 | return ( |
@@ -83,44 +126,18 @@ export default function App() { |
83 | 126 | <span className="mr-3 text-primary">.massa</span> |
84 | 127 | </form> |
85 | 128 |
|
86 | | - <h2 className="text-2xl font-bold mb-4">Quick Access</h2> |
| 129 | + <h2 className="paragraph-lg text-2xl font-bold mb-4 text-secondary">Quick Access</h2> |
87 | 130 |
|
88 | 131 | <div className="grid grid-cols-1 md:grid-cols-3 gap-6 w-full md:w-4/5 lg:w-3/4 xl:w-2/3 mb-8"> |
89 | | - {/* DeWeb Homepage Card */} |
90 | | - <div |
91 | | - onClick={() => redirectTo('deweb')} |
92 | | - className="bg-secondary text-primary p-6 rounded-lg shadow-lg cursor-pointer hover:bg-opacity-90 transition-all" |
93 | | - > |
94 | | - <div className="flex items-center justify-center mb-4"> |
95 | | - <FiGlobe className="text-4xl" /> |
96 | | - </div> |
97 | | - <h3 className="text-xl font-bold mb-2">DeWeb</h3> |
98 | | - <p className="text-sm">Search for websites and browse the list of websites uploaded on DeWeb</p> |
99 | | - </div> |
100 | | - |
101 | | - {/* MNS Card */} |
102 | | - <div |
103 | | - onClick={() => redirectTo('mns')} |
104 | | - className="bg-secondary text-primary p-6 rounded-lg shadow-lg cursor-pointer hover:bg-opacity-90 transition-all" |
105 | | - > |
106 | | - <div className="flex items-center justify-center mb-4"> |
107 | | - <FiHash className="text-4xl" /> |
108 | | - </div> |
109 | | - <h3 className="text-xl font-bold mb-2">Massa Name System</h3> |
110 | | - <p className="text-sm">Decentralized naming service for users and smart contracts on the Massa blockchain</p> |
111 | | - </div> |
112 | | - |
113 | | - {/* DeWeb Uploader Card */} |
114 | | - <div |
115 | | - onClick={() => redirectTo('dws')} |
116 | | - className="bg-secondary text-primary p-6 rounded-lg shadow-lg cursor-pointer hover:bg-opacity-90 transition-all" |
117 | | - > |
118 | | - <div className="flex items-center justify-center mb-4"> |
119 | | - <FiUpload className="text-4xl" /> |
120 | | - </div> |
121 | | - <h3 className="text-xl font-bold mb-2">DeWeb Uploader</h3> |
122 | | - <p className="text-sm">Upload and manage your websites on DeWeb</p> |
123 | | - </div> |
| 132 | + {quickAccessItems.map((item) => ( |
| 133 | + <QuickAccessItem |
| 134 | + key={item.path} |
| 135 | + path={item.path} |
| 136 | + title={item.title} |
| 137 | + description={item.description} |
| 138 | + href={generateUrl(item.service, item.pathUrl || '')} |
| 139 | + /> |
| 140 | + ))} |
124 | 141 | </div> |
125 | 142 | </div> |
126 | 143 | ); |
|
0 commit comments