fix: simplify widget feedback
This commit is contained in:
1 parent
0e01ac67df
commit
3bd80dcc58
1 file changed
+3
-10
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useCallback } from "react";
|
import { useCallback } from "react";
|
||||||
import { Badge, Center, Group, Stack, Text, Tooltip, UnstyledButton } from "@mantine/core";
|
import { Badge, Center, Group, Stack, Text, UnstyledButton } from "@mantine/core";
|
||||||
import { IconBinaryTree } from "@tabler/icons-react";
|
import { IconBinaryTree } from "@tabler/icons-react";
|
||||||
|
|
||||||
import { clientApi } from "@homarr/api/client";
|
import { clientApi } from "@homarr/api/client";
|
||||||
@@ -38,7 +38,7 @@ export default function SmartHomeEntityStateWidget({
|
|||||||
const canInteract = useIntegrationsWithInteractAccess().some(({ id }) => id === integrationId);
|
const canInteract = useIntegrationsWithInteractAccess().some(({ id }) => id === integrationId);
|
||||||
|
|
||||||
const utils = clientApi.useUtils();
|
const utils = clientApi.useUtils();
|
||||||
const { mutate, isPending, error } = clientApi.widget.smartHome.switchEntity.useMutation({
|
const { mutate, isPending } = clientApi.widget.smartHome.switchEntity.useMutation({
|
||||||
onSettled: () => void utils.widget.smartHome.entityDetails.invalidate(input),
|
onSettled: () => void utils.widget.smartHome.entityDetails.invalidate(input),
|
||||||
onError: () =>
|
onError: () =>
|
||||||
showErrorNotification({
|
showErrorNotification({
|
||||||
@@ -110,7 +110,7 @@ export default function SmartHomeEntityStateWidget({
|
|||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
disabled={!isActionable}
|
disabled={!isActionable}
|
||||||
aria-label={`${displayName}: ${state}${attribute}`}
|
aria-label={`${displayName}: ${state}${attribute}`}
|
||||||
aria-description={queryErrorLabel ?? (error ? t("widget.smartHome-entityState.error.toggleFailed") : undefined)}
|
aria-description={queryErrorLabel}
|
||||||
w="100%"
|
w="100%"
|
||||||
h="100%"
|
h="100%"
|
||||||
styles={{
|
styles={{
|
||||||
@@ -153,13 +153,6 @@ export default function SmartHomeEntityStateWidget({
|
|||||||
</Text>
|
</Text>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{error && (
|
|
||||||
<Tooltip label={error.message} multiline>
|
|
||||||
<Text size="xs" c="red" lineClamp={2} tabIndex={0}>
|
|
||||||
{t("widget.smartHome-entityState.error.toggleFailed")}
|
|
||||||
</Text>
|
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</Center>
|
</Center>
|
||||||
</UnstyledButton>
|
</UnstyledButton>
|
||||||
|
|||||||
Reference in new issue
Block a user