@@ -2,11 +2,11 @@ import h from "./main.module.sass";
22import { useState } from 'react' ;
33import mapboxgl from 'mapbox-gl' ;
44import 'mapbox-gl/dist/mapbox-gl.css' ;
5- import { BlankImage , getProfilePicUrl , Image , createCheckins } from "~/components/general" ;
5+ import { BlankImage , getProfilePicUrl , Image , createCheckins , Comments } from "~/components/general" ;
66import "@macrostrat/style-system" ;
7- import { SETTINGS } from "@macrostrat-web/settings" ;
7+ import { rockdApiURL , SETTINGS } from "@macrostrat-web/settings" ;
88import { DarkModeButton , useDarkMode } from "@macrostrat/ui-components" ;
9- import { Divider , Icon , Spinner } from "@blueprintjs/core" ;
9+ import { Divider , Icon , Overlay2 , Spinner } from "@blueprintjs/core" ;
1010import {
1111 MapAreaContainer ,
1212 MapMarker ,
@@ -15,9 +15,10 @@ import {
1515} from "@macrostrat/map-interface" ;
1616import { useMapRef } from "@macrostrat/mapbox-react" ;
1717
18- export function Trips ( { data} ) {
18+ export function Trips ( { data, commentsData } ) {
1919 const [ showSatelite , setSatelite ] = useState ( false ) ;
2020 console . log ( "Trips data:" , data ) ;
21+ console . log ( "Comments data:" , commentsData ) ;
2122
2223 const style = useMapStyle ( { showSatelite} ) ;
2324
@@ -28,7 +29,7 @@ export function Trips({data}) {
2829 data . updated = date . toLocaleDateString ( 'en-US' , options ) ;
2930
3031 const toolbar = h ( Toolbar , { showSatelite, setSatelite} ) ;
31- const sidebar = h ( SideBar , { data} ) ;
32+ const sidebar = h ( SideBar , { data, commentsData } ) ;
3233
3334 if ( ! sidebar ) {
3435 return h ( "div" , { className : 'loading' } , [
@@ -101,11 +102,13 @@ function useMapStyle({showSatelite}) {
101102 return showSatelite ? SETTINGS . satelliteMapURL : useDarkMode ( ) ?. isEnabled ? SETTINGS . darkMapURL : SETTINGS . whiteMapURL ;
102103}
103104
104- function SideBar ( { data} ) {
105+ function SideBar ( { data, commentsData } ) {
105106 const mapRef = useMapRef ( ) ;
106107 const map = mapRef . current ;
107108 const profile_pic = h ( BlankImage , { src : getProfilePicUrl ( data . person_id ) , className : "profile-pic-header" } ) ;
108109 const stops = data . stops ;
110+ const [ commentsOpen , setCommentsOpen ] = useState ( false ) ;
111+ console . log ( "commentsOpen:" , commentsOpen ) ;
109112
110113 if ( ! map ) return h ( "div" , { className : "stop-container loading2" } , [
111114 h ( "h1" , "Loading trip " + data . trip_id + "..." ) ,
@@ -187,12 +190,34 @@ function SideBar({data}) {
187190 h ( 'h4' , { className : 'edited' } , "Edited " + data . updated ) ,
188191 ] ) ,
189192 h ( 'div' , { className : 'download-button' } , [
190- h ( 'a' , { className : 'kmz' , href : import . meta . env . ROCKD_API_URL + "/trips/" + data . trip_id + "?format=kmz" } , "DOWNLOAD KMZ" ) ,
193+ h ( 'a' , { className : 'kmz' , href : rockdApiURL + "/trips/" + data . trip_id + "?format=kmz" } , "DOWNLOAD KMZ" ) ,
191194 ] ) ,
192195 ] ) ,
193196 h ( "div.details" , [
194197 h ( 'h1' , { className : 'park' } , data . name ) ,
195198 h ( 'p' , { className : 'description' } , data . description ) ,
199+ h . if ( commentsData ?. length > 0 ) ( 'div' , { className : 'download-button' , onClick : ( ) => setCommentsOpen ( true ) } , [
200+ h ( 'div' , { className : 'kmz' } , "View comments" ) ,
201+ ] ) ,
202+ h . if ( commentsData ?. length > 0 ) ( Overlay2 , { className : 'overlay' , isOpen : commentsOpen , usePortal : true } , [
203+ h ( 'div' , { className : 'overlay-content' } , [
204+ h ( 'div.comments-container' , [
205+ h ( 'div.comments-header' , [
206+ h ( 'h2' , { className : 'comments-title' } , "Comments" ) ,
207+ h ( Icon , {
208+ icon : "cross" ,
209+ className : "close-icon" ,
210+ onClick : ( ) => {
211+ setCommentsOpen ( false )
212+ } ,
213+ style : { cursor : "pointer" , color : "red" } ,
214+ } ) ,
215+ ] ) ,
216+ h ( Divider ) ,
217+ h ( Comments , { comments : commentsData } ) ,
218+ ] )
219+ ] )
220+ ] )
196221 ] ) ,
197222 ] ) ,
198223 h ( 'div' , { className : 'stop-bottom' } , [
0 commit comments