removed console.log statements
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
'use client';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { StationOptionalDefaultsSchema } from '@repo/db/zod';
|
||||
import { set, useForm } from 'react-hook-form';
|
||||
import { z } from 'zod';
|
||||
import { BosUse, Country, Station } from '@repo/db';
|
||||
import { FileText, LocateIcon, PlaneIcon } from 'lucide-react';
|
||||
import { Input } from '../../../../_components/ui/Input';
|
||||
import { useState } from 'react';
|
||||
import { deleteStation, upsertStation } from '../action';
|
||||
import { Button } from '../../../../_components/ui/Button';
|
||||
import { redirect } from 'next/navigation';
|
||||
"use client";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { StationOptionalDefaultsSchema } from "@repo/db/zod";
|
||||
import { set, useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
import { BosUse, Country, Station } from "@repo/db";
|
||||
import { FileText, LocateIcon, PlaneIcon } from "lucide-react";
|
||||
import { Input } from "../../../../_components/ui/Input";
|
||||
import { useState } from "react";
|
||||
import { deleteStation, upsertStation } from "../action";
|
||||
import { Button } from "../../../../_components/ui/Button";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export const StationForm = ({ station }: { station?: Station }) => {
|
||||
const form = useForm<z.infer<typeof StationOptionalDefaultsSchema>>({
|
||||
@@ -18,7 +18,6 @@ export const StationForm = ({ station }: { station?: Station }) => {
|
||||
});
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [deleteLoading, setDeleteLoading] = useState(false);
|
||||
console.log(form.formState.errors);
|
||||
return (
|
||||
<>
|
||||
<form
|
||||
@@ -78,7 +77,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
|
||||
</span>
|
||||
<select
|
||||
className="input-sm select select-bordered select-sm"
|
||||
{...form.register('bosUse')}
|
||||
{...form.register("bosUse")}
|
||||
>
|
||||
{Object.keys(BosUse).map((use) => (
|
||||
<option key={use} value={use}>
|
||||
@@ -100,7 +99,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
|
||||
</span>
|
||||
<select
|
||||
className="input-sm select select-bordered select-sm"
|
||||
{...form.register('country', {})}
|
||||
{...form.register("country", {})}
|
||||
>
|
||||
{Object.keys(Country).map((use) => (
|
||||
<option key={use} value={use}>
|
||||
@@ -130,7 +129,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
|
||||
<input
|
||||
type="checkbox"
|
||||
className="toggle"
|
||||
{...form.register('hasWinch')}
|
||||
{...form.register("hasWinch")}
|
||||
/>
|
||||
</label>
|
||||
<label className="label cursor-pointer">
|
||||
@@ -138,7 +137,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
|
||||
<input
|
||||
type="checkbox"
|
||||
className="toggle"
|
||||
{...form.register('hasNvg')}
|
||||
{...form.register("hasNvg")}
|
||||
/>
|
||||
</label>
|
||||
<label className="label cursor-pointer">
|
||||
@@ -146,7 +145,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
|
||||
<input
|
||||
type="checkbox"
|
||||
className="toggle"
|
||||
{...form.register('is24h')}
|
||||
{...form.register("is24h")}
|
||||
/>
|
||||
</label>
|
||||
<label className="label cursor-pointer">
|
||||
@@ -154,7 +153,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
|
||||
<input
|
||||
type="checkbox"
|
||||
className="toggle"
|
||||
{...form.register('hasRope')}
|
||||
{...form.register("hasRope")}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
@@ -182,7 +181,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
|
||||
<input
|
||||
type="checkbox"
|
||||
className="toggle"
|
||||
{...form.register('hideRangeRings')}
|
||||
{...form.register("hideRangeRings")}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
@@ -230,7 +229,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
|
||||
onClick={async () => {
|
||||
setDeleteLoading(true);
|
||||
await deleteStation(station.id);
|
||||
redirect('/admin/station');
|
||||
redirect("/admin/station");
|
||||
}}
|
||||
className="btn btn-error"
|
||||
>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PrismaClient } from '@repo/db';
|
||||
import { PrismaClient } from "@repo/db";
|
||||
|
||||
export default async ({ params }: { params: Promise<{ id: string }> }) => {
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
@@ -150,7 +150,6 @@ export const SocialForm = ({
|
||||
});
|
||||
|
||||
if (!user) return null;
|
||||
console.log("Dirty", form.formState.isDirty);
|
||||
return (
|
||||
<form
|
||||
className="card-body"
|
||||
@@ -269,7 +268,7 @@ export const PasswordForm = ({ user }: { user: User }) => {
|
||||
setIsLoading(true);
|
||||
const result = await changePassword(
|
||||
values.password,
|
||||
values.newPassword
|
||||
values.newPassword,
|
||||
);
|
||||
form.reset(values);
|
||||
setIsLoading(false);
|
||||
|
||||
@@ -64,7 +64,6 @@ export function PaginatedTable<TData>({
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
refresh: () => {
|
||||
console.log("refresh");
|
||||
RefreshTableData();
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
import {
|
||||
AuthOptions,
|
||||
getServerSession as getNextAuthServerSession,
|
||||
} from 'next-auth';
|
||||
import { PrismaAdapter } from '@next-auth/prisma-adapter';
|
||||
import Credentials from 'next-auth/providers/credentials';
|
||||
import { PrismaClient } from '@repo/db';
|
||||
import bcrypt from 'bcryptjs';
|
||||
} from "next-auth";
|
||||
import { PrismaAdapter } from "@next-auth/prisma-adapter";
|
||||
import Credentials from "next-auth/providers/credentials";
|
||||
import { PrismaClient } from "@repo/db";
|
||||
import bcrypt from "bcryptjs";
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
export const options: AuthOptions = {
|
||||
providers: [
|
||||
Credentials({
|
||||
credentials: {
|
||||
email: { label: 'Email', type: 'email', placeholder: 'E-Mail' },
|
||||
password: { label: 'Password', type: 'password' },
|
||||
email: { label: "Email", type: "email", placeholder: "E-Mail" },
|
||||
password: { label: "Password", type: "password" },
|
||||
},
|
||||
async authorize(credentials, req) {
|
||||
try {
|
||||
if (!credentials) throw new Error('No credentials provided');
|
||||
if (!credentials) throw new Error("No credentials provided");
|
||||
const user = await prisma.user.findFirstOrThrow({
|
||||
where: { email: credentials.email },
|
||||
});
|
||||
if (bcrypt.compareSync(credentials.password, user.password)) {
|
||||
console.log('User found and password correct', user);
|
||||
return user;
|
||||
}
|
||||
return null;
|
||||
@@ -34,14 +33,14 @@ export const options: AuthOptions = {
|
||||
],
|
||||
secret: process.env.NEXTAUTH_SECRET,
|
||||
session: {
|
||||
strategy: 'jwt',
|
||||
strategy: "jwt",
|
||||
maxAge: 30 * 24 * 60 * 60,
|
||||
},
|
||||
|
||||
adapter: PrismaAdapter(prisma as any),
|
||||
callbacks: {
|
||||
jwt: async ({ token, user }) => {
|
||||
if (user && 'firstname' in user) {
|
||||
if (user && "firstname" in user) {
|
||||
return {
|
||||
...token,
|
||||
...user,
|
||||
@@ -57,10 +56,10 @@ export const options: AuthOptions = {
|
||||
},
|
||||
},
|
||||
pages: {
|
||||
signIn: '/login',
|
||||
signOut: '/logout',
|
||||
error: '/authError',
|
||||
newUser: '/register',
|
||||
signIn: "/login",
|
||||
signOut: "/logout",
|
||||
error: "/authError",
|
||||
newUser: "/register",
|
||||
},
|
||||
} satisfies AuthOptions;
|
||||
|
||||
|
||||
@@ -5,15 +5,11 @@ import { services } from "../../../(auth)/oauth/page";
|
||||
|
||||
export const POST = async (req: NextRequest) => {
|
||||
const form = new URLSearchParams(await req.text());
|
||||
console.log("POST body:");
|
||||
const client = new PrismaClient();
|
||||
const accessToken = form.get("token") || form.get("code");
|
||||
const clientId = form.get("client_id");
|
||||
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);
|
||||
|
||||
if (!accessToken)
|
||||
|
||||
Reference in New Issue
Block a user