Changeset 79a0317 for imaps-frontend/src/pages/MyMaps
- Timestamp:
- 01/21/25 03:08:24 (3 days ago)
- Branches:
- main
- Parents:
- 0c6b92a
- Location:
- imaps-frontend/src/pages/MyMaps
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/src/pages/MyMaps/CreateMaps.module.css
r0c6b92a r79a0317 55 55 margin-bottom: 30px; 56 56 text-align: center; 57 margin-top: 5em; 58 57 59 } 58 60 59 61 .searchBar input { 60 width: 300px; 62 /*width: 300px;*/ 63 width: 33vw; 61 64 padding: 10px; 62 65 font-size: 16px; … … 83 86 display: flex; 84 87 flex-direction: column; 85 align-items: center; /* Center items horizontally */86 justify-content: flex-start; /* Ensure tiles stack from the top */88 align-items: center; 89 justify-content: flex-start; 87 90 padding: 10px; 91 /*padding-left: 2.5em;*/ 88 92 background-color: #f9f9f9; 89 93 border-radius: 8px; 90 94 box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); 91 } 95 96 } 97 92 98 93 99 .tile { … … 127 133 } 128 134 135 .plusButton { 136 width: 50px; 137 height: 50px; 138 border: none; 139 cursor: pointer; 140 display: flex; 141 align-items: center; 142 justify-content: center; 143 transition: transform 0.3s ease-in-out; 144 background: #4ebc3b; 145 margin-right: 20px; 146 } 147 148 .plusButton img { 149 width: 50px; 150 height: auto; 151 margin-left: 0; 152 } 153 154 .plusButton:hover { 155 transform: scale(1.1); 156 background: #46be2f; 157 } 158 159 .header { 160 display: flex; 161 align-items: center; 162 justify-content: space-between; 163 background-color: #f8f9fa; /* Light grey background for a clean look */ 164 border-bottom: 1px solid #ddd; /* Subtle separation from the rest of the page */ 165 padding: 10px 20px; /* Add some space around the content */ 166 box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Light shadow for subtle elevation */ 167 } 168 169 .header .logo-wrapper, 170 .header .profile-wrapper { 171 display: flex; 172 align-items: center; 173 } 174 175 .header h1 { 176 font-size: 1.5rem; /* Slightly larger font size */ 177 color: #333; /* Dark grey for a professional tone */ 178 margin: 0 auto; /* Center-align the title */ 179 font-weight: 600; /* Semi-bold text for emphasis */ 180 text-align: center; 181 flex-grow: 1; /* Allow it to take space in the middle */ 182 } 183 184 .logo-wrapper { 185 margin-right: auto; /* Push logo to the far left */ 186 } 187 188 .profile-wrapper { 189 margin-left: auto; /* Push profile to the far right */ 190 } 191 192 193 194 129 195 @media (max-width: 768px) { 130 196 .mapsContainer { -
imaps-frontend/src/pages/MyMaps/MyMaps.jsx
r0c6b92a r79a0317 10 10 import {useAppContext} from "../../components/AppContext/AppContext.jsx"; 11 11 import config from "../../scripts/net/netconfig.js"; 12 import {element} from "prop-types";13 12 import Toast from "../../components/Toast/Toast.jsx"; 13 import plus_icon from "../../assets/plus_icon.png"; 14 14 15 15 const renderTile = ({data, isDragging}, openMapInfo) => ( … … 65 65 setToastMessage(message); 66 66 setToastType(type); 67 setTimeout(() => setToastMessage(null), 3000); // Automatically hide the toast after 3 seconds 68 }; 69 67 setTimeout(() => setToastMessage(null), 3000); 68 }; 70 69 71 70 const handleUpdate = async (updatedMap) => { 72 // Placeholder for map update logic 71 try { 72 let httpService = new HttpService(true); 73 const response = await httpService.post( 74 config.my_maps.edit_map_info, 75 updatedMap 76 ); 77 closeMapInfoModal() 78 window.location.reload(); 79 80 } catch (error) { 81 showToast("Map Name already taken", 0) 82 closeMapInfoModal() 83 } 73 84 }; 74 85 … … 83 94 setTiles((prevTiles) => prevTiles.filter((tile) => tile.mapName !== mapName)); 84 95 setAllTiles((prevTiles) => prevTiles.filter((tile) => tile.mapName !== mapName)); 85 showToast("Map deleted", 1) 96 showToast("Map deleted", 1); 86 97 }) 87 98 .catch((error) => { 88 99 const errorMessage = error.response?.data?.error || error.message || "Unknown error"; 89 // alert(`Error deleting the map: ${errorMessage}`); 90 showToast(`Error deleting the map: ${errorMessage}`, 0) 100 showToast(`Error deleting the map: ${errorMessage}`, 0); 91 101 }); 92 102 }; … … 97 107 98 108 httpService 99 .put(`${config.my_maps.add}?username=${ username}`, mapDetails)109 .put(`${config.my_maps.add}?username=${encodeURI(username)}`, mapDetails) 100 110 .then((respMap) => { 101 console.log("RESP NEW MAP: " + respMap)102 111 const mapTile = { 103 112 mapName: respMap.mapName, … … 108 117 modified_at: respMap.modifiedAt, 109 118 published_at: respMap.published_at, 110 gmaps_url: respMap.gmaps _url,119 gmaps_url: respMap.gmapsUrl, 111 120 image_url: card, 112 121 is_published: respMap.is_published, 122 mapType: respMap.mapType 113 123 }; 114 124 … … 116 126 setTiles((prevTiles) => [...prevTiles, mapTile]); 117 127 showToast("Map added successfully!"); 118 119 120 128 }) 121 129 .catch((error) => { 122 showToast("Map name already taken", 0) 130 showToast("Map name already taken", 0); 123 131 }); 124 132 }; … … 129 137 httpService.setAuthenticated(); 130 138 131 const respMaps = await httpService.get(`${config.my_maps.display}?username=${username}`); 139 const respMaps = await httpService.get( 140 `${config.my_maps.display}?username=${encodeURI(username)}` 141 ); 132 142 133 143 const mapTiles = respMaps.map((elem) => ({ … … 139 149 modified_at: elem.modifiedAt, 140 150 published_at: elem.published_at, 141 gmaps_url: elem.g MapsUrl,151 gmaps_url: elem.gmapsUrl, 142 152 image_url: card, 143 153 numFavourites: elem.numFavourites, 144 154 })); 145 146 155 147 156 setTiles(mapTiles); … … 154 163 setPublicMaps(tiles.filter((tile) => tile.status === "PUBLIC")); 155 164 setPrivateMaps(tiles.filter((tile) => tile.status === "PRIVATE")); 156 setPendingMaps(tiles.filter((tile) => tile.status === " INVALID"));165 setPendingMaps(tiles.filter((tile) => tile.status === "PENDING")); 157 166 }, [tiles]); 158 167 … … 164 173 return ( 165 174 <div className={styles.container}> 166 <Logo/> 167 <Profile/> 175 176 <div className={`${styles.logoWrapper}`}> 177 <Logo/> 178 </div> 168 179 <h1>Your Maps</h1> 169 170 <div className={styles.actionButtons}> 171 <button className={styles.createMapsButton} onClick={openCreateModal}> 172 Create Map 173 </button> 174 </div> 180 <div className={`${styles.profileWrapper}`}> 181 <Profile/> 182 </div> 183 175 184 176 185 <div className={styles.searchBar}> 177 <input type="text" placeholder="Search for maps..." onChange={handleSearch}/> 186 <input 187 type="text" 188 placeholder="Search for maps..." 189 onChange={handleSearch} 190 /> 178 191 </div> 179 192 … … 201 214 forceTileHeight={170} 202 215 /> 216 <button className={styles.plusButton} onClick={openCreateModal}> 217 <img src={plus_icon} alt="Add Map"/> 218 </button> 203 219 </div> 204 220 … … 222 238 onDelete={deleteMap} 223 239 onUpdate={handleUpdate} 224 onPublish={() => { 240 onPublish={(updatedMap = null) => { 241 242 const updatedTile = { 243 mapName: updatedMap.mapName, 244 cols: 1, 245 rows: 1, 246 status: updatedMap.mapStatus, 247 created_at: updatedMap.createdAt, 248 modified_at: updatedMap.modifiedAt, 249 published_at: updatedMap.published_at, 250 gmaps_url: updatedMap.gMapsUrl, 251 image_url: card, 252 numFavourites: updatedMap.numFavourites, 253 } 225 254 showToast(`Map ${selectedMap.mapName} published successfully!`); 226 255 setPrivateMaps((prevMaps) => prevMaps.filter(m => m.mapName !== selectedMap.mapName)) 227 setPendingMaps((prevMaps) => [...prevMaps, allTiles.find(m => m.mapName = selectedMap.mapName)])256 setPendingMaps((prevMaps) => [...prevMaps, updatedTile]) 228 257 closeMapInfoModal() 229 258 }} … … 236 265 /> 237 266 238 {toastMessage && <Toast message={toastMessage} type={toastType} onClose={() => setToastMessage(null)}/>} 267 {toastMessage && ( 268 <Toast 269 message={toastMessage} 270 type={toastType} 271 onClose={() => setToastMessage(null)} 272 /> 273 )} 239 274 </div> 240 275 );
Note:
See TracChangeset
for help on using the changeset viewer.