> ## Documentation Index
> Fetch the complete documentation index at: https://docs.quinnsambal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Workspace

<style>
  {`
    [class*="max-w-none"][class*="table"] {
      display: block !important;
      overflow-x: auto !important;
      max-width: 100% !important;
      width: 100% !important;
      flex-grow: 0 !important;
    }
    [class*="max-w-none"][class*="table"] > table {
      width: 100% !important;
      max-width: 100% !important;
      table-layout: fixed !important;
    }
    .mermaid {
      max-width: 100% !important;
      overflow-x: auto !important;
    }
    article svg[role="img"] {
      max-width: 100% !important;
      height: auto !important;
    }
    article img, .prose img {
      max-width: 100% !important;
      height: auto !important;
    }
    img[src*="LOGO"], img[src*="logo"] {
      max-width: 120px !important;
      max-height: 40px !important;
      width: auto !important;
      height: auto !important;
      object-fit: contain !important;
    }
    `}
</style>

***

title: "Workspace"
description: "Ruang kerja personal untuk mengelola tugas, catatan, dan aktivitas individual dengan fitur produktivitas terintegrasi."
-------------------------------------------------------------------------------------------------------------------------------------

# Workspace

<img src="https://mintcdn.com/quinnofspicy/e4f_upKhVWcjsUmM/docs/mintlify/screenshots/core/workspace.png?fit=max&auto=format&n=e4f_upKhVWcjsUmM&q=85&s=df47635745bbca84f1176c1449c7ebf4" alt="Workspace" width="1920" height="1080" data-path="docs/mintlify/screenshots/core/workspace.png" />

**Workspace** adalah ruang kerja personal kamu di dalam SNISHOP ERP. Setiap user memiliki workspace sendiri yang berfungsi sebagai **meja kerja digital** — tempat semua tugas, catatan, dokumen, dan aktivitas yang terkait langsung dengan kamu terkumpul dalam satu tampilan terorganisir.

Workspace dirancang untuk **fokus individual** — memungkinkan kamu mengelola pekerjaan tanpa terganggu oleh aktivitas tim secara keseluruhan, sekaligus tetap terhubung dengan kolaborasi tim ketika dibutuhkan.

## Workspace vs Workspaces

| Aspek | Workspace (Personal) | Workspaces (Tim) |
| - | - | - |
| **Scope** | Individual user | Tim / Departemen / Project |
| **Data** | Tugas, catatan, aktivitas personal | Tugas tim, diskusi, dokumen bersama |
| **Visibility** | Hanya kamu | Anggota workspace |
| **Tujuan** | "Apa yang harus saya kerjakan?" | "Apa yang tim kerjakan?" |
| **Jumlah** | 1 per user | Banyak, bisa bergabung beberapa |
| **Kepemilikan** | Dimiliki oleh satu user | Bisa memiliki banyak anggota |
| **Company Binding** | `company_id` bisa null | Terikat ke company tertentu |

## Arsitektur Workspace

```mermaid theme={null}
graph TD
    A[Workspace Personal] --> B[Task Manager]
    A --> C[Notes & Memo]
    A --> D[Activity Log]
    A --> E[Quick Access]
    A --> F[Status & Presence]
    A --> G[Productivity Widget]
    
    B --> B1[Tugas dari modul]
    B --> B2[Tugas manual]
    B --> B3[Reminder & deadline]
    
    C --> C1[Catatan pribadi]
    C --> C2[Memo cepat]
    C --> C3[Snippet & template]
    
    D --> D1[Log aktivitas hari ini]
    D --> D2[Riwayat transaksi]
    D --> D3[Audit trail personal]

    E --> E1[Recent documents]
    E --> E2[Frequent actions]
    E --> E3[Starred items]
    E --> E4[Custom shortcuts]
```

## Komponen Utama

### 1. Task Manager

Daftar tugas personal yang ditugaskan ke kamu, lengkap dengan manajemen prioritas:

| Field | Deskripsi | Opsi |
| - | - | - |
| **Judul** | Nama tugas | Input teks |
| **Deskripsi** | Detail tugas | Rich text |
| **Prioritas** | Tingkat urgensi | Urgent, High, Normal, Low |
| **Deadline** | Batas waktu selesai | Date & time picker |
| **Status** | Progress tugas | Pending, In Progress, Review, Done |
| **Label** | Kategorisasi tugas | Custom tags (multi-select) |
| **Lampiran** | File terkait | Upload file (max 10MB) |
| **Sumber** | Modul asal tugas | POS, Inventory, Finance, dll |

**Sortir & Filter Tugas:**

* Urutkan berdasarkan: deadline, prioritas, tanggal dibuat, atau status
* Filter berdasarkan: label, status, tanggal, atau modul asal
* Pencarian cepat dengan keyword di judul atau deskripsi

**Task Lifecycle**:

