handclick button
How to perform a confirmation or validate an action before handleSave operation, in this code: const handleClick = async () => {
mutateUpdate({
resource: "rqp-requisicaos",
id: params.id!,
values: {
createnota: 1,
notaNumber: 1 - -
const itens = tableQueryResult?.data?.data ?? []; const loading = isLoading isFetching; const pdfOpenHandler = async () => { await refetch(); show(); };
if ( createnota === true ) { return ( <> <Button loading={loading} onClick={handleClick} type="primary" icon={<FilePdfOutlined />} > Create </Button> </> ); }
${totalId?.total}
,
//notaNumberYear: notaNumero ,
nota_datecreated: currentDate,
notaCreatedBy: identity?.id,
},
mutationMode: "optimistic",
invalidates: [/*"list", "many", */"detail"],
successNotification: false,
errorNotification: false,
});
}
const {
id,
status,
userId,
cod,
createdAt,
createnota
} = data?.data {};
const itens = tableQueryResult?.data?.data ?? []; const loading = isLoading isFetching; const pdfOpenHandler = async () => { await refetch(); show(); };
if ( createnota === true ) { return ( <> <Button loading={loading} onClick={handleClick} type="primary" icon={<FilePdfOutlined />} > Create </Button> </> ); }
5 Replies
Hi @Sly. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To perform a confirmation or validation before the
handleSave
operation, you can use a confirmation dialog. This can be done using Ant Design's Modal.confirm()
method. Here's an example of how you can modify your handleClick
function to include a confirmation dialog:
In this example, the onOk
function is where the mutateUpdate
function is called. This function will only be executed if the user clicks the OK button in the confirmation dialog.
Please note that this code is not directly from the knowledge sources provided, but it's a common way to handle confirmations in Ant Design, which is used in Refine.
For more information on how to use Ant Design's Modal component, you can check the Ant Design documentation (https://ant.design/components/modal/).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1172098337760096258> kapa.ai is still learning and improving, please let us know how it did by reacting below
secure-lavenderOP•10mo ago
@kapa.ai how to show a custom successNotification after click OK
Let me check the knowledge base for you. One moment! :books:
----------------------
To show a custom success notification after clicking OK, you can use the
successNotification
prop in your mutateUpdate
function. This prop allows you to customize the success notification that shows up when the data is fetched successfully.
Here's an example of how you can modify your handleClick
function to include a custom success notification:
In this example, the successNotification
function is where the custom success notification is defined. This function will only be executed if the data is fetched successfully.
Please note that this code is not directly from the knowledge sources provided, but it's a common way to handle notifications in Refine.
For more information on how to use Refine's useNotification
hook, you can check the Refine documentation (https://refine.dev/docs/api-references/hooks/notification/useNotification).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1172098337760096258> kapa.ai is still learning and improving, please let us know how it did by reacting below