Files
twenty_crm/front/src/modules/views/scopes/ViewScope.tsx
2023-10-31 12:12:52 +01:00

42 lines
1.1 KiB
TypeScript

import { ReactNode } from 'react';
import { Filter } from '@/ui/object/filter/types/Filter';
import { Sort } from '@/ui/object/sort/types/Sort';
import { ViewField } from '../types/ViewField';
import { ViewScopeInitEffect } from './init-effect/ViewScopeInitEffect';
import { ViewScopeInternalContext } from './scope-internal-context/ViewScopeInternalContext';
type ViewScopeProps = {
children: ReactNode;
viewScopeId: string;
onViewSortsChange?: (sorts: Sort[]) => void | Promise<void>;
onViewFiltersChange?: (filters: Filter[]) => void | Promise<void>;
onViewFieldsChange?: (fields: ViewField[]) => void | Promise<void>;
};
export const ViewScope = ({
children,
viewScopeId,
onViewSortsChange,
onViewFiltersChange,
onViewFieldsChange,
}: ViewScopeProps) => {
return (
<ViewScopeInternalContext.Provider
value={{
scopeId: viewScopeId,
}}
>
<ViewScopeInitEffect
viewScopeId={viewScopeId}
onViewSortsChange={onViewSortsChange}
onViewFiltersChange={onViewFiltersChange}
onViewFieldsChange={onViewFieldsChange}
/>
{children}
</ViewScopeInternalContext.Provider>
);
};