Skip to content

Commit ab8a8d9

Browse files
committed
Change about and fix types and minor fixes
1 parent 2605cd5 commit ab8a8d9

File tree

19 files changed

+219
-77
lines changed

19 files changed

+219
-77
lines changed

api/labels/useUpdateLabel.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const useUpdateLabel = ({
1818
`${LABELS_API_ENDPOINT}/${label.id}`,
1919
{
2020
method: "PUT",
21-
data: label,
21+
data: { ...label },
2222
headers: {
2323
"Content-Type": "application/json",
2424
},

app/about/page.tsx

+88-14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Metadata } from "next";
22
import { Container, Typography, List, ListItem, Box } from "@mui/material";
33
import { Button } from "@/components/buttons";
44
import Link from "next/link";
5+
import Image from "next/image";
56

67
export const metadata: Metadata = {
78
title: "About My Lib - Your Personal Code Library",
@@ -13,17 +14,21 @@ export const metadata: Metadata = {
1314
export default function AboutPage() {
1415
return (
1516
<Container maxWidth="lg" sx={{ py: 8 }}>
16-
<Typography variant="h1" gutterBottom textAlign="center">
17-
About My Lib
17+
<Typography component="h1" variant="h2" my={3} textAlign="center">
18+
My Lib: Your Universal Code & Knowledge Organizer for IT Professionals
1819
</Typography>
1920

20-
<Typography paragraph fontSize={18}>
21-
My Lib is a powerful yet simple tool designed for developers who need a
22-
fast, organized, and efficient way to save and retrieve code snippets,
23-
scripts, configurations, and more.
21+
<Typography fontSize={18}>
22+
My Lib is an intuitive platform built for developers, DevOps engineers,
23+
IT specialists, and anyone working with code or technical information.
24+
More than just a snippet manager, it’s a versatile workspace to organize
25+
your knowledge
2426
</Typography>
2527

26-
<Box display="flex" gap={3} justifyContent="center" my={3}>
28+
<Box display="flex" gap={3} justifyContent="center" my={5}>
29+
<Button size="large" variant="contained" href="/" component={Link}>
30+
Homepage
31+
</Button>
2732
<Button size="large" variant="contained" href="/login" component={Link}>
2833
Sign in
2934
</Button>
@@ -37,17 +42,86 @@ export default function AboutPage() {
3742
</Button>
3843
</Box>
3944

40-
<Typography variant="h2" gutterBottom textAlign="center">
41-
Why Use My Lib?
45+
<Typography variant="h2" my={3} textAlign="center">
46+
What Makes My Lib Indispensable?
47+
</Typography>
48+
49+
<Typography fontSize={18} mb={2}>
50+
🚀 Build Your Personal Code Library Save code snippets in any language
51+
(JavaScript, Python, Go, SQL, etc.) for frontend, backend, mobile
52+
development, or automation tasks. The built-in code editor with syntax
53+
highlighting ensures a seamless coding experience.
54+
</Typography>
55+
56+
<Typography fontSize={18} mb={2}>
57+
📂 Organize Beyond Code Store server configurations, instructions,
58+
documentation, checklists, bookmarks, and even images. The rich text
59+
editor lets you format content, add tables, lists, and embed media.
60+
</Typography>
61+
62+
<Typography fontSize={18} mb={2}>
63+
🏷️ Instant Access with Categories & Labels Sort data into customizable
64+
categories and apply labels for precise filtering. Examples: “Docker
65+
Configs, “React Hooks, “SQL Templates.
4266
</Typography>
4367

44-
<Typography paragraph fontSize={18}>
45-
Instead of searching through old projects or repositories, save your
46-
frequently used code in My Lib and retrieve it instantly whenever you
47-
need it. Perfect for work, personal projects, and improving efficiency.
68+
<Typography fontSize={18}>
69+
🔍 Find Anything in Seconds Search by category names, labels, or content
70+
within code items—no more digging through messy folders, old projects,
71+
or dozens of repositories. Stop wasting time scrolling through forums or
72+
GitHub to rediscover solutions you’ve already used. With My Lib, every
73+
piece of code, configuration, or knowledge you’ve saved is just a quick
74+
search away.
4875
</Typography>
4976

50-
<Typography variant="h3" gutterBottom textAlign="center">
77+
<Box display={{ xs: "none", md: "block" }}>
78+
<Typography component="h3" variant="h2" my={5} textAlign="center">
79+
Example of usage:
80+
</Typography>
81+
82+
<Typography variant="h4" mb={2}>
83+
Home page with categories:
84+
</Typography>
85+
86+
<Box
87+
height={560}
88+
width={1}
89+
position="relative"
90+
border={1}
91+
borderRadius={2}
92+
overflow="hidden"
93+
>
94+
<Image
95+
src="/about/categories.png"
96+
alt="Categories example"
97+
objectFit="contain"
98+
fill
99+
/>
100+
</Box>
101+
102+
<Typography variant="h4" my={2}>
103+
Code items inside category:
104+
</Typography>
105+
106+
<Box
107+
height={550}
108+
width={1}
109+
position="relative"
110+
border={1}
111+
borderRadius={2}
112+
mt={2}
113+
overflow="hidden"
114+
>
115+
<Image
116+
src="/about/code-items-styles.png"
117+
alt="Code items example"
118+
objectFit="contain"
119+
fill
120+
/>
121+
</Box>
122+
</Box>
123+
124+
<Typography component="h4" variant="h2" my={3} textAlign="center">
51125
Key Features
52126
</Typography>
53127

app/api/categories/[id]/route.ts

+18-5
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@ import { NextRequest, NextResponse } from "next/server";
22
import { connectDb } from "@/lib";
33
import Category from "@/models/category";
44
import { ZodError, z } from "zod";
5-
import Label from "@/models/label";
65
import { MongoError } from "@/types";
6+
import { getServerSession } from "next-auth";
7+
import { authConfig } from "@/configs";
8+
import CodeItem from "@/models/code-item";
79

810
interface UpdateCategoryRequest {
911
name: string;
1012
}
1113

1214
export async function PUT(
1315
req: NextRequest,
14-
{ params }: { params: { id: string } }
16+
{ params }: { params: Promise<{ id: string }> }
1517
) {
1618
try {
1719
await connectDb();
1820

19-
const id = params.id;
21+
const id = (await params).id;
2022
const body = (await req.json()) as UpdateCategoryRequest;
2123

2224
if (!id) {
@@ -93,12 +95,21 @@ export async function PUT(
9395

9496
export async function DELETE(
9597
req: NextRequest,
96-
{ params }: { params: { id: string } }
98+
{ params }: { params: Promise<{ id: string }> }
9799
) {
98100
try {
99101
await connectDb();
100102

101-
const categoryId = params.id;
103+
const session = await getServerSession({ ...authConfig });
104+
const userId = session?.user?.id;
105+
const categoryId = (await params).id;
106+
107+
if (!userId) {
108+
return NextResponse.json(
109+
{ success: false, error: "Unauthorized" },
110+
{ status: 401 }
111+
);
112+
}
102113

103114
if (!categoryId) {
104115
return NextResponse.json(
@@ -109,6 +120,8 @@ export async function DELETE(
109120
);
110121
}
111122

123+
await CodeItem.deleteMany({ user_id: userId, category_id: categoryId });
124+
112125
await Category.findOneAndDelete({ _id: categoryId });
113126

114127
return NextResponse.json({ success: true });

app/api/code-items/[id]/route.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ const deleteImagesFromS3 = async (codeItemId: string) => {
7070

7171
export async function PUT(
7272
req: NextRequest,
73-
{ params }: { params: { id: string } }
73+
{ params }: { params: Promise<{ id: string }> }
7474
) {
7575
try {
7676
await connectDb();
7777

78-
const id = params.id;
78+
const id = (await params).id;
7979
const body = (await req.json()) as UpdateCodeItemRequest;
8080

8181
const parsedBody = await validateBody(body);
@@ -103,12 +103,12 @@ export async function PUT(
103103

104104
export async function DELETE(
105105
req: NextRequest,
106-
{ params }: { params: { id: string } }
106+
{ params }: { params: Promise<{ id: string }> }
107107
) {
108108
try {
109109
await connectDb();
110110

111-
const codeItemId = params.id;
111+
const codeItemId = (await params).id;
112112

113113
await deleteImagesFromS3(codeItemId);
114114

@@ -122,14 +122,14 @@ export async function DELETE(
122122

123123
export async function GET(
124124
req: NextRequest,
125-
{ params }: { params: { id: string } }
125+
{ params }: { params: Promise<{ id: string }> }
126126
) {
127127
try {
128128
await connectDb();
129129

130130
const session = await getServerSession({ ...authConfig });
131131
const userId = session?.user?.id;
132-
const codeItemId = params.id;
132+
const codeItemId = (await params).id;
133133

134134
const codeItem = await CodeItem.findById(codeItemId);
135135

app/api/labels/[id]/route.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ const deleteLabel = async (labelId: string): Promise<void> => {
6868

6969
export async function PUT(
7070
req: NextRequest,
71-
{ params }: { params: { id: string } }
71+
{ params }: { params: Promise<{ id: string }> }
7272
) {
7373
try {
7474
await connectDb();
7575

76-
const id = params.id;
76+
const id = (await params).id;
7777
const body = (await req.json()) as UpdateLabelRequest;
7878

7979
if (!id) {
@@ -116,12 +116,12 @@ export async function PUT(
116116

117117
export async function DELETE(
118118
req: NextRequest,
119-
{ params }: { params: { id: string } }
119+
{ params }: { params: Promise<{ id: string }> }
120120
) {
121121
try {
122122
await connectDb();
123123

124-
const labelId = params.id;
124+
const labelId = (await params).id;
125125

126126
if (!labelId) {
127127
return NextResponse.json(

app/code-items/CodeItemsList.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ import Link from "next/link";
55
import { useGetCodeItems, useGetLabels } from "@/api";
66
import AddIcon from "@mui/icons-material/Add";
77
import { useSearchParams } from "next/navigation";
8-
import { Box, List, Grid2, useMediaQuery, useTheme } from "@mui/material";
8+
import {
9+
Box,
10+
List,
11+
Grid2,
12+
useMediaQuery,
13+
useTheme,
14+
Typography,
15+
} from "@mui/material";
916
import {
1017
LoadingSpinner,
1118
SearchInput,
@@ -102,7 +109,7 @@ export const CodeItemsList = ({ pageTitle }: CodeItemsListProps) => {
102109
}}
103110
/>
104111
</Box>
105-
) : (
112+
) : codeItems.length ? (
106113
<List
107114
dense
108115
sx={{ width: "100%", "& .MuiTypography-root": { fontSize: 20 } }}
@@ -127,6 +134,8 @@ export const CodeItemsList = ({ pageTitle }: CodeItemsListProps) => {
127134
</Box>
128135
)}
129136
</List>
137+
) : (
138+
<Typography mt={3}>No code items found...</Typography>
130139
)}
131140
</MainLayout>
132141
);

app/code-items/edit/[id]/page.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import { fetchOneCodeItem } from "@/api/codeItems/fetchOneCodeItem";
99
import { EditCodeItem } from "./edit";
1010

1111
interface EditPageProps {
12-
params: {
13-
id: string;
14-
};
12+
params: Promise<{ id: string }>;
1513
}
1614

1715
const CodeItemEditPage = async ({ params }: EditPageProps) => {

app/code-items/page.tsx

+3-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ import { CodeItemsList } from "./CodeItemsList";
99
import { cookies } from "next/headers";
1010

1111
interface CodeItemsPageProps {
12-
searchParams:
13-
| string
14-
| string[][]
15-
| Record<string, string>
16-
| URLSearchParams
17-
| undefined;
12+
searchParams: Promise<
13+
string | string[][] | Record<string, string> | URLSearchParams | undefined
14+
>;
1815
}
1916

2017
const CodeItemsPage = async ({ searchParams }: CodeItemsPageProps) => {

app/code-items/show/[id]/page.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import { fetchOneCodeItem } from "@/api/codeItems/fetchOneCodeItem";
99
import { ShowCodeItem } from "./show";
1010

1111
interface EditPageProps {
12-
params: {
13-
id: string;
14-
};
12+
params: Promise<{ id: string }>;
1513
}
1614

1715
const CodeIteShowPage = async ({ params }: EditPageProps) => {

components/Header.tsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ export const Header = () => {
6262
<Box sx={{ flexGrow: 0 }}>
6363
<Tooltip title="Open settings">
6464
<IconButton onClick={onOpenUserMenu} sx={{ p: 0 }}>
65-
<Avatar alt={userName} src={userImage ?? userName} />
65+
<Avatar alt={userName} src={userImage}>
66+
{userImage ? null : userName?.[0]?.toUpperCase()}
67+
</Avatar>
6668
</IconButton>
6769
</Tooltip>
6870
<Menu
@@ -94,6 +96,17 @@ export const Header = () => {
9496
<Typography variant="subtitle2">Dark mode</Typography>
9597
</Box>
9698

99+
<MenuItem>
100+
<Typography
101+
component={Link}
102+
width={1}
103+
href="/about"
104+
color="primary"
105+
>
106+
About
107+
</Typography>
108+
</MenuItem>
109+
97110
<MenuItem onClick={() => signOut()}>
98111
<Typography textAlign="center" color="primary">
99112
Log out

components/MainLayout.tsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,19 @@ export const MainLayout = ({
2626
<Grid2 container gap={2} direction="column">
2727
{toolbar}
2828

29-
<Typography variant="h2" mb={{ xs: 2, md: 4 }} {...titleProps}>
29+
<Typography
30+
variant="h2"
31+
mb={{ xs: 2, md: 4 }}
32+
title={title}
33+
sx={{
34+
display: "-webkit-box",
35+
WebkitBoxOrient: "vertical",
36+
WebkitLineClamp: 2,
37+
overflow: "hidden",
38+
wordBreak: "break-all",
39+
}}
40+
{...titleProps}
41+
>
3042
{title}
3143
</Typography>
3244

0 commit comments

Comments
 (0)