Calendar Component Documentation
Dokumentasi lengkap untuk reusable Calendar Component yang dibangun dengan React Big Calendar, React Query, dan TypeScript.
๐ Daftar Dokumentasiโ
Dokumentasi ini terdiri dari 4 file utama:
1. ๐ Calendar Component - Full Documentationโ
File: calendar-component.md
Dokumentasi lengkap tentang Calendar Component, mencakup:
- Overview & fitur-fitur
- API Reference lengkap
- Props & types detail
- 7+ contoh penggunaan
- Data normalization
- React Query integration
- Localization
- Common pitfalls
- Testing guide
- Migration guide
Kapan membaca: Saat pertama kali ingin memahami component secara mendalam atau butuh referensi API lengkap.
2. ๐ Installation Guideโ
File: calendar-installation.md
Panduan step-by-step untuk menginstall dan setup Calendar ke project baru:
- Prerequisites & dependencies
- File structure & copy files
- Setup React Query
- Import styles
- Adjust import paths
- Setup Day.js
- Basic implementation
- CRUD operations
- Configuration
- Customize UI
- Testing setup
- Troubleshooting
Kapan membaca: Saat ingin mengimplementasikan Calendar Component ke project baru.
3. ๐ก Best Practices & Tipsโ
File: calendar-best-practices.md
Best practices, patterns, dan tips advanced:
- Architecture patterns (hooks, context)
- Performance optimization
- Styling best practices (CSS-in-JS, Tailwind)
- Security best practices
- Mobile optimization
- Testing patterns
- Error handling
- Analytics & monitoring
- Advanced tips (multi-tenant, DnD)
- Production checklist
Kapan membaca: Setelah berhasil implementasi basic, ingin optimize dan improve kualitas code.
4. โก Quick Referenceโ
File: calendar-quick-reference.md
Cheatsheet untuk penggunaan cepat:
- Installation command
- Basic usage
- Common props table
- Event object structure
- 15+ common patterns
- Event handlers
- Styling snippets
- React Query config
- Troubleshooting quick fixes
- Mobile setup
- Performance tips
- TypeScript types
Kapan membaca: Saat development, butuh referensi cepat tanpa perlu baca dokumentasi lengkap.
๐ฏ Reading Pathโ
Path 1: Implementasi Baru (First Time)โ
- โ Baca Installation Guide (Step 1-11)
- โ Setup basic calendar
- โ Baca Quick Reference untuk patterns
- โ Lihat Full Documentation untuk detail API
- โ Baca Best Practices untuk optimization
Estimasi waktu: 2-3 jam
Path 2: Quick Start (Sudah Familiar)โ
- โ Lihat Quick Reference
- โ Copy pattern yang sesuai
- โ Adjust sesuai kebutuhan
Estimasi waktu: 15-30 menit
Path 3: Deep Dive (Advanced)โ
- โ Baca Full Documentation cover-to-cover
- โ Baca Best Practices untuk patterns
- โ
Review source code di
components/Calendar/ - โ Experiment dengan custom implementations
Estimasi waktu: 4-6 jam
๐ Struktur Componentโ
components/Calendar/
โโโ index.tsx # Legacy wrapper
โโโ GenericCalendar.tsx # Main component (recommended) โญ
โโโ CustomEvent.tsx # Custom event renderer
โโโ CustomToolbar.tsx # Custom toolbar component
โโโ Calendar.module.css # Styling
โโโ types.ts # TypeScript types
โโโ utils/
โโโ helper.ts # Helper functions
๐ Quick Startโ
Minimal Setupโ
# Install dependencies
npm install react-big-calendar date-fns dayjs @tanstack/react-query
// Import component
import { GenericOptimizedCalendar } from '@/components/Calendar/GenericCalendar';
// Use in your app
<div style={{ height: '600px' }}>
<GenericOptimizedCalendar
onFetchEvents={async (start, end) => {
const res = await fetch(`/api/events?start=${start}&end=${end}`);
return res.json();
}}
/>
</div>
That's it! โจ
๐จ Features Highlightโ
โ Core Featuresโ
- Full TypeScript support
- React Query integration (auto-caching)
- Multiple views (month, week, day, agenda)
- Custom event colors
- Localization (ID default, customizable)
- Responsive & mobile-friendly
โ Advanced Featuresโ
- Time window restriction (jam kerja)
- Working days filter
- Overlap prevention
- Date range restrictions (past/future)
- Custom event renderer
- Custom toolbar
- Manual refresh API
- Disabled states
โ Developer Experienceโ
- Fully typed with TypeScript
- Comprehensive documentation
- Multiple usage examples
- Best practices guide
- Quick reference cheatsheet
- Testing examples
๐ฆ Dependenciesโ
Requiredโ
{
"react": "^18.2.0",
"react-big-calendar": "^1.8.5",
"date-fns": "^3.0.0",
"dayjs": "^1.11.10",
"@tanstack/react-query": "^5.0.0"
}
Optional (for UI)โ
{
"@mantine/core": "^7.5.0",
"@mantine/hooks": "^7.5.0",
"@tabler/icons-react": "^2.46.0"
}
๐ฏ Common Use Casesโ
1. Simple Event Calendarโ
<GenericOptimizedCalendar
onFetchEvents={fetchEvents}
/>
2. Working Hours Calendarโ
<GenericOptimizedCalendar
onFetchEvents={fetchEvents}
timeWindow={{ start: '08:00', end: '17:00' }}
workingDays={[1, 2, 3, 4, 5]}
/>
3. No Overlap Calendarโ
<GenericOptimizedCalendar
onFetchEvents={fetchEvents}
preventOverlap={true}
/>
4. Custom Colors Calendarโ
<GenericOptimizedCalendar
onFetchEvents={fetchEvents}
getEventColor={(event) => event.color || '#3174ad'}
/>
Lihat Quick Reference untuk lebih banyak contoh!
๐งช Testingโ
import { render, waitFor } from '@testing-library/react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { GenericOptimizedCalendar } from './GenericCalendar';
test('renders calendar with events', async () => {
const mockFetch = jest.fn().mockResolvedValue([
{ id: '1', title: 'Test', start: new Date(), end: new Date() }
]);
render(
<QueryClientProvider client={new QueryClient()}>
<div style={{ height: '600px' }}>
<GenericOptimizedCalendar onFetchEvents={mockFetch} />
</div>
</QueryClientProvider>
);
await waitFor(() => expect(mockFetch).toHaveBeenCalled());
});
๐ Troubleshootingโ
Calendar tidak tampilโ
Solution: Set explicit height pada container
Events tidak munculโ
Solution: Check API response format (id, title, start, end required)
Import errorโ
Solution: Update tsconfig.json atau use relative imports
Lihat Installation Guide untuk troubleshooting lengkap!
๐ Documentation Structureโ
docs/
โโโ README.md # File ini (overview)
โโโ calendar-component.md # Full documentation
โโโ calendar-installation.md # Installation guide
โโโ calendar-best-practices.md # Best practices & tips
โโโ calendar-quick-reference.md # Cheatsheet
๐ Related Resourcesโ
๐ Version Historyโ
v2.0.0 (Current)โ
- โ GenericCalendar dengan full TypeScript support
- โ React Query v5 integration
- โ Improved time window API
- โ Better error handling
- โ Comprehensive documentation
v1.0.0 (Legacy)โ
- Basic calendar dengan query key
- Limited TypeScript support
- See
index.tsxfor legacy implementation
๐ค Contributingโ
Jika ingin menambahkan fitur atau improve documentation:
- Update component source code
- Update types di
types.ts - Update dokumentasi yang relevan:
- API changes โ
calendar-component.md - Setup changes โ
calendar-installation.md - New patterns โ
calendar-best-practices.md - Quick snippets โ
calendar-quick-reference.md
- API changes โ
- Add examples
- Update this README if needed
๐ฌ Supportโ
Jika ada pertanyaan:
- ๐ Check dokumentasi (4 files di atas)
- ๐ Search di source code
- ๐งช Review test examples
- ๐ก Check best practices
- ๐ Contact maintainer
๐ Licenseโ
Component ini adalah bagian dari project Sisappra internal. Silakan disesuaikan dengan kebutuhan project Anda.
โจ Quick Linksโ
- ๐ Full Documentation - API Reference lengkap
- ๐ Installation - Setup guide step-by-step
- ๐ก Best Practices - Tips & patterns
- โก Quick Reference - Cheatsheet
Happy Coding! ๐
Last updated: December 5, 2025
Maintainer: Sisappra Development Team