-
-
Notifications
You must be signed in to change notification settings - Fork 411
Closed
Description
Feature Request: Enhanced Configuration for toast.promise States
Problem Statement:
Currently, toast.promise supports basic customization of messages for different states (loading, success, error), but lacks support for detailed configurations like different actions and descriptions for each state. If a user tries to add a custom component to implement description and buttons, they lose the consistent styling provided by the library(also code becomes cumbersome).
Using data and error parameters to show a toast description, supplying an action based on the result of the promise would be really elegant. You can make user go to the output's page on success while open logs on error.
Note: Please let me know if there is an easy way of doing that but I'm missing.
Example Usage:
toast.promise(
new Promise((resolve, reject) => {
setTimeout(() => {
if (Math.random() > 0.2) {
resolve("Transcription successful");
} else {
reject("Transcription failed");
}
}, 1000);
}), {
loading: {
"Loading", {
description: "Please wait for a few seconds..."
}
},
success: {
"Transcription successful", {
description: "Your transcription has been completed successfully.",
action: {
label: "View transcription",
onClick: () => {
console.log("View transcription");
}
}
}
},
error: {
"Transcription failed", {
description: "Unable to complete your transcription at this time."
}
}
}
);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels