mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-06 20:15:17 +02:00
Merge pull request #1166 from SohamBhattacharjee2003/fix/remove-unnecessary-use-client-directives
fix: remove unnecessary use client directives
This commit is contained in:
commit
cf2115bc90
6 changed files with 26 additions and 57 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { AnimatePresence, motion } from "motion/react";
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
import { useSearchParams } from "next/navigation";
|
import { useSearchParams } from "next/navigation";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { Suspense, useEffect, useState } from "react";
|
import { Suspense, useEffect, useState } from "react";
|
||||||
|
|
@ -16,6 +17,7 @@ import { LocalLoginForm } from "./LocalLoginForm";
|
||||||
function LoginContent() {
|
function LoginContent() {
|
||||||
const t = useTranslations("auth");
|
const t = useTranslations("auth");
|
||||||
const tCommon = useTranslations("common");
|
const tCommon = useTranslations("common");
|
||||||
|
const router = useRouter();
|
||||||
const [authType, setAuthType] = useState<string | null>(null);
|
const [authType, setAuthType] = useState<string | null>(null);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [urlError, setUrlError] = useState<{ title: string; message: string } | null>(null);
|
const [urlError, setUrlError] = useState<{ title: string; message: string } | null>(null);
|
||||||
|
|
@ -79,7 +81,7 @@ function LoginContent() {
|
||||||
if (shouldRetry(error)) {
|
if (shouldRetry(error)) {
|
||||||
toastOptions.action = {
|
toastOptions.action = {
|
||||||
label: "Retry",
|
label: "Retry",
|
||||||
onClick: () => window.location.reload(),
|
onClick: () => router.refresh(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,10 @@
|
||||||
"use client";
|
|
||||||
|
|
||||||
import { motion } from "motion/react";
|
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
|
|
||||||
export default function Loading() {
|
export default function Loading() {
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<div className="w-full px-6 py-4 space-y-6 min-h-[calc(100vh-64px)] animate-in fade-in duration-300">
|
||||||
initial={{ opacity: 0, y: 20 }}
|
|
||||||
animate={{ opacity: 1, y: 0 }}
|
|
||||||
transition={{ duration: 0.3 }}
|
|
||||||
className="w-full px-6 py-4 space-y-6 min-h-[calc(100vh-64px)]"
|
|
||||||
>
|
|
||||||
{/* Summary Dashboard Skeleton */}
|
{/* Summary Dashboard Skeleton */}
|
||||||
<motion.div
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||||
className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4"
|
|
||||||
initial={{ opacity: 0 }}
|
|
||||||
animate={{ opacity: 1 }}
|
|
||||||
>
|
|
||||||
{[...Array(4)].map((_, i) => (
|
{[...Array(4)].map((_, i) => (
|
||||||
<div key={i} className="rounded-lg border p-4">
|
<div key={i} className="rounded-lg border p-4">
|
||||||
<div className="flex flex-row items-center justify-between space-y-0 pb-2">
|
<div className="flex flex-row items-center justify-between space-y-0 pb-2">
|
||||||
|
|
@ -29,44 +17,29 @@ export default function Loading() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</motion.div>
|
</div>
|
||||||
|
|
||||||
{/* Header Section Skeleton */}
|
{/* Header Section Skeleton */}
|
||||||
<motion.div
|
<div className="flex items-center justify-between">
|
||||||
className="flex items-center justify-between"
|
|
||||||
initial={{ opacity: 0, y: 10 }}
|
|
||||||
animate={{ opacity: 1, y: 0 }}
|
|
||||||
transition={{ delay: 0.1 }}
|
|
||||||
>
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Skeleton className="h-8 w-48" />
|
<Skeleton className="h-8 w-48" />
|
||||||
<Skeleton className="h-4 w-64" />
|
<Skeleton className="h-4 w-64" />
|
||||||
</div>
|
</div>
|
||||||
<Skeleton className="h-9 w-24" />
|
<Skeleton className="h-9 w-24" />
|
||||||
</motion.div>
|
</div>
|
||||||
|
|
||||||
{/* Filters Skeleton */}
|
{/* Filters Skeleton */}
|
||||||
<motion.div
|
<div className="flex flex-wrap items-center justify-start gap-3 w-full">
|
||||||
className="flex flex-wrap items-center justify-start gap-3 w-full"
|
|
||||||
initial={{ opacity: 0, y: 10 }}
|
|
||||||
animate={{ opacity: 1, y: 0 }}
|
|
||||||
transition={{ delay: 0.2 }}
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-3 flex-wrap w-full sm:w-auto">
|
<div className="flex items-center gap-3 flex-wrap w-full sm:w-auto">
|
||||||
<Skeleton className="h-9 w-full sm:w-60" />
|
<Skeleton className="h-9 w-full sm:w-60" />
|
||||||
<Skeleton className="h-9 w-24" />
|
<Skeleton className="h-9 w-24" />
|
||||||
<Skeleton className="h-9 w-24" />
|
<Skeleton className="h-9 w-24" />
|
||||||
<Skeleton className="h-9 w-20" />
|
<Skeleton className="h-9 w-20" />
|
||||||
</div>
|
</div>
|
||||||
</motion.div>
|
</div>
|
||||||
|
|
||||||
{/* Table Skeleton */}
|
{/* Table Skeleton */}
|
||||||
<motion.div
|
<div className="rounded-md border overflow-hidden">
|
||||||
className="rounded-md border overflow-hidden"
|
|
||||||
initial={{ opacity: 0, y: 20 }}
|
|
||||||
animate={{ opacity: 1, y: 0 }}
|
|
||||||
transition={{ delay: 0.3 }}
|
|
||||||
>
|
|
||||||
{/* Table Header */}
|
{/* Table Header */}
|
||||||
<div className="border-b bg-muted/50 px-4 py-3 flex items-center gap-4">
|
<div className="border-b bg-muted/50 px-4 py-3 flex items-center gap-4">
|
||||||
<Skeleton className="h-4 w-4" />
|
<Skeleton className="h-4 w-4" />
|
||||||
|
|
@ -99,27 +72,18 @@ export default function Loading() {
|
||||||
<Skeleton className="h-8 w-8" />
|
<Skeleton className="h-8 w-8" />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</motion.div>
|
</div>
|
||||||
|
|
||||||
{/* Pagination Skeleton */}
|
{/* Pagination Skeleton */}
|
||||||
<div className="flex items-center justify-between gap-8 mt-4">
|
<div className="flex items-center justify-between gap-8 mt-4">
|
||||||
<motion.div
|
<div className="flex items-center gap-3">
|
||||||
className="flex items-center gap-3"
|
|
||||||
initial={{ opacity: 0, x: -20 }}
|
|
||||||
animate={{ opacity: 1, x: 0 }}
|
|
||||||
>
|
|
||||||
<Skeleton className="h-4 w-20 max-sm:sr-only" />
|
<Skeleton className="h-4 w-20 max-sm:sr-only" />
|
||||||
<Skeleton className="h-9 w-16" />
|
<Skeleton className="h-9 w-16" />
|
||||||
</motion.div>
|
</div>
|
||||||
|
|
||||||
<motion.div
|
<div className="flex grow justify-end">
|
||||||
className="flex grow justify-end"
|
|
||||||
initial={{ opacity: 0 }}
|
|
||||||
animate={{ opacity: 1 }}
|
|
||||||
transition={{ delay: 0.2 }}
|
|
||||||
>
|
|
||||||
<Skeleton className="h-4 w-40" />
|
<Skeleton className="h-4 w-40" />
|
||||||
</motion.div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Skeleton className="h-9 w-9" />
|
<Skeleton className="h-9 w-9" />
|
||||||
|
|
@ -128,6 +92,6 @@ export default function Loading() {
|
||||||
<Skeleton className="h-9 w-9" />
|
<Skeleton className="h-9 w-9" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</motion.div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
"use client";
|
|
||||||
|
|
||||||
import type { Separator } from "fumadocs-core/page-tree";
|
import type { Separator } from "fumadocs-core/page-tree";
|
||||||
|
|
||||||
export function SidebarSeparator({ item }: { item: Separator }) {
|
export function SidebarSeparator({ item }: { item: Separator }) {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import { BadgeCheck, LogOut } from "lucide-react";
|
import { BadgeCheck, LogOut } from "lucide-react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
|
@ -27,6 +28,7 @@ export function UserDropdown({
|
||||||
avatar: string;
|
avatar: string;
|
||||||
};
|
};
|
||||||
}) {
|
}) {
|
||||||
|
const router = useRouter();
|
||||||
const [isLoggingOut, setIsLoggingOut] = useState(false);
|
const [isLoggingOut, setIsLoggingOut] = useState(false);
|
||||||
|
|
||||||
const handleLogout = async () => {
|
const handleLogout = async () => {
|
||||||
|
|
@ -38,12 +40,16 @@ export function UserDropdown({
|
||||||
|
|
||||||
await logout();
|
await logout();
|
||||||
|
|
||||||
|
router.push("/");
|
||||||
|
router.refresh();
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window !== "undefined") {
|
||||||
window.location.href = getLoginPath();
|
window.location.href = getLoginPath();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error during logout:", error);
|
console.error("Error during logout:", error);
|
||||||
await logout();
|
await logout();
|
||||||
|
router.push("/");
|
||||||
|
router.refresh();
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window !== "undefined") {
|
||||||
window.location.href = getLoginPath();
|
window.location.href = getLoginPath();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
"use client";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps SearchSourceConnectorType to DocumentType for fetching document counts
|
* Maps SearchSourceConnectorType to DocumentType for fetching document counts
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { useAtomValue } from "jotai";
|
import { useAtomValue } from "jotai";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
|
|
@ -43,6 +44,7 @@ interface CreateSearchSpaceDialogProps {
|
||||||
export function CreateSearchSpaceDialog({ open, onOpenChange }: CreateSearchSpaceDialogProps) {
|
export function CreateSearchSpaceDialog({ open, onOpenChange }: CreateSearchSpaceDialogProps) {
|
||||||
const t = useTranslations("searchSpace");
|
const t = useTranslations("searchSpace");
|
||||||
const tCommon = useTranslations("common");
|
const tCommon = useTranslations("common");
|
||||||
|
const router = useRouter();
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
const { mutateAsync: createSearchSpace } = useAtomValue(createSearchSpaceMutationAtom);
|
const { mutateAsync: createSearchSpace } = useAtomValue(createSearchSpaceMutationAtom);
|
||||||
|
|
@ -65,8 +67,7 @@ export function CreateSearchSpaceDialog({ open, onOpenChange }: CreateSearchSpac
|
||||||
|
|
||||||
trackSearchSpaceCreated(result.id, values.name);
|
trackSearchSpaceCreated(result.id, values.name);
|
||||||
|
|
||||||
// Hard redirect to ensure fresh state
|
router.push(`/dashboard/${result.id}/onboard`);
|
||||||
window.location.href = `/dashboard/${result.id}/onboard`;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to create search space:", error);
|
console.error("Failed to create search space:", error);
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue