fix: resolver avisos de build e tipagem
This commit is contained in:
parent
741f1d7f9c
commit
fa9efdb5af
7 changed files with 154 additions and 59 deletions
|
|
@ -11,8 +11,8 @@ import {
|
|||
TrendingUp,
|
||||
PanelsTopLeft,
|
||||
UserCog,
|
||||
Building,
|
||||
Building2,
|
||||
Skyscraper,
|
||||
Waypoints,
|
||||
Clock4,
|
||||
Timer,
|
||||
|
|
@ -108,7 +108,7 @@ const navigation: NavigationGroup[] = [
|
|||
{
|
||||
title: "Empresas",
|
||||
url: "/admin/companies",
|
||||
icon: Skyscraper,
|
||||
icon: Building,
|
||||
requiredRole: "admin",
|
||||
},
|
||||
{ title: "Usuários", url: "/admin/users", icon: Users, requiredRole: "admin" },
|
||||
|
|
|
|||
|
|
@ -150,6 +150,14 @@ type PackedLayoutItem = LayoutStateItem & {
|
|||
y: number
|
||||
}
|
||||
|
||||
type CanvasRenderableItem = {
|
||||
key: string
|
||||
layout: PackedLayoutItem
|
||||
minW?: number
|
||||
minH?: number
|
||||
element: React.ReactNode
|
||||
}
|
||||
|
||||
type DashboardDetailResult = {
|
||||
dashboard: DashboardRecord
|
||||
widgets: DashboardWidgetRecord[]
|
||||
|
|
@ -542,8 +550,6 @@ export function DashboardBuilder({ dashboardId, editable = true, mode = "edit" }
|
|||
return {
|
||||
key: item.i,
|
||||
layout: item,
|
||||
minW: item.minW,
|
||||
minH: item.minH,
|
||||
element: (
|
||||
<BuilderWidgetCard
|
||||
key={widget.widgetKey}
|
||||
|
|
@ -561,9 +567,11 @@ export function DashboardBuilder({ dashboardId, editable = true, mode = "edit" }
|
|||
onReadyChange={(ready) => handleWidgetReady(widget.widgetKey, ready)}
|
||||
/>
|
||||
),
|
||||
}
|
||||
...(item.minW !== undefined ? { minW: item.minW } : {}),
|
||||
...(item.minH !== undefined ? { minH: item.minH } : {}),
|
||||
} satisfies CanvasRenderableItem
|
||||
})
|
||||
.filter((item): item is { key: string; layout: PackedLayoutItem; minW?: number; minH?: number; element: React.ReactNode } => Boolean(item))
|
||||
.filter(Boolean) as CanvasRenderableItem[]
|
||||
|
||||
const allWidgetsReady = canvasItems.length > 0 && canvasItems.every((item) => readyWidgets.has(item.key))
|
||||
|
||||
|
|
@ -1177,34 +1185,37 @@ function WidgetConfigDialog({
|
|||
widget: DashboardWidgetRecord | null
|
||||
onSubmit: (values: WidgetConfigFormValues) => Promise<void>
|
||||
}) {
|
||||
const normalizedConfig = getWidgetConfigForWidget(widget)
|
||||
const form = useForm<WidgetConfigFormValues>({
|
||||
resolver: zodResolver(widgetConfigSchema),
|
||||
defaultValues: {
|
||||
title: widget?.title ?? widget?.config?.title ?? "",
|
||||
type: widget?.type ?? "kpi",
|
||||
metricKey: widget?.config?.dataSource?.metricKey ?? "",
|
||||
stacked: Boolean((widget?.config as { encoding?: { stacked?: boolean } })?.encoding?.stacked ?? false),
|
||||
legend: Boolean((widget?.config as { options?: { legend?: boolean } })?.options?.legend ?? true),
|
||||
rangeOverride: typeof (widget?.config as { dataSource?: { params?: Record<string, unknown> } })?.dataSource?.params?.range === "string"
|
||||
? ((widget?.config as { dataSource?: { params?: Record<string, unknown> } })?.dataSource?.params?.range as string)
|
||||
: "",
|
||||
showTooltip: Boolean((widget?.config as { options?: { tooltip?: boolean } })?.options?.tooltip ?? true),
|
||||
title: normalizedConfig?.title ?? widget?.title ?? "",
|
||||
type: normalizedConfig?.type ?? widget?.type ?? "kpi",
|
||||
metricKey: normalizedConfig?.dataSource?.metricKey ?? "",
|
||||
stacked: Boolean(normalizedConfig?.encoding && "stacked" in normalizedConfig.encoding ? normalizedConfig.encoding.stacked : false),
|
||||
legend: Boolean(normalizedConfig?.options && "legend" in normalizedConfig.options ? normalizedConfig.options.legend : true),
|
||||
rangeOverride:
|
||||
typeof normalizedConfig?.dataSource?.params?.range === "string"
|
||||
? (normalizedConfig.dataSource?.params?.range as string)
|
||||
: "",
|
||||
showTooltip: Boolean(normalizedConfig?.options && "tooltip" in normalizedConfig.options ? normalizedConfig.options.tooltip : true),
|
||||
},
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (!widget) return
|
||||
const config = getWidgetConfigForWidget(widget)
|
||||
form.reset({
|
||||
title: widget.title ?? (widget.config as { title?: string })?.title ?? "",
|
||||
type: widget.type,
|
||||
metricKey: (widget.config as { dataSource?: { metricKey?: string } })?.dataSource?.metricKey ?? "",
|
||||
stacked: Boolean((widget.config as { encoding?: { stacked?: boolean } })?.encoding?.stacked ?? false),
|
||||
legend: Boolean((widget.config as { options?: { legend?: boolean } })?.options?.legend ?? true),
|
||||
title: config?.title ?? widget.title ?? "",
|
||||
type: config?.type ?? widget.type,
|
||||
metricKey: config?.dataSource?.metricKey ?? "",
|
||||
stacked: Boolean(config?.encoding && "stacked" in config.encoding ? config.encoding.stacked : false),
|
||||
legend: Boolean(config?.options && "legend" in config.options ? config.options.legend : true),
|
||||
rangeOverride:
|
||||
typeof (widget.config as { dataSource?: { params?: Record<string, unknown> } })?.dataSource?.params?.range === "string"
|
||||
? ((widget.config as { dataSource?: { params?: Record<string, unknown> } })?.dataSource?.params?.range as string)
|
||||
typeof config?.dataSource?.params?.range === "string"
|
||||
? (config.dataSource?.params?.range as string)
|
||||
: "",
|
||||
showTooltip: Boolean((widget.config as { options?: { tooltip?: boolean } })?.options?.tooltip ?? true),
|
||||
showTooltip: Boolean(config?.options && "tooltip" in config.options ? config.options.tooltip : true),
|
||||
})
|
||||
}, [widget, form])
|
||||
|
||||
|
|
@ -1249,19 +1260,19 @@ function WidgetConfigDialog({
|
|||
<SwitchField
|
||||
label="Legend"
|
||||
description="Mostra a legenda na visualização."
|
||||
checked={form.watch("legend")}
|
||||
checked={Boolean(form.watch("legend"))}
|
||||
onCheckedChange={(checked) => form.setValue("legend", checked)}
|
||||
/>
|
||||
<SwitchField
|
||||
label="Stacked"
|
||||
description="Acumula as séries no eixo Y."
|
||||
checked={form.watch("stacked")}
|
||||
checked={Boolean(form.watch("stacked"))}
|
||||
onCheckedChange={(checked) => form.setValue("stacked", checked)}
|
||||
/>
|
||||
<SwitchField
|
||||
label="Tooltip"
|
||||
description="Mantém o tooltip interativo."
|
||||
checked={form.watch("showTooltip")}
|
||||
checked={Boolean(form.watch("showTooltip"))}
|
||||
onCheckedChange={(checked) => form.setValue("showTooltip", checked)}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ export function WidgetRenderer({ widget, filters, mode = "edit", onReadyChange }
|
|||
const widgetType = (config.type ?? widget.type ?? "text").toLowerCase()
|
||||
const title = config.title ?? widget.title ?? "Widget"
|
||||
const description = config.description
|
||||
const mergedParams = useMemo(() => mergeFilterParams(config.dataSource?.params, filters), [config.dataSource?.params, filters])
|
||||
const mergedParams = mergeFilterParams(config.dataSource?.params, filters)
|
||||
const metric = useMetricData({
|
||||
metricKey: config.dataSource?.metricKey,
|
||||
params: mergedParams,
|
||||
|
|
@ -708,13 +708,7 @@ function renderGauge({
|
|||
outerRadius={110}
|
||||
data={[{ name: "SLA", value: display }]}
|
||||
>
|
||||
<RadialBar
|
||||
minAngle={15}
|
||||
background
|
||||
dataKey="value"
|
||||
cornerRadius={5}
|
||||
fill="var(--color-value)"
|
||||
/>
|
||||
<RadialBar background dataKey="value" cornerRadius={5} fill="var(--color-value)" />
|
||||
<RechartsTooltip
|
||||
cursor={false}
|
||||
content={<ChartTooltipContent hideLabel valueFormatter={(val) => percentFormatter.format(Number(val ?? 0))} />}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue