Skip to content

Commit 3af2b0c

Browse files
committed
log poc
1 parent 44a2051 commit 3af2b0c

File tree

8 files changed

+1051
-1
lines changed

8 files changed

+1051
-1
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"use server";
2+
3+
import { readLocationsForProject } from "@/db/crud/map";
4+
import { getServerUser } from "@/lib/auth";
5+
import { getProjectForUser } from "@/lib/dal/projects";
6+
import { notFound } from "next/navigation";
7+
8+
export async function getLocationsAction(projectId: string) {
9+
const user = await getServerUser();
10+
11+
if (!user) {
12+
notFound();
13+
}
14+
15+
const project = await getProjectForUser(user, projectId);
16+
17+
if (!project) {
18+
notFound();
19+
}
20+
21+
const locations = await readLocationsForProject(projectId);
22+
23+
return locations;
24+
}

packages/app/src/app/(app)/projects/[projectId]/data/layout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { tableConfigToNodes } from "@/components/data/data-sidebar/table-config"
77
import { DataWrapper } from "@/components/data/data-wrapper";
88
import { notFound } from "next/navigation";
99
import { getFoldersForProject } from "@/lib/dal/folders";
10+
import { readLocationsForProject } from "@/db/crud/map";
1011

1112
type Props = {
1213
params: { projectId: string };
@@ -26,6 +27,7 @@ export default async function Layout({ params, children }: Props) {
2627
const { tableCounts, plots, queries } = await getProjectData(projectId);
2728
const queryFolders = await getFoldersForProject(projectId, "query");
2829
const plotFolders = await getFoldersForProject(projectId, "plot");
30+
const locations = await readLocationsForProject(projectId);
2931

3032
return (
3133
<>
@@ -38,6 +40,7 @@ export default async function Layout({ params, children }: Props) {
3840
queries={queries}
3941
queryFolders={queryFolders}
4042
plotFolders={plotFolders}
43+
locations={locations}
4144
>
4245
{children}
4346
</DataWrapper>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { getServerUser } from "@/lib/auth";
2+
import { getProjectForUser } from "@/lib/dal/projects";
3+
import { parseStringParam } from "@/lib/routing";
4+
import { notFound } from "next/navigation";
5+
import { getLocationAction } from "@/actions/map/getLocation";
6+
import { ProfessionalBoreholeLog } from "@/components/data/borehole-log";
7+
8+
type Props = {
9+
params: { projectId: string; locationId: string };
10+
};
11+
12+
export default async function LogPage({ params }: Props) {
13+
const projectId = parseStringParam(params.projectId);
14+
const locationId = parseStringParam(params.locationId);
15+
16+
const user = await getServerUser();
17+
const { project } = await getProjectForUser(user, projectId);
18+
19+
if (!project) {
20+
notFound();
21+
}
22+
23+
const location = await getLocationAction(locationId, projectId);
24+
25+
if (!location) {
26+
notFound();
27+
}
28+
29+
return (
30+
<div className="flex h-full flex-col">
31+
<ProfessionalBoreholeLog
32+
geologyData={location.geologyData}
33+
locationIdentifier={location.locationIdentifier}
34+
groundLevel={location.groundLevel}
35+
finalDepth={location.finalDepth}
36+
/>
37+
</div>
38+
);
39+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { ProfessionalBoreholeLog } from "./professional-borehole-log";

0 commit comments

Comments
 (0)