2024-11-04 23:55:08 +01:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
export const dynamic = "force-static";
|
|
|
|
|
|
Refactor ScriptItem and Buttons components to enhance layout and integrate dropdown for links. Update InterFaces component for improved styling and structure. (#3567)
* Refactor ScriptItem and Buttons components to enhance layout and integrate dropdown for links. Update InterFaces component for improved styling and structure.
* Add React Query integration and enhance component structure
- Introduced `@tanstack/react-query` for data fetching and state management.
- Added `QueryProvider` component to wrap the application with QueryClient.
- Refactored `ScriptItem` to utilize `useVersions` hook for fetching versions.
- Created `ResourceDisplay` and `VersionBadge` components for better resource representation.
- Improved layout and styling across various components, including `Alerts`, `Buttons`, and `DefaultPassword`.
- Updated `layout.tsx` to include the new `QueryProvider` for global state management.
* Remove bun.lock file to streamline dependency management and prevent potential conflicts.
* Update dependencies in package.json and package-lock.json
- Removed `@vercel/analytics` from dependencies.
- Upgraded `vitest` and related packages to version `3.1.1`.
- Updated various packages to their latest versions for improved performance and compatibility.
- Adjusted Node.js engine requirements to support newer versions.
* Update dependencies in package.json and package-lock.json
- Upgraded various Radix UI components to their latest versions for improved functionality and performance.
- Updated `chart.js`, `class-variance-authority`, `cmdk`, `framer-motion`, `fuse.js`, `nuqs`, `pocketbase`, and other packages to their latest versions.
- Enhanced TypeScript and ESLint packages for better type checking and linting capabilities.
- Updated Tailwind CSS and related plugins for improved styling and utility classes.
- Adjusted Node.js engine requirements in several packages to support newer versions.
2025-04-01 15:38:57 +02:00
|
|
|
import { ScriptItem } from "@/app/scripts/_components/ScriptItem";
|
2024-11-08 22:27:01 +01:00
|
|
|
import { fetchCategories } from "@/lib/data";
|
2024-11-04 23:55:08 +01:00
|
|
|
import { Category, Script } from "@/lib/types";
|
|
|
|
|
import { Loader2 } from "lucide-react";
|
|
|
|
|
import { useQueryState } from "nuqs";
|
2024-11-08 22:27:01 +01:00
|
|
|
import { Suspense, useEffect, useState } from "react";
|
2024-11-04 23:55:08 +01:00
|
|
|
import {
|
|
|
|
|
LatestScripts,
|
|
|
|
|
MostViewedScripts,
|
|
|
|
|
} from "./_components/ScriptInfoBlocks";
|
2024-11-08 22:27:01 +01:00
|
|
|
import Sidebar from "./_components/Sidebar";
|
2024-11-04 23:55:08 +01:00
|
|
|
|
|
|
|
|
function ScriptContent() {
|
|
|
|
|
const [selectedScript, setSelectedScript] = useQueryState("id");
|
|
|
|
|
const [links, setLinks] = useState<Category[]>([]);
|
|
|
|
|
const [item, setItem] = useState<Script>();
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (selectedScript && links.length > 0) {
|
|
|
|
|
const script = links
|
2024-11-06 23:47:04 +01:00
|
|
|
.map((category) => category.scripts)
|
2024-11-04 23:55:08 +01:00
|
|
|
.flat()
|
2024-11-08 22:27:01 +01:00
|
|
|
.find((script) => script.slug === selectedScript);
|
2024-11-04 23:55:08 +01:00
|
|
|
setItem(script);
|
|
|
|
|
}
|
|
|
|
|
}, [selectedScript, links]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2024-11-06 23:47:04 +01:00
|
|
|
fetchCategories()
|
|
|
|
|
.then((categories) => {
|
|
|
|
|
setLinks(categories);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => console.error(error));
|
2024-11-04 23:55:08 +01:00
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="mb-3">
|
|
|
|
|
<div className="mt-20 flex sm:px-4 xl:px-0">
|
|
|
|
|
<div className="hidden sm:flex">
|
|
|
|
|
<Sidebar
|
|
|
|
|
items={links}
|
|
|
|
|
selectedScript={selectedScript}
|
|
|
|
|
setSelectedScript={setSelectedScript}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2025-06-16 17:13:33 +02:00
|
|
|
<div className="mx-4 w-full sm:mx-0 sm:ml-4">
|
2024-11-04 23:55:08 +01:00
|
|
|
{selectedScript && item ? (
|
|
|
|
|
<ScriptItem item={item} setSelectedScript={setSelectedScript} />
|
|
|
|
|
) : (
|
|
|
|
|
<div className="flex w-full flex-col gap-5">
|
|
|
|
|
<LatestScripts items={links} />
|
|
|
|
|
<MostViewedScripts items={links} />
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function Page() {
|
|
|
|
|
return (
|
|
|
|
|
<Suspense
|
|
|
|
|
fallback={
|
|
|
|
|
<div className="flex h-screen w-full flex-col items-center justify-center gap-5 bg-background px-4 md:px-6">
|
|
|
|
|
<div className="space-y-2 text-center">
|
|
|
|
|
<Loader2 className="h-10 w-10 animate-spin" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<ScriptContent />
|
|
|
|
|
</Suspense>
|
|
|
|
|
);
|
2024-11-08 22:27:01 +01:00
|
|
|
}
|