Skip to content

Commit b87cdb1

Browse files
committed
Fix some linter errors and edit and move actions in pages
1 parent 5925506 commit b87cdb1

File tree

15 files changed

+33
-55
lines changed

15 files changed

+33
-55
lines changed

apps/backend/src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import {
44
NestFastifyApplication,
55
} from "@nestjs/platform-fastify";
66
import { AppModule } from "./app.module.js";
7+
import { env } from "process";
78

89
async function bootstrap() {
910
const app = await NestFactory.create<NestFastifyApplication>(
1011
AppModule,
1112
new FastifyAdapter()
1213
);
13-
await app.listen(process.env.PORT ?? 3000);
14+
await app.listen(env.PORT ?? 3000);
1415
}
1516
bootstrap();

apps/web/src/app/[...path]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { MovePageWrapper } from "~/components/wiki/MovePageWrapper";
1515

1616
export const revalidate = 900; // 15 minutes as we are dynamically telling the server to revalidate
1717
export const fetchCache = "force-cache";
18-
export const dynamic = "force-static";
18+
export const dynamic = "auto";
1919

2020
/**
2121
* Generates static paths for all existing wiki pages at build time.

apps/web/src/app/admin/dashboard/page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { useTRPC } from "~/server/client";
55
import { useQuery } from "@tanstack/react-query";
66
import type { AppRouter } from "~/server/routers";
77
import Link from "next/link";
8-
import { formatDistanceToNow } from "date-fns";
98

109
// Define type for the stats object returned by the API
1110
type SystemStatsQueryProcedure = AppRouter["admin"]["system"]["getStats"];

apps/web/src/app/admin/permissions/permissions-actions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ export function PermissionsActions() {
202202
</div>
203203
<p className="text-text-tertiary mt-2 w-full text-sm">
204204
Validate checks registry against DB. Fix actions are only available if
205-
validation fails. 'Remove Extras' deletes DB permissions not in the
206-
code registry (potentially impactful).
205+
validation fails. &apos;Remove Extras&apos; deletes DB permissions not
206+
in the code registry (potentially impactful).
207207
</p>
208208
</div>
209209

apps/web/src/app/admin/settings/components/category-settings.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {
4242
EyeOff,
4343
} from "lucide-react";
4444
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
45+
import { logger } from "@repo/logger";
4546

4647
interface CategorySettingsProps {
4748
category: SettingCategory;
@@ -62,7 +63,9 @@ export function CategorySettings({
6263
);
6364

6465
// State for edited values
65-
const [editedValues, setEditedValues] = useState<Record<string, any>>({});
66+
const [editedValues, setEditedValues] = useState<
67+
Record<string, string | number | boolean | object>
68+
>({});
6669
const [historyKey, setHistoryKey] = useState<string | null>(null);
6770

6871
const byCategoryQueryKey = trpc.admin.settings.getByCategory.queryKey();
@@ -105,7 +108,10 @@ export function CategorySettings({
105108
)
106109
);
107110

108-
const handleValueChange = (key: string, value: any) => {
111+
const handleValueChange = (
112+
key: string,
113+
value: string | number | boolean | object
114+
) => {
109115
setEditedValues((prev) => ({
110116
...prev,
111117
[key]: value,
@@ -132,7 +138,7 @@ export function CategorySettings({
132138
const key = setting.key;
133139
const value = key in editedValues ? editedValues[key] : setting.value;
134140
const type = setting.meta.type;
135-
const isEdited = key in editedValues;
141+
// const isEdited = key in editedValues;
136142
const isSecret = setting.meta.isSecret;
137143

138144
switch (type) {
@@ -208,7 +214,11 @@ export function CategorySettings({
208214
const parsed = JSON.parse(e.target.value);
209215
handleValueChange(key, parsed);
210216
} catch (error) {
211-
// Don't update if invalid JSON
217+
if (error instanceof Error) {
218+
logger.error(error.message);
219+
} else {
220+
logger.error(error as string);
221+
}
212222
}
213223
}}
214224
className="border-input bg-background-paper min-h-[100px] w-full rounded-md border px-3 py-2 text-sm"

apps/web/src/app/api/openapi.json/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const openApiDocument = generateOpenApiDocument(appRouter, {
1010
});
1111

1212
export async function GET(request: NextRequest) {
13+
void request;
1314
return new Response(JSON.stringify(openApiDocument), {
1415
headers: { "Content-Type": "application/json" },
1516
});

apps/web/src/app/api/rest/[...trpc]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const handler = (req: NextRequest) => {
1010
return createOpenApiFetchHandler({
1111
endpoint: "/api/rest", // Match the file path
1212
router: appRouter,
13-
// @ts-ignore - Temporarily ignore type mismatch to focus on runtime error
13+
// @ts-expect-error - TODO: Fix this type
1414
createContext: () => createContext(req),
1515
req,
1616
});

apps/web/src/components/auth/LoginForm.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Alert, AlertDescription } from "@repo/ui";
88
import { Button } from "@repo/ui";
99
import { Input } from "@repo/ui";
1010
import { useSetting } from "~/lib/hooks/use-settings";
11+
import { usePermissions } from "./permission/client";
1112

1213
// Create a separate component to read searchParams to work with Suspense
1314
function RegistrationSuccessMessage() {
@@ -34,6 +35,7 @@ export function LoginForm() {
3435
const [error, setError] = useState("");
3536
const [isLoading, setIsLoading] = useState(false);
3637
const { value: allowRegistration } = useSetting("auth.allowRegistration");
38+
const { reloadPermissions } = usePermissions();
3739

3840
const handleSubmit = async (e: React.FormEvent) => {
3941
e.preventDefault();
@@ -52,8 +54,8 @@ export function LoginForm() {
5254
setIsLoading(false);
5355
} else {
5456
// Redirect to home page
57+
await reloadPermissions();
5558
router.push("/");
56-
router.refresh();
5759
}
5860
} catch {
5961
setError("An error occurred during login");

apps/web/src/components/wiki/WikiLockInfo.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
TooltipProvider,
1313
TooltipTrigger,
1414
} from "@repo/ui";
15-
import { LockIcon, UnlockIcon, PencilIcon, XCircleIcon } from "lucide-react";
15+
import { LockIcon, UnlockIcon, XCircleIcon } from "lucide-react";
1616

1717
interface WikiLockInfoProps {
1818
pageId: number;
@@ -30,7 +30,6 @@ export function WikiLockInfo({
3030
lockedByName,
3131
lockedUntil,
3232
isCurrentUserLockOwner,
33-
editPath,
3433
displayMode = "full",
3534
}: WikiLockInfoProps) {
3635
const router = useRouter();
@@ -50,11 +49,6 @@ export function WikiLockInfo({
5049
})
5150
);
5251

53-
// Handle edit button click
54-
const handleEdit = () => {
55-
router.push(editPath);
56-
};
57-
5852
// Handle release lock button click
5953
const handleReleaseLock = () => {
6054
releaseLockMutation.mutate({ id: pageId });

apps/web/src/components/wiki/WikiPage.tsx

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,10 @@ export function WikiPage({
3434
content,
3535
createdBy,
3636
updatedBy,
37-
lockedBy,
38-
lockExpiresAt,
3937
createdAt,
4038
updatedAt,
4139
tags = [],
4240
path,
43-
currentUserId,
4441
}: WikiPageProps) {
4542
const router = useRouter();
4643
const [hasSubpages, setHasSubpages] = useState(false);
@@ -59,25 +56,6 @@ export function WikiPage({
5956
})
6057
);
6158

62-
// Determine if the page is currently locked
63-
const isLocked = Boolean(
64-
lockedBy && lockExpiresAt && new Date(lockExpiresAt) > new Date()
65-
);
66-
67-
// Determine if the current user is the lock owner
68-
const isCurrentUserLockOwner = Boolean(
69-
currentUserId && lockedBy && lockedBy.id === currentUserId
70-
);
71-
72-
// Handle rename action
73-
const handleRename = (e: React.MouseEvent) => {
74-
e.preventDefault();
75-
e.stopPropagation();
76-
setNewName(title);
77-
setRenameConflict(false);
78-
setShowRenameModal(true);
79-
};
80-
8159
// Handle rename submission
8260
const renameNode = () => {
8361
if (!newName.trim()) return;
@@ -97,13 +75,6 @@ export function WikiPage({
9775
setShowRenameModal(false);
9876
};
9977

100-
// Handle move action
101-
const handleMove = (e: React.MouseEvent) => {
102-
e.preventDefault();
103-
e.stopPropagation();
104-
setShowMoveModal(true);
105-
};
106-
10778
// Check if the current page has subpages
10879
const { data: folderStructure } = useQuery(
10980
trpc.wiki.getFolderStructure.queryOptions()

0 commit comments

Comments
 (0)