|
| 1 | +import React, { useState, useEffect } from 'react'; |
| 2 | +import { useParams, Link } from 'react-router-dom'; |
| 3 | +import useSeo from '../../hooks/useSeo'; |
| 4 | +import { ArrowLeftIcon } from '@phosphor-icons/react'; |
| 5 | +import { motion } from 'framer-motion'; |
| 6 | + |
| 7 | +const RoadmapItemDetailPage = () => { |
| 8 | + const { id } = useParams(); |
| 9 | + const [roadmapItem, setRoadmapItem] = useState(null); |
| 10 | + const [isLoading, setIsLoading] = useState(true); |
| 11 | + |
| 12 | + useSeo({ |
| 13 | + title: roadmapItem ? `${roadmapItem.title} | Roadmap` : 'Roadmap Item | Fezcodex', |
| 14 | + description: roadmapItem ? roadmapItem.description : 'Details of a roadmap item.', |
| 15 | + keywords: ['Fezcodex', 'roadmap', 'item', id], |
| 16 | + ogTitle: roadmapItem ? `${roadmapItem.title} | Roadmap` : 'Roadmap Item | Fezcodex', |
| 17 | + ogDescription: roadmapItem ? roadmapItem.description : 'Details of a roadmap item.', |
| 18 | + ogImage: 'https://fezcode.github.io/logo512.png', // Assuming a default image |
| 19 | + twitterCard: 'summary_large_image', |
| 20 | + twitterTitle: roadmapItem ? `${roadmapItem.title} | Roadmap` : 'Roadmap Item | Fezcodex', |
| 21 | + twitterDescription: roadmapItem ? roadmapItem.description : 'Details of a roadmap item.', |
| 22 | + twitterImage: 'https://fezcode.github.io/logo512.png', |
| 23 | + }); |
| 24 | + |
| 25 | + useEffect(() => { |
| 26 | + const fetchRoadmapItem = async () => { |
| 27 | + try { |
| 28 | + const response = await fetch('/roadmap/roadmap.json'); |
| 29 | + const data = await response.json(); |
| 30 | + const foundItem = data.find((item) => item.id === id); |
| 31 | + setRoadmapItem(foundItem); |
| 32 | + setIsLoading(false); |
| 33 | + } catch (error) { |
| 34 | + console.error('Failed to fetch roadmap item:', error); |
| 35 | + setIsLoading(false); |
| 36 | + } |
| 37 | + }; |
| 38 | + |
| 39 | + fetchRoadmapItem(); |
| 40 | + }, [id]); |
| 41 | + |
| 42 | + const getStatusColor = (status) => { |
| 43 | + switch (status) { |
| 44 | + case 'Planned': |
| 45 | + return 'bg-blue-500'; |
| 46 | + case 'In Progress': |
| 47 | + return 'bg-yellow-500'; |
| 48 | + case 'Completed': |
| 49 | + return 'bg-green-500'; |
| 50 | + case 'On Hold': |
| 51 | + return 'bg-red-500'; |
| 52 | + default: |
| 53 | + return 'bg-gray-500'; |
| 54 | + } |
| 55 | + }; |
| 56 | + |
| 57 | + const getPriorityColor = (priority) => { |
| 58 | + switch (priority) { |
| 59 | + case 'High': |
| 60 | + return 'text-red-400'; |
| 61 | + case 'Medium': |
| 62 | + return 'text-yellow-400'; |
| 63 | + case 'Low': |
| 64 | + return 'text-green-400'; |
| 65 | + default: |
| 66 | + return 'text-gray-400'; |
| 67 | + } |
| 68 | + }; |
| 69 | + |
| 70 | + if (isLoading) { |
| 71 | + return ( |
| 72 | + <div className="py-8 sm:py-16 text-center text-gray-400">Loading...</div> |
| 73 | + ); |
| 74 | + } |
| 75 | + |
| 76 | + if (!roadmapItem) { |
| 77 | + return ( |
| 78 | + <div className="py-8 sm:py-16 text-center text-gray-400"> |
| 79 | + Roadmap item not found. |
| 80 | + </div> |
| 81 | + ); |
| 82 | + } |
| 83 | + |
| 84 | + return ( |
| 85 | + <motion.div |
| 86 | + initial={{ opacity: 0, y: 20 }} |
| 87 | + animate={{ opacity: 1, y: 0 }} |
| 88 | + transition={{ duration: 0.5 }} |
| 89 | + className="py-8 sm:py-16" |
| 90 | + > |
| 91 | + <div className="mx-auto max-w-4xl px-6 lg:px-8"> |
| 92 | + <Link |
| 93 | + to="/roadmap" |
| 94 | + className="group text-primary-400 hover:underline flex items-center gap-2 text-lg mb-8" |
| 95 | + > |
| 96 | + <ArrowLeftIcon className="text-xl transition-transform group-hover:-translate-x-1" />{' '} |
| 97 | + Back to Roadmap |
| 98 | + </Link> |
| 99 | + |
| 100 | + <div className="bg-gray-900/80 backdrop-blur-xl rounded-xl shadow-xl p-6 lg:p-8 border border-gray-700 relative overflow-hidden"> |
| 101 | + {/* Subtle Grid Background */} |
| 102 | + <div |
| 103 | + className="absolute inset-0 opacity-[0.03] pointer-events-none z-0" |
| 104 | + style={{ |
| 105 | + backgroundImage: |
| 106 | + 'linear-gradient(to right, #ffffff 1px, transparent 1px), linear-gradient(to bottom, #ffffff 1px, transparent 1px)', |
| 107 | + backgroundSize: '20px 20px', |
| 108 | + }} |
| 109 | + ></div> |
| 110 | + <h1 className="text-4xl font-bold text-white mb-4 relative z-10 font-mono tracking-tight"> |
| 111 | + {roadmapItem.title} |
| 112 | + </h1> |
| 113 | + <p className="text-gray-300 text-lg mb-6 relative z-10 font-mono"> |
| 114 | + {roadmapItem.description} |
| 115 | + </p> |
| 116 | + |
| 117 | + <div className="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6 relative z-10"> |
| 118 | + <div> |
| 119 | + <p className="text-gray-400 font-mono font-medium">Status:</p> |
| 120 | + <span |
| 121 | + className={`px-3 py-1 inline-flex text-sm leading-5 font-semibold rounded-full ${getStatusColor(roadmapItem.status)}`} |
| 122 | + > |
| 123 | + {roadmapItem.status || 'Planned'} |
| 124 | + </span> |
| 125 | + </div> |
| 126 | + <div> |
| 127 | + <p className="text-gray-400 font-mono font-medium">Priority:</p> |
| 128 | + <span |
| 129 | + className={`px-3 py-1 inline-flex text-sm leading-5 font-semibold rounded-full ${getPriorityColor(roadmapItem.priority)}`} |
| 130 | + > |
| 131 | + {roadmapItem.priority || 'Low'} |
| 132 | + </span> |
| 133 | + </div> |
| 134 | + <div> |
| 135 | + <p className="text-gray-400 font-mono font-medium">Category:</p> |
| 136 | + <p className="text-white font-mono">{roadmapItem.category}</p> |
| 137 | + </div> |
| 138 | + <div> |
| 139 | + <p className="text-gray-400 font-mono font-medium">Created At:</p> |
| 140 | + <p className="text-white font-mono"> |
| 141 | + {new Date(roadmapItem.created_at).toLocaleDateString()} |
| 142 | + </p> |
| 143 | + </div> |
| 144 | + {roadmapItem.due_date && ( |
| 145 | + <div> |
| 146 | + <p className="text-gray-400 font-mono font-medium">Due Date:</p> |
| 147 | + <p className="text-white font-mono"> |
| 148 | + {new Date(roadmapItem.due_date).toLocaleDateString()} |
| 149 | + </p> |
| 150 | + </div> |
| 151 | + )} |
| 152 | + </div> |
| 153 | + |
| 154 | + {roadmapItem.notes && ( |
| 155 | + <div className="mt-6 border-t border-gray-700 pt-6 relative z-10"> |
| 156 | + <h3 className="text-xl font-mono font-semibold text-white mb-2">Notes:</h3> |
| 157 | + <p className="text-gray-300 font-mono whitespace-pre-wrap"> |
| 158 | + {roadmapItem.notes} |
| 159 | + </p> |
| 160 | + </div> |
| 161 | + )} |
| 162 | + </div> |
| 163 | + </div> |
| 164 | + </motion.div> |
| 165 | + ); |
| 166 | +}; |
| 167 | + |
| 168 | +export default RoadmapItemDetailPage; |
0 commit comments