All files / applications/go-by-transit/src/view/nearby/components NearbyPlaceDetails.tsx

66.66% Statements 2/3
92.2% Branches 71/77
66.66% Functions 2/3
66.66% Lines 2/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346                                                                                          214x                   10x                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
import { Button } from "@wintermuted/ui-react";
import React from "react";
import { PlaceDetailsPanel } from "@overworld/ui";
import FontAwesome from "react-fontawesome";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Link } from "react-router-dom";
import {
  categoryName,
  CULTURE_PLACE_CATEGORIES,
  OUTING_PLACE_CATEGORIES,
  PLACE_INFO,
  placePlannerLink,
  type InterestPlace,
  type PlaceCategory,
  type PlaceSourceState,
} from "@overworld/places/catalog";
import { type SavedPlaceControls } from "@overworld/places/savedPlaces";
import { placeIconDefinition } from "../util/mapbox/placeIcons";
import LoadStatus, { type LoadIssue } from "./PlacesLoadStatus";
 
interface Props {
  selected: InterestPlace;
  heading: React.Ref<HTMLHeadingElement>;
  sources: Record<PlaceCategory, PlaceSourceState>;
  placeIssues: LoadIssue[];
  savedIssues: LoadIssue[];
  markerIssues: LoadIssue[];
  savedPlaces?: SavedPlaceControls;
  origin?: number[];
  originMode?: string;
  viewSearch: string;
}
 
