@@ -4,11 +4,12 @@ import 'mapbox-gl/dist/mapbox-gl.css';
44import { BlankImage , Footer , getProfilePicUrl , getImageUrl , Comments } from "~/components/general" ;
55import { Icon , Divider , H2 } from "@blueprintjs/core" ;
66import h from "./main.module.sass" ;
7- import { SETTINGS } from "@macrostrat-web/settings" ;
7+ import { rockdApiOldURL , SETTINGS } from "@macrostrat-web/settings" ;
88import "@macrostrat/style-system" ;
99import { Overlay2 } from "@blueprintjs/core" ;
1010import { LithologyList } from "@macrostrat/data-components" ;
1111import { ClientOnly } from "vike-react/ClientOnly" ;
12+ import { macrostratApiURL } from "@macrostrat-web/settings" ;
1213
1314function Map ( props ) {
1415 return h (
@@ -59,14 +60,13 @@ export function Checkins({checkin, comments}) {
5960 checkin . observations . forEach ( observation => {
6061 // if photo exists
6162 const imageSrc = getImageUrl ( checkin . person_id , observation . photo ) ;
62- let observationBody = observationFooter ( observation ) ;
6363
6464 observations . push (
6565 h ( 'div' , { className : 'observation' } , [
6666 h ( 'a' , { href : "/photo/" + observation . photo } ,
6767 h ( BlankImage , { className : 'observation-image' , src : imageSrc } )
6868 ) ,
69- observationBody ,
69+ h ( ObservationFooter , { observation } ) ,
7070 ] )
7171 ) ;
7272 } ) ;
@@ -136,7 +136,7 @@ function Overlay({checkin, center, LngLatProps, ratingArr, profile_pic}) {
136136 ] )
137137}
138138
139- function observationFooter ( observation ) {
139+ export function ObservationFooter ( { observation} ) {
140140 const LngLatProps = {
141141 position : {
142142 lat : observation . lat ,
@@ -172,22 +172,30 @@ function observationFooter(observation) {
172172 return `#${ red } ${ green } ${ blue } ` ;
173173 }
174174
175- let obsAge = observation . age_est ? observation . age_est . name + " (" + observation . age_est . b_age + " - " + observation ?. age_est ?. t_age + ")" : null ;
176-
177175 let lithologies = [ ] ;
178176 rocks . liths ?. forEach ( lith => {
179177 if ( ! lith . color . includes ( "#" ) ) {
180178 lithologies . push ( {
181- name : lith . name ,
182- color : rgbaStringToHex ( lith . color ) } ) ;
179+ ...lith ,
180+ color : rgbaStringToHex ( lith . color ) ,
181+ } ) ;
183182 } else {
184183 lithologies . push ( lith ) ;
185184 }
186185 } ) ;
187186
187+ if ( rocks . interval ?. name ) {
188+ lithologies . push ( {
189+ name : rocks . interval . name ,
190+ int_id : rocks . interval . int_id ,
191+ color : `rgba(${ rocks . interval . color } )` ,
192+ } )
193+ }
194+
188195 if ( rocks . strat_name ?. strat_name_long ) {
189196 lithologies . push ( {
190197 name : rocks . strat_name ?. strat_name_long ,
198+ strat_id : rocks . strat_name ?. strat_name_id
191199 } )
192200 }
193201
@@ -197,16 +205,6 @@ function observationFooter(observation) {
197205 } )
198206 }
199207
200- if ( obsAge ) {
201- lithologies . push ( {
202- name : obsAge
203- } )
204- }
205- if ( rocks . interval ?. name ) {
206- lithologies . push ( {
207- name : rocks . interval . name
208- } )
209- }
210208 if ( observation . orientation . feature ?. name ) {
211209 lithologies . push ( {
212210 name : observation . orientation . feature ?. name
@@ -215,14 +213,26 @@ function observationFooter(observation) {
215213
216214 const show = lithologies . length > 0 || rocks ?. notes ?. length > 0 && observation . lat && rocks . strat_name ?. strat_name_long ;
217215
216+ const handleClick = ( e , data ) => {
217+ if ( data . int_id ) {
218+ window . open ( macrostratApiURL + `/lex/intervals/${ data . int_id } ` , '_blank' ) ;
219+ }
220+ if ( data . strat_id ) {
221+ window . open ( macrostratApiURL + `/lex/strat-names/${ data . strat_id } ` , '_blank' ) ;
222+ }
223+ if ( data . lith_id ) {
224+ window . open ( macrostratApiURL + `/lex/lithology/${ data . lith_id } ` , '_blank' ) ;
225+ }
226+ } ;
227+
218228 // observation body
219229 return h . if ( show ) ( "div" , { className : 'observation-body' } , [
220230 observation . lat && rocks . strat_name ?. strat_name_long ? h ( 'h4' , { className : 'observation-header' } , [
221231 rocks . strat_name ?. strat_name_long ,
222232 observation . lat ? LngLatCoords ( LngLatProps ) : null ,
223233 ] ) : null ,
224234 h ( 'div' , { className : 'observation-details' } , [
225- h ( LithologyList , { lithologies } ) ,
235+ h ( LithologyList , { lithologies, onClickItem : handleClick } ) ,
226236 h ( 'p' , { className : "notes" } , rocks . notes ) ,
227237 ] ) ,
228238 ] ) ;
0 commit comments