|
| 1 | +import React from "react"; |
| 2 | +import { ArrowLeft, Search, AlertCircle, X } from "lucide-react"; |
| 3 | +import Footer from "./Footer"; |
| 4 | + |
| 5 | +interface BlacklistManagementProps { |
| 6 | + searchTerm: string; |
| 7 | + currentUrl: string; |
| 8 | + filteredBlacklist: string[]; |
| 9 | + isCurrentUrlBlacklisted: boolean; |
| 10 | + onSearchChange: (value: string) => void; |
| 11 | + onReturnToMain: () => void; |
| 12 | + onAddCurrentSite: () => void; |
| 13 | + onRemoveSite: (site: string) => void; |
| 14 | +} |
| 15 | + |
| 16 | +const BlacklistManagement: React.FC<BlacklistManagementProps> = ({ |
| 17 | + searchTerm, |
| 18 | + currentUrl, |
| 19 | + filteredBlacklist, |
| 20 | + isCurrentUrlBlacklisted, |
| 21 | + onSearchChange, |
| 22 | + onReturnToMain, |
| 23 | + onAddCurrentSite, |
| 24 | + onRemoveSite, |
| 25 | +}) => { |
| 26 | + return ( |
| 27 | + <div className="flex flex-col min-h-[700px]"> |
| 28 | + <div className="flex items-center gap-3 mb-4"> |
| 29 | + <button |
| 30 | + onClick={onReturnToMain} |
| 31 | + className="p-1 rounded-full hover:bg-neutral-100" |
| 32 | + > |
| 33 | + <ArrowLeft size={18} /> |
| 34 | + </button> |
| 35 | + <h1 className="text-xl font-bold">Manage Excluded Sites</h1> |
| 36 | + </div> |
| 37 | + |
| 38 | + <div className="relative mb-3"> |
| 39 | + <div className="absolute left-3 top-1/2 -translate-y-1/2 text-neutral-500"> |
| 40 | + <Search size={15} /> |
| 41 | + </div> |
| 42 | + <input |
| 43 | + type="text" |
| 44 | + className="w-full pl-9 pr-3 py-2 bg-white border border-neutral-200 rounded-lg text-sm" |
| 45 | + placeholder="Search excluded sites..." |
| 46 | + value={searchTerm} |
| 47 | + onChange={(e) => onSearchChange(e.target.value)} |
| 48 | + autoFocus |
| 49 | + /> |
| 50 | + </div> |
| 51 | + |
| 52 | + <div className="mb-4"> |
| 53 | + <h2 className="text-sm font-medium text-neutral-500 mb-2"> |
| 54 | + Current Site |
| 55 | + </h2> |
| 56 | + <div className="bg-white rounded-lg border border-neutral-200 p-3 flex justify-between items-center"> |
| 57 | + <div className="flex items-center gap-2"> |
| 58 | + <div className="w-5 h-5 bg-neutral-200 rounded-full overflow-hidden"> |
| 59 | + {currentUrl && ( |
| 60 | + <img |
| 61 | + src={`https://www.google.com/s2/favicons?domain=${currentUrl}&sz=64`} |
| 62 | + alt="" |
| 63 | + className="w-full h-full object-cover" |
| 64 | + /> |
| 65 | + )} |
| 66 | + </div> |
| 67 | + <span className="text-sm font-medium truncate max-w-[200px]"> |
| 68 | + {currentUrl} |
| 69 | + </span> |
| 70 | + </div> |
| 71 | + |
| 72 | + {isCurrentUrlBlacklisted ? ( |
| 73 | + <button |
| 74 | + onClick={() => onRemoveSite(currentUrl)} |
| 75 | + className="text-sm px-3 py-1 bg-neutral-200 text-neutral-700 rounded-sm hover:bg-neutral-300 transition-colors" |
| 76 | + > |
| 77 | + Remove |
| 78 | + </button> |
| 79 | + ) : ( |
| 80 | + <button |
| 81 | + onClick={onAddCurrentSite} |
| 82 | + className="text-sm px-3 py-1 bg-neutral-900 text-white rounded-sm hover:bg-neutral-800 transition-colors flex items-center gap-1" |
| 83 | + > |
| 84 | + Exclude |
| 85 | + </button> |
| 86 | + )} |
| 87 | + </div> |
| 88 | + </div> |
| 89 | + |
| 90 | + <div className="flex-1 overflow-hidden flex flex-col min-h-0"> |
| 91 | + <h2 className="text-sm font-medium text-neutral-500 mb-2"> |
| 92 | + All Excluded Sites |
| 93 | + </h2> |
| 94 | + <div className="flex-1 overflow-y-auto bg-white rounded-lg border border-neutral-200"> |
| 95 | + {filteredBlacklist.length > 0 ? ( |
| 96 | + filteredBlacklist.map((site) => ( |
| 97 | + <div |
| 98 | + key={site} |
| 99 | + className="flex justify-between items-center py-3 px-3 border-b border-neutral-200 last:border-0 hover:bg-neutral-50" |
| 100 | + > |
| 101 | + <div className="flex items-center gap-2"> |
| 102 | + <div className="w-5 h-5 bg-neutral-200 rounded-full overflow-hidden"> |
| 103 | + <img |
| 104 | + src={`https://www.google.com/s2/favicons?domain=${site}&sz=64`} |
| 105 | + alt="" |
| 106 | + className="w-full h-full object-cover" |
| 107 | + /> |
| 108 | + </div> |
| 109 | + <span className="text-sm text-neutral-700">{site}</span> |
| 110 | + </div> |
| 111 | + <button |
| 112 | + onClick={() => onRemoveSite(site)} |
| 113 | + className="text-neutral-500 hover:text-red-500" |
| 114 | + > |
| 115 | + <X size={15} /> |
| 116 | + </button> |
| 117 | + </div> |
| 118 | + )) |
| 119 | + ) : ( |
| 120 | + <div className="py-8 px-3 text-center flex flex-col items-center gap-2"> |
| 121 | + {searchTerm ? ( |
| 122 | + <p className="text-sm text-neutral-500"> |
| 123 | + No results match "{searchTerm}" |
| 124 | + </p> |
| 125 | + ) : ( |
| 126 | + <> |
| 127 | + <div className="text-neutral-400"> |
| 128 | + <AlertCircle size={15} /> |
| 129 | + </div> |
| 130 | + <p className="text-sm text-neutral-500"> |
| 131 | + No sites in exclusion list yet |
| 132 | + </p> |
| 133 | + </> |
| 134 | + )} |
| 135 | + </div> |
| 136 | + )} |
| 137 | + </div> |
| 138 | + </div> |
| 139 | + |
| 140 | + <Footer /> |
| 141 | + </div> |
| 142 | + ); |
| 143 | +}; |
| 144 | + |
| 145 | +export default BlacklistManagement; |
0 commit comments