Skip to Content

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

PropTypeDescription
openbooleanModal open state
onOpenChange(open: boolean) => voidOpen state handler
entityEntityEntity to flag as default
entityConfigEntityConfigEntity configuration
flagUrlstringAPI endpoint to set the default flag
onSuccess() => voidCalled after setting

The API endpoint should atomically unset the previous default and set the new one in a single transaction.


Last updated on