feat: able to remove share page deployment

This commit is contained in:
BennyKok
2024-01-16 23:51:04 +08:00
parent b6be0bd462
commit f8ac6fb251
4 changed files with 103 additions and 35 deletions
+35
View File
@@ -0,0 +1,35 @@
"use client";
import { LoadingIcon } from "@/components/LoadingIcon";
import { callServerPromise } from "@/components/callServerPromise";
import { useRouter } from "next/navigation";
import { useState } from "react";
export function ButtonAction({
action,
children,
...rest
}: {
action: () => Promise<any>;
children: React.ReactNode;
}) {
const [pending, setPending] = useState(false);
const router = useRouter();
return (
<button
onClick={async () => {
if (pending) return;
setPending(true);
await callServerPromise(action());
setPending(false);
router.refresh();
}}
{...rest}
>
{children} {pending && <LoadingIcon />}
</button>
);
}