refactor: improve code formatting and readability across multiple files
This commit is contained in:
@@ -26,15 +26,23 @@ vi.mock("next/link", () => {
|
||||
// wrappers still render <SignedOut/> from @clerk/nextjs (which crashes in real builds).
|
||||
vi.mock("@clerk/nextjs", () => {
|
||||
return {
|
||||
ClerkProvider: ({ children }: { children: React.ReactNode }) => <>{children}</>,
|
||||
ClerkProvider: ({ children }: { children: React.ReactNode }) => (
|
||||
<>{children}</>
|
||||
),
|
||||
SignedIn: () => {
|
||||
throw new Error("@clerk/nextjs SignedIn rendered (unexpected in secretless mode)");
|
||||
throw new Error(
|
||||
"@clerk/nextjs SignedIn rendered (unexpected in secretless mode)",
|
||||
);
|
||||
},
|
||||
SignedOut: () => {
|
||||
throw new Error("@clerk/nextjs SignedOut rendered without ClerkProvider");
|
||||
},
|
||||
SignInButton: ({ children }: { children: React.ReactNode }) => <>{children}</>,
|
||||
SignOutButton: ({ children }: { children: React.ReactNode }) => <>{children}</>,
|
||||
SignInButton: ({ children }: { children: React.ReactNode }) => (
|
||||
<>{children}</>
|
||||
),
|
||||
SignOutButton: ({ children }: { children: React.ReactNode }) => (
|
||||
<>{children}</>
|
||||
),
|
||||
useAuth: () => ({ isLoaded: true, isSignedIn: false }),
|
||||
useUser: () => ({ isLoaded: true, isSignedIn: false, user: null }),
|
||||
};
|
||||
|
||||
@@ -135,7 +135,11 @@ const SSE_RECONNECT_BACKOFF = {
|
||||
|
||||
type HeartbeatUnit = "s" | "m" | "h" | "d";
|
||||
|
||||
const HEARTBEAT_PRESETS: Array<{ label: string; amount: number; unit: HeartbeatUnit }> = [
|
||||
const HEARTBEAT_PRESETS: Array<{
|
||||
label: string;
|
||||
amount: number;
|
||||
unit: HeartbeatUnit;
|
||||
}> = [
|
||||
{ label: "30s", amount: 30, unit: "s" },
|
||||
{ label: "1m", amount: 1, unit: "m" },
|
||||
{ label: "2m", amount: 2, unit: "m" },
|
||||
@@ -781,22 +785,22 @@ export default function BoardGroupDetailPage() {
|
||||
{HEARTBEAT_PRESETS.map((preset) => {
|
||||
const value = `${preset.amount}${preset.unit}`;
|
||||
return (
|
||||
<button
|
||||
key={value}
|
||||
type="button"
|
||||
className={cn(
|
||||
"rounded-md px-2.5 py-1 text-xs font-semibold transition-colors",
|
||||
heartbeatEvery === value
|
||||
? "bg-slate-900 text-white"
|
||||
: "text-slate-600 hover:bg-slate-100 hover:text-slate-900",
|
||||
)}
|
||||
onClick={() => {
|
||||
setHeartbeatAmount(String(preset.amount));
|
||||
setHeartbeatUnit(preset.unit);
|
||||
}}
|
||||
>
|
||||
{preset.label}
|
||||
</button>
|
||||
<button
|
||||
key={value}
|
||||
type="button"
|
||||
className={cn(
|
||||
"rounded-md px-2.5 py-1 text-xs font-semibold transition-colors",
|
||||
heartbeatEvery === value
|
||||
? "bg-slate-900 text-white"
|
||||
: "text-slate-600 hover:bg-slate-100 hover:text-slate-900",
|
||||
)}
|
||||
onClick={() => {
|
||||
setHeartbeatAmount(String(preset.amount));
|
||||
setHeartbeatUnit(preset.unit);
|
||||
}}
|
||||
>
|
||||
{preset.label}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
// IMPORTANT: keep this file dependency-free (no `"use client"`, no React, no Clerk imports)
|
||||
// so it can be used from both client and server/edge entrypoints.
|
||||
|
||||
export function isLikelyValidClerkPublishableKey(key: string | undefined): key is string {
|
||||
export function isLikelyValidClerkPublishableKey(
|
||||
key: string | undefined,
|
||||
): key is string {
|
||||
if (!key) return false;
|
||||
|
||||
// Clerk publishable keys look like: pk_test_... or pk_live_...
|
||||
|
||||
@@ -4,7 +4,9 @@ import { clerkMiddleware } from "@clerk/nextjs/server";
|
||||
import { isLikelyValidClerkPublishableKey } from "@/auth/clerkKey";
|
||||
|
||||
const isClerkEnabled = () =>
|
||||
isLikelyValidClerkPublishableKey(process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY);
|
||||
isLikelyValidClerkPublishableKey(
|
||||
process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY,
|
||||
);
|
||||
|
||||
export default isClerkEnabled() ? clerkMiddleware() : () => NextResponse.next();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user