What will be the optional solution for the following use case: A dialog is opened on the screen, when clicking on an action button to send the dialog (after filling in details), in some cases a warning should appear. The user can either accept the warning and send the data or make changes in the dialog and send it again. Where, ideally, I will place the warnings? Should I have a toggle button?
I think, when sending this with error is possible, then displaying it on the top of the div element with error color defined in design system(red, pink, orange) and text, which inform user about warning and how to fix it.
I would suggest that such functionality is better implemented in-place, rather than opening an extra dialog.
If you present a subset of information in such dialog, it could be lacking some context. This would then require the user to have to remember what was on the previous screen, or they might click cancel to go back to the previous screen (to remind themselves of the context), and then need to remember which errors were listed in the dialog.
It would be better to show all the warnings in-place in the form, beside the relevant fields. A overall warning can be placed beside the submit button, and the button itself can be disabled until the issues with the data are fixed.
If you need to allow users to override the warnings, provide a checkbox to tick which re-enables the submit button.
You have a couple of options:
Alerts tend to attract the attention, yet require no further action from the user and could be ignored in some cases, and as @Franchesca has mentioned, this pattern can be placed directly where the issue stands.
Alerts with confirmation are similar to plain alerts, but they do require action from the user to ensure that they are aware of what is going on, the downside is that it's not recommended to place it with the field, but instead with the action, this means the user would still have to scan and find where the issue is.
Dialogs attract extra attention as they are stronger in terms of interruption, that's why many designers use it only when it is crucial, they can also generate disappointment, can you imagine a user filling the form for a long time, and just when they thought they are ready, they get this annoying message that notifies them with the bad news.
So let's look at how it goes from the user perspective: