Skip to content

Commit efa94c7

Browse files
committed
fix: address coderabbit frontend review
1 parent 0b0a478 commit efa94c7

22 files changed

Lines changed: 279 additions & 169 deletions

File tree

src/app/(public)/products/[slug]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ export default async function ProductPage({ params }: ProductPageProps) {
155155
<section className="pb-24 md:pb-32">
156156
<div className="mx-auto max-w-5xl px-6">
157157
<div className="max-w-3xl space-y-6 font-sans text-lg leading-[1.75] text-[#2C3A52]">
158-
{product.description.split(/\n{2,}/).map((paragraph) => (
159-
<p key={paragraph}>{paragraph}</p>
158+
{product.description.split(/\n{2,}/).map((paragraph, index) => (
159+
<p key={`${product.id}-paragraph-${index}`}>{paragraph}</p>
160160
))}
161161
</div>
162162
</div>

src/app/admin/applications/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ import ApplicationsManager, {
33
type AdminApplication,
44
} from "@/components/admin/ApplicationsManager";
55
import { careerApplications, careers, db } from "@/db";
6+
import { requireAdminSession } from "@/lib/admin-auth";
67

78
export default async function AdminApplicationsPage() {
9+
await requireAdminSession();
10+
811
const applications = await db
912
.select({
1013
id: careerApplications.id,

src/app/admin/blog/[id]/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { eq } from "drizzle-orm";
33
import { BlogPostForm } from "@/components/admin/ResourceForms";
44
import type { TiptapJson } from "@/components/admin/RichTextEditor";
55
import { blogPosts, db } from "@/db";
6+
import { requireAdminSession } from "@/lib/admin-auth";
67

78
type EditBlogPostPageProps = {
89
params: {
@@ -17,6 +18,8 @@ function isTiptapJson(value: unknown): value is TiptapJson {
1718
export default async function EditBlogPostPage({
1819
params,
1920
}: EditBlogPostPageProps) {
21+
await requireAdminSession();
22+
2023
const [post] = await db
2124
.select()
2225
.from(blogPosts)

src/app/admin/blog/page.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { desc } from "drizzle-orm";
33
import AdminDeleteButton from "@/components/admin/AdminDeleteButton";
44
import Button from "@/components/ui/Button";
55
import { blogPosts, db } from "@/db";
6+
import { requireAdminSession } from "@/lib/admin-auth";
67

78
function formatDate(date: Date | null) {
89
if (!date) {
@@ -17,6 +18,8 @@ function formatDate(date: Date | null) {
1718
}
1819

1920
export default async function AdminBlogPage() {
21+
await requireAdminSession();
22+
2023
const posts = await db
2124
.select()
2225
.from(blogPosts)
@@ -54,11 +57,13 @@ export default async function AdminBlogPage() {
5457
<td className="px-4 py-3 text-[#2C3A52]">{post.category}</td>
5558
<td className="px-4 py-3 text-[#2C3A52]">{post.is_published ? "Yes" : "No"}</td>
5659
<td className="px-4 py-3 text-[#2C3A52]">{formatDate(post.published_at)}</td>
57-
<td className="flex gap-2 px-4 py-3">
58-
<Button asChild variant="secondary" size="sm">
59-
<Link href={`/admin/blog/${post.id}`}>Edit</Link>
60-
</Button>
61-
<AdminDeleteButton endpoint={`/api/admin/blog/${post.id}`} />
60+
<td className="px-4 py-3">
61+
<div className="flex gap-2">
62+
<Button asChild variant="secondary" size="sm">
63+
<Link href={`/admin/blog/${post.id}`}>Edit</Link>
64+
</Button>
65+
<AdminDeleteButton endpoint={`/api/admin/blog/${post.id}`} />
66+
</div>
6267
</td>
6368
</tr>
6469
))}

src/app/admin/careers/[id]/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { notFound } from "next/navigation";
22
import { eq } from "drizzle-orm";
33
import { CareerForm } from "@/components/admin/ResourceForms";
44
import { careers, db } from "@/db";
5+
import { requireAdminSession } from "@/lib/admin-auth";
56

67
type EditCareerPageProps = {
78
params: {
@@ -10,6 +11,8 @@ type EditCareerPageProps = {
1011
};
1112

1213
export default async function EditCareerPage({ params }: EditCareerPageProps) {
14+
await requireAdminSession();
15+
1316
const [career] = await db
1417
.select()
1518
.from(careers)

src/app/admin/careers/page.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ import { desc } from "drizzle-orm";
33
import AdminDeleteButton from "@/components/admin/AdminDeleteButton";
44
import Button from "@/components/ui/Button";
55
import { careers, db } from "@/db";
6+
import { requireAdminSession } from "@/lib/admin-auth";
67

78
export default async function AdminCareersPage() {
9+
await requireAdminSession();
10+
811
const careerList = await db
912
.select()
1013
.from(careers)
@@ -42,11 +45,13 @@ export default async function AdminCareersPage() {
4245
<td className="px-4 py-3 text-[#2C3A52]">{career.type}</td>
4346
<td className="px-4 py-3 text-[#2C3A52]">{career.location}</td>
4447
<td className="px-4 py-3 text-[#2C3A52]">{career.is_open ? "Yes" : "No"}</td>
45-
<td className="flex gap-2 px-4 py-3">
46-
<Button asChild variant="secondary" size="sm">
47-
<Link href={`/admin/careers/${career.id}`}>Edit</Link>
48-
</Button>
49-
<AdminDeleteButton endpoint={`/api/admin/careers/${career.id}`} />
48+
<td className="px-4 py-3">
49+
<div className="flex gap-2">
50+
<Button asChild variant="secondary" size="sm">
51+
<Link href={`/admin/careers/${career.id}`}>Edit</Link>
52+
</Button>
53+
<AdminDeleteButton endpoint={`/api/admin/careers/${career.id}`} />
54+
</div>
5055
</td>
5156
</tr>
5257
))}

src/app/admin/dashboard/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
products,
99
teamMembers,
1010
} from "@/db";
11+
import { requireAdminSession } from "@/lib/admin-auth";
1112

1213
function formatDate(date: Date) {
1314
return new Intl.DateTimeFormat("en", {
@@ -79,6 +80,8 @@ async function getDashboardData() {
7980
}
8081

8182
export default async function AdminDashboardPage() {
83+
await requireAdminSession();
84+
8285
const { stats, unreadMessages, pendingApplications } =
8386
await getDashboardData();
8487

src/app/admin/messages/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ import MessagesManager, {
33
type AdminMessage,
44
} from "@/components/admin/MessagesManager";
55
import { contactSubmissions, db } from "@/db";
6+
import { requireAdminSession } from "@/lib/admin-auth";
67

78
export default async function AdminMessagesPage() {
9+
await requireAdminSession();
10+
811
const messages = await db
912
.select()
1013
.from(contactSubmissions)

src/app/admin/products/[id]/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { notFound } from "next/navigation";
22
import { eq } from "drizzle-orm";
33
import { ProductForm } from "@/components/admin/ResourceForms";
44
import { db, products } from "@/db";
5+
import { requireAdminSession } from "@/lib/admin-auth";
56

67
type EditProductPageProps = {
78
params: {
@@ -10,6 +11,8 @@ type EditProductPageProps = {
1011
};
1112

1213
export default async function EditProductPage({ params }: EditProductPageProps) {
14+
await requireAdminSession();
15+
1316
const [product] = await db
1417
.select()
1518
.from(products)

src/app/admin/products/page.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ import { asc } from "drizzle-orm";
33
import AdminDeleteButton from "@/components/admin/AdminDeleteButton";
44
import Button from "@/components/ui/Button";
55
import { db, products } from "@/db";
6+
import { requireAdminSession } from "@/lib/admin-auth";
67

78
export default async function AdminProductsPage() {
9+
await requireAdminSession();
10+
811
const productList = await db
912
.select()
1013
.from(products)
@@ -42,11 +45,13 @@ export default async function AdminProductsPage() {
4245
<td className="px-4 py-3 text-[#2C3A52]">{product.slug}</td>
4346
<td className="px-4 py-3 text-[#2C3A52]">{product.status}</td>
4447
<td className="px-4 py-3 text-[#2C3A52]">{product.is_featured ? "Yes" : "No"}</td>
45-
<td className="flex gap-2 px-4 py-3">
46-
<Button asChild variant="secondary" size="sm">
47-
<Link href={`/admin/products/${product.id}`}>Edit</Link>
48-
</Button>
49-
<AdminDeleteButton endpoint={`/api/admin/products/${product.id}`} />
48+
<td className="px-4 py-3">
49+
<div className="flex gap-2">
50+
<Button asChild variant="secondary" size="sm">
51+
<Link href={`/admin/products/${product.id}`}>Edit</Link>
52+
</Button>
53+
<AdminDeleteButton endpoint={`/api/admin/products/${product.id}`} />
54+
</div>
5055
</td>
5156
</tr>
5257
))}

0 commit comments

Comments
 (0)