- Introduced RowActions component to manage row-level actions with tooltips and dropdown menus. - Created types for row actions and page actions to standardize action properties. - Implemented utility function to map action intents to Mantine theme colors. - Updated CoreAppShell component to support optional slots for better flexibility. - Added enterprise module structure with context hooks for managing module state and actions. - Implemented draft management for forms to enhance user experience during data entry. - Established context providers for detail, form, and index pages to streamline data handling. - Updated dependencies to ensure compatibility with the latest versions.
23 lines
824 B
TypeScript
23 lines
824 B
TypeScript
import { createContext, useContext } from 'react';
|
|
import type { BaseEntity } from '@repo/core-api/data-services';
|
|
|
|
export interface IndexPageContextValue<E extends BaseEntity = BaseEntity> {
|
|
renderRowActions: (row: E) => React.ReactNode;
|
|
refreshGrid: () => void;
|
|
// State for batch modals
|
|
isConfirmModalOpen: boolean;
|
|
setIsConfirmModalOpen: (open: boolean) => void;
|
|
isDeleteModalOpen: boolean;
|
|
setIsDeleteModalOpen: (open: boolean) => void;
|
|
}
|
|
|
|
export const IndexPageContext = createContext<IndexPageContextValue<any> | null>(null);
|
|
|
|
export function useIndexPageContext<E extends BaseEntity = BaseEntity>(): IndexPageContextValue<E> {
|
|
const context = useContext(IndexPageContext);
|
|
if (!context) {
|
|
throw new Error('useIndexPageContext must be used within an IndexPageProvider');
|
|
}
|
|
return context;
|
|
}
|