0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(console): hide success rate on the hook details page when no request happened (#3897)

This commit is contained in:
Xiao Yijun 2023-05-25 10:39:03 +08:00 committed by GitHub
parent 37c3f5952d
commit e7ee0a9523
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -42,6 +42,7 @@ function WebhookDetails() {
const { data, error, mutate } = useSWR<HookResponse, RequestError>(
id && buildUrl(`api/hooks/${id}`, { includeExecutionStats: String(true) })
);
const { executionStats } = data ?? {};
const isLoading = !data && !error;
const api = useApi();
@ -113,18 +114,22 @@ function WebhookDetails() {
<div className={styles.metadata}>
<div className={styles.title}>{data.name}</div>
<div>
{isEnabled ? (
{isEnabled && executionStats ? (
<div className={styles.state}>
<SuccessRate
className={styles.successRate}
successCount={data.executionStats.successCount}
totalCount={data.executionStats.requestCount}
/>
<DynamicT forKey="webhook_details.success_rate" />
<div className={styles.verticalBar} />
{executionStats.requestCount > 0 && (
<>
<SuccessRate
className={styles.successRate}
successCount={executionStats.successCount}
totalCount={executionStats.requestCount}
/>
<DynamicT forKey="webhook_details.success_rate" />
<div className={styles.verticalBar} />
</>
)}
<DynamicT
forKey="webhook_details.requests"
interpolation={{ value: data.executionStats.requestCount }}
interpolation={{ value: executionStats.requestCount }}
/>
</div>
) : (