diff --git a/apps/start/src/components/charts/chart-tooltip.tsx b/apps/start/src/components/charts/chart-tooltip.tsx index d79f3ac5..70e0a3c7 100644 --- a/apps/start/src/components/charts/chart-tooltip.tsx +++ b/apps/start/src/components/charts/chart-tooltip.tsx @@ -3,7 +3,7 @@ import { createContext, useContext as useBaseContext } from 'react'; import { Tooltip as RechartsTooltip, type TooltipProps } from 'recharts'; export function createChartTooltip< - PropsFromTooltip extends Record, + PropsFromTooltip, PropsFromContext extends Record, >( Tooltip: React.ComponentType< diff --git a/apps/start/src/components/feedback-button.tsx b/apps/start/src/components/feedback-button.tsx index 77652cc6..d7745261 100644 --- a/apps/start/src/components/feedback-button.tsx +++ b/apps/start/src/components/feedback-button.tsx @@ -8,7 +8,7 @@ export function FeedbackButton() { return ( + +
+ { + dispatch(changeChartType(type)); + }} + value={report.chartType} + /> + { + dispatch(changeDateRanges(value)); + }} + value={report.range} + onStartDateChange={(date) => dispatch(changeStartDate(date))} + onEndDateChange={(date) => dispatch(changeEndDate(date))} + endDate={report.endDate} + startDate={report.startDate} + /> + dispatch(changeInterval(newInterval))} + range={report.range} + chartType={report.chartType} + startDate={report.startDate} + endDate={report.endDate} + /> + +
+
+
- -
- { - dispatch(changeChartType(type)); - }} - value={report.chartType} - /> - { - dispatch(changeDateRanges(value)); - }} - value={report.range} - onStartDateChange={(date) => dispatch(changeStartDate(date))} - onEndDateChange={(date) => dispatch(changeEndDate(date))} - endDate={report.endDate} - startDate={report.startDate} - /> - dispatch(changeInterval(newInterval))} - range={report.range} - chartType={report.chartType} - startDate={report.startDate} - endDate={report.endDate} - /> -
-
- +
+ {report.ready && ( + + )}
-
- {report.ready && ( - - )} -
diff --git a/apps/start/src/components/report/ReportSaveButton.tsx b/apps/start/src/components/report/ReportSaveButton.tsx index fd8c7fd0..66a4865f 100644 --- a/apps/start/src/components/report/ReportSaveButton.tsx +++ b/apps/start/src/components/report/ReportSaveButton.tsx @@ -6,7 +6,11 @@ import { SaveIcon } from 'lucide-react'; import { toast } from 'sonner'; import { useTRPC } from '@/integrations/trpc/react'; -import { useIsFetching, useMutation } from '@tanstack/react-query'; +import { + useIsFetching, + useMutation, + useQueryClient, +} from '@tanstack/react-query'; import { useParams } from '@tanstack/react-router'; import { resetDirty } from './reportSlice'; @@ -22,13 +26,20 @@ export function ReportSaveButton({ className }: ReportSaveButtonProps) { ]; const { reportId } = useParams({ strict: false }); const dispatch = useDispatch(); + const queryClient = useQueryClient(); const update = useMutation( trpc.report.update.mutationOptions({ - onSuccess() { + onSuccess(res) { dispatch(resetDirty()); toast('Success', { description: 'Report updated.', }); + queryClient.invalidateQueries( + trpc.report.list.queryFilter({ + dashboardId: res.dashboardId, + projectId: res.projectId, + }), + ); }, onError: handleError, }), diff --git a/apps/start/src/components/report/edit-report-name.tsx b/apps/start/src/components/report/edit-report-name.tsx index df2d1853..14b310fb 100644 --- a/apps/start/src/components/report/edit-report-name.tsx +++ b/apps/start/src/components/report/edit-report-name.tsx @@ -1,31 +1,35 @@ +import { useDispatch, useSelector } from '@/redux'; import { PencilIcon } from 'lucide-react'; import { useEffect, useRef, useState } from 'react'; +import { Input } from '../ui/input'; +import { setName } from './reportSlice'; type Props = { name?: string; }; const EditReportName = ({ name }: Props) => { + const reportName = useSelector((state) => state.report.name); + const dispatch = useDispatch(); const [isEditing, setIsEditing] = useState(false); - const [newName, setNewName] = useState(name); + const [newName, setNewName] = useState(reportName); const inputRef = useRef(null); + useEffect(() => { + setNewName(reportName); + }, [reportName]); + const onSubmit = () => { if (newName === name) { return setIsEditing(false); } - if (newName === '') { - setNewName(name); + if (!newName) { + setNewName(reportName); } - window.dispatchEvent( - new CustomEvent('report-name-change', { - detail: newName === '' ? name : newName, - }), - ); - setIsEditing(false); + dispatch(setName(newName)); }; useEffect(() => { @@ -36,11 +40,10 @@ const EditReportName = ({ name }: Props) => { if (isEditing) { return ( -
- + { if (e.key === 'Enter') { @@ -59,11 +62,14 @@ const EditReportName = ({ name }: Props) => { return ( ); }; diff --git a/apps/start/src/components/sidebar-project-menu.tsx b/apps/start/src/components/sidebar-project-menu.tsx index da345616..80c5c8dd 100644 --- a/apps/start/src/components/sidebar-project-menu.tsx +++ b/apps/start/src/components/sidebar-project-menu.tsx @@ -117,7 +117,14 @@ export function ActionCTAButton() { useEffect(() => { const interval = setInterval(() => { - setCurrentActionIndex((prevIndex) => (prevIndex + 1) % ACTIONS.length); + setCurrentActionIndex((prevIndex) => { + const nextIndex = (prevIndex + 1) % ACTIONS.length; + if (nextIndex === 0 && prevIndex !== 0) { + clearInterval(interval); + return 0; + } + return nextIndex; + }); }, 2000); return () => clearInterval(interval); diff --git a/apps/start/src/components/sidebar.tsx b/apps/start/src/components/sidebar.tsx index ad6f3a36..e816acd4 100644 --- a/apps/start/src/components/sidebar.tsx +++ b/apps/start/src/components/sidebar.tsx @@ -111,7 +111,7 @@ export function SidebarContainer({ {active ? : }
-
+
@@ -120,7 +120,6 @@ export function SidebarContainer({ projects={projects} organizations={organizations} /> -
- +
+ + +
{isSelfHosted && (
Self-hosted instance diff --git a/apps/start/src/modals/add-reference.tsx b/apps/start/src/modals/add-reference.tsx index fce6d27a..4af13aab 100644 --- a/apps/start/src/modals/add-reference.tsx +++ b/apps/start/src/modals/add-reference.tsx @@ -18,7 +18,11 @@ import { ModalContent, ModalHeader } from './Modal/Container'; type IForm = z.infer; -export default function AddReference() { +interface AddReferenceProps { + datetime?: string; +} + +export default function AddReference({ datetime }: AddReferenceProps = {}) { const { projectId } = useAppParams(); const queryClient = useQueryClient(); const { register, handleSubmit, formState, control } = useForm({ @@ -27,7 +31,7 @@ export default function AddReference() { title: '', description: '', projectId, - datetime: new Date().toISOString(), + datetime: datetime || new Date().toISOString(), }, }); @@ -52,7 +56,7 @@ export default function AddReference() { className="flex flex-col gap-4" onSubmit={handleSubmit((values) => mutation.mutate(values))} > - + -

{text}

+

{text}

+ } />
{dashboards.map((item) => { diff --git a/apps/start/src/routes/_app.$organizationId.$projectId_.dashboards_.$dashboardId.tsx b/apps/start/src/routes/_app.$organizationId.$projectId_.dashboards_.$dashboardId.tsx index f53387af..64d51c37 100644 --- a/apps/start/src/routes/_app.$organizationId.$projectId_.dashboards_.$dashboardId.tsx +++ b/apps/start/src/routes/_app.$organizationId.$projectId_.dashboards_.$dashboardId.tsx @@ -460,63 +460,63 @@ function Component() { return ( -
- -
- - - - Create report - Report - - - - - - - - - showConfirm({ - title: 'Reset layout', - text: 'Are you sure you want to reset the layout to default? This will clear all custom positioning and sizing.', - onConfirm: () => - resetLayout.mutate({ dashboardId, projectId }), - }) - } - > - - Reset layout - - - showConfirm({ - title: 'Delete dashboard', - text: 'Are you sure you want to delete this dashboard? All your reports will be deleted!', - onConfirm: () => - dashboardDeletion.mutate({ id: dashboardId }), - }) - } - > - - Delete dashboard - - - - -
-
+ + + + + Create report + Report + + + + + + + + + showConfirm({ + title: 'Reset layout', + text: 'Are you sure you want to reset the layout to default? This will clear all custom positioning and sizing.', + onConfirm: () => + resetLayout.mutate({ dashboardId, projectId }), + }) + } + > + + Reset layout + + + showConfirm({ + title: 'Delete dashboard', + text: 'Are you sure you want to delete this dashboard? All your reports will be deleted!', + onConfirm: () => + dashboardDeletion.mutate({ id: dashboardId }), + }) + } + > + + Delete dashboard + + + + + + } + /> {reports.length === 0 ? (