Files
echecsfrance/src/server/myZones.ts
T
owenrees da78e82a44 upgrade Nodemailer to v10
fix dead code with knip

upgrade TS to v6 and fix linting errors

auto apply oxfmt rules

fix linting errors - unused deps etc

ignore file

remove all ignored files in knip

add knip - dead code analysis tool

swap prettier and eslint of oxfmt and oxlint

fix: fix map rendering in react strict mode

fix: headlessUI float replace

fix: disable Matomo if not URL and SITE ID exist

upgrade: 1st pass upgrade to Next.js v16

deps: upgrade react to v19
2026-09-29 22:16:07 +02:00

36 lines
918 B
TypeScript

"use server";
import { FeatureCollection } from "geojson";
import { omit } from "lodash";
import { ObjectId } from "mongodb";
import { auth } from "@/auth";
import { collections, dbConnect } from "@/server/mongodb";
import { ZoneModel } from "./models/zoneModel";
import { actionClient } from "./safeAction";
export type Zone = Omit<ZoneModel, "userId" | "features"> & {
id: string;
features: FeatureCollection;
};
export const myZones = actionClient.action(async () => {
await dbConnect();
const user = await auth();
if (!user?.user) {
throw new Error("You must be logged in to fetch your zones");
}
const zones = await collections.zones!.find({ userId: new ObjectId(user.user!.id!) }).toArray();
const result: Zone[] = zones.map((zone) => ({
...omit(zone, ["_id", "userId"]),
id: zone._id.toString(),
features: zone.features as FeatureCollection,
}));
return result;
});