@@ -10,6 +10,7 @@ import { Overlay2 } from "@blueprintjs/core";
1010import { LithologyList } from "@macrostrat/data-components" ;
1111import { ClientOnly } from "vike-react/ClientOnly" ;
1212import { macrostratApiURL } from "@macrostrat-web/settings" ;
13+ import { ContentPage } from "~/layouts" ;
1314
1415function Map ( props ) {
1516 return h (
@@ -23,13 +24,22 @@ function Map(props) {
2324}
2425
2526export function Checkins ( { checkin, comments} ) {
26- console . log ( "Checkin data:" , checkin ) ;
27+ if ( checkin === undefined ) {
28+ return h ( 'div' , [
29+ h ( ContentPage , [
30+ h ( 'h2' , "Checkin not found" ) ,
31+ h ( Divider ) ,
32+ h ( 'p' , "This checkin does not exist or has been deleted." ) ,
33+ ] ) ,
34+ h ( Footer )
35+ ] ) ;
36+ }
2737 const center = {
2838 lat : checkin . lat ,
2939 lng : checkin . lng
3040 }
3141
32- let profile_pic = h ( 'div.profile-header' , h ( BlankImage , { src : getProfilePicUrl ( checkin . person_id ) , className : "profile-picture" } ) ) ;
42+ let profile_pic = h ( 'div.profile-header' , h ( BlankImage , { src : getProfilePicUrl ( checkin . person_id ) , className : "profile-picture" } ) ) ;
3343
3444 // format rating
3545 let ratingArr = [ ] ;
@@ -48,8 +58,8 @@ export function Checkins({checkin, comments}) {
4858 const headerBody = h ( 'h4' , { className : 'observation-header' } , checkin . notes ) ;
4959
5060 observations . push (
51- h ( 'div' , { className : 'observation' } , [
52- h ( 'a' , { href : "/photo/" + checkin . photo } ,
61+ h . if ( checkin . photo || checkin . notes ) ( 'div' , { className : 'observation' } , [
62+ h . if ( checkin . photo ) ( 'a' , { href : "/photo/" + checkin . photo } ,
5363 h ( BlankImage , { className : 'observation-image' , src : imageSrc , alt : "presentation" } )
5464 ) ,
5565 h ( "div.observation-body" , headerBody ) ,
@@ -61,9 +71,11 @@ export function Checkins({checkin, comments}) {
6171 // if photo exists
6272 const imageSrc = getImageUrl ( checkin . person_id , observation . photo ) ;
6373
74+ console . log ( "Observation data:" , observation ) ;
75+
6476 observations . push (
65- h ( 'div' , { className : 'observation' } , [
66- h ( 'a' , { href : "/photo/" + observation . photo } ,
77+ h . if ( observation . photo || observation . lat || observation . lng || ! objectNull ( observation . fossils ) || ! objectNull ( observation . minerals ) || ! objectNull ( observation . rocks ) ) ( 'div' , { className : 'observation' } , [
78+ h . if ( observation . photo ) ( 'a' , { href : "/photo/" + observation . photo } ,
6779 h ( BlankImage , { className : 'observation-image' , src : imageSrc } )
6880 ) ,
6981 h ( ObservationFooter , { observation} ) ,
@@ -188,7 +200,7 @@ export function ObservationFooter({observation}) {
188200 lithologies . push ( {
189201 name : rocks . interval . name ,
190202 int_id : rocks . interval . int_id ,
191- color : `rgba(${ rocks . interval . color } )` ,
203+ color : rocks . interval . color . includes ( "#" ) ? rocks . interval . color : `rgba(${ rocks . interval . color } )` ,
192204 } )
193205 }
194206
@@ -225,6 +237,8 @@ export function ObservationFooter({observation}) {
225237 }
226238 } ;
227239
240+ console . log ( "Rocks data:" , lithologies ) ;
241+
228242 // observation body
229243 return h . if ( show ) ( "div" , { className : 'observation-body' } , [
230244 observation . lat && rocks . strat_name ?. strat_name_long ? h ( 'h4' , { className : 'observation-header' } , [
@@ -236,4 +250,8 @@ export function ObservationFooter({observation}) {
236250 h ( 'p' , { className : "notes" } , rocks . notes ) ,
237251 ] ) ,
238252 ] ) ;
253+ }
254+
255+ function objectNull ( obj ) {
256+ return Object . keys ( obj ) . length === 0 && obj . constructor === Object ;
239257}
0 commit comments