diff --git a/src/app/[locale]/dashboard/projects/[projectId]/delete-card.tsx b/src/app/[locale]/dashboard/projects/[projectId]/delete-card.tsx
index 687f099..df216e8 100644
--- a/src/app/[locale]/dashboard/projects/[projectId]/delete-card.tsx
+++ b/src/app/[locale]/dashboard/projects/[projectId]/delete-card.tsx
@@ -13,7 +13,7 @@ import {
} from "~/components/ui/alert-dialog";
import { Button } from "~/components/ui/button";
import { Card, CardDescription, CardTitle } from "~/components/ui/card";
-import { toast } from "~/components/ui/use-toast";
+import { toast } from "~/hooks/use-toast";
import { deleteProjectById } from "../action";
export default function DeleteCard({ id }: { id: string }) {
@@ -39,7 +39,7 @@ export default function DeleteCard({ id }: { id: string }) {
return (
- Delete Project
+ Delete Project
The project will be permanently deleted. This action is irreversible
and can not be undone.
diff --git a/src/app/[locale]/dashboard/projects/[projectId]/editable-details.tsx b/src/app/[locale]/dashboard/projects/[projectId]/editable-details.tsx
index 6ad6202..4e1a92a 100644
--- a/src/app/[locale]/dashboard/projects/[projectId]/editable-details.tsx
+++ b/src/app/[locale]/dashboard/projects/[projectId]/editable-details.tsx
@@ -14,7 +14,7 @@ import {
FormMessage,
} from "~/components/ui/form";
import { Input } from "~/components/ui/input";
-import { toast } from "~/components/ui/use-toast";
+import { toast } from "~/hooks/use-toast";
import { updateProjectById } from "../action";
import { projectSchema, type ProjectFormValues } from "../create-project-modal";
@@ -56,7 +56,7 @@ export default function EditableDetails({
ID
-
+
@@ -95,7 +95,7 @@ export default function EditableDetails({
type="submit"
>
{form.formState.isSubmitting && (
-
+
)}
Save
diff --git a/src/app/[locale]/dashboard/projects/[projectId]/page.tsx b/src/app/[locale]/dashboard/projects/[projectId]/page.tsx
index e23763a..eaf16ce 100644
--- a/src/app/[locale]/dashboard/projects/[projectId]/page.tsx
+++ b/src/app/[locale]/dashboard/projects/[projectId]/page.tsx
@@ -4,9 +4,9 @@ import TabSections from "./tab-sections";
export default async function SingleProject({
params,
}: {
- params: { projectId: string };
+ params: Promise<{ projectId: string }>;
}) {
- const { projectId } = params;
+ const { projectId } = await params;
const project = await getProjectById(projectId);
return ;
}
diff --git a/src/app/[locale]/dashboard/projects/action.ts b/src/app/[locale]/dashboard/projects/action.ts
index 079f071..e39c216 100644
--- a/src/app/[locale]/dashboard/projects/action.ts
+++ b/src/app/[locale]/dashboard/projects/action.ts
@@ -3,9 +3,9 @@
import { type Project } from "@prisma/client";
import { revalidatePath } from "next/cache";
import { redirect } from "next/navigation";
-import { validateRequest } from "~/actions/auth";
import { getUserSubscriptionPlan } from "~/actions/subscription";
import prisma from "~/lib/prisma";
+import { getCurrentSession } from "~/lib/session";
interface Payload {
name: string;
@@ -13,7 +13,7 @@ interface Payload {
}
export async function createProject(payload: Payload) {
- const { user } = await validateRequest();
+ const { user } = await getCurrentSession();
await prisma.project.create({
data: {
@@ -30,7 +30,7 @@ export async function createProject(payload: Payload) {
}
export async function checkIfFreePlanLimitReached() {
- const { user } = await validateRequest();
+ const { user } = await getCurrentSession();
const subscriptionPlan = await getUserSubscriptionPlan(user?.id as string);
// If user is on a free plan.
@@ -47,7 +47,7 @@ export async function checkIfFreePlanLimitReached() {
}
export async function getProjects() {
- const { user } = await validateRequest();
+ const { user } = await getCurrentSession();
const projects = await prisma.project.findMany({
where: {
userId: user?.id,
@@ -60,7 +60,7 @@ export async function getProjects() {
}
export async function getProjectById(id: string) {
- const { user } = await validateRequest();
+ const { user } = await getCurrentSession();
const project = await prisma.project.findFirst({
where: {
id,
@@ -71,7 +71,7 @@ export async function getProjectById(id: string) {
}
export async function updateProjectById(id: string, payload: Payload) {
- const { user } = await validateRequest();
+ const { user } = await getCurrentSession();
await prisma.project.update({
where: {
id,
@@ -83,7 +83,7 @@ export async function updateProjectById(id: string, payload: Payload) {
}
export async function deleteProjectById(id: string) {
- const { user } = await validateRequest();
+ const { user } = await getCurrentSession();
await prisma.project.delete({
where: {
id,
diff --git a/src/app/[locale]/dashboard/projects/create-project-modal.tsx b/src/app/[locale]/dashboard/projects/create-project-modal.tsx
index 65a7ea9..c653d07 100644
--- a/src/app/[locale]/dashboard/projects/create-project-modal.tsx
+++ b/src/app/[locale]/dashboard/projects/create-project-modal.tsx
@@ -24,7 +24,7 @@ import {
FormMessage,
} from "~/components/ui/form";
import { Input } from "~/components/ui/input";
-import { toast } from "~/components/ui/use-toast";
+import { toast } from "~/hooks/use-toast";
import { FreePlanLimitError } from "~/lib/utils";
import { checkIfFreePlanLimitReached, createProject } from "./action";
@@ -79,9 +79,9 @@ export default function CreateProjectModal() {
className="flex flex-col items-center justify-center gap-y-2.5 p-8 text-center hover:bg-accent"
>
-
Create a project
+
Create a project
diff --git a/src/app/[locale]/dashboard/settings/page.tsx b/src/app/[locale]/dashboard/settings/page.tsx
index b67b515..10b093d 100644
--- a/src/app/[locale]/dashboard/settings/page.tsx
+++ b/src/app/[locale]/dashboard/settings/page.tsx
@@ -1,6 +1,5 @@
-import { type User } from "lucia";
import { type Metadata } from "next";
-import { validateRequest } from "~/actions/auth";
+import { getCurrentSession } from "~/lib/session";
import SettingsForm from "./settings-form";
export const metadata: Metadata = {
@@ -8,6 +7,6 @@ export const metadata: Metadata = {
};
export default async function Settings() {
- const { user } = await validateRequest();
- return ;
+ const { user } = await getCurrentSession();
+ return ;
}
diff --git a/src/app/[locale]/dashboard/settings/settings-form.tsx b/src/app/[locale]/dashboard/settings/settings-form.tsx
index f0a8ac8..2a87bd9 100644
--- a/src/app/[locale]/dashboard/settings/settings-form.tsx
+++ b/src/app/[locale]/dashboard/settings/settings-form.tsx
@@ -1,10 +1,10 @@
"use client";
import { zodResolver } from "@hookform/resolvers/zod";
-import { type User } from "lucia";
+import { User } from "@prisma/client";
import { Loader2 } from "lucide-react";
import dynamic from "next/dynamic";
-import { useEffect, useRef, useTransition } from "react";
+import { useEffect, useMemo, useRef, useTransition } from "react";
import { useForm } from "react-hook-form";
import { Avatar, AvatarFallback, AvatarImage } from "~/components/ui/avatar";
import { Button } from "~/components/ui/button";
@@ -18,7 +18,7 @@ import {
FormMessage,
} from "~/components/ui/form";
import { Input } from "~/components/ui/input";
-import { useToast } from "~/components/ui/use-toast";
+import { useToast } from "~/hooks/use-toast";
import { settingsSchema, type SettingsValues } from "~/types";
import {
removeNewImageFromCDN,
@@ -85,8 +85,12 @@ export default function SettingsForm({ currentUser }: { currentUser: User }) {
reset();
};
- const isFormDisabled =
- formState.isSubmitting || isPending || !formState.isDirty;
+ const isFormDisabled = useMemo(
+ () => formState.isSubmitting || isPending || !formState.isDirty,
+ [formState.isSubmitting, isPending, formState.isDirty]
+ );
+
+ console.log(formState.isSubmitting, isPending, !formState.isDirty);
return (