removed console.log statements

This commit is contained in:
PxlLoewe
2025-02-27 00:34:53 +01:00
parent 9366f8f6b4
commit bbcde2eb4a
7 changed files with 639 additions and 647 deletions

View File

@@ -1,15 +1,15 @@
'use client'; "use client";
import { zodResolver } from '@hookform/resolvers/zod'; import { zodResolver } from "@hookform/resolvers/zod";
import { StationOptionalDefaultsSchema } from '@repo/db/zod'; import { StationOptionalDefaultsSchema } from "@repo/db/zod";
import { set, useForm } from 'react-hook-form'; import { set, useForm } from "react-hook-form";
import { z } from 'zod'; import { z } from "zod";
import { BosUse, Country, Station } from '@repo/db'; import { BosUse, Country, Station } from "@repo/db";
import { FileText, LocateIcon, PlaneIcon } from 'lucide-react'; import { FileText, LocateIcon, PlaneIcon } from "lucide-react";
import { Input } from '../../../../_components/ui/Input'; import { Input } from "../../../../_components/ui/Input";
import { useState } from 'react'; import { useState } from "react";
import { deleteStation, upsertStation } from '../action'; import { deleteStation, upsertStation } from "../action";
import { Button } from '../../../../_components/ui/Button'; import { Button } from "../../../../_components/ui/Button";
import { redirect } from 'next/navigation'; import { redirect } from "next/navigation";
export const StationForm = ({ station }: { station?: Station }) => { export const StationForm = ({ station }: { station?: Station }) => {
const form = useForm<z.infer<typeof StationOptionalDefaultsSchema>>({ const form = useForm<z.infer<typeof StationOptionalDefaultsSchema>>({
@@ -18,7 +18,6 @@ export const StationForm = ({ station }: { station?: Station }) => {
}); });
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [deleteLoading, setDeleteLoading] = useState(false); const [deleteLoading, setDeleteLoading] = useState(false);
console.log(form.formState.errors);
return ( return (
<> <>
<form <form
@@ -78,7 +77,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
</span> </span>
<select <select
className="input-sm select select-bordered select-sm" className="input-sm select select-bordered select-sm"
{...form.register('bosUse')} {...form.register("bosUse")}
> >
{Object.keys(BosUse).map((use) => ( {Object.keys(BosUse).map((use) => (
<option key={use} value={use}> <option key={use} value={use}>
@@ -100,7 +99,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
</span> </span>
<select <select
className="input-sm select select-bordered select-sm" className="input-sm select select-bordered select-sm"
{...form.register('country', {})} {...form.register("country", {})}
> >
{Object.keys(Country).map((use) => ( {Object.keys(Country).map((use) => (
<option key={use} value={use}> <option key={use} value={use}>
@@ -130,7 +129,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
<input <input
type="checkbox" type="checkbox"
className="toggle" className="toggle"
{...form.register('hasWinch')} {...form.register("hasWinch")}
/> />
</label> </label>
<label className="label cursor-pointer"> <label className="label cursor-pointer">
@@ -138,7 +137,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
<input <input
type="checkbox" type="checkbox"
className="toggle" className="toggle"
{...form.register('hasNvg')} {...form.register("hasNvg")}
/> />
</label> </label>
<label className="label cursor-pointer"> <label className="label cursor-pointer">
@@ -146,7 +145,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
<input <input
type="checkbox" type="checkbox"
className="toggle" className="toggle"
{...form.register('is24h')} {...form.register("is24h")}
/> />
</label> </label>
<label className="label cursor-pointer"> <label className="label cursor-pointer">
@@ -154,7 +153,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
<input <input
type="checkbox" type="checkbox"
className="toggle" className="toggle"
{...form.register('hasRope')} {...form.register("hasRope")}
/> />
</label> </label>
</div> </div>
@@ -182,7 +181,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
<input <input
type="checkbox" type="checkbox"
className="toggle" className="toggle"
{...form.register('hideRangeRings')} {...form.register("hideRangeRings")}
/> />
</label> </label>
</div> </div>
@@ -230,7 +229,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
onClick={async () => { onClick={async () => {
setDeleteLoading(true); setDeleteLoading(true);
await deleteStation(station.id); await deleteStation(station.id);
redirect('/admin/station'); redirect("/admin/station");
}} }}
className="btn btn-error" className="btn btn-error"
> >

View File

@@ -1,4 +1,4 @@
import { PrismaClient } from '@repo/db'; import { PrismaClient } from "@repo/db";
export default async ({ params }: { params: Promise<{ id: string }> }) => { export default async ({ params }: { params: Promise<{ id: string }> }) => {
const prisma = new PrismaClient(); const prisma = new PrismaClient();

View File

@@ -150,7 +150,6 @@ export const SocialForm = ({
}); });
if (!user) return null; if (!user) return null;
console.log("Dirty", form.formState.isDirty);
return ( return (
<form <form
className="card-body" className="card-body"
@@ -269,7 +268,7 @@ export const PasswordForm = ({ user }: { user: User }) => {
setIsLoading(true); setIsLoading(true);
const result = await changePassword( const result = await changePassword(
values.password, values.password,
values.newPassword values.newPassword,
); );
form.reset(values); form.reset(values);
setIsLoading(false); setIsLoading(false);

View File

@@ -64,7 +64,6 @@ export function PaginatedTable<TData>({
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
refresh: () => { refresh: () => {
console.log("refresh");
RefreshTableData(); RefreshTableData();
}, },
})); }));

View File

@@ -1,28 +1,27 @@
import { import {
AuthOptions, AuthOptions,
getServerSession as getNextAuthServerSession, getServerSession as getNextAuthServerSession,
} from 'next-auth'; } from "next-auth";
import { PrismaAdapter } from '@next-auth/prisma-adapter'; import { PrismaAdapter } from "@next-auth/prisma-adapter";
import Credentials from 'next-auth/providers/credentials'; import Credentials from "next-auth/providers/credentials";
import { PrismaClient } from '@repo/db'; import { PrismaClient } from "@repo/db";
import bcrypt from 'bcryptjs'; import bcrypt from "bcryptjs";
const prisma = new PrismaClient(); const prisma = new PrismaClient();
export const options: AuthOptions = { export const options: AuthOptions = {
providers: [ providers: [
Credentials({ Credentials({
credentials: { credentials: {
email: { label: 'Email', type: 'email', placeholder: 'E-Mail' }, email: { label: "Email", type: "email", placeholder: "E-Mail" },
password: { label: 'Password', type: 'password' }, password: { label: "Password", type: "password" },
}, },
async authorize(credentials, req) { async authorize(credentials, req) {
try { try {
if (!credentials) throw new Error('No credentials provided'); if (!credentials) throw new Error("No credentials provided");
const user = await prisma.user.findFirstOrThrow({ const user = await prisma.user.findFirstOrThrow({
where: { email: credentials.email }, where: { email: credentials.email },
}); });
if (bcrypt.compareSync(credentials.password, user.password)) { if (bcrypt.compareSync(credentials.password, user.password)) {
console.log('User found and password correct', user);
return user; return user;
} }
return null; return null;
@@ -34,14 +33,14 @@ export const options: AuthOptions = {
], ],
secret: process.env.NEXTAUTH_SECRET, secret: process.env.NEXTAUTH_SECRET,
session: { session: {
strategy: 'jwt', strategy: "jwt",
maxAge: 30 * 24 * 60 * 60, maxAge: 30 * 24 * 60 * 60,
}, },
adapter: PrismaAdapter(prisma as any), adapter: PrismaAdapter(prisma as any),
callbacks: { callbacks: {
jwt: async ({ token, user }) => { jwt: async ({ token, user }) => {
if (user && 'firstname' in user) { if (user && "firstname" in user) {
return { return {
...token, ...token,
...user, ...user,
@@ -57,10 +56,10 @@ export const options: AuthOptions = {
}, },
}, },
pages: { pages: {
signIn: '/login', signIn: "/login",
signOut: '/logout', signOut: "/logout",
error: '/authError', error: "/authError",
newUser: '/register', newUser: "/register",
}, },
} satisfies AuthOptions; } satisfies AuthOptions;

View File

@@ -5,15 +5,11 @@ import { services } from "../../../(auth)/oauth/page";
export const POST = async (req: NextRequest) => { export const POST = async (req: NextRequest) => {
const form = new URLSearchParams(await req.text()); const form = new URLSearchParams(await req.text());
console.log("POST body:");
const client = new PrismaClient(); const client = new PrismaClient();
const accessToken = form.get("token") || form.get("code"); const accessToken = form.get("token") || form.get("code");
const clientId = form.get("client_id"); const clientId = form.get("client_id");
const clientSecret = form.get("client_secret"); const clientSecret = form.get("client_secret");
console.log("Access token:", accessToken);
console.log("Client ID:", clientId);
console.log("Secret:", clientSecret);
const service = services.find((s) => s.id === clientId); const service = services.find((s) => s.id === clientId);
if (!accessToken) if (!accessToken)