```mermaid theme={null}
stateDiagram-v2
    [*] --> Pending: Tugas dibuat/ditugaskan
    Pending --> InProgress: User mulai mengerjakan
    InProgress --> Review: Submit untuk review
    Review --> Done: Approved / selesai
    Review --> InProgress: Rejected, perlu revisi
    Pending --> Pending: Snooze (tunda)
    Done --> [*]
    
    note right of Pending
        Bisa dari modul lain:
        POS → Approval diskon
        Inventory → Stock opname
        Finance → Invoice approval
    end note
```

### 2. Notes & Memo

Catatan personal yang bisa kamu simpan di workspace:

| Tipe Catatan | Deskripsi | Contoh Penggunaan |
| - | - | - |
| **Quick Note** | Catatan singkat satu baris | "Ingat: follow up customer X" |
| **Detailed Note** | Catatan panjang dengan formatting | Draft email, meeting notes |
| **Pinned Note** | Catatan yang dipinned di atas | Informasi penting yang selalu dibutuhkan |
| **Template Note** | Template yang bisa dipakai ulang | Template follow-up customer |

**Note Entity Schema**:

| Field | Type | Deskripsi |
| - | - | - |
| `id` | UUID | Unique identifier |
| `title` | String | Judul catatan |
| `content` | Rich Text | Isi catatan (markdown supported) |
| `type` | Enum | quick, detailed, pinned, template |
| `tags` | String\[] | Label/tag untuk kategorisasi |
| `is_pinned` | Boolean | Apakah di-pin di atas |
| `created_at` | Timestamp | Waktu dibuat |
| `updated_at` | Timestamp | Waktu terakhir diubah |
| `user_id` | UUID | Owner catatan |

### 3. Activity Log

Log aktivitas kamu sendiri untuk tracking produktivitas:

| Informasi | Deskripsi |
| - | - |
| **Aksi** | Apa yang kamu lakukan (buat invoice, update stok, dll) |
| **Objek** | Data yang dioperasikan (nama invoice, produk, dll) |
| **Waktu** | Kapan aksi dilakukan (timestamp) |
| **Modul** | Modul tempat aksi dilakukan |
| **Durasi** | Berapa lama waktu yang dihabiskan (untuk task) |

**Activity Log Flow**:

```mermaid theme={null}
sequenceDiagram
    participant U as User
    participant M as Module (POS/Inventory/Finance)
    participant AL as Activity Log
    participant W as Workspace

    U->>M: Perform action (e.g., create invoice)
    M->>AL: Log activity entry
    AL->>AL: Store: action, entity, timestamp, module
    AL->>W: Push to workspace feed
    W-->>U: Display in activity panel
```

### 4. Quick Access

Shortcut ke dokumen atau transaksi yang sering kamu akses:

* **Recent Documents** — 5 dokumen terakhir yang kamu buka
* **Frequent Actions** — Aksi yang paling sering kamu lakukan
* **Starred Items** — Item yang kamu tandai sebagai favorit
* **Custom Shortcuts** — Shortcut yang kamu buat sendiri

### 5. Status & Presence

Indikator ketersediaan kamu untuk tim:

| Status | Ikon | Deskripsi |
| - | - | - |
| **Online** | 🟢 | Aktif dan tersedia |
| **Busy** | 🔴 | Sedang fokus, jangan ganggu |
| **Away** | 🟡 | Sementara tidak di tempat |
| **Offline** | ⚫ | Tidak terhubung |

Kamu bisa set status manual atau biarkan sistem mendeteksi otomatis berdasarkan aktivitas.

**Presence Detection**:

```mermaid theme={null}
flowchart TD
    A[User Activity] --> B{Active in last 5 min?}
    B -->|Yes| C[Set Online]
    B -->|No| D{Active in last 30 min?}
    D -->|Yes| E[Set Away]
    D -->|No| F[Set Offline]
    
    G[Manual Override] --> H[User sets status]
    H --> I[Override auto-detection]
    
    C & E & F --> J[Broadcast via WebSocket]
    I --> J
    J --> K[Other users see your status]
```

### 6. Productivity Widget

Widget yang menunjukkan metrik produktivitas kamu:

| Metrik | Deskripsi | Periode |
| - | - | - |
| **Tugas Selesai** | Jumlah tugas yang diselesaikan | Hari / Minggu / Bulan |
| **Rata-rata Waktu** | Waktu rata-rata menyelesaikan tugas | Minggu ini |
| **Streak** | Jumlah hari berturut-turut produktif | Saat ini |
| **Completion Rate** | Persentase tugas selesai vs total | Bulan ini |

**Productivity Metrics Calculation**:

```mermaid theme={null}
flowchart LR
    subgraph "Input"
        T1[Task completed timestamps]
        T2[Task created timestamps]
        T3[Task deadlines]
    end

    subgraph "Calculations"
        T1 & T2 --> C1[Avg completion time]
        T1 --> C2[Daily completion count]
        C2 --> C3[Streak counter]
        T1 & T3 --> C4[On-time rate %]
    end

    subgraph "Display"
        C1 --> D1[Widget Card]
        C2 --> D2[Widget Card]
        C3 --> D3[Widget Card]
        C4 --> D4[Widget Card]
    end
```

