@mui-toolpad-extended-tuni/calendar 3.1.0 → 3.2.0

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/README.md CHANGED
@@ -49,7 +49,7 @@ npm install @mui-toolpad-extended-tuni/calendar @mui-toolpad-extended-tuni/main
49
49
 
50
50
  ## API Configuration
51
51
 
52
- **Note**: The calendar package does not make direct API calls. It receives events through the EventBus system from other microservices (primarily the courses package). However, you can configure calendar endpoints if you plan to add direct API integration in the future.
52
+ **Note**: The calendar package does not make direct API calls. It receives events through the EventBus system from other microservices (primarily the courses package). However, you can configure calendar endpoints via the `apiEndpoints` prop if you plan to add direct API integration in the future.
53
53
 
54
54
  ### Default Endpoints
55
55
 
@@ -61,6 +61,23 @@ If you need to configure calendar endpoints for future API integration:
61
61
  - `put: "api/calendar/:id/"` - PUT update event
62
62
  - `delete: "api/calendar/:id/"` - DELETE event
63
63
 
64
+ ### Customizing Endpoints
65
+
66
+ ```tsx
67
+ import { CalendarMicroservice } from '@mui-toolpad-extended-tuni/calendar';
68
+ import type { CalendarApiEndpoints } from '@mui-toolpad-extended-tuni/calendar';
69
+
70
+ const calendarEndpoints: CalendarApiEndpoints = {
71
+ get: "https://api.example.com/v1/calendar",
72
+ getById: "https://api.example.com/v1/calendar/:id",
73
+ post: "https://api.example.com/v1/calendar",
74
+ put: "https://api.example.com/v1/calendar/:id",
75
+ delete: "https://api.example.com/v1/calendar/:id",
76
+ };
77
+
78
+ <CalendarMicroservice apiEndpoints={calendarEndpoints} />
79
+ ```
80
+
64
81
  **Current Implementation**: The calendar currently uses EventBus to receive events from other microservices. Direct API endpoints are reserved for future use.
65
82
 
66
83
  ## Usage
@@ -308,6 +325,9 @@ interface Event {
308
325
  - `createCalendarEvent` - Helper function to create calendar events
309
326
  - `getContrastColor` - Helper function to get contrasting text color
310
327
 
328
+ ### Hooks
329
+ - `useCalendarApiConfig()` - Hook to access calendar API endpoint configuration (for future use)
330
+
311
331
  ### Types
312
332
  - `CalendarEvent` - Calendar event interface
313
333
  - `CalendarEventType` - Calendar event type enumeration
@@ -1,6 +1,9 @@
1
1
  import { default as React, ReactNode } from 'react';
2
- interface CalendarMicroserviceProps {
2
+ import { CalendarApiEndpoints } from '@mui-toolpad-extended-tuni/core';
3
+ export interface CalendarMicroserviceProps {
3
4
  children?: ReactNode;
5
+ /** API endpoint configuration for the calendar microservice (for future use) */
6
+ apiEndpoints?: CalendarApiEndpoints;
4
7
  }
5
8
  /**
6
9
  * CalendarMicroservice Component
@@ -0,0 +1,15 @@
1
+ import { CalendarApiEndpoints } from '@mui-toolpad-extended-tuni/core';
2
+ /**
3
+ * Hook to access calendar API configuration.
4
+ * Returns the calendar endpoint configuration merged with defaults.
5
+ *
6
+ * @returns Calendar API endpoints configuration, or undefined if not registered
7
+ * @throws Error if used outside of ApiConfigProvider
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * const calendarConfig = useCalendarApiConfig();
12
+ * const endpoint = calendarConfig?.get; // "api/calendar/" or custom value
13
+ * ```
14
+ */
15
+ export declare const useCalendarApiConfig: () => CalendarApiEndpoints | undefined;