Quick Duplicate
QuickDuplicate opens a confirmation/edit modal for duplicating an entity. The user can optionally modify fields before confirming.
Import
import { QuickDuplicate } from "@phpcreation/frontend-crud-react-nextjs-bundle/components/QuickDuplicate";Usage
import { QuickDuplicate } from "...";
<QuickDuplicate
open={open}
onOpenChange={setOpen}
entity={entity}
entityConfig={entityConfig}
formFields={duplicateFormFields}
onSuccess={(newEntity) => {
setOpen(false);
router.push(`/entities/${newEntity.id}`);
}}
/>Props
| Prop | Type | Description |
|---|---|---|
open | boolean | Modal open state |
onOpenChange | (open: boolean) => void | Open state handler |
entity | Entity | Source entity to duplicate |
entityConfig | EntityConfig | Entity configuration |
formFields | FieldConfig[] | Fields shown for override before duplicating |
onSuccess | (newEntity: Entity) => void | Called after duplication |
Duplication POSTs to the entity API with the copied field values. Unique fields (e.g., name) are typically pre-cleared for the user to fill in.
Related
Last updated on