feat: add share page settings dialog + add org id to deployment as well
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
"use client";
|
||||
|
||||
import { callServerPromise } from "@/components/callServerPromise";
|
||||
import { useEffect, useState, useTransition } from "react";
|
||||
|
||||
export function useServerActionData<I, O>(
|
||||
action: (data: I) => Promise<O>,
|
||||
input: I
|
||||
) {
|
||||
const [data, setData] = useState<O | null>(null);
|
||||
const [pending, startTransition] = useTransition();
|
||||
const [started, setStarted] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
startTransition(() => {
|
||||
setStarted(true);
|
||||
callServerPromise(action(input)).then(setData);
|
||||
});
|
||||
}, [action, input]);
|
||||
|
||||
return {
|
||||
started,
|
||||
data,
|
||||
pending,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user