fastapi-rtk
Version:
A React component library for FastAPI in combination with FastAPI React Toolkit backend, built with Mantine, JsonForms, and Zustand.
28 lines (27 loc) • 1.51 kB
JavaScript
import { jsx } from "react/jsx-runtime";
import { useActionIcon } from "fastapi-rtk/hooks";
import { ThemeIcon, Loader, Tooltip, ActionIcon } from "@mantine/core";
import { memo, useState } from "react";
import { useApi } from "../../hooks/api/useApi.mjs";
import "../../Wrappers/Provider/Contexts/LangContext.mjs";
import { useTranslation } from "../../../../.external/esm/react-i18next@15.7.3_i18next@25.5.2_react-dom@18.3.1_react@18.3.1_typescript@5.9.2/react-i18next/dist/es/useTranslation.mjs";
import IconRefresh from "../../../../.external/esm/@tabler_icons-react@3.18.0_react@18.3.1/@tabler/icons-react/dist/esm/icons/IconRefresh.mjs";
const Refresh = memo(({ tooltipProps, ...props }) => {
const { t } = useTranslation();
const [loading, setLoading] = useState(false);
const { refetch } = useApi();
const actionIconProps = useActionIcon({
onClick: () => {
setLoading(true);
refetch().finally(() => {
setLoading(false);
});
},
...props
});
return loading ? /* @__PURE__ */ jsx(ThemeIcon, { variant: "transparent", size: actionIconProps.size, c: actionIconProps.c, children: /* @__PURE__ */ jsx(Loader, { size: "100%", color: actionIconProps.c }) }) : /* @__PURE__ */ jsx(Tooltip, { ...tooltipProps, label: (tooltipProps == null ? void 0 : tooltipProps.refresh) ?? t("Refresh"), children: /* @__PURE__ */ jsx(ActionIcon, { ...actionIconProps, children: /* @__PURE__ */ jsx(IconRefresh, {}) }) });
});
Refresh.displayName = "Refresh";
export {
Refresh
};