## Cara Akses

| Metode | Cara |
| - | - |
| **Sidebar** | Klik menu **Workspace** |
| **Avatar Menu** | Klik nama/foto di pojok kanan atas → **My Workspace** |
| **Keyboard** | Tekan `W` untuk akses cepat |
| **Home** | Klik widget "My Tasks" di halaman Home |

## Flow Penggunaan

```mermaid theme={null}
flowchart LR
    A[Buka Workspace] --> B[Review tugas pending]
    B --> C[Pilih tugas prioritas tinggi]
    C --> D[Klik untuk detail]
    D --> E[Kerjakan tugas]
    E --> F[Tandai selesai]
    F --> G[Update catatan jika perlu]
    G --> B
```

## Integrasi dengan Modul Lain

Workspace terhubung dengan berbagai modul untuk menangkap tugas secara otomatis:

| Modul Asal | Tipe Tugas yang Muncul | Trigger |
| - | - | - |
| **POS** | Approval diskon, refund request | Diskon >20% atau refund >Rp500K |
| **Inventory** | Stock opname task, low stock review | Stok \< minimum threshold |
| **Manufacturing** | QC check, batch approval | Production stage = QC |
| **Finance** | Invoice approval, expense review | Invoice > approval threshold |
| **CRM** | Follow-up customer, lead qualification | Lead baru atau follow-up due |
| **HR** | Leave approval, timesheet review | Leave request submitted |

### Auto-Task Creation Flow

```mermaid theme={null}
flowchart TD
    subgraph "Module Events"
        POS[POS: Diskon >20%] 
        INV[Inventory: Stok menipis]
        FIN[Finance: Invoice baru]
        CRM[CRM: Lead masuk]
    end

    subgraph "Task Engine"
        POS & INV & FIN & CRM --> TE[Task Engine]
        TE --> TR[Routing: Assignee based on role]
        TR --> TP[Priority: Based on amount/urgency]
        TP --> TD[Deadline: Based on SLA]
    end

    subgraph "Workspace"
        TD --> WS[Personal Workspace]
        WS --> Notif[Push notification]
    end
```

## Tips

* **Cek workspace setiap pagi** untuk melihat tugas yang masuk semalam dan merencanakan hari kerja
* **Gunakan label prioritas** untuk menandai tugas yang urgent supaya tidak terlewat
* **Catatan di workspace bersifat personal** — hanya kamu yang bisa melihatnya. Gunakan untuk hal-hal yang tidak perlu dibagikan ke tim
* **Tandai tugas selesai segera** setelah dikerjakan supaya progress kamu terupdate dan produktivitas terpantau
* **Manfaatkan quick access** untuk menyimpan link ke dokumen yang sering kamu buka supaya tidak perlu cari berulang
* **Set status "Busy"** saat kamu perlu fokus — tim akan tahu untuk tidak mengganggu kecuali urgent

***

## Diagram Relasi Entitas (ERD)

Berikut adalah diagram relasi antar entitas yang membentuk ekosistem Workspace di SNISHOP ERP:

```mermaid theme={null}
erDiagram
    User ||--o{ Workspace : "memiliki (owner)"
    User ||--o{ WorkspaceMember : "bergabung sebagai"
    User ||--o{ Task : "diberi tugas (assignee)"
    User ||--o{ Note : "membuat catatan"
    User ||--o{ Label : "memiliki label"
    User ||--o{ Achievement : "meraih prestasi"
    User ||--o{ RecurringTask : "ditugaskan recurring"
    User ||--o{ TimeEntry : "mencatat waktu"
    User }o--o| Company : "active company"
    User }o--o{ CompanyMember : "anggota company"

    Workspace ||--o{ WorkspaceMember : "memiliki anggota"
    Workspace ||--o{ Task : "memiliki tugas"
    Workspace ||--o{ Note : "memiliki catatan"
    Workspace ||--o{ Label : "memiliki label"
    Workspace ||--o{ RecurringTask : "memiliki recurring"
    Workspace }o--o| Company : "terikat ke company"

    Task }o--|| Workspace : "berada di workspace"
    Task }o--o| Task : "parent/sub-task"
    Task }o--o| RecurringTask : "dibuat dari recurring"
    Task }o--o| Company : "terikat ke company"
    Task }o--o{ TimeEntry : "dicatat waktunya"

    Note }o--|| Workspace : "berada di workspace"
    Note }o--o| Note : "parent/child hierarki"
    Note }o--o| Company : "terikat ke company"

    RecurringTask }o--|| Workspace : "berada di workspace"
    RecurringTask ||--o{ Task : "menghasilkan task"

    Label }o--|| Workspace : "berada di workspace"

    WorkspaceMember }o--|| Workspace : "anggota dari"
    WorkspaceMember }o--|| User : "user yang bergabung"

    Company ||--o{ CompanyMember : "memiliki anggota"
    Company ||--o{ Workspace : "memiliki workspace tim"
```

***

## Entity Schema Reference

