mirror of
https://github.com/logto-io/logto.git
synced 2025-02-17 22:04:19 -05:00
fix(console): refresh hook on data updated (#3898)
This commit is contained in:
parent
e7ee0a9523
commit
ab38cbffeb
1 changed files with 4 additions and 4 deletions
|
@ -42,7 +42,7 @@ function WebhookDetails() {
|
|||
const { data, error, mutate } = useSWR<HookResponse, RequestError>(
|
||||
id && buildUrl(`api/hooks/${id}`, { includeExecutionStats: String(true) })
|
||||
);
|
||||
const { executionStats } = data ?? {};
|
||||
const { enabled: isEnabled, executionStats } = data ?? {};
|
||||
const isLoading = !data && !error;
|
||||
const api = useApi();
|
||||
|
||||
|
@ -53,7 +53,6 @@ function WebhookDetails() {
|
|||
const [isDeleting, setIsDeleting] = useState(false);
|
||||
const [isDisableFormOpen, setIsDisableFormOpen] = useState(false);
|
||||
const [isUpdatingEnableState, setIsUpdatingEnableState] = useState(false);
|
||||
const [isEnabled, setIsEnabled] = useState(data?.enabled ?? true);
|
||||
|
||||
useEffect(() => {
|
||||
setIsDeleteFormOpen(false);
|
||||
|
@ -84,11 +83,12 @@ function WebhookDetails() {
|
|||
setIsUpdatingEnableState(true);
|
||||
|
||||
try {
|
||||
const { enabled } = await api
|
||||
const updatedHook = await api
|
||||
.patch(`api/hooks/${data.id}`, { json: { enabled: !isEnabled } })
|
||||
.json<Hook>();
|
||||
setIsEnabled(enabled);
|
||||
void mutate({ ...updatedHook, executionStats: data.executionStats });
|
||||
setIsDisableFormOpen(false);
|
||||
const { enabled } = updatedHook;
|
||||
toast.success(
|
||||
t(enabled ? 'webhook_details.webhook_reactivated' : 'webhook_details.webhook_disabled')
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue