Skip to content

Commit 6f3863f

Browse files
committed
admin dashboard nextjs version errors fixed
1 parent 429ee22 commit 6f3863f

File tree

5 files changed

+202
-16
lines changed

5 files changed

+202
-16
lines changed

app/(dashboard)/admin/categories/[id]/page.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
"use client";
22
import { DashboardSidebar } from "@/components";
33
import { useRouter } from "next/navigation";
4-
import React, { useEffect, useState } from "react";
4+
import React, { useEffect, useState, use } from "react";
55
import toast from "react-hot-toast";
66
import { formatCategoryName } from "../../../../../utils/categoryFormating";
77
import { convertCategoryNameToURLFriendly } from "../../../../../utils/categoryFormating";
88
import apiClient from "@/lib/api";
99

1010
interface DashboardSingleCategoryProps {
11-
params: { id: number };
11+
params: Promise<{ id: string }>;
1212
}
1313

1414
const DashboardSingleCategory = ({
15-
params: { id },
15+
params,
1616
}: DashboardSingleCategoryProps) => {
17+
const resolvedParams = use(params);
18+
const id = resolvedParams.id;
19+
1720
const [categoryInput, setCategoryInput] = useState<{ name: string }>({
1821
name: "",
1922
});

app/(dashboard)/admin/products/[id]/page.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { CustomButton, DashboardSidebar, SectionTitle } from "@/components";
33
import Image from "next/image";
44
import { useRouter } from "next/navigation";
5-
import React, { useEffect, useState } from "react";
5+
import React, { useEffect, useState, use } from "react";
66
import toast from "react-hot-toast";
77
import {
88
convertCategoryNameToURLFriendly as convertSlugToURLFriendly,
@@ -12,12 +12,15 @@ import { nanoid } from "nanoid";
1212
import apiClient from "@/lib/api";
1313

1414
interface DashboardProductDetailsProps {
15-
params: { id: number };
15+
params: Promise<{ id: string }>;
1616
}
1717

1818
const DashboardProductDetails = ({
19-
params: { id },
19+
params,
2020
}: DashboardProductDetailsProps) => {
21+
const resolvedParams = use(params);
22+
const id = resolvedParams.id;
23+
2124
const [product, setProduct] = useState<Product>();
2225
const [categories, setCategories] = useState<Category[]>();
2326
const [otherImages, setOtherImages] = useState<OtherImages[]>([]);
@@ -149,7 +152,7 @@ const DashboardProductDetails = ({
149152
<input
150153
type="text"
151154
className="input input-bordered w-full max-w-xs"
152-
value={product?.title}
155+
value={product?.title || ""}
153156
onChange={(e) =>
154157
setProduct({ ...product!, title: e.target.value })
155158
}
@@ -167,7 +170,7 @@ const DashboardProductDetails = ({
167170
<input
168171
type="text"
169172
className="input input-bordered w-full max-w-xs"
170-
value={product?.price}
173+
value={product?.price || ""}
171174
onChange={(e) =>
172175
setProduct({ ...product!, price: Number(e.target.value) })
173176
}
@@ -184,7 +187,7 @@ const DashboardProductDetails = ({
184187
<input
185188
type="text"
186189
className="input input-bordered w-full max-w-xs"
187-
value={product?.manufacturer}
190+
value={product?.manufacturer || ""}
188191
onChange={(e) =>
189192
setProduct({ ...product!, manufacturer: e.target.value })
190193
}
@@ -202,7 +205,7 @@ const DashboardProductDetails = ({
202205
<input
203206
type="text"
204207
className="input input-bordered w-full max-w-xs"
205-
value={product?.slug && convertSlugToURLFriendly(product?.slug)}
208+
value={product?.slug ? convertSlugToURLFriendly(product?.slug) : ""}
206209
onChange={(e) =>
207210
setProduct({
208211
...product!,
@@ -222,7 +225,7 @@ const DashboardProductDetails = ({
222225
</div>
223226
<select
224227
className="select select-bordered"
225-
value={product?.inStock}
228+
value={product?.inStock ?? 1}
226229
onChange={(e) => {
227230
setProduct({ ...product!, inStock: Number(e.target.value) });
228231
}}
@@ -241,7 +244,7 @@ const DashboardProductDetails = ({
241244
</div>
242245
<select
243246
className="select select-bordered"
244-
value={product?.categoryId}
247+
value={product?.categoryId || ""}
245248
onChange={(e) =>
246249
setProduct({
247250
...product!,
@@ -308,7 +311,7 @@ const DashboardProductDetails = ({
308311
</div>
309312
<textarea
310313
className="textarea textarea-bordered h-24"
311-
value={product?.description}
314+
value={product?.description || ""}
312315
onChange={(e) =>
313316
setProduct({ ...product!, description: e.target.value })
314317
}

app/(dashboard)/admin/users/[id]/page.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
"use client";
22
import { DashboardSidebar } from "@/components";
3-
import React, { useEffect, useState } from "react";
3+
import React, { useEffect, useState, use } from "react";
44
import toast from "react-hot-toast";
55
import { useRouter } from "next/navigation";
66
import { isValidEmailAddressFormat } from "@/lib/utils";
77
import apiClient from "@/lib/api";
88

99
interface DashboardUserDetailsProps {
10-
params: { id: number };
10+
params: Promise<{ id: string }>;
1111
}
1212

1313
const DashboardSingleUserPage = ({
14-
params: { id },
14+
params,
1515
}: DashboardUserDetailsProps) => {
16+
const resolvedParams = use(params);
17+
const id = resolvedParams.id;
18+
1619
const [userInput, setUserInput] = useState<{
1720
email: string;
1821
newPassword: string;

0 commit comments

Comments
 (0)