Skip to content

Commit f28fd9f

Browse files
committed
a few mods to match strabospot feedback
1 parent 9e7065a commit f28fd9f

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

pages/dev/strabospot/featured-checkins.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ import { PageCarousel, fetchRockdData } from "~/components";
1212
import { createCheckins } from "~/components/checkin.client";
1313
import { useAsyncMemo } from "@macrostrat/ui-components";
1414
import { useMapRef } from "@macrostrat/mapbox-react";
15-
import { sendCheckinsToStrabospotDataset } from "./strabospot-integration";
15+
import {
16+
sendCheckinsToStrabospotDataset,
17+
getStrabospotDatasetId,
18+
getStrabospotProjectId,
19+
} from "./strabospot-integration";
1620
import { getStoredRockdToken } from "../../login/rockd-auth";
1721
const selectionCardStyle = {
1822
position: "relative" as const,
@@ -286,6 +290,7 @@ export function FeatureDetails({
286290
]
287291
);
288292
});
293+
const datasetId = getStrabospotDatasetId();
289294

290295
return h("div.checkin-container", [
291296
checkinCards,
@@ -398,7 +403,10 @@ export function FeatureDetails({
398403
h(
399404
"a",
400405
{
401-
href: "https://strabospot.org/my_field_data",
406+
href:
407+
datasetId != null
408+
? `https://strabospot.org/fieldland/?datasetid=${datasetId}`
409+
: "https://strabospot.org/fieldland/",
402410
target: "_blank",
403411
rel: "noopener noreferrer",
404412
style: successDialogLinkStyle,

pages/dev/strabospot/strabospot-integration.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,15 @@ function formatDateYYYYMMDD(date = new Date()) {
7979
}
8080

8181
function generateUniqueNumericId(existingIds: number[]) {
82-
let candidate = Date.now();
82+
let candidate = parseInt(
83+
`${Math.floor(Date.now() / 1000)}${Math.floor(1000 + Math.random() * 9000)}`
84+
);
8385
while (existingIds.includes(candidate)) {
84-
candidate += 1;
86+
candidate = parseInt(
87+
`${Math.floor(Date.now() / 1000)}${Math.floor(
88+
1000 + Math.random() * 9000
89+
)}`
90+
);
8591
}
8692
return candidate;
8793
}
@@ -306,6 +312,16 @@ export function getStoredStrabospotAuth(): StoredStrabospotAuth | null {
306312
}
307313
}
308314

315+
export function getStrabospotDatasetId(): number | null {
316+
const auth = getStoredStrabospotAuth();
317+
return auth?.datasetId ?? null;
318+
}
319+
320+
export function getStrabospotProjectId(): number | null {
321+
const auth = getStoredStrabospotAuth();
322+
return auth?.projectId ?? null;
323+
}
324+
309325
export function clearStoredStrabospotAuth() {
310326
localStorage.removeItem(STORAGE_KEY);
311327
}

0 commit comments

Comments
 (0)