* chore: analytics endpoint * added anlytics v2 * updated status icons * added area chart in workitems and en translations * active projects * chore: created analytics chart * chore: validation errors * improved radar-chart , added empty states , added projects summary * chore: added a new graph in advance analytics * integrated priority chart * chore: added csv exporter * added priority dropdown * integrated created vs resolved chart * custom x and y axis label in bar and area chart * added wrapper styles to legends * added filter components * fixed temp data imports * integrated filters in priority charts * added label to priority chart and updated duration filter * refactor * reverted to void onchange * fixed some contant exports * fixed type issues * fixed some type and build issues * chore: updated the filtering logic for analytics * updated default value to last_30_days * percentage value whole number and added some rules for axis options * fixed some translations * added - custom tick for radar, calc of insight cards, filter labels * chore: opitmised the analytics endpoint * replace old analytics path with new , updated labels of insight card, done some store fixes * chore: updated the export request * Enhanced ProjectSelect to support multi-select, improved state management, and optimized data fetching and component structure. * fix: round completion percentage calculation in ActiveProjectItem * added empty states in project insights * Added loader and empty state in created/resolved chart * added loaders * added icons in filters * added custom colors in customised charts * cleaned up some code * added some responsiveness * updated translations * updated serrchbar for the table * added work item modal in project analytics * fixed some of the layput issues in the peek view * chore: updated the base function for viewsets * synced tab to url * code cleanup * chore: updated the export logic * fixed project_ids filter * added icon in projectdropdown * updated export button position * export csv and emptystates icons * refactor * code refactor * updated loaders, moved color pallete to contants, added nullish collasece operator in neccessary places * removed uneccessary cn * fixed formatting issues * fixed empty project_ids in payload * improved null checks * optimized charts * modified relevant variables to observable.ref * fixed the duration type * optimized some code * updated query key in project-insight * updated query key in project-insight * updated formatting * chore: replaced analytics route with new one and done some optimizations * removed the old analytics --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
58 lines
2.1 KiB
TypeScript
58 lines
2.1 KiB
TypeScript
// plane package imports
|
|
import { observer } from "mobx-react-lite";
|
|
import { useParams } from "next/navigation";
|
|
import useSWR from "swr";
|
|
import { insightsFields } from "@plane/constants";
|
|
import { useTranslation } from "@plane/i18n";
|
|
import { IAnalyticsResponseV2, TAnalyticsTabsV2Base } from "@plane/types";
|
|
//hooks
|
|
import { cn } from "@/helpers/common.helper";
|
|
import { useAnalyticsV2 } from "@/hooks/store/use-analytics-v2";
|
|
//services
|
|
import { AnalyticsV2Service } from "@/services/analytics-v2.service";
|
|
// plane web components
|
|
import InsightCard from "./insight-card";
|
|
|
|
const analyticsV2Service = new AnalyticsV2Service();
|
|
|
|
const TotalInsights: React.FC<{ analyticsType: TAnalyticsTabsV2Base; peekView?: boolean }> = observer(
|
|
({ analyticsType, peekView }) => {
|
|
const params = useParams();
|
|
const workspaceSlug = params.workspaceSlug as string;
|
|
const { t } = useTranslation();
|
|
const { selectedDuration, selectedProjects, selectedDurationLabel } = useAnalyticsV2();
|
|
|
|
const { data: totalInsightsData, isLoading } = useSWR(
|
|
`total-insights-${analyticsType}-${selectedDuration}-${selectedProjects}`,
|
|
() =>
|
|
analyticsV2Service.getAdvanceAnalytics<IAnalyticsResponseV2>(workspaceSlug, analyticsType, {
|
|
date_filter: selectedDuration,
|
|
...(selectedProjects?.length > 0 ? { project_ids: selectedProjects.join(",") } : {}),
|
|
})
|
|
);
|
|
return (
|
|
<div
|
|
className={cn(
|
|
"grid grid-cols-1 gap-8 sm:grid-cols-2 md:gap-10",
|
|
!peekView
|
|
? insightsFields[analyticsType].length % 5 === 0
|
|
? "gap-10 lg:grid-cols-5"
|
|
: "gap-8 lg:grid-cols-4"
|
|
: "grid-cols-2"
|
|
)}
|
|
>
|
|
{insightsFields[analyticsType]?.map((item: string) => (
|
|
<InsightCard
|
|
key={`${analyticsType}-${item}`}
|
|
isLoading={isLoading}
|
|
data={totalInsightsData?.[item]}
|
|
label={t(`workspace_analytics.${item}`)}
|
|
versus={selectedDurationLabel}
|
|
/>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|
|
);
|
|
|
|
export default TotalInsights;
|