'use server';

import { prisma, Prisma, Station } from '@repo/db';

export const upsertStation = async (
  station: Prisma.StationCreateInput,
  id?: Station['id']
) => {
  const newStation = id
    ? await prisma.station.update({
        where: { id: id },
        data: station,
      })
    : await prisma.station.create({ data: station });
  return newStation;
};

export const deleteStation = async (id: Station['id']) => {
  await prisma.station.delete({ where: { id: id } });
};
