feat: add share page settings dialog + add org id to deployment as well

This commit is contained in:
BennyKok
2024-01-20 12:06:26 +08:00
parent a2d0e93172
commit 163e6f0426
32 changed files with 2396 additions and 253 deletions
+27 -3
View File
@@ -1,14 +1,21 @@
"use client";
import { LoadingIcon } from "@/components/LoadingIcon";
import { Button } from "@/components/ui/button";
import { RefreshCcw } from "lucide-react";
import { useRouter } from "next/navigation";
import { useEffect, useTransition } from "react";
export function RouteRefresher(props: { interval: number }) {
export function RouteRefresher(props: {
interval: number;
autoRefresh: boolean;
}) {
const [isPending, startTransition] = useTransition();
const router = useRouter();
useEffect(() => {
if (!props.autoRefresh) return;
let timeout: NodeJS.Timeout;
const refresh = () => {
@@ -35,7 +42,24 @@ export function RouteRefresher(props: { interval: number }) {
clearTimeout(timeout);
window.removeEventListener("visibilitychange", handleVisibilityChange);
};
}, [props.interval, router]);
}, [props.interval, router, props.autoRefresh]);
return <div>{isPending && <LoadingIcon />}</div>;
return (
<div>
{isPending && <LoadingIcon />}
{!isPending && !props.autoRefresh && (
<Button
className="p-0 h-min"
variant="ghost"
onClick={() => {
startTransition(() => {
router.refresh();
});
}}
>
<RefreshCcw size={14} />
</Button>
)}
</div>
);
}