@jmruthers/pace-core 0.5.76 → 0.5.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/{RBACService-C4udt_Zp.d.ts → AuthService-Df3IozMG.d.ts} +10 -118
- package/dist/{DataTable-ntgmhO2W.d.ts → DataTable-BE0OXZKQ.d.ts} +9 -2
- package/dist/{DataTable-4GAVPIEG.js → DataTable-ETGVF4Y5.js} +50 -13
- package/dist/{PublicLoadingSpinner-BiNER8F5.d.ts → PublicLoadingSpinner-CnUaz0vG.d.ts} +5 -2
- package/dist/{UnifiedAuthProvider-Bj6YCf7c.d.ts → UnifiedAuthProvider-B391Aqum.d.ts} +42 -45
- package/dist/{UnifiedAuthProvider-3NKDOSOK.js → UnifiedAuthProvider-P5SOJAQ6.js} +4 -5
- package/dist/{api-DDMUKIUD.js → api-KG4A2X7P.js} +9 -3
- package/dist/{audit-6TOCAMKO.js → audit-65VNHEV2.js} +2 -2
- package/dist/{chunk-K34IM5CT.js → chunk-2OGV6IRV.js} +196 -626
- package/dist/chunk-2OGV6IRV.js.map +1 -0
- package/dist/{chunk-NTNILOBC.js → chunk-5BO3MI5Y.js} +4 -4
- package/dist/{chunk-XLZ7U46Z.js → chunk-CVMVPYAL.js} +9 -60
- package/dist/chunk-CVMVPYAL.js.map +1 -0
- package/dist/{chunk-URUTVZ7N.js → chunk-FL4ZCQLD.js} +2 -2
- package/dist/{chunk-LW7MMEAQ.js → chunk-FT2M4R4F.js} +2 -2
- package/dist/{chunk-5BSLGBYI.js → chunk-JCQZ6LA7.js} +2 -8
- package/dist/{chunk-5BSLGBYI.js.map → chunk-JCQZ6LA7.js.map} +1 -1
- package/dist/{chunk-KHJS6VIA.js → chunk-LRQ6RBJC.js} +157 -112
- package/dist/chunk-LRQ6RBJC.js.map +1 -0
- package/dist/{chunk-WN6XJWOS.js → chunk-MNJXXD6C.js} +274 -743
- package/dist/chunk-MNJXXD6C.js.map +1 -0
- package/dist/{chunk-KK73ZB4E.js → chunk-PTR5PMPE.js} +153 -132
- package/dist/chunk-PTR5PMPE.js.map +1 -0
- package/dist/{chunk-B2WTCLCV.js → chunk-Q7APDV6H.js} +18 -8
- package/dist/chunk-Q7APDV6H.js.map +1 -0
- package/dist/{chunk-A4FUBC7B.js → chunk-QGVSOUJ2.js} +2 -4
- package/dist/{chunk-A4FUBC7B.js.map → chunk-QGVSOUJ2.js.map} +1 -1
- package/dist/{chunk-FGMFQSHX.js → chunk-S63MFSY6.js} +500 -551
- package/dist/chunk-S63MFSY6.js.map +1 -0
- package/dist/{chunk-AFGTSUAD.js → chunk-VSOKOFRF.js} +4 -4
- package/dist/chunk-WUXCWRL6.js +20 -0
- package/dist/chunk-WUXCWRL6.js.map +1 -0
- package/dist/{chunk-Y6TXWPJO.js → chunk-YVVGHRGI.js} +105 -31
- package/dist/chunk-YVVGHRGI.js.map +1 -0
- package/dist/{chunk-M5IWZRBT.js → chunk-ZMNXIJP4.js} +2187 -981
- package/dist/chunk-ZMNXIJP4.js.map +1 -0
- package/dist/components.d.ts +6 -6
- package/dist/components.js +14 -18
- package/dist/components.js.map +1 -1
- package/dist/{database-C3Szpi5J.d.ts → database-BXAfr2Y_.d.ts} +18 -0
- package/dist/hooks.d.ts +5 -5
- package/dist/hooks.js +8 -9
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +19 -27
- package/dist/index.js +21 -29
- package/dist/index.js.map +1 -1
- package/dist/{organisation-BtshODVF.d.ts → organisation-D6qRDtbF.d.ts} +1 -1
- package/dist/providers.d.ts +7 -21
- package/dist/providers.js +3 -10
- package/dist/rbac/index.d.ts +71 -221
- package/dist/rbac/index.js +15 -16
- package/dist/{types-CGX9Vyf5.d.ts → types-BDg1mAGG.d.ts} +36 -6
- package/dist/types.d.ts +3 -3
- package/dist/types.js +61 -18
- package/dist/types.js.map +1 -1
- package/dist/{unified-CM7T0aTK.d.ts → unified-DQ4VcT7H.d.ts} +1 -1
- package/dist/{usePublicRouteParams-B-CumWRc.d.ts → usePublicRouteParams-BlgwXweB.d.ts} +3 -3
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +52 -9
- package/dist/utils.js.map +1 -1
- package/docs/CONTENT_AUDIT_REPORT.md +253 -0
- package/docs/DOCUMENTATION_AUDIT.md +172 -0
- package/docs/README.md +142 -147
- package/docs/STYLE_GUIDE.md +37 -0
- package/docs/api/classes/ColumnFactory.md +17 -17
- package/docs/api/classes/ErrorBoundary.md +1 -1
- package/docs/api/classes/InvalidScopeError.md +4 -4
- package/docs/api/classes/MissingUserContextError.md +4 -4
- package/docs/api/classes/OrganisationContextRequiredError.md +4 -4
- package/docs/api/classes/PermissionDeniedError.md +5 -5
- package/docs/api/classes/PublicErrorBoundary.md +1 -1
- package/docs/api/classes/RBACAuditManager.md +8 -8
- package/docs/api/classes/RBACCache.md +35 -5
- package/docs/api/classes/RBACEngine.md +49 -20
- package/docs/api/classes/RBACError.md +4 -4
- package/docs/api/classes/RBACNotInitializedError.md +4 -4
- package/docs/api/classes/SecureSupabaseClient.md +1 -1
- package/docs/api/classes/StorageUtils.md +1 -1
- package/docs/api/enums/FileCategory.md +1 -1
- package/docs/api/interfaces/AggregateConfig.md +4 -4
- package/docs/api/interfaces/ButtonProps.md +1 -1
- package/docs/api/interfaces/CardProps.md +1 -1
- package/docs/api/interfaces/ColorPalette.md +1 -1
- package/docs/api/interfaces/ColorShade.md +1 -1
- package/docs/api/interfaces/DataAccessRecord.md +1 -1
- package/docs/api/interfaces/DataRecord.md +11 -0
- package/docs/api/interfaces/DataTableAction.md +65 -29
- package/docs/api/interfaces/DataTableColumn.md +36 -23
- package/docs/api/interfaces/DataTableProps.md +80 -38
- package/docs/api/interfaces/DataTableToolbarButton.md +7 -7
- package/docs/api/interfaces/EmptyStateConfig.md +5 -5
- package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
- package/docs/api/interfaces/EventLogoProps.md +1 -1
- package/docs/api/interfaces/FileDisplayProps.md +1 -1
- package/docs/api/interfaces/FileMetadata.md +1 -1
- package/docs/api/interfaces/FileReference.md +1 -1
- package/docs/api/interfaces/FileSizeLimits.md +1 -1
- package/docs/api/interfaces/FileUploadOptions.md +1 -1
- package/docs/api/interfaces/FileUploadProps.md +1 -1
- package/docs/api/interfaces/FooterProps.md +1 -1
- package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
- package/docs/api/interfaces/InputProps.md +1 -1
- package/docs/api/interfaces/LabelProps.md +1 -1
- package/docs/api/interfaces/LoginFormProps.md +1 -1
- package/docs/api/interfaces/NavigationAccessRecord.md +11 -11
- package/docs/api/interfaces/NavigationContextType.md +9 -9
- package/docs/api/interfaces/NavigationGuardProps.md +1 -1
- package/docs/api/interfaces/NavigationItem.md +1 -1
- package/docs/api/interfaces/NavigationMenuProps.md +1 -1
- package/docs/api/interfaces/NavigationProviderProps.md +7 -7
- package/docs/api/interfaces/Organisation.md +1 -1
- package/docs/api/interfaces/OrganisationContextType.md +1 -1
- package/docs/api/interfaces/OrganisationMembership.md +1 -1
- package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
- package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
- package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
- package/docs/api/interfaces/PaceLoginPageProps.md +16 -3
- package/docs/api/interfaces/PageAccessRecord.md +1 -1
- package/docs/api/interfaces/PagePermissionContextType.md +1 -1
- package/docs/api/interfaces/PagePermissionGuardProps.md +2 -2
- package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
- package/docs/api/interfaces/PaletteData.md +1 -1
- package/docs/api/interfaces/PermissionEnforcerProps.md +4 -4
- package/docs/api/interfaces/PublicErrorBoundaryProps.md +1 -1
- package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
- package/docs/api/interfaces/PublicLoadingSpinnerProps.md +1 -1
- package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
- package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
- package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
- package/docs/api/interfaces/RBACConfig.md +1 -1
- package/docs/api/interfaces/RBACLogger.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
- package/docs/api/interfaces/RouteAccessRecord.md +2 -2
- package/docs/api/interfaces/RouteConfig.md +2 -2
- package/docs/api/interfaces/SecureDataContextType.md +1 -1
- package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
- package/docs/api/interfaces/StorageConfig.md +1 -1
- package/docs/api/interfaces/StorageFileInfo.md +1 -1
- package/docs/api/interfaces/StorageFileMetadata.md +1 -1
- package/docs/api/interfaces/StorageListOptions.md +1 -1
- package/docs/api/interfaces/StorageListResult.md +1 -1
- package/docs/api/interfaces/StorageUploadOptions.md +1 -1
- package/docs/api/interfaces/StorageUploadResult.md +1 -1
- package/docs/api/interfaces/StorageUrlOptions.md +1 -1
- package/docs/api/interfaces/StyleImport.md +1 -1
- package/docs/api/interfaces/SwitchProps.md +1 -1
- package/docs/api/interfaces/ToastActionElement.md +1 -1
- package/docs/api/interfaces/ToastProps.md +1 -1
- package/docs/api/interfaces/UnifiedAuthContextType.md +94 -521
- package/docs/api/interfaces/UnifiedAuthProviderProps.md +16 -16
- package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
- package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventLogoOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventLogoReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
- package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeOptions.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeReturn.md +1 -1
- package/docs/api/interfaces/UserEventAccess.md +11 -11
- package/docs/api/interfaces/UserMenuProps.md +1 -1
- package/docs/api/interfaces/UserProfile.md +1 -1
- package/docs/api/modules.md +251 -269
- package/docs/api-reference/components.md +193 -0
- package/docs/api-reference/hooks.md +265 -0
- package/docs/api-reference/providers.md +6 -0
- package/docs/api-reference/types.md +6 -0
- package/docs/api-reference/utilities.md +207 -0
- package/docs/architecture/README.md +6 -0
- package/docs/{database-schema-requirements.md → architecture/database-schema-requirements.md} +6 -0
- package/docs/architecture/rbac-security-architecture.md +258 -0
- package/docs/architecture/services.md +9 -1
- package/docs/best-practices/README.md +6 -0
- package/docs/best-practices/accessibility.md +6 -0
- package/docs/{common-patterns.md → best-practices/common-patterns.md} +6 -0
- package/docs/best-practices/deployment.md +6 -0
- package/docs/best-practices/performance.md +475 -2
- package/docs/best-practices/security.md +6 -0
- package/docs/best-practices/testing.md +6 -0
- package/docs/core-concepts/authentication.md +6 -0
- package/docs/core-concepts/events.md +6 -0
- package/docs/core-concepts/organisations.md +6 -0
- package/docs/core-concepts/permissions.md +6 -0
- package/docs/core-concepts/rbac-system.md +8 -0
- package/docs/documentation-index.md +121 -182
- package/docs/{consuming-app-vite-config.md → getting-started/consuming-app-vite-config.md} +6 -0
- package/docs/getting-started/documentation-index.md +40 -0
- package/docs/getting-started/examples/README.md +878 -35
- package/docs/{faq.md → getting-started/faq.md} +7 -1
- package/docs/getting-started/installation-guide.md +6 -0
- package/docs/{quick-reference.md → getting-started/quick-reference.md} +6 -0
- package/docs/implementation-guides/app-layout.md +6 -0
- package/docs/implementation-guides/authentication.md +1021 -0
- package/docs/implementation-guides/component-styling.md +6 -0
- package/docs/implementation-guides/data-tables.md +1264 -2076
- package/docs/implementation-guides/dynamic-colors.md +6 -0
- package/docs/implementation-guides/event-theming-summary.md +6 -0
- package/docs/{file-reference-system.md → implementation-guides/file-reference-system.md} +6 -0
- package/docs/implementation-guides/file-upload-storage.md +6 -0
- package/docs/implementation-guides/forms.md +6 -0
- package/docs/implementation-guides/inactivity-tracking.md +6 -0
- package/docs/implementation-guides/navigation.md +6 -0
- package/docs/implementation-guides/organisation-security.md +6 -0
- package/docs/implementation-guides/permission-enforcement.md +6 -0
- package/docs/implementation-guides/public-pages-advanced.md +6 -0
- package/docs/implementation-guides/public-pages.md +6 -0
- package/docs/migration/MIGRATION_GUIDE.md +827 -351
- package/docs/migration/README.md +7 -1
- package/docs/migration/organisation-context-timing-fix.md +6 -0
- package/docs/migration/rbac-migration.md +44 -1
- package/docs/migration/service-architecture.md +6 -0
- package/docs/migration/v0.4.15-tailwind-scanning.md +6 -0
- package/docs/migration/v0.4.16-css-first-approach.md +6 -0
- package/docs/migration/v0.4.17-source-path-fix.md +6 -0
- package/docs/rbac/README-rbac-rls-integration.md +6 -0
- package/docs/rbac/README.md +6 -0
- package/docs/rbac/advanced-patterns.md +6 -0
- package/docs/rbac/api-reference.md +7 -1
- package/docs/rbac/breaking-changes-v3.md +222 -0
- package/docs/rbac/examples/rbac-rls-integration-example.md +6 -0
- package/docs/rbac/examples.md +6 -0
- package/docs/rbac/getting-started.md +6 -0
- package/docs/rbac/migration-guide.md +260 -0
- package/docs/rbac/quick-start.md +70 -13
- package/docs/rbac/rbac-rls-integration.md +6 -0
- package/docs/rbac/super-admin-guide.md +6 -0
- package/docs/rbac/troubleshooting.md +6 -0
- package/docs/security/README.md +6 -0
- package/docs/security/checklist.md +6 -0
- package/docs/styles/README.md +7 -1
- package/docs/{usage.md → styles/usage.md} +6 -0
- package/docs/testing/README.md +6 -0
- package/docs/{visual-testing.md → testing/visual-testing.md} +6 -0
- package/docs/troubleshooting/README.md +387 -5
- package/docs/troubleshooting/cake-page-permission-guard-issue-summary.md +6 -0
- package/docs/troubleshooting/common-issues.md +6 -0
- package/docs/troubleshooting/database-view-compatibility.md +6 -0
- package/docs/troubleshooting/organisation-context-setup.md +6 -0
- package/docs/troubleshooting/react-hooks-issue-analysis.md +6 -0
- package/docs/troubleshooting/styling-issues.md +6 -0
- package/docs/troubleshooting/tailwind-content-scanning.md +6 -0
- package/package.json +1 -1
- package/src/__tests__/helpers/__tests__/test-providers.test.tsx +2 -1
- package/src/__tests__/helpers/test-providers.tsx +3 -53
- package/src/components/DataTable/DataTable.test.tsx +319 -0
- package/src/components/DataTable/DataTable.tsx +32 -11
- package/src/components/DataTable/__tests__/{DataTable.comprehensive.test.tsx → DataTable.comprehensive.test.tsx.skip} +6 -4
- package/src/components/DataTable/__tests__/{DataTable.test.tsx → DataTable.test.tsx.skip} +6 -4
- package/src/components/DataTable/__tests__/DataTableCore.test.tsx +31 -9
- package/src/components/DataTable/__tests__/a11y.basic.test.tsx +601 -0
- package/src/components/DataTable/__tests__/keyboard.test.tsx +615 -0
- package/src/components/DataTable/__tests__/pagination.modes.test.tsx +639 -0
- package/src/components/DataTable/__tests__/ssr.strict-mode.test.tsx.skip +330 -0
- package/src/components/DataTable/components/AccessDeniedPage.tsx +2 -2
- package/src/components/DataTable/components/ActionButtons.tsx +88 -104
- package/src/components/DataTable/components/DataTableCore.tsx +309 -337
- package/src/components/DataTable/components/DataTableErrorBoundary.tsx +4 -2
- package/src/components/DataTable/components/DataTableModals.tsx +22 -1
- package/src/components/DataTable/components/EditableRow.tsx +69 -84
- package/src/components/DataTable/components/EmptyState.tsx +5 -1
- package/src/components/DataTable/components/ImportModal.tsx +65 -36
- package/src/components/DataTable/components/PaginationControls.tsx +40 -100
- package/src/components/DataTable/components/UnifiedTableBody.tsx +125 -148
- package/src/components/DataTable/context/DataTableContext.tsx +1 -1
- package/src/components/DataTable/core/ColumnFactory.ts +5 -0
- package/src/components/DataTable/examples/HierarchicalActionsExample.tsx +12 -10
- package/src/components/DataTable/examples/HierarchicalExample.tsx +1 -1
- package/src/components/DataTable/examples/InitialPageSizeExample.tsx +1 -0
- package/src/components/DataTable/examples/PerformanceExample.tsx +1 -0
- package/src/components/DataTable/hooks/__tests__/useColumnOrderPersistence.test.ts +1 -5
- package/src/components/DataTable/hooks/__tests__/useColumnVisibilityPersistence.test.ts +167 -0
- package/src/components/DataTable/hooks/index.ts +7 -0
- package/src/components/DataTable/hooks/useColumnOrderPersistence.ts +32 -15
- package/src/components/DataTable/hooks/useColumnVisibilityPersistence.ts +102 -0
- package/src/components/DataTable/hooks/useDataTableConfiguration.ts +89 -0
- package/src/components/DataTable/hooks/useDataTableDataPipeline.ts +117 -0
- package/src/components/DataTable/hooks/useDataTablePermissions.ts +71 -27
- package/src/components/DataTable/hooks/useDataTableState.ts +39 -11
- package/src/components/DataTable/hooks/useEffectiveColumnOrder.ts +33 -0
- package/src/components/DataTable/hooks/useHierarchicalState.ts +15 -1
- package/src/components/DataTable/hooks/useKeyboardNavigation.ts +447 -0
- package/src/components/DataTable/hooks/useServerSideDataEffect.ts +94 -0
- package/src/components/DataTable/hooks/useTableColumns.ts +10 -7
- package/src/components/DataTable/hooks/useTableHandlers.ts +174 -0
- package/src/components/DataTable/index.ts +12 -3
- package/src/components/DataTable/types.ts +129 -9
- package/src/components/DataTable/utils/__tests__/exportUtils.test.ts +159 -22
- package/src/components/DataTable/utils/__tests__/flexibleImport.test.ts +111 -0
- package/src/components/DataTable/utils/__tests__/rowUtils.test.ts +15 -29
- package/src/components/DataTable/utils/a11yUtils.ts +244 -0
- package/src/components/DataTable/utils/debugTools.ts +609 -0
- package/src/components/DataTable/utils/exportUtils.ts +114 -16
- package/src/components/DataTable/utils/flexibleImport.ts +202 -32
- package/src/components/DataTable/utils/hierarchicalUtils.ts +1 -1
- package/src/components/DataTable/utils/index.ts +2 -0
- package/src/components/DataTable/utils/paginationUtils.ts +350 -0
- package/src/components/DataTable/utils/rowUtils.ts +6 -5
- package/src/components/NavigationMenu/NavigationMenu.test.tsx +19 -24
- package/src/components/NavigationMenu/NavigationMenu.tsx +19 -8
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.security.test.tsx +1 -23
- package/src/components/PaceLoginPage/PaceLoginPage.test.tsx +56 -6
- package/src/components/PaceLoginPage/PaceLoginPage.tsx +137 -13
- package/src/components/PublicLayout/__tests__/PublicPageHeader.test.tsx +1 -1
- package/src/components/Select/Select.tsx +1 -0
- package/src/components/examples/PermissionExample.tsx +173 -0
- package/src/examples/CorrectPublicPageImplementation.tsx +301 -0
- package/src/examples/PublicEventPage.tsx +274 -0
- package/src/examples/PublicPageApp.tsx +308 -0
- package/src/examples/PublicPageUsageExample.tsx +216 -0
- package/src/hooks/__tests__/useOrganisationPermissions.unit.test.tsx +12 -1
- package/src/hooks/__tests__/useOrganisationSecurity.unit.test.tsx +129 -17
- package/src/hooks/__tests__/useRBAC.unit.test.ts +151 -846
- package/src/hooks/useOrganisationPermissions.test.ts +42 -18
- package/src/hooks/useOrganisationPermissions.ts +12 -6
- package/src/hooks/useOrganisationSecurity.test.ts +138 -85
- package/src/hooks/useOrganisationSecurity.ts +41 -10
- package/src/index.ts +0 -1
- package/src/providers/AuthProvider.simplified.tsx +880 -0
- package/src/providers/UnifiedAuthProvider.test.simple.tsx +8 -8
- package/src/providers/__tests__/UnifiedAuthProvider.test.tsx +29 -19
- package/src/providers/index.ts +0 -1
- package/src/providers/services/EventServiceProvider.tsx +19 -15
- package/src/providers/services/InactivityServiceProvider.tsx +19 -15
- package/src/providers/services/OrganisationServiceProvider.tsx +19 -15
- package/src/providers/services/UnifiedAuthProvider.tsx +156 -127
- package/src/providers/services/__tests__/AuthServiceProvider.integration.test.tsx +1 -1
- package/src/providers/services/__tests__/UnifiedAuthProvider.integration.test.tsx +3 -3
- package/src/rbac/README.md +1 -1
- package/src/rbac/__tests__/adapters.comprehensive.test.tsx +25 -27
- package/src/rbac/__tests__/auth-rbac-security.integration.test.tsx +313 -0
- package/src/rbac/__tests__/engine.comprehensive.test.ts +114 -348
- package/src/rbac/__tests__/rbac-engine-core-logic.test.ts +28 -110
- package/src/rbac/__tests__/rbac-engine-simplified.test.ts +33 -85
- package/src/rbac/__tests__/scenarios.user-role.test.tsx +2 -2
- package/src/rbac/adapters.tsx +26 -69
- package/src/rbac/api.test.ts +90 -27
- package/src/rbac/api.ts +61 -10
- package/src/rbac/audit.test.ts +33 -38
- package/src/rbac/audit.ts +21 -6
- package/src/rbac/cache.ts +33 -1
- package/src/rbac/components/NavigationGuard.tsx +11 -11
- package/src/rbac/components/NavigationProvider.test.tsx +11 -5
- package/src/rbac/components/NavigationProvider.tsx +37 -13
- package/src/rbac/components/PagePermissionGuard.tsx +111 -50
- package/src/rbac/components/PagePermissionProvider.tsx +5 -5
- package/src/rbac/components/PermissionEnforcer.tsx +11 -11
- package/src/rbac/components/RoleBasedRouter.tsx +5 -5
- package/src/rbac/components/SecureDataProvider.tsx +5 -5
- package/src/rbac/components/__tests__/NavigationGuard.test.tsx +8 -8
- package/src/rbac/components/__tests__/PagePermissionGuard.test.tsx +14 -14
- package/src/rbac/components/__tests__/PermissionEnforcer.test.tsx +12 -12
- package/src/rbac/components/__tests__/RoleBasedRouter.test.tsx +6 -6
- package/src/rbac/engine.test.simple.ts +19 -13
- package/src/rbac/engine.test.ts +1 -0
- package/src/rbac/engine.ts +330 -766
- package/src/rbac/errors.ts +156 -0
- package/src/rbac/hooks/usePermissions.ts +32 -10
- package/src/rbac/hooks/useRBAC.test.ts +126 -512
- package/src/rbac/hooks/useRBAC.ts +147 -193
- package/src/rbac/hooks/useResolvedScope.ts +12 -0
- package/src/rbac/index.ts +7 -4
- package/src/rbac/security.ts +109 -18
- package/src/rbac/types.ts +12 -1
- package/src/services/AuthService.ts +2 -15
- package/src/services/EventService.ts +43 -46
- package/src/services/OrganisationService.ts +51 -31
- package/src/services/__tests__/AuthService.test.ts +1 -1
- package/src/services/__tests__/EventService.test.ts +1 -1
- package/src/services/__tests__/OrganisationService.test.ts +1 -1
- package/src/services/base/BaseService.ts +8 -0
- package/src/styles/base.css +208 -0
- package/src/styles/semantic.css +24 -0
- package/src/types/database.generated.ts +7347 -0
- package/src/types/database.ts +20 -0
- package/src/utils/logger.ts +179 -0
- package/src/utils/organisationContext.ts +11 -4
- package/src/utils/storage/__tests__/helpers.unit.test.ts +6 -2
- package/dist/appNameResolver-UURKN7NF.js +0 -22
- package/dist/audit-6TOCAMKO.js.map +0 -1
- package/dist/chunk-B2WTCLCV.js.map +0 -1
- package/dist/chunk-FGMFQSHX.js.map +0 -1
- package/dist/chunk-K34IM5CT.js.map +0 -1
- package/dist/chunk-KHJS6VIA.js.map +0 -1
- package/dist/chunk-KK73ZB4E.js.map +0 -1
- package/dist/chunk-M5IWZRBT.js.map +0 -1
- package/dist/chunk-ULBI5JGB.js +0 -109
- package/dist/chunk-ULBI5JGB.js.map +0 -1
- package/dist/chunk-WN6XJWOS.js.map +0 -1
- package/dist/chunk-XLZ7U46Z.js.map +0 -1
- package/dist/chunk-Y6TXWPJO.js.map +0 -1
- package/docs/DOCUMENTATION_CHECKLIST.md +0 -281
- package/docs/TERMINOLOGY.md +0 -231
- package/docs/api/interfaces/RBACContextType.md +0 -468
- package/docs/api/interfaces/RBACProviderProps.md +0 -107
- package/docs/best-practices/performance-expansion.md +0 -473
- package/docs/breaking-changes.md +0 -179
- package/docs/consuming-app-example.md +0 -290
- package/docs/documentation-templates.md +0 -539
- package/docs/examples/navigation-menu-auth-fix.md +0 -344
- package/docs/getting-started/examples/basic-auth-app.md +0 -520
- package/docs/getting-started/examples/full-featured-app.md +0 -616
- package/docs/getting-started/quick-start.md +0 -376
- package/docs/implementation-guides/datatable-filtering.md +0 -313
- package/docs/implementation-guides/datatable-rbac-usage.md +0 -317
- package/docs/implementation-guides/hierarchical-datatable.md +0 -850
- package/docs/implementation-guides/large-datasets.md +0 -281
- package/docs/implementation-guides/performance.md +0 -403
- package/docs/migration/quick-migration-guide.md +0 -320
- package/docs/migration-guide.md +0 -193
- package/docs/migration-guides/unified-auth-provider-mandatory-timeouts.md +0 -226
- package/docs/performance/README.md +0 -551
- package/docs/style-guide.md +0 -964
- package/docs/troubleshooting/authentication-issues.md +0 -334
- package/docs/troubleshooting/debugging.md +0 -1117
- package/docs/troubleshooting/migration.md +0 -918
- package/src/__tests__/hooks/usePermissions.test.ts +0 -261
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.rbac.test.tsx +0 -574
- package/src/hooks/__tests__/ServiceHooks.test.tsx +0 -613
- package/src/hooks/services/__tests__/useServiceHooks.test.tsx +0 -137
- package/src/hooks/services/usePermissions.ts +0 -70
- package/src/hooks/services/useRBACService.ts +0 -30
- package/src/hooks/usePermissionCheck.ts +0 -150
- package/src/providers/__tests__/ServiceProviders.test.tsx +0 -477
- package/src/providers/services/RBACServiceProvider.tsx +0 -79
- package/src/rbac/__tests__/integration.authflow.test.tsx +0 -119
- package/src/rbac/__tests__/integration.navigation.test.tsx +0 -69
- package/src/rbac/__tests__/integration.securedata.test.tsx +0 -92
- package/src/rbac/__tests__/integration.smoke.test.tsx +0 -73
- package/src/rbac/providers/RBACProvider.tsx +0 -645
- package/src/rbac/providers/__tests__/RBACProvider.integration.test.tsx +0 -688
- package/src/rbac/providers/__tests__/RBACProvider.test.tsx +0 -1186
- package/src/rbac/providers/index.ts +0 -11
- package/src/services/RBACService.ts +0 -522
- package/src/services/__tests__/RBACService.test.ts +0 -492
- package/src/services/interfaces/IRBACService.ts +0 -62
- package/src/utils/appNameResolver.test 2.ts +0 -494
- /package/dist/{DataTable-4GAVPIEG.js.map → DataTable-ETGVF4Y5.js.map} +0 -0
- /package/dist/{UnifiedAuthProvider-3NKDOSOK.js.map → UnifiedAuthProvider-P5SOJAQ6.js.map} +0 -0
- /package/dist/{api-DDMUKIUD.js.map → api-KG4A2X7P.js.map} +0 -0
- /package/dist/{appNameResolver-UURKN7NF.js.map → audit-65VNHEV2.js.map} +0 -0
- /package/dist/{chunk-NTNILOBC.js.map → chunk-5BO3MI5Y.js.map} +0 -0
- /package/dist/{chunk-URUTVZ7N.js.map → chunk-FL4ZCQLD.js.map} +0 -0
- /package/dist/{chunk-LW7MMEAQ.js.map → chunk-FT2M4R4F.js.map} +0 -0
- /package/dist/{chunk-AFGTSUAD.js.map → chunk-VSOKOFRF.js.map} +0 -0
- /package/docs/{app.css.example → styles/app.css.example} +0 -0
|
@@ -1,616 +0,0 @@
|
|
|
1
|
-
# Full-Featured Application
|
|
2
|
-
|
|
3
|
-
A complete meal management application demonstrating all PACE Core features including authentication, RBAC, data tables, forms, and permission enforcement.
|
|
4
|
-
|
|
5
|
-
## 🎯 What This Example Shows
|
|
6
|
-
|
|
7
|
-
- Complete authentication flow with RBAC
|
|
8
|
-
- Multi-tenant organisation support
|
|
9
|
-
- Event management and selection
|
|
10
|
-
- Advanced DataTable with CRUD operations
|
|
11
|
-
- Form validation and error handling
|
|
12
|
-
- Permission enforcement at page and component level
|
|
13
|
-
- Responsive layout with navigation
|
|
14
|
-
- Production-ready patterns
|
|
15
|
-
|
|
16
|
-
## 📁 Project Structure
|
|
17
|
-
|
|
18
|
-
```
|
|
19
|
-
src/
|
|
20
|
-
├── App.tsx # Main app with all providers
|
|
21
|
-
├── lib/
|
|
22
|
-
│ └── supabase.ts # Supabase client
|
|
23
|
-
├── components/
|
|
24
|
-
│ ├── auth/
|
|
25
|
-
│ │ ├── LoginPage.tsx # Login form
|
|
26
|
-
│ │ └── ProtectedRoute.tsx # Route protection
|
|
27
|
-
│ ├── layout/
|
|
28
|
-
│ │ ├── AppLayout.tsx # Main layout
|
|
29
|
-
│ │ └── Navigation.tsx # Navigation menu
|
|
30
|
-
│ ├── dashboard/
|
|
31
|
-
│ │ └── DashboardPage.tsx # Dashboard with metrics
|
|
32
|
-
│ ├── meals/
|
|
33
|
-
│ │ ├── MealsPage.tsx # Meals list with DataTable
|
|
34
|
-
│ │ ├── MealForm.tsx # Add/edit meal form
|
|
35
|
-
│ │ └── MealModal.tsx # Modal for meal operations
|
|
36
|
-
│ ├── users/
|
|
37
|
-
│ │ ├── UsersPage.tsx # User management
|
|
38
|
-
│ │ └── UserForm.tsx # User creation/editing
|
|
39
|
-
│ └── shared/
|
|
40
|
-
│ ├── LoadingSpinner.tsx # Loading states
|
|
41
|
-
│ └── ErrorBoundary.tsx # Error handling
|
|
42
|
-
├── hooks/
|
|
43
|
-
│ ├── useMeals.ts # Meals data management
|
|
44
|
-
│ └── useUsers.ts # Users data management
|
|
45
|
-
├── types/
|
|
46
|
-
│ ├── meal.ts # Meal type definitions
|
|
47
|
-
│ └── user.ts # User type definitions
|
|
48
|
-
└── utils/
|
|
49
|
-
├── permissions.ts # Permission checking
|
|
50
|
-
└── validation.ts # Form validation schemas
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## 🚀 Implementation
|
|
54
|
-
|
|
55
|
-
### 1. App.tsx - Complete Application Setup
|
|
56
|
-
|
|
57
|
-
```tsx
|
|
58
|
-
import {
|
|
59
|
-
UnifiedAuthProvider,
|
|
60
|
-
OrganisationProvider,
|
|
61
|
-
EventProvider,
|
|
62
|
-
ErrorBoundary
|
|
63
|
-
} from '@jmruthers/pace-core';
|
|
64
|
-
import { BrowserRouter } from 'react-router-dom';
|
|
65
|
-
import { supabase } from './lib/supabase';
|
|
66
|
-
import { AppRoutes } from './components/AppRoutes';
|
|
67
|
-
|
|
68
|
-
function App() {
|
|
69
|
-
return (
|
|
70
|
-
<ErrorBoundary>
|
|
71
|
-
<UnifiedAuthProvider
|
|
72
|
-
supabaseClient={supabase}
|
|
73
|
-
appName="meal-manager"
|
|
74
|
-
enableRBAC={true}
|
|
75
|
-
requireOrganisationContext={true}
|
|
76
|
-
persistState={true}
|
|
77
|
-
>
|
|
78
|
-
<OrganisationProvider>
|
|
79
|
-
<EventProvider>
|
|
80
|
-
<BrowserRouter>
|
|
81
|
-
<AppRoutes />
|
|
82
|
-
</BrowserRouter>
|
|
83
|
-
</EventProvider>
|
|
84
|
-
</OrganisationProvider>
|
|
85
|
-
</UnifiedAuthProvider>
|
|
86
|
-
</ErrorBoundary>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export default App;
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### 2. AppRoutes.tsx - Route Configuration
|
|
94
|
-
|
|
95
|
-
```tsx
|
|
96
|
-
import { Routes, Route, Navigate } from 'react-router-dom';
|
|
97
|
-
import { ProtectedRoute } from './auth/ProtectedRoute';
|
|
98
|
-
import { AppLayout } from './layout/AppLayout';
|
|
99
|
-
import { LoginPage } from './auth/LoginPage';
|
|
100
|
-
import { DashboardPage } from './dashboard/DashboardPage';
|
|
101
|
-
import { MealsPage } from './meals/MealsPage';
|
|
102
|
-
import { UsersPage } from './users/UsersPage';
|
|
103
|
-
|
|
104
|
-
export function AppRoutes() {
|
|
105
|
-
return (
|
|
106
|
-
<Routes>
|
|
107
|
-
<Route path="/login" element={<LoginPage />} />
|
|
108
|
-
|
|
109
|
-
<Route path="/" element={
|
|
110
|
-
<ProtectedRoute>
|
|
111
|
-
<AppLayout />
|
|
112
|
-
</ProtectedRoute>
|
|
113
|
-
}>
|
|
114
|
-
<Route index element={<DashboardPage />} />
|
|
115
|
-
<Route path="meals" element={<MealsPage />} />
|
|
116
|
-
<Route path="users" element={<UsersPage />} />
|
|
117
|
-
</Route>
|
|
118
|
-
|
|
119
|
-
<Route path="*" element={<Navigate to="/" replace />} />
|
|
120
|
-
</Routes>
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### 3. ProtectedRoute.tsx - Route Protection
|
|
126
|
-
|
|
127
|
-
```tsx
|
|
128
|
-
import { useUnifiedAuth } from '@jmruthers/pace-core';
|
|
129
|
-
import { Navigate, useLocation } from 'react-router-dom';
|
|
130
|
-
import { LoadingSpinner } from '../shared/LoadingSpinner';
|
|
131
|
-
|
|
132
|
-
interface ProtectedRouteProps {
|
|
133
|
-
children: React.ReactNode;
|
|
134
|
-
requiredPermission?: string;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export function ProtectedRoute({ children, requiredPermission }: ProtectedRouteProps) {
|
|
138
|
-
const { user, loading, hasPermission } = useUnifiedAuth();
|
|
139
|
-
const location = useLocation();
|
|
140
|
-
|
|
141
|
-
if (loading) {
|
|
142
|
-
return <LoadingSpinner />;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (!user) {
|
|
146
|
-
return <Navigate to="/login" state={{ from: location }} replace />;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (requiredPermission && !hasPermission(requiredPermission)) {
|
|
150
|
-
return <Navigate to="/unauthorized" replace />;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return <>{children}</>;
|
|
154
|
-
}
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### 4. AppLayout.tsx - Main Layout
|
|
158
|
-
|
|
159
|
-
```tsx
|
|
160
|
-
import { PaceAppLayout, OrganisationSelector, EventSelector } from '@jmruthers/pace-core';
|
|
161
|
-
import { Outlet } from 'react-router-dom';
|
|
162
|
-
|
|
163
|
-
const navItems = [
|
|
164
|
-
{
|
|
165
|
-
title: 'Dashboard',
|
|
166
|
-
href: '/',
|
|
167
|
-
icon: 'HomeIcon',
|
|
168
|
-
permission: 'read:dashboard'
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
title: 'Meals',
|
|
172
|
-
href: '/meals',
|
|
173
|
-
icon: 'UtensilsIcon',
|
|
174
|
-
permission: 'read:meals'
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
title: 'Users',
|
|
178
|
-
href: '/users',
|
|
179
|
-
icon: 'UsersIcon',
|
|
180
|
-
permission: 'read:users'
|
|
181
|
-
}
|
|
182
|
-
];
|
|
183
|
-
|
|
184
|
-
export function AppLayout() {
|
|
185
|
-
return (
|
|
186
|
-
<PaceAppLayout
|
|
187
|
-
appName="Meal Manager"
|
|
188
|
-
navItems={navItems}
|
|
189
|
-
enforcePermissions={true}
|
|
190
|
-
defaultPermission="read"
|
|
191
|
-
headerActions={
|
|
192
|
-
<>
|
|
193
|
-
<OrganisationSelector />
|
|
194
|
-
<EventSelector />
|
|
195
|
-
</>
|
|
196
|
-
}
|
|
197
|
-
>
|
|
198
|
-
<Outlet />
|
|
199
|
-
</PaceAppLayout>
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### 5. DashboardPage.tsx - Dashboard with Metrics
|
|
205
|
-
|
|
206
|
-
```tsx
|
|
207
|
-
import { Card, CardHeader, CardTitle, CardContent } from '@jmruthers/pace-core';
|
|
208
|
-
import { useUnifiedAuth } from '@jmruthers/pace-core';
|
|
209
|
-
import { useMeals } from '../../hooks/useMeals';
|
|
210
|
-
import { useUsers } from '../../hooks/useUsers';
|
|
211
|
-
|
|
212
|
-
export function DashboardPage() {
|
|
213
|
-
const { user } = useUnifiedAuth();
|
|
214
|
-
const { meals, loading: mealsLoading } = useMeals();
|
|
215
|
-
const { users, loading: usersLoading } = useUsers();
|
|
216
|
-
|
|
217
|
-
const totalMeals = meals?.length || 0;
|
|
218
|
-
const totalUsers = users?.length || 0;
|
|
219
|
-
const thisWeekMeals = meals?.filter(meal => {
|
|
220
|
-
const weekAgo = new Date();
|
|
221
|
-
weekAgo.setDate(weekAgo.getDate() - 7);
|
|
222
|
-
return new Date(meal.date) >= weekAgo;
|
|
223
|
-
}).length || 0;
|
|
224
|
-
|
|
225
|
-
return (
|
|
226
|
-
<div className="p-6">
|
|
227
|
-
<div className="mb-8">
|
|
228
|
-
<h1 className="text-3xl font-bold text-sec-900">Dashboard</h1>
|
|
229
|
-
<p className="text-sec-600 mt-2">
|
|
230
|
-
Welcome back, {user?.email}. Here's what's happening with your meals.
|
|
231
|
-
</p>
|
|
232
|
-
</div>
|
|
233
|
-
|
|
234
|
-
<div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
|
|
235
|
-
<Card>
|
|
236
|
-
<CardHeader>
|
|
237
|
-
<CardTitle>Total Meals</CardTitle>
|
|
238
|
-
</CardHeader>
|
|
239
|
-
<CardContent>
|
|
240
|
-
<p className="text-3xl font-bold">{mealsLoading ? '...' : totalMeals}</p>
|
|
241
|
-
<p className="text-sm text-sec-600">All time</p>
|
|
242
|
-
</CardContent>
|
|
243
|
-
</Card>
|
|
244
|
-
|
|
245
|
-
<Card>
|
|
246
|
-
<CardHeader>
|
|
247
|
-
<CardTitle>This Week</CardTitle>
|
|
248
|
-
</CardHeader>
|
|
249
|
-
<CardContent>
|
|
250
|
-
<p className="text-3xl font-bold">{mealsLoading ? '...' : thisWeekMeals}</p>
|
|
251
|
-
<p className="text-sm text-sec-600">Last 7 days</p>
|
|
252
|
-
</CardContent>
|
|
253
|
-
</Card>
|
|
254
|
-
|
|
255
|
-
<Card>
|
|
256
|
-
<CardHeader>
|
|
257
|
-
<CardTitle>Total Users</CardTitle>
|
|
258
|
-
</CardHeader>
|
|
259
|
-
<CardContent>
|
|
260
|
-
<p className="text-3xl font-bold">{usersLoading ? '...' : totalUsers}</p>
|
|
261
|
-
<p className="text-sm text-sec-600">Active users</p>
|
|
262
|
-
</CardContent>
|
|
263
|
-
</Card>
|
|
264
|
-
</div>
|
|
265
|
-
|
|
266
|
-
{/* Recent Activity */}
|
|
267
|
-
<Card>
|
|
268
|
-
<CardHeader>
|
|
269
|
-
<CardTitle>Recent Activity</CardTitle>
|
|
270
|
-
</CardHeader>
|
|
271
|
-
<CardContent>
|
|
272
|
-
<p className="text-sec-600">
|
|
273
|
-
Your meal tracking activity will appear here.
|
|
274
|
-
</p>
|
|
275
|
-
</CardContent>
|
|
276
|
-
</Card>
|
|
277
|
-
</div>
|
|
278
|
-
);
|
|
279
|
-
}
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### 6. MealsPage.tsx - Advanced DataTable
|
|
283
|
-
|
|
284
|
-
```tsx
|
|
285
|
-
import { useState } from 'react';
|
|
286
|
-
import {
|
|
287
|
-
DataTable,
|
|
288
|
-
Button,
|
|
289
|
-
useToast,
|
|
290
|
-
useUnifiedAuth
|
|
291
|
-
} from '@jmruthers/pace-core';
|
|
292
|
-
import { MealForm } from './MealForm';
|
|
293
|
-
import { useMeals } from '../../hooks/useMeals';
|
|
294
|
-
import { Meal } from '../../types/meal';
|
|
295
|
-
|
|
296
|
-
export function MealsPage() {
|
|
297
|
-
const [showForm, setShowForm] = useState(false);
|
|
298
|
-
const [editingMeal, setEditingMeal] = useState<Meal | null>(null);
|
|
299
|
-
const { meals, loading, createMeal, updateMeal, deleteMeal } = useMeals();
|
|
300
|
-
const { hasPermission } = useUnifiedAuth();
|
|
301
|
-
const { toast } = useToast();
|
|
302
|
-
|
|
303
|
-
const canCreate = hasPermission('create:meals');
|
|
304
|
-
const canEdit = hasPermission('update:meals');
|
|
305
|
-
const canDelete = hasPermission('delete:meals');
|
|
306
|
-
|
|
307
|
-
const columns = [
|
|
308
|
-
{
|
|
309
|
-
accessorKey: 'name',
|
|
310
|
-
header: 'Meal Name',
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
accessorKey: 'category',
|
|
314
|
-
header: 'Category',
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
accessorKey: 'calories',
|
|
318
|
-
header: 'Calories',
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
accessorKey: 'date',
|
|
322
|
-
header: 'Date',
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
id: 'actions',
|
|
326
|
-
header: 'Actions',
|
|
327
|
-
cell: ({ row }: any) => (
|
|
328
|
-
<div className="flex gap-2">
|
|
329
|
-
{canEdit && (
|
|
330
|
-
<Button
|
|
331
|
-
variant="outline"
|
|
332
|
-
size="sm"
|
|
333
|
-
onClick={() => setEditingMeal(row.original)}
|
|
334
|
-
>
|
|
335
|
-
Edit
|
|
336
|
-
</Button>
|
|
337
|
-
)}
|
|
338
|
-
{canDelete && (
|
|
339
|
-
<Button
|
|
340
|
-
variant="destructive"
|
|
341
|
-
size="sm"
|
|
342
|
-
onClick={() => handleDelete(row.original.id)}
|
|
343
|
-
>
|
|
344
|
-
Delete
|
|
345
|
-
</Button>
|
|
346
|
-
)}
|
|
347
|
-
</div>
|
|
348
|
-
),
|
|
349
|
-
},
|
|
350
|
-
];
|
|
351
|
-
|
|
352
|
-
const handleDelete = async (id: string) => {
|
|
353
|
-
try {
|
|
354
|
-
await deleteMeal(id);
|
|
355
|
-
toast({
|
|
356
|
-
title: 'Success',
|
|
357
|
-
description: 'Meal deleted successfully',
|
|
358
|
-
});
|
|
359
|
-
} catch (error) {
|
|
360
|
-
toast({
|
|
361
|
-
title: 'Error',
|
|
362
|
-
description: 'Failed to delete meal',
|
|
363
|
-
variant: 'destructive',
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
const handleSubmit = async (mealData: Partial<Meal>) => {
|
|
369
|
-
try {
|
|
370
|
-
if (editingMeal) {
|
|
371
|
-
await updateMeal(editingMeal.id, mealData);
|
|
372
|
-
toast({
|
|
373
|
-
title: 'Success',
|
|
374
|
-
description: 'Meal updated successfully',
|
|
375
|
-
});
|
|
376
|
-
} else {
|
|
377
|
-
await createMeal(mealData);
|
|
378
|
-
toast({
|
|
379
|
-
title: 'Success',
|
|
380
|
-
description: 'Meal created successfully',
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
setShowForm(false);
|
|
384
|
-
setEditingMeal(null);
|
|
385
|
-
} catch (error) {
|
|
386
|
-
toast({
|
|
387
|
-
title: 'Error',
|
|
388
|
-
description: 'Failed to save meal',
|
|
389
|
-
variant: 'destructive',
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
return (
|
|
395
|
-
<div className="p-6">
|
|
396
|
-
<div className="flex justify-between items-center mb-6">
|
|
397
|
-
<h1 className="text-2xl font-bold">Meals</h1>
|
|
398
|
-
{canCreate && (
|
|
399
|
-
<Button onClick={() => setShowForm(true)}>
|
|
400
|
-
Add Meal
|
|
401
|
-
</Button>
|
|
402
|
-
)}
|
|
403
|
-
</div>
|
|
404
|
-
|
|
405
|
-
<DataTable
|
|
406
|
-
data={meals || []}
|
|
407
|
-
columns={columns}
|
|
408
|
-
isLoading={loading}
|
|
409
|
-
features={{
|
|
410
|
-
search: true,
|
|
411
|
-
pagination: true,
|
|
412
|
-
}}
|
|
413
|
-
onRowClick={(meal) => canEdit && setEditingMeal(meal)}
|
|
414
|
-
/>
|
|
415
|
-
|
|
416
|
-
{showForm && (
|
|
417
|
-
<MealForm
|
|
418
|
-
meal={editingMeal}
|
|
419
|
-
onSubmit={handleSubmit}
|
|
420
|
-
onCancel={() => {
|
|
421
|
-
setShowForm(false);
|
|
422
|
-
setEditingMeal(null);
|
|
423
|
-
}}
|
|
424
|
-
/>
|
|
425
|
-
)}
|
|
426
|
-
</div>
|
|
427
|
-
);
|
|
428
|
-
}
|
|
429
|
-
```
|
|
430
|
-
|
|
431
|
-
### 7. MealForm.tsx - Form with Validation
|
|
432
|
-
|
|
433
|
-
```tsx
|
|
434
|
-
import { useForm } from 'react-hook-form';
|
|
435
|
-
import { zodResolver } from '@hookform/resolvers/zod';
|
|
436
|
-
import { z } from 'zod';
|
|
437
|
-
import {
|
|
438
|
-
Form,
|
|
439
|
-
FormField,
|
|
440
|
-
FormItem,
|
|
441
|
-
FormLabel,
|
|
442
|
-
FormControl,
|
|
443
|
-
FormMessage,
|
|
444
|
-
Button,
|
|
445
|
-
Input,
|
|
446
|
-
Select,
|
|
447
|
-
SelectContent,
|
|
448
|
-
SelectItem,
|
|
449
|
-
SelectTrigger,
|
|
450
|
-
SelectValue,
|
|
451
|
-
Card,
|
|
452
|
-
CardHeader,
|
|
453
|
-
CardTitle,
|
|
454
|
-
CardContent
|
|
455
|
-
} from '@jmruthers/pace-core';
|
|
456
|
-
import { Meal } from '../../types/meal';
|
|
457
|
-
|
|
458
|
-
const mealSchema = z.object({
|
|
459
|
-
name: z.string().min(1, 'Meal name is required'),
|
|
460
|
-
category: z.string().min(1, 'Category is required'),
|
|
461
|
-
calories: z.number().min(1, 'Calories must be greater than 0'),
|
|
462
|
-
date: z.string().min(1, 'Date is required'),
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
interface MealFormProps {
|
|
466
|
-
meal?: Meal | null;
|
|
467
|
-
onSubmit: (data: Partial<Meal>) => Promise<void>;
|
|
468
|
-
onCancel: () => void;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
export function MealForm({ meal, onSubmit, onCancel }: MealFormProps) {
|
|
472
|
-
const form = useForm({
|
|
473
|
-
resolver: zodResolver(mealSchema),
|
|
474
|
-
defaultValues: {
|
|
475
|
-
name: meal?.name || '',
|
|
476
|
-
category: meal?.category || '',
|
|
477
|
-
calories: meal?.calories || 0,
|
|
478
|
-
date: meal?.date || new Date().toISOString().split('T')[0],
|
|
479
|
-
},
|
|
480
|
-
});
|
|
481
|
-
|
|
482
|
-
const handleSubmit = async (data: any) => {
|
|
483
|
-
await onSubmit(data);
|
|
484
|
-
};
|
|
485
|
-
|
|
486
|
-
return (
|
|
487
|
-
<Card className="mt-6">
|
|
488
|
-
<CardHeader>
|
|
489
|
-
<CardTitle>{meal ? 'Edit Meal' : 'Add New Meal'}</CardTitle>
|
|
490
|
-
</CardHeader>
|
|
491
|
-
<CardContent>
|
|
492
|
-
<Form {...form}>
|
|
493
|
-
<form onSubmit={form.handleSubmit(handleSubmit)} className="space-y-4">
|
|
494
|
-
<FormField
|
|
495
|
-
control={form.control}
|
|
496
|
-
name="name"
|
|
497
|
-
render={({ field }) => (
|
|
498
|
-
<FormItem>
|
|
499
|
-
<FormLabel>Meal Name</FormLabel>
|
|
500
|
-
<FormControl>
|
|
501
|
-
<Input placeholder="Enter meal name" {...field} />
|
|
502
|
-
</FormControl>
|
|
503
|
-
<FormMessage />
|
|
504
|
-
</FormItem>
|
|
505
|
-
)}
|
|
506
|
-
/>
|
|
507
|
-
|
|
508
|
-
<FormField
|
|
509
|
-
control={form.control}
|
|
510
|
-
name="category"
|
|
511
|
-
render={({ field }) => (
|
|
512
|
-
<FormItem>
|
|
513
|
-
<FormLabel>Category</FormLabel>
|
|
514
|
-
<Select onValueChange={field.onChange} defaultValue={field.value}>
|
|
515
|
-
<FormControl>
|
|
516
|
-
<SelectTrigger>
|
|
517
|
-
<SelectValue placeholder="Select category" />
|
|
518
|
-
</SelectTrigger>
|
|
519
|
-
</FormControl>
|
|
520
|
-
<SelectContent>
|
|
521
|
-
<SelectItem value="breakfast">Breakfast</SelectItem>
|
|
522
|
-
<SelectItem value="lunch">Lunch</SelectItem>
|
|
523
|
-
<SelectItem value="dinner">Dinner</SelectItem>
|
|
524
|
-
<SelectItem value="snack">Snack</SelectItem>
|
|
525
|
-
</SelectContent>
|
|
526
|
-
</Select>
|
|
527
|
-
<FormMessage />
|
|
528
|
-
</FormItem>
|
|
529
|
-
)}
|
|
530
|
-
/>
|
|
531
|
-
|
|
532
|
-
<FormField
|
|
533
|
-
control={form.control}
|
|
534
|
-
name="calories"
|
|
535
|
-
render={({ field }) => (
|
|
536
|
-
<FormItem>
|
|
537
|
-
<FormLabel>Calories</FormLabel>
|
|
538
|
-
<FormControl>
|
|
539
|
-
<Input
|
|
540
|
-
type="number"
|
|
541
|
-
placeholder="Enter calories"
|
|
542
|
-
{...field}
|
|
543
|
-
onChange={(e) => field.onChange(parseInt(e.target.value) || 0)}
|
|
544
|
-
/>
|
|
545
|
-
</FormControl>
|
|
546
|
-
<FormMessage />
|
|
547
|
-
</FormItem>
|
|
548
|
-
)}
|
|
549
|
-
/>
|
|
550
|
-
|
|
551
|
-
<FormField
|
|
552
|
-
control={form.control}
|
|
553
|
-
name="date"
|
|
554
|
-
render={({ field }) => (
|
|
555
|
-
<FormItem>
|
|
556
|
-
<FormLabel>Date</FormLabel>
|
|
557
|
-
<FormControl>
|
|
558
|
-
<Input type="date" {...field} />
|
|
559
|
-
</FormControl>
|
|
560
|
-
<FormMessage />
|
|
561
|
-
</FormItem>
|
|
562
|
-
)}
|
|
563
|
-
/>
|
|
564
|
-
|
|
565
|
-
<div className="flex gap-2 pt-4">
|
|
566
|
-
<Button type="submit">
|
|
567
|
-
{meal ? 'Update Meal' : 'Add Meal'}
|
|
568
|
-
</Button>
|
|
569
|
-
<Button type="button" variant="outline" onClick={onCancel}>
|
|
570
|
-
Cancel
|
|
571
|
-
</Button>
|
|
572
|
-
</div>
|
|
573
|
-
</form>
|
|
574
|
-
</Form>
|
|
575
|
-
</CardContent>
|
|
576
|
-
</Card>
|
|
577
|
-
);
|
|
578
|
-
}
|
|
579
|
-
```
|
|
580
|
-
|
|
581
|
-
## 🔧 Environment Setup
|
|
582
|
-
|
|
583
|
-
Create `.env.local`:
|
|
584
|
-
|
|
585
|
-
```bash
|
|
586
|
-
REACT_APP_SUPABASE_URL=https://your-project.supabase.co
|
|
587
|
-
REACT_APP_SUPABASE_ANON_KEY=your-anon-key-here
|
|
588
|
-
```
|
|
589
|
-
|
|
590
|
-
## 🎉 What You Get
|
|
591
|
-
|
|
592
|
-
- ✅ Complete authentication with RBAC
|
|
593
|
-
- ✅ Multi-tenant organisation support
|
|
594
|
-
- ✅ Event management
|
|
595
|
-
- ✅ Advanced DataTable with CRUD
|
|
596
|
-
- ✅ Form validation with Zod
|
|
597
|
-
- ✅ Permission enforcement
|
|
598
|
-
- ✅ Responsive layout
|
|
599
|
-
- ✅ Error handling and loading states
|
|
600
|
-
- ✅ Toast notifications
|
|
601
|
-
- ✅ Production-ready patterns
|
|
602
|
-
|
|
603
|
-
## 🚀 Next Steps
|
|
604
|
-
|
|
605
|
-
- **Customize the design** - Adapt to your brand
|
|
606
|
-
- **Add more features** - Reporting, analytics, integrations
|
|
607
|
-
- **Implement real data** - Connect to your database
|
|
608
|
-
- **Add tests** - Unit and integration testing
|
|
609
|
-
- **Deploy** - Production deployment
|
|
610
|
-
|
|
611
|
-
## 📚 Related Documentation
|
|
612
|
-
|
|
613
|
-
- **[Core Concepts](../core-concepts/)** - Understand authentication and RBAC
|
|
614
|
-
- **[Implementation Guides](../implementation-guides/)** - Advanced patterns
|
|
615
|
-
- **[API Reference](../api-reference/)** - All components and hooks
|
|
616
|
-
- **[Best Practices](../best-practices/)** - Production deployment
|