Karyawan · Impor dari Excel
Import employees from Excel in 4 steps: upload, match columns, check and fix rows, result.
$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/screen-karyawan-impor.jsonWhen to use
- Adding many employees at once (a new company, 10+ people): "Impor dari Excel" in the Karyawan header and in the first-run card.
- Any spreadsheet, not only the MaHR template: step 2 maps every file column to a MaHR column.
When not to use
- One or two people → Tambah karyawan (the Sheet on Karyawan · Daftar).
- Changing existing employees → Karyawan · Detail (the Ubah panels). The import adds people; it never updates them (duplicates are errors).
Built from
Usage
The screen is the page content only. Put it inside AppShell (once, in your layout) and pass your data.
Installation
Adds the screen, its parts and its types. The components it uses come with it (registry dependencies).
API
import { KaryawanImpor } from "@/components/screens/karyawan-impor/karyawan-impor"| Prop | Type | Default | Description |
|---|---|---|---|
step | "unggah" | "cocokkan" | "cek" | "selesai" | – | The app owns the step (in the URL). The body enters from the direction of travel; header row and action bar stay. |
data | ImporData | – | { mahrColumns, departments, banks, file, matches, cek?, result? }. The screen never reads the file; see types.ts. |
data.file | FileSlot: empty · reading { progress } · ready { rows, columns } · error { message } | – | Step 1 slot (one height in every state). Accept .xlsx and .csv, 5 MB, 1.000 rows; one message per cause with its fix. |
data.matches | ColumnMatch[] | – | One per file column: header, 2 samples, target, auto, skipped, note. "Lanjut" is disabled only while a required column (5 + Email kerja or Nomor HP) has no file column. |
data.cek · filter | CekData · "masalah" | "perbaiki" | "nanti" | "semua" | – | Counts + the rows of the filter, 10 per page (the app filters and pages). |
status · error · onRetry | "ready" | "loading" | "error" | – | Step 3 check: loading = "Memeriksa 48 baris…" + skeletons; error = LoadError with "Kode: IMP-500 · …". |
onSaveRow | (fix: RowFix) => RowFixErrors | void | Promise<…> | – | "Simpan baris" in Perbaiki baris. Resolve to field errors (e.g. duplicate email) to keep the panel open and shake them. |
importing · importFailed · onImport | boolean · boolean · () => void | – | "Impor 44 karyawan" → "Mengimpor…" (Kembali and Batal impor locked). Failed: danger Callout "Impor gagal", nothing saved, the primary retries. |
sendInvites · onSendInvitesChange | boolean · (on) => void | true | "Kirim undangan login" on step 3: by email, else WhatsApp. Selesai says how many went each way. |
onCancel | () => void | – | "Batal impor": at once while nothing was read; else after "Batalkan impor?" (destructive Dialog). |
listHref · listRender | string · ReactElement | "/karyawan" | "Lihat daftar karyawan →": the flow exit, a real link with the primary look (docs/buttons.md). |
helpHref | string | "/bantuan#impor-karyawan" | "Butuh bantuan?" opens in a new tab, so the chosen file is not lost. |
onDownloadTemplate · onDownloadFailed · onViewNotPayable · onImportAnother | () => void | – | Template file; failed rows (.xlsx with a "Masalah" column); Daftar filtered on belum bisa digaji; a clean step 1. |
defaultUi | { panelRow?, panelFailed?, columnsExpanded?, cancelAsking? } | – | Start UI state for previews and tests only. |