### Workspace Entity

Definisi lengkap field pada entitas `Workspace`:

| Field | Type | Required | Default | Deskripsi |
| - | - | - | - | - |
| `company_id` | `string` | No | `null` | ID perusahaan. Null untuk personal workspace |
| `name` | `string` | **Yes** | — | Nama workspace |
| `description` | `string` | No | — | Deskripsi workspace |
| `icon` | `string` | No | — | Icon workspace (emoji atau URL) |
| `color` | `string` | No | `#2563eb` | Warna tema workspace (hex color) |
| `owner_id` | `string` | **Yes** | — | ID pemilik workspace |
| `is_personal` | `boolean` | No | `false` | Apakah workspace bersifat pribadi |
| `settings` | `object` | No | — | Konfigurasi tambahan workspace |
| `settings.allow_public_sharing` | `boolean` | No | `false` | Izinkan berbagi konten ke publik |
| `settings.default_task_priority` | `enum` | No | `medium` | Prioritas default tugas baru |

### WorkspaceMember Entity

Definisi lengkap field pada entitas `WorkspaceMember`:

| Field | Type | Required | Default | Deskripsi |
| - | - | - | - | - |
| `workspace_id` | `string` | **Yes** | — | ID workspace yang diikuti |
| `user_id` | `string` | **Yes** | — | ID user yang bergabung |
| `role` | `enum` | No | `member` | Peran dalam workspace |
| `invited_by` | `string` | No | — | ID user yang mengundang |
| `joined_at` | `datetime` | No | — | Waktu bergabung |
| `description` | `string` | No | — | Catatan tambahan mengenai anggota (max 1000 karakter) |
| `permissions` | `object` | No | — | Hak akses detail dalam workspace |
| `permissions.can_create_tasks` | `boolean` | No | `true` | Dapat membuat tugas baru |
| `permissions.can_edit_tasks` | `boolean` | No | `true` | Dapat mengedit tugas |
| `permissions.can_delete_tasks` | `boolean` | No | `false` | Dapat menghapus tugas |
| `permissions.can_invite_members` | `boolean` | No | `false` | Dapat mengundang anggota baru |
| `permissions.can_access_all_tasks` | `boolean` | No | `false` | Akses ke semua task terlepas dari assignment |

### Task Entity

Definisi lengkap field pada entitas `Task`:

| Field | Type | Required | Default | Deskripsi |
| - | - | - | - | - |
| `workspace_id` | `string` | **Yes** | — | ID workspace tempat tugas berada |
| `company_id` | `string` | No | `null` | ID perusahaan (null untuk personal) |
| `title` | `string` | **Yes** | — | Judul tugas |
| `content` | `string` | No | — | Deskripsi/detail tugas |
| `status` | `enum` | No | `todo` | Status tugas |
| `priority` | `enum` | No | `medium` | Tingkat prioritas |
| `due_date` | `datetime` | No | — | Batas waktu penyelesaian |
| `assignee_id` | `string` | No | — | ID user yang ditugaskan |
| `tags` | `string[]` | No | — | Label/tag kategorisasi |
| `estimated_time` | `number` | No | — | Estimasi waktu dalam menit |
| `actual_time` | `number` | No | — | Waktu aktual yang dihabiskan (menit) |
| `is_time_tracked` | `boolean` | No | `false` | Apakah waktu dilacak |
| `time_entries` | `object[]` | No | — | Daftar entri waktu (start, end, duration) |
| `parent_task_id` | `string` | No | — | ID parent task untuk sub-tasks |
| `sub_tasks` | `string[]` | No | — | Array ID sub-task |
| `recurring_task_id` | `string` | No | — | ID recurring task jika dibuat otomatis |
| `completed_at` | `datetime` | No | — | Timestamp saat tugas selesai |
| `reminder_sent` | `boolean` | No | `false` | Apakah reminder sudah dikirim |
| `google_event_id` | `string` | No | — | ID event pada Google Calendar |
| `reminder_config` | `object` | No | — | Konfigurasi notifikasi sebelum tugas |

### Note Entity

Definisi lengkap field pada entitas `Note`:

| Field | Type | Required | Default | Deskripsi |
| - | - | - | - | - |
| `title` | `string` | **Yes** | — | Judul catatan |
| `content` | `string` | No | — | Konten catatan dalam format rich text |
| `workspace_id` | `string` | **Yes** | — | ID workspace |
| `company_id` | `string` | No | `null` | ID perusahaan (null untuk personal) |
| `parent_id` | `string` | No | — | ID catatan parent untuk hierarki |
| `icon` | `string` | No | — | Icon catatan |
| `is_template` | `boolean` | No | `false` | Apakah catatan template |
| `is_public` | `boolean` | No | `false` | Apakah catatan dapat diakses publik |
| `tags` | `string[]` | No | — | Tag untuk kategorisasi |
| `labels` | `string[]` | No | — | ID label yang diterapkan |
| `color` | `string` | No | — | Warna background catatan |
| `pinned` | `boolean` | No | `false` | Apakah catatan di-pin |
| `archived` | `boolean` | No | `false` | Apakah catatan diarsipkan |
| `reminder_time` | `datetime` | No | — | Waktu pengingat |
| `blocks` | `object[]` | No | — | Block-based content (text, heading, bullet, todo, dll) |

