Files
tailwind-ui-library/components/hooks/useStatus.tsx
T
2026-10-01 08:02:47 +01:00

45 lines
1018 B
TypeScript

import React from "react";
export type TWUIErrorType = {
msg?: string;
};
type Params = {
initialLoading?: boolean;
initialReady?: boolean;
initialOpen?: boolean;
};
export type TWUIStatusType = {
msg?: string;
error?: boolean;
success?: boolean;
loading?: boolean;
};
export default function useStatus(params?: Params) {
const [refresh, setRefresh] = React.useState(0);
const [loading, setLoading] = React.useState(
params?.initialLoading || false,
);
const [status, setStatus] = React.useState<TWUIStatusType>();
const [ready, setReady] = React.useState(params?.initialReady || false);
const [open, setOpen] = React.useState(params?.initialOpen || false);
const [error, setError] = React.useState<TWUIErrorType>();
return {
refresh,
setRefresh,
loading,
setLoading,
status,
setStatus,
ready,
setReady,
open,
setOpen,
error,
setError,
};
}