* Wip refactoring view * Post merge conflicts * Fix review * Add create view capability * Fix create object missing view * Fix tests
33 lines
814 B
TypeScript
33 lines
814 B
TypeScript
import { ReactNode } from 'react';
|
|
|
|
import { GraphQLView } from '@/views/types/GraphQLView';
|
|
|
|
import { ViewScopeInitEffect } from './init-effect/ViewScopeInitEffect';
|
|
import { ViewScopeInternalContext } from './scope-internal-context/ViewScopeInternalContext';
|
|
|
|
type ViewScopeProps = {
|
|
children: ReactNode;
|
|
viewScopeId: string;
|
|
onCurrentViewChange: (view: GraphQLView | undefined) => void | Promise<void>;
|
|
};
|
|
|
|
export const ViewScope = ({
|
|
children,
|
|
viewScopeId,
|
|
onCurrentViewChange,
|
|
}: ViewScopeProps) => {
|
|
return (
|
|
<ViewScopeInternalContext.Provider
|
|
value={{
|
|
scopeId: viewScopeId,
|
|
}}
|
|
>
|
|
<ViewScopeInitEffect
|
|
viewScopeId={viewScopeId}
|
|
onCurrentViewChange={onCurrentViewChange}
|
|
/>
|
|
{children}
|
|
</ViewScopeInternalContext.Provider>
|
|
);
|
|
};
|