Skip to content

Commit 07e4bf9

Browse files
committed
fix: zoom to range
1 parent a9d2e26 commit 07e4bf9

File tree

3 files changed

+619
-20
lines changed

3 files changed

+619
-20
lines changed

apps/dashboard/components/charts/edit-annotation-modal.tsx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ import {
3434
import { cn } from "@/lib/utils";
3535
import type { Annotation, AnnotationFormData } from "@/types/annotations";
3636

37-
interface EditAnnotationModalProps {
37+
type EditAnnotationModalProps = {
3838
isOpen: boolean;
3939
annotation: Annotation | null;
4040
onClose: () => void;
4141
onSave: (id: string, updates: AnnotationFormData) => Promise<void>;
4242
isSaving?: boolean;
43-
}
43+
};
4444

4545
export function EditAnnotationModal({
4646
isOpen,
@@ -88,7 +88,9 @@ export function EditAnnotationModal({
8888
};
8989

9090
const handleSave = async () => {
91-
if (!annotation) return;
91+
if (!annotation) {
92+
return;
93+
}
9294

9395
const formData: AnnotationFormData = {
9496
text: sanitizeAnnotationText(text),
@@ -124,7 +126,9 @@ export function EditAnnotationModal({
124126
return `${formatDate(startDate)} - ${formatDate(endDate)}`;
125127
};
126128

127-
if (!annotation) return null;
129+
if (!annotation) {
130+
return null;
131+
}
128132

129133
return (
130134
<Dialog onOpenChange={onClose} open={isOpen}>
@@ -220,19 +224,20 @@ export function EditAnnotationModal({
220224
{COMMON_ANNOTATION_TAGS.filter(
221225
(tag) => !selectedTags.includes(tag.value)
222226
).map((tag) => (
223-
<button
227+
<Button
224228
className="flex items-center gap-1 rounded-full border border-border bg-background px-3 py-1 text-xs transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50"
225229
disabled={isSaving}
226230
key={tag.value}
227231
onClick={() => addTag(tag.value)}
228232
style={{ borderColor: tag.color }}
233+
type="button"
229234
>
230235
<div
231236
className="h-2 w-2 rounded-full"
232237
style={{ backgroundColor: tag.color }}
233238
/>
234239
{tag.label}
235-
</button>
240+
</Button>
236241
))}
237242
</div>
238243
</div>
@@ -244,7 +249,7 @@ export function EditAnnotationModal({
244249
<Label className="font-medium">Annotation Color</Label>
245250
<div className="flex gap-2">
246251
{ANNOTATION_COLORS.map((color) => (
247-
<button
252+
<Button
248253
className={cn(
249254
"h-10 w-10 rounded-full border-2 transition-all hover:scale-110 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:scale-100",
250255
selectedColor === color.value
@@ -256,7 +261,14 @@ export function EditAnnotationModal({
256261
onClick={() => setSelectedColor(color.value)}
257262
style={{ backgroundColor: color.value }}
258263
title={color.label}
259-
/>
264+
type="button"
265+
>
266+
<div
267+
className="h-2 w-2 rounded-full"
268+
style={{ backgroundColor: color.value }}
269+
/>
270+
{color.label}
271+
</Button>
260272
))}
261273
</div>
262274
</div>

apps/dashboard/components/charts/metrics-chart-with-annotations.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ type MetricsChartWithAnnotationsProps = {
2323
title?: string;
2424
description?: string;
2525
className?: string;
26-
metricsFilterAction?: (metric: any) => boolean;
26+
metricsFilter?: (metric: any) => boolean;
2727
showLegend?: boolean;
28-
onRangeSelectAction?: (dateRange: { startDate: Date; endDate: Date }) => void;
28+
onRangeSelect?: (dateRange: { startDate: Date; endDate: Date }) => void;
2929
dateRange?: {
3030
startDate: Date;
3131
endDate: Date;
@@ -41,9 +41,9 @@ export function MetricsChartWithAnnotations({
4141
title,
4242
description,
4343
className,
44-
metricsFilterAction,
44+
metricsFilter,
4545
showLegend = true,
46-
onRangeSelectAction,
46+
onRangeSelect,
4747
dateRange,
4848
}: MetricsChartWithAnnotationsProps) {
4949
const [editingAnnotation, setEditingAnnotation] = useState<Annotation | null>(
@@ -85,7 +85,7 @@ export function MetricsChartWithAnnotations({
8585
input: {
8686
websiteId,
8787
chartType: "metrics" as const,
88-
chartContext: chartContext!,
88+
chartContext: chartContext as any,
8989
},
9090
}),
9191
enabled: !!websiteId && !!chartContext,
@@ -216,11 +216,11 @@ export function MetricsChartWithAnnotations({
216216
granularity={dateRange?.granularity}
217217
height={height}
218218
isLoading={isLoading}
219-
metricsFilterAction={metricsFilterAction}
219+
metricsFilter={metricsFilter}
220220
onCreateAnnotation={handleCreateAnnotation}
221221
onDeleteAnnotation={handleDeleteAnnotation}
222222
onEditAnnotation={handleEditAnnotation}
223-
onRangeSelectAction={onRangeSelectAction}
223+
onRangeSelect={onRangeSelect}
224224
onToggleAnnotations={setShowAnnotations}
225225
showAnnotations={showAnnotations}
226226
showLegend={showLegend}

0 commit comments

Comments
 (0)