### Label Entity

Definisi lengkap field pada entitas `Label`:

| Field | Type | Required | Default | Deskripsi |
| - | - | - | - | - |
| `name` | `string` | **Yes** | — | Nama label |
| `color` | `string` | No | `#9CA3AF` | Warna label (hex color) |
| `icon` | `string` | No | `🏷️` | Icon label (emoji) |
| `description` | `string` | No | — | Penjelasan singkat kegunaan label (max 1000 karakter) |
| `user_id` | `string` | **Yes** | — | ID pemilik label |
| `workspace_id` | `string` | No | — | ID workspace |

### RecurringTask Entity

Definisi lengkap field pada entitas `RecurringTask`:

| Field | Type | Required | Default | Deskripsi |
| - | - | - | - | - |
| `task_id` | `string` | No | — | ID tugas template |
| `workspace_id` | `string` | **Yes** | — | ID workspace |
| `title` | `string` | **Yes** | — | Judul recurring task |
| `content` | `string` | No | — | Deskripsi tugas |
| `frequency` | `enum` | **Yes** | — | Frekuensi pengulangan |
| `interval` | `number` | No | `1` | Interval pengulangan (misal: setiap 2 minggu) |
| `days_of_week` | `number[]` | No | — | Hari dalam seminggu (0-6) |
| `day_of_month` | `number` | No | — | Tanggal dalam sebulan |
| `start_date` | `datetime` | **Yes** | — | Tanggal mulai recurring |
| `end_date` | `datetime` | No | — | Tanggal berakhir recurring |
| `is_active` | `boolean` | No | `true` | Apakah recurring aktif |
| `last_generated` | `datetime` | No | — | Terakhir kali task baru dibuat |
| `priority` | `enum` | No | `medium` | Tingkat prioritas |
| `assignee_id` | `string` | No | — | ID user yang ditugaskan |

### User Entity (Workspace-Related Fields)

Field pada entitas `User` yang berkaitan langsung dengan fitur Workspace:

| Field | Type | Required | Default | Deskripsi |
| - | - | - | - | - |
| `email` | `string` | **Yes** | — | Email pengguna |
| `full_name` | `string` | **Yes** | — | Nama lengkap pengguna |
| `role` | `enum` | No | — | Role di aplikasi: `admin` atau `user` |
| `active_company_id` | `string` | No | — | ID company yang sedang aktif |
| `productivity_score` | `number` | No | `0` | Skor produktivitas pengguna |
| `current_streak` | `number` | No | `0` | Streak hari berturut-turut menyelesaikan tugas |
| `longest_streak` | `number` | No | `0` | Streak terpanjang yang pernah dicapai |
| `last_active_date` | `date` | No | — | Tanggal terakhir aktif |
| `total_tasks_completed` | `number` | No | `0` | Total tugas yang pernah diselesaikan |
| `total_notes_created` | `number` | No | `0` | Total catatan yang pernah dibuat |
| `achievement_points` | `number` | No | `0` | Poin pencapaian |
| `user_level` | `number` | No | `1` | Level pengguna berdasarkan achievement points |
| `subscription_plan` | `enum` | No | `free` | Plan membership aktif |
| `preferences` | `object` | No | — | Preferensi user (theme, warna, wallpaper) |

***

## Referensi Enum

### Workspace Settings — `default_task_priority`

| Nilai | Deskripsi |
| - | - |
| `low` | Prioritas rendah — tugas bisa menunggu |
| `medium` | Prioritas sedang — standar default |
| `high` | Prioritas tinggi — perlu segera diselesaikan |
| `urgent` | Urgent — harus diselesaikan segera |

### WorkspaceMember — `role`

| Nilai | Deskripsi | Hak Akses Utama |
| - | - | - |
| `owner` | Pemilik workspace | Full control, bisa menghapus workspace |
| `admin` | Administrator workspace | Kelola anggota, konfigurasi, dan semua task |
| `member` | Anggota biasa | Buat dan edit task sendiri |
| `viewer` | Hanya lihat | Lihat task dan catatan, tidak bisa edit |

### Task — `status`

| Nilai | Deskripsi | Warna Indikator |
| - | - | - |
| `todo` | Belum dimulai | Abu-abu |
| `in_progress` | Sedang dikerjakan | Biru |
| `completed` | Sudah selesai (menunggu verifikasi) | Hijau |
| `done` | Selesai dan diverifikasi | Hijau tua |

### Task — `priority`

| Nilai | Deskripsi | Warna Indikator |
| - | - | - |
| `low` | Rendah — kerjakan saat ada waktu | Abu-abu |
| `medium` | Sedang — prioritas standar | Kuning |
| `high` | Tinggi — perlu segera | Oranye |
| `urgent` | Sangat urgent — harus sekarang | Merah |