export default function NearbyPlaceDetails({
  selected,
  heading,
  sources,
  placeIssues,
  savedIssues,
  markerIssues,
  savedPlaces,
  origin,
  originMode,
  viewSearch,
}: Props) {
  return (
    <PlaceDetailsPanel
      name={selected.name}
      headingId="selected-place-heading"
      headingRef={heading}
      status={
        <>
          <LoadStatus
            label={categoryName(selected.category)}
            issues={placeIssues.filter(
              (issue) => issue.label === categoryName(selected.category),
            )}
            loading={sources[selected.category].loading}
          />
          <LoadStatus label="Saved places" issues={savedIssues} />
          <LoadStatus label="Place markers" issues={markerIssues} />
        </>
      }
      category={
        <>
          <FontAwesomeIcon
            icon={placeIconDefinition(selected.category)}
            aria-hidden="true"
          />{" "}
          {PLACE_INFO[selected.category].singular}
        </>
      }
      bookmarkAction={
        savedPlaces && (
          <Button
            size="sm"
            variant="secondary"
            aria-pressed={Boolean(savedPlaces.saved[selected.id])}
            onClick={() => savedPlaces.toggle(selected)}
          >
            <FontAwesome
              name={savedPlaces.saved[selected.id] ? "bookmark" : "bookmark-o"}
              aria-hidden="true"
            />{" "}
            {savedPlaces.saved[selected.id]
              ? "Remove saved place"
              : "Save place"}
          </Button>
        )
      }
      address={selected.address}
      arrivalNotice="Approximate map location, not a verified public entrance. Confirm your arrival point before finding trips."
      tripAction={
        <Link
          className="wm-btn wm-btn-primary"
          to={placePlannerLink(selected, origin, originMode, viewSearch)}
        >
          Plan a trip here
        </Link>
      }
      sourceUrl={selected.sourceUrl}
      website={selected.website}
      sourceDate={
        sources[selected.category].snapshot?.sourceUpdatedAt
          ? new Date(
              sources[selected.category].snapshot.sourceUpdatedAt,
            ).toLocaleDateString()
          : undefined
      }
    >
      {["drinking-fountain", "picnic-seating", "park-artwork"].includes(
        selected.category,
      ) && (
        <section aria-label="Park amenity information">
          <h3>Source-listed amenity</h3>
          <p>
            {selected.amenityStyle ||
              selected.amenityType ||
              PLACE_INFO[selected.category].singular}
          </p>
          {selected.category === "drinking-fountain" ? (
            <p>
              Water service, potability, seasonal operation and accessible
              approaches are not verified. Some listed assets are dog bowls.
              Check local signs and the fixture before relying on this stop.
            </p>
          ) : selected.category === "picnic-seating" ? (
            <p>
              Each marker represents an individual table or bench, not a
              reservable picnic area. Seating, availability, reservations, fees,
              condition and accessible approaches are not verified.
            </p>
          ) : (
            <p>
              This is a Parks asset record, not a complete public-art directory
              or a verified artwork title. Current visibility, condition and
              public access are not verified.
            </p>
          )}
        </section>
      )}
      {selected.category === "grocery-store" && (
        <p>
          Source-listed grocery store, not live opening or stock information.
          Confirm the current location and hours before traveling.
        </p>
      )}
      {selected.category === "reuse-repair" && (
        <section aria-label="Reuse and repair services">
          <h3>Source-listed services</h3>
          {selected.reuseServices && <p>{selected.reuseServices}</p>}
          {selected.reuseItems && (
            <p>
              <strong>Items:</strong> {selected.reuseItems}
            </p>
          )}
          <p>
            This listing may be out of date. Confirm hours, eligibility,
            appointments, accepted items, and fees before visiting or bringing
            donations.
          </p>
        </section>
      )}
      {selected.category === "csa-pickup" && (
        <section aria-label="CSA pickup information">
          <h3>Source-listed pickup</h3>
          {selected.pickupSeason && (
            <p>
              <strong>Season:</strong> {selected.pickupSeason}
            </p>
          )}
          {selected.pickupProducts && (
            <p>
              <strong>Products:</strong> {selected.pickupProducts}
            </p>
          )}
          <p>
            Community-supported agriculture (CSA) pickups may require
            membership, scheduled collection, and permission to access the site.
            This is not a public market or a live schedule. Confirm the current
            pickup location and arrangements with the farm; do not enter private
            property without permission.
          </p>
        </section>
      )}
      {selected.category === "bicycle-parking" && (
        <section aria-label="Bicycle rack information">
          <h3>Source-listed rack</h3>
          <p>
            <strong>Capacity:</strong>{" "}
            {selected.bikeSpaces === undefined
              ? "Unknown"
              : `${selected.bikeSpaces} spaces`}
          </p>
          <p>
            <strong>Covered:</strong>{" "}
            {selected.bikeCovered === "yes"
              ? "Yes"
              : selected.bikeCovered === "no"
                ? "No"
                : "Unknown"}
          </p>
          <p>
            Markers and cluster counts represent racks, not spaces. This is not
            live availability or a guarantee of condition, security, or access.
            Check the rack and local signs before parking. Trip planning does
            not reserve parking or select a cycling route.
          </p>
        </section>
      )}
      {selected.category === "public-restroom" && (
        <section aria-label="Restroom access">
          <h3>Source-listed access</h3>
          <p>
            <strong>Status:</strong>{" "}
            {selected.restroomStatus === "listed-24-7"
              ? "Listed 24/7 in the source; not verified."
              : "Opening status unknown."}
          </p>
          <p>
            <strong>ADA designation:</strong>{" "}
            {selected.restroomAda === "yes"
              ? "Yes (source-listed)"
              : selected.restroomAda === "no"
                ? "No (source-listed)"
                : "Unknown"}
          </p>
          <p>
            Not live availability or a verified accessible route. Seasonal
            closures, fees, or building access restrictions may apply. Check
            with Portland Parks before relying on this stop.
          </p>
        </section>
      )}
      {selected.category === "heritage-tree" && (
        <section aria-label="Heritage tree access">
          {selected.scientificName && (
            <p>
              <em>{selected.scientificName}</em>
            </p>
          )}
          {selected.treeOwnership && (
            <p>
              <strong>Source-listed setting:</strong> {selected.treeOwnership}
            </p>
          )}
          <p>
            This point marks the tree trunk, not a public entrance. Trees may be
            on private land or not visible from public paths. View only from
            lawful public access; do not enter private property.
          </p>
        </section>
      )}
      {selected.category === "community-garden" && (
        <p>
          Garden plots may require registration and have restricted access.
          Check with Portland Parks before visiting.
        </p>
      )}
      {CULTURE_PLACE_CATEGORIES.includes(selected.category) && (
        <section aria-label="Cultural venue information">
          <h3>Source-mapped venue</h3>
          <p>
            This community-mapped listing is not live opening information.
            Admission, tickets, reservations, accessibility and public access
            are not verified. Confirm the current location, hours and visiting
            arrangements with the venue.
          </p>
        </section>
      )}
      {OUTING_PLACE_CATEGORIES.includes(selected.category) && (
        <section aria-label="Outing destination information">
          {selected.siteType && (
            <p>
              <strong>Source-listed type:</strong> {selected.siteType}
            </p>
          )}
          <p>
            This community-mapped listing is not live opening or availability
            information. Confirm public access, hours, fees and accessibility
            before visiting. Do not enter restricted property.
          </p>
          {selected.category === "splash-pad" && (
            <p>
              Water operation is seasonal and not verified. A mapped splash pad
              is not a drinking-water source or a guarantee that water is
              running.
            </p>
          )}
          {["playground", "sports-court", "skatepark"].includes(
            selected.category,
          ) && (
            <p>
              Mapped facilities do not establish current condition, age
              suitability, opening hours or availability. School and managed
              sites may have restricted access; check posted rules and
              reservations.
            </p>
          )}
          {["public-garden", "nature-reserve", "viewpoint"].includes(
            selected.category,
          ) && (
            <p>
              Use designated public entrances and paths. Conservation
              restrictions, tickets and seasonal closures may apply; this point
              does not establish a safe or accessible approach.
            </p>
          )}
          {["historic-site", "public-art"].includes(selected.category) && (
            <p>
              View only from lawful public access. A source classification is
              not verified historic designation, an artwork title or permission
              to enter a building or site.
            </p>
          )}
        </section>
      )}
      {selected.category === "farmers-market" && (
        <section aria-label="Market schedule">
          <h3>Source-listed schedule</h3>
          <p>
            This snapshot may contain older seasonal dates and hours. Check the
            market website before traveling; this is not live opening
            information.
          </p>
          {selected.marketDays && (
            <p>
              <strong>Days:</strong> {selected.marketDays}
            </p>
          )}
          {selected.marketSeason && (
            <p>
              <strong>Season:</strong> {selected.marketSeason}
            </p>
          )}
          {selected.marketHours && (
            <p>
              <strong>Hours:</strong> {selected.marketHours}
            </p>
          )}
        </section>
      )}
    </PlaceDetailsPanel>
  );
}