Skip to main content

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)โ€‹

  1. โœ… Baca Installation Guide (Step 1-11)
  2. โœ… Setup basic calendar
  3. โœ… Baca Quick Reference untuk patterns
  4. โœ… Lihat Full Documentation untuk detail API
  5. โœ… Baca Best Practices untuk optimization

Estimasi waktu: 2-3 jam


Path 2: Quick Start (Sudah Familiar)โ€‹

  1. โœ… Lihat Quick Reference
  2. โœ… Copy pattern yang sesuai
  3. โœ… Adjust sesuai kebutuhan

Estimasi waktu: 15-30 menit


Path 3: Deep Dive (Advanced)โ€‹

  1. โœ… Baca Full Documentation cover-to-cover
  2. โœ… Baca Best Practices untuk patterns
  3. โœ… Review source code di components/Calendar/
  4. โœ… 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


๐Ÿ“ 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.tsx for legacy implementation

๐Ÿค Contributingโ€‹

Jika ingin menambahkan fitur atau improve documentation:

  1. Update component source code
  2. Update types di types.ts
  3. 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
  4. Add examples
  5. Update this README if needed

๐Ÿ’ฌ Supportโ€‹

Jika ada pertanyaan:

  1. ๐Ÿ“– Check dokumentasi (4 files di atas)
  2. ๐Ÿ” Search di source code
  3. ๐Ÿงช Review test examples
  4. ๐Ÿ’ก Check best practices
  5. ๐Ÿ“ž Contact maintainer

๐Ÿ“„ Licenseโ€‹

Component ini adalah bagian dari project Sisappra internal. Silakan disesuaikan dengan kebutuhan project Anda.



Happy Coding! ๐ŸŽ‰

Last updated: December 5, 2025
Maintainer: Sisappra Development Team