diff --git a/apps/dashboard/src/components/report/sidebar/ReportFormula.tsx b/apps/dashboard/src/components/report/sidebar/ReportFormula.tsx
index 8e181726..727b1b14 100644
--- a/apps/dashboard/src/components/report/sidebar/ReportFormula.tsx
+++ b/apps/dashboard/src/components/report/sidebar/ReportFormula.tsx
@@ -3,6 +3,10 @@
import { Input } from '@/components/ui/input';
import { useDispatch, useSelector } from '@/redux';
+import { Badge } from '@/components/ui/badge';
+import { AnimatePresence, motion } from 'framer-motion';
+import { RefreshCcwIcon } from 'lucide-react';
+import { type InputHTMLAttributes, useEffect, useState } from 'react';
import { changeFormula } from '../reportSlice';
export function ReportFormula() {
@@ -13,14 +17,65 @@ export function ReportFormula() {
);
}
+
+function InputFormula({
+ value,
+ onChangeValue,
+ ...props
+}: {
+ value: string | undefined;
+ onChangeValue: (value: string) => void;
+} & InputHTMLAttributes) {
+ const [internalValue, setInternalValue] = useState(value ?? '');
+
+ useEffect(() => {
+ if (value !== internalValue) {
+ setInternalValue(value ?? '');
+ }
+ }, [value]);
+
+ return (
+
+
setInternalValue(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter') {
+ onChangeValue(internalValue);
+ }
+ }}
+ size="default"
+ />
+
+
+ {internalValue !== value && (
+ onChangeValue(internalValue)}
+ >
+
+ Press enter
+
+
+
+ )}
+
+
+
+ );
+}
diff --git a/packages/trpc/src/routers/chart.helpers.ts b/packages/trpc/src/routers/chart.helpers.ts
index 5477f3dd..7afc7d7d 100644
--- a/packages/trpc/src/routers/chart.helpers.ts
+++ b/packages/trpc/src/routers/chart.helpers.ts
@@ -99,19 +99,20 @@ export function withFormula(
};
});
}
-
return [
{
...series[0],
data: series[0].data.map((item, dIndex) => {
- const scope = series.reduce((acc, item) => {
- if (!item.event.id) {
- return acc;
+ const scope = series.reduce((acc, item, index) => {
+ const readableId = alphabetIds[index];
+
+ if (!readableId) {
+ throw new Error('no alphabet id for serie in withFormula');
}
return {
...acc,
- [item.event.id]: item.data[dIndex]?.count ?? 0,
+ [readableId]: item.data[dIndex]?.count ?? 0,
};
}, {});