Files
calendar/packages/features/insights/context/provider.ts
T
d180e14013 feat: insights orgs [CAL-1888] (#9551)
* initial commit

* fixes on data returned

* mobile style fixes

* Update on styles and dates not being shown on graphics

* feat: update insights filters UI (#9756)

* feat: update insights filters UI

Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>

* Fixes for filters with new UI

* fix initialConfig lost while clearing filters

* Add single user conditional for first render

---------

Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Alan <alannnc@gmail.com>

---------

Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Efraín Rochín <roae.85@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
2023-06-29 19:03:44 +02:00

43 lines
1.2 KiB
TypeScript

import * as React from "react";
import type { Dayjs } from "@calcom/dayjs";
interface IFilter {
dateRange: [Dayjs, Dayjs, null | string];
selectedTimeView?: "year" | "week" | "month";
selectedFilter?: Array<"user" | "event-type"> | null;
selectedTeamId?: number | null;
selectedTeamName?: string | null;
selectedUserId?: number | null;
selectedMemberUserId?: number | null;
selectedEventTypeId?: number | null;
isAll?: boolean;
initialConfig?: {
teamId?: number | null;
userId?: number | null;
isAll?: boolean;
};
}
export type FilterContextType = {
filter: IFilter;
clearFilters: () => void;
setConfigFilters: (config: Partial<IFilter>) => 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);
}