Default Flag Modal
DefaultFlagModal opens a confirmation dialog for marking an entity as the “default” record in its collection (e.g., default currency, default tax rate). Setting a new default clears the previous one.
Import
import { DefaultFlagModal } from "@phpcreation/frontend-crud-react-nextjs-bundle/components/DefaultFlagModal";Usage
import { DefaultFlagModal } from "...";
<DefaultFlagModal
open={defaultOpen}
onOpenChange={setDefaultOpen}
entity={entity}
entityConfig={entityConfig}
flagUrl={`/api/currencies/${entity.id}/set-default`}
onSuccess={() => {
setDefaultOpen(false);
refetch();
}}
/>Props
| Prop | Type | Description |
|---|---|---|
open | boolean | Modal open state |
onOpenChange | (open: boolean) => void | Open state handler |
entity | Entity | Entity to flag as default |
entityConfig | EntityConfig | Entity configuration |
flagUrl | string | API endpoint to set the default flag |
onSuccess | () => void | Called after setting |
The API endpoint should atomically unset the previous default and set the new one in a single transaction.
Related
Last updated on