### Note — `blocks[].type`

| Nilai | Deskripsi |
| - | - |
| `text` | Blok teks biasa |
| `heading` | Judul / sub-judul |
| `bullet` | Daftar bullet (unordered list) |
| `number` | Daftar bernomor (ordered list) |
| `todo` | Checkbox item (todo list) |
| `quote` | Kutipan / blockquote |
| `code` | Blok kode |
| `divider` | Garis pemisah |
| `image` | Gambar / ilustrasi |
| `table` | Tabel data |

### RecurringTask — `frequency`

| Nilai | Deskripsi | Contoh |
| - | - | - |
| `daily` | Setiap hari | Daily standup reminder |
| `weekly` | Setiap minggu | Weekly report (setiap Senin) |
| `monthly` | Setiap bulan | Monthly closing task |
| `yearly` | Setiap tahun | Annual review |

### User — `role`

| Nilai | Deskripsi |
| - | - |
| `admin` | Administrator aplikasi — akses penuh ke semua fitur |
| `user` | User biasa — akses sesuai workspace dan company |

### User — `subscription_plan`

| Nilai | Deskripsi |
| - | - |
| `free` | Plan gratis — fitur dasar |
| `pro` | Plan profesional — fitur lanjutan |
| `business` | Plan bisnis — untuk tim kecil |
| `advanced` | Plan advanced — fitur lengkap |
| `enterprise` | Plan enterprise — full access + dedicated support |

### User — `membership_duration_type`

| Nilai | Deskripsi |
| - | - |
| `monthly` | Langganan bulanan |
| `yearly` | Langganan tahunan |
| `custom` | Durasi kustom |
| `lifetime` | Akses seumur hidup |

### User — `admin_type`

| Nilai | Deskripsi |
| - | - |
| `owner` | Full access ke seluruh aplikasi |
| `basic` | Hanya transaksi produk digital |

### User — `admin_tier`

| Nilai | Deskripsi |
| - | - |
| `none` | Bukan admin company |
| `business` | Admin untuk tier business |
| `advanced` | Admin untuk tier advanced |
| `enterprise` | Admin untuk tier enterprise |

### Achievement — `achievement_type`

| Nilai | Deskripsi |
| - | - |
| `task_streak` | Menyelesaikan tugas berturut-turut |
| `first_task` | Menyelesaikan tugas pertama |
| `task_master` | Menyelesaikan banyak tugas |
| `note_taker` | Membuat banyak catatan |
| `financial_tracker` | Tracking keuangan secara konsisten |
| `collaborator` | Berkolaborasi dalam workspace tim |
| `early_bird` | Produktif di pagi hari |
| `night_owl` | Produktif di malam hari |
| `team_player` | Berkontribusi di banyak workspace |
| `productivity_champion` | Skor produktivitas tertinggi |

***

## Workspace Lifecycle

Diagram state berikut menggambarkan siklus hidup sebuah Workspace dari pembuatan hingga penghapusan:

```mermaid theme={null}
stateDiagram-v2
    [*] --> Created: User membuat workspace baru
    Created --> Active: Workspace dikonfigurasi dan siap digunakan
    
    state Active {
        [*] --> Configuring
        Configuring --> InUse: Setup selesai (nama, warna, settings)
        InUse --> ManagingMembers: Tambah anggota (untuk tim)
        ManagingMembers --> InUse: Anggota bergabung
        InUse --> ProcessingTasks: Task masuk dan dikerjakan
        ProcessingTasks --> InUse: Task diselesaikan
    }
    
    Active --> Archived: Tidak aktif dalam 90 hari
    Active --> Archived: Owner mengarsipkan manual
    Archived --> Active: Owner mengaktifkan kembali
    Archived --> Deleted: Owner menghapus workspace
    Active --> Deleted: Owner menghapus workspace
    
    Deleted --> [*]: Data dihapus permanen (soft delete)
    
    note right of Active
        Workspace personal selalu aktif
        selama user aktif menggunakan sistem
    end note
    
    note right of Archived
        Data tetap tersimpan tapi
        tidak muncul di sidebar
    end note
```

***

## Sequence Diagrams

### Flow: Navigasi Workspace

```mermaid theme={null}
sequenceDiagram
    participant U as User
    participant App as Aplikasi
    participant WS as Workspace Service
    participant DB as Database

    U->>App: Klik menu "Workspace" di sidebar
    App->>WS: GET /workspace/personal
    WS->>DB: Query workspace WHERE owner_id = user.id AND is_personal = true
    DB-->>WS: Return workspace data
    WS->>DB: Query tasks WHERE workspace_id = ws.id AND status != done
    DB-->>WS: Return active tasks
    WS->>DB: Query notes WHERE workspace_id = ws.id AND archived = false
    DB-->>WS: Return active notes
    WS-->>App: Return workspace + tasks + notes
    App-->>U: Render workspace dashboard
    U->>App: Klik task untuk detail
    App->>WS: GET /tasks/:id
    WS-->>App: Return task detail
    App-->>U: Show task detail panel
```

