- Added Zod schemas for dashboard queries, entries, summaries, and companies. - Created dashboard API functions for fetching summary, work, attention, activity, and companies data. - Developed dashboard components including BlockState, DashboardDetailsDialog, and DashboardPage for rendering dashboard information. - Implemented quick create functionality for companies, tickets, interventions, assets, and resources. - Introduced a new ResourceDashboardReader for querying resource-related data. - Added a StatisticCard component for displaying key performance indicators in the dashboard.
36 lines
790 B
TypeScript
36 lines
790 B
TypeScript
import type { ReactNode } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
type QueryState = { isPending: boolean; isError: boolean };
|
|
export function BlockState({
|
|
query,
|
|
empty,
|
|
emptyText,
|
|
children,
|
|
}: {
|
|
query: QueryState;
|
|
empty: boolean;
|
|
emptyText: string;
|
|
children: ReactNode;
|
|
}) {
|
|
const { t } = useTranslation("companies");
|
|
if (query.isPending) {
|
|
return (
|
|
<p className="py-6 text-sm text-muted-foreground" role="status">
|
|
{t("loading")}
|
|
</p>
|
|
);
|
|
}
|
|
if (query.isError) {
|
|
return (
|
|
<p className="py-6 text-sm text-destructive" role="alert">
|
|
{t("dashboard.blockError")}
|
|
</p>
|
|
);
|
|
}
|
|
if (empty) {
|
|
return <p className="py-6 text-sm text-muted-foreground">{emptyText}</p>;
|
|
}
|
|
return children;
|
|
}
|