* init page * init insights frontend * nit * nit * nit * merge * fixed icons * i18n, needs features * Init insights trpc * Using trpc on client * Added events timeline * Seed analytics script * connect ui with trpc * Added and fixed event time lines * WIP popular days and avg time duration event type * added new metric graphs * improved upgrade tip * always show upgrade screen * upgrade tremor.so and select inputs for page * Remove log * Move everything to components and add context * Fix select types using calcom ui one * Adding translations * Add missing translations * Add more translations * min fix * Fixes for date select * Prefer early return and mobile design fixes * Fix style for mobile * Fix data with userId filter from popular events * add user id to average time duration * Removed submodules * Delete website * Update yarn.lock * Code organization and type fixes * trpc fixes * Builds are now passing * Relocates server code * Cleanup * Medium size screen fixes * Added TODO --------- Co-authored-by: Alan <alannnc@gmail.com> Co-authored-by: zomars <zomars@me.com>
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import * as React from "react";
|
|
|
|
import type { Dayjs } from "@calcom/dayjs";
|
|
|
|
export type FilterContextType = {
|
|
filter: {
|
|
dateRange: [Dayjs, Dayjs, null | string];
|
|
selectedTimeView: "year" | "week" | "month";
|
|
selectedFilter: Array<"user" | "event-type"> | null;
|
|
selectedTeamId: number | null;
|
|
selectedTeamName: string | null;
|
|
selectedUserId: number | null;
|
|
selectedEventTypeId: number | null;
|
|
};
|
|
setDateRange: ([start, end, range]: [Dayjs, Dayjs, null | string]) => void;
|
|
setSelectedFilter: (filter: Array<"user" | "event-type"> | null) => void;
|
|
setSelectedTeamId: (teamId: number | null) => void;
|
|
setSelectedTeamName: (teamName: string | null) => void;
|
|
setSelectedUserId: (userId: number | null) => void;
|
|
setSelectedEventTypeId: (eventTypeId: number | null) => void;
|
|
setSelectedTimeView: (timeView: "year" | "week" | "month") => void;
|
|
};
|
|
|
|
export const FilterContext = React.createContext<FilterContextType | null>(null);
|
|
|
|
export function useFilterContext() {
|
|
const context = React.useContext(FilterContext);
|
|
|
|
if (!context) {
|
|
throw new Error("useFilterContext must be used within a FilterProvider");
|
|
}
|
|
|
|
return context;
|
|
}
|
|
|
|
export function FilterProvider<F extends FilterContextType>(props: { value: F; children: React.ReactNode }) {
|
|
return React.createElement(FilterContext.Provider, { value: props.value }, props.children);
|
|
}
|