### Flow: Manajemen Anggota Workspace Tim

```mermaid theme={null}
sequenceDiagram
    participant Owner as Workspace Owner
    participant App as Aplikasi
    participant WS as Workspace Service
    participant Notif as Notification Service
    participant Invitee as User yang Diundang

    Owner->>App: Buka Settings > Members
    App->>WS: GET /workspace/:id/members
    WS-->>App: Return daftar anggota

    Owner->>App: Klik "Undang Anggota"
    Owner->>App: Masukkan email & pilih role
    App->>WS: POST /workspace/:id/invite
    WS->>WS: Validasi: pengirim adalah owner/admin
    WS->>WS: Buat WorkspaceMember record (role = member)
    WS->>Notif: Kirim notifikasi undangan
    Notif-->>Invitee: Push notification + email undangan

    Invitee->>App: Buka undangan
    Invitee->>App: Klik "Terima Undangan"
    App->>WS: PATCH /workspace-members/:id (joined_at = now)
    WS-->>App: Return updated membership
    App-->>Invitee: Redirect ke workspace

    Note over Owner,Invitee: Alternatif: Owner bisa hapus anggota
    Owner->>App: Klik "Hapus" pada anggota
    App->>WS: DELETE /workspace-members/:id
    WS->>WS: Validasi: pengirim adalah owner/admin
    WS-->>App: Return success
```

### Flow: Pembuatan Tugas Otomatis dari Modul

```mermaid theme={null}
sequenceDiagram
    participant Mod as Modul (POS/Inventory/Finance)
    participant TE as Task Engine
    participant WS as Workspace Service
    participant U as User (Assignee)
    participant Notif as Notification

    Mod->>TE: Trigger event (e.g., diskon >20%)
    TE->>TE: Tentukan assignee berdasarkan role
    TE->>TE: Tentukan prioritas berdasarkan nilai/urgensi
    TE->>TE: Tentukan deadline berdasarkan SLA
    TE->>WS: POST /tasks (auto-created)
    WS->>WS: Simpan task dengan status = todo
    WS->>Notif: Kirim notifikasi tugas baru
    Notif-->>U: Push notification + badge update
    U->>WS: Buka workspace, lihat tugas baru
    WS-->>U: Tampilkan task di Task Manager
    U->>WS: Update status ke in_progress
    U->>WS: Kerjakan dan update ke completed
    WS->>Mod: Callback: tugas selesai
```

### Flow: Pencatatan Waktu (Time Tracking)

```mermaid theme={null}
sequenceDiagram
    participant U as User
    participant Task as Task Manager
    participant TE as TimeEntry Service
    participant WS as Workspace
    participant DB as Database

    U->>Task: Buka detail tugas
    U->>Task: Klik "Mulai Timer"
    Task->>TE: POST /time-entries (start_time = now)
    TE->>DB: Simpan time entry (status = running)
    TE-->>Task: Return time entry ID
    Task-->>U: Tampilkan timer berjalan

    U->>Task: Klik "Berhenti Timer"
    Task->>TE: PATCH /time-entries/:id (end_time = now)
    TE->>TE: Hitung duration = end_time - start_time
    TE->>DB: Update time entry
    TE->>Task: PATCH /tasks/:id (actual_time += duration)
    Task->>DB: Update task actual_time
    TE-->>U: Tampilkan durasi tercatat
```

***

## RBAC — Hak Akses dalam Workspace

Tabel berikut merangkum hak akses berdasarkan role dalam WorkspaceMember:

| Aksi | `owner` | `admin` | `member` | `viewer` |
| - | - | - | - | - |
| **Lihat semua task** | ✅ | ✅ | ❌ (hanya assigned) | ✅ (read-only) |
| **Buat task baru** | ✅ | ✅ | ✅ (jika `can_create_tasks`) | ❌ |
| **Edit task sendiri** | ✅ | ✅ | ✅ (jika `can_edit_tasks`) | ❌ |
| **Edit task orang lain** | ✅ | ✅ | ❌ | ❌ |
| **Hapus task** | ✅ | ✅ | ❌ (kecuali `can_delete_tasks`) | ❌ |
| **Undang anggota** | ✅ | ✅ (jika `can_invite_members`) | ❌ | ❌ |
| **Hapus anggota** | ✅ | ✅ | ❌ | ❌ |
| **Ubah role anggota** | ✅ | ✅ | ❌ | ❌ |
| **Ubah settings workspace** | ✅ | ✅ | ❌ | ❌ |
| **Arsipkan/Hapus workspace** | ✅ | ❌ | ❌ | ❌ |
| **Lihat catatan semua anggota** | ✅ | ✅ (jika `can_access_all_tasks`) | ❌ | ✅ (read-only) |
| **Buat catatan** | ✅ | ✅ | ✅ | ❌ |
| **Edit catatan sendiri** | ✅ | ✅ | ✅ | ❌ |
| **Transfer kepemilikan** | ✅ | ❌ | ❌ | ❌ |

### Catatan Penting tentang RBAC

* **Personal workspace** (`is_personal = true`) tidak menggunakan RBAC karena hanya dimiliki oleh satu user
* **Workspace tim** menggunakan RBAC penuh berdasarkan `WorkspaceMember.role` dan `permissions`
* **Owner bisa lebih dari satu** — field `role` pada WorkspaceMember mendukung multiple owners
* **Permissions bersifat granular** — selain role, ada field `permissions` object yang bisa di-customize per anggota
* **CompanyMember permissions** terpisah dari WorkspaceMember permissions — user bisa memiliki hak akses berbeda di level company vs level workspace

***

## Company-Workspace Relationship

Workspace bisa terikat dengan Company melalui field `company_id`. Berikut adalah hubungan antara Company dan Workspace:

| Aspek | Personal Workspace | Company Workspace |
| - | - | - |
| **`company_id`** | `null` | Terisi ID company |
| **Kepemilikan** | Satu user | Company (owner = company owner) |
| **Anggota** | Hanya owner | Bisa punya banyak WorkspaceMember |
| **Data** | Tugas dan catatan personal | Tugas dan catatan terkait bisnis |
| **Integrasi** | Terbatas | Terhubung ke modul POS, Inventory, Finance, dll |
| **RBAC** | Tidak berlaku | Berlaku penuh |

### Company Entity (Ringkasan Field Relevan)

| Field | Type | Required | Deskripsi |
| - | - | - | - |
| `name` | `string` | **Yes** | Nama perusahaan |
| `owner_id` | `string` | **Yes** | ID owner perusahaan |
| `owner_email` | `string` | **Yes** | Email owner |
| `description` | `string` | No | Deskripsi perusahaan |
| `industry` | `enum` | No | Industri: retail, manufacturing, services, technology, food\_beverage, healthcare, education, other |
| `address` | `string` | No | Alamat perusahaan |
| `phone` | `string` | No | Nomor telepon |
| `email` | `string` | No | Email perusahaan |
| `website` | `string` | No | Website perusahaan |
| `logo_url` | `string` | No | URL logo perusahaan |
| `tax_id` | `string` | No | NPWP perusahaan |
| `employee_count` | `number` | No | Jumlah karyawan (default: 0) |
| `business_type` | `string` | No | Kategori bisnis dari onboarding |
| `active_modules` | `string` | No | JSON array ID modul aktif |
| `settings` | `object` | No | Konfigurasi perusahaan (jam kerja, kebijakan cuti, pajak, dll) |

***

## Achievement System di Workspace

Workspace terintegrasi dengan sistem Achievement untuk gamifikasi produktivitas:

| Achievement Type | Syarat | Poin |
| - | - | - |
| `first_task` | Menyelesaikan tugas pertama kali | 10 |
| `task_streak` | 7 hari berturut-turut menyelesaikan tugas | 25 |
| `task_master` | Menyelesaikan 100 tugas | 50 |
| `note_taker` | Membuat 50 catatan | 20 |
| `early_bird` | Menyelesaikan tugas sebelum jam 9 pagi (10x) | 15 |
| `night_owl` | Menyelesaikan tugas setelah jam 9 malam (10x) | 15 |
| `collaborator` | Bergabung di 3+ workspace tim | 30 |
| `team_player` | Berkontribusi di 5+ workspace tim | 50 |
| `productivity_champion` | Skor produktivitas > 1000 | 100 |
| `financial_tracker` | Tracking keuangan 30 hari berturut-turut | 25 |

**Level progression** dihitung berdasarkan akumulasi `achievement_points` pada entitas User.

***

## Best Practices

### Untuk Personal Workspace

1. **Review harian** — Luangkan 5 menit setiap pagi untuk melihat tugas pending dan merencanakan hari
2. **Gunakan label** — Kategorikan tugas dengan label agar mudah difilter dan dicari
3. **Pin catatan penting** — Pin catatan yang sering dibutuhkan agar mudah diakses
4. **Selesaikan tugas segera** — Jangan tunda menandai tugas selesai agar streak dan produktivitas terupdate
5. **Manfaatkan recurring task** — Untuk tugas rutin, buat recurring task agar otomatis dibuat setiap periode

### Untuk Workspace Tim

1. **Tentukan role dengan jelas** — Berikan role yang sesuai agar hak akses tepat
2. **Customize permissions** — Gunakan field `permissions` untuk kontrol granular per anggota
3. **Set default priority** — Atur `settings.default_task_priority` sesuai budaya kerja tim
4. **Monitor activity log** — Owner/admin sebaiknya memantau log aktivitas untuk transparansi
5. **Gunakan deskripsi anggota** — Isi field `description` pada WorkspaceMember untuk keterangan peran

***

**Related Documentation**:

* [Home](/docs/core/home)
* [Workspaces](/docs/core/workspaces)
* [Dashboard](/docs/core/dashboard)
* [Settings](/docs/core/settings)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.