update toast

This commit is contained in:
MuslemRahimi 2025-03-04 17:32:43 +01:00
parent 5588179ac7
commit 94298ec33f
23 changed files with 283 additions and 92 deletions

View File

@ -39,12 +39,18 @@
async function sendFeedback() {
if (inputValue?.length === 0) {
toast.error("Please enter your feedback");
toast.error("Please enter your feedback", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
return;
}
if (rating?.length === 0 && category === "general") {
toast.error("Please select an emoji");
toast.error("Please select an emoji", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
return;
}
@ -68,7 +74,10 @@
body: JSON.stringify(postData),
});
toast.success("Thank you for your feedback");
toast.success("Thank you for your feedback", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
rating = "";
inputValue = "";

View File

@ -19,15 +19,24 @@
case "success":
case "redirect":
isClicked = true;
toast.success("Login successfully!");
toast.success("Login successfully!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
case "failure":
toast.error("Invalid credentials");
toast.error("Invalid credentials", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
case "error":
toast.error(result.error.message);
toast.error(result.error.message, {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
break;
default:
await update();
@ -57,15 +66,24 @@
case "success":
case "redirect":
isClicked = true;
toast.success("Registration successfully!");
toast.success("Registration successfully!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
case "failure":
toast.error("Invalid credentials");
toast.error("Invalid credentials", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
case "error":
toast.error(result.error.message);
toast.error(result.error.message, {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
break;
default:
await update();

View File

@ -18,7 +18,10 @@
async function handleCreateAlert() {
// Validate input locally.
if (targetPrice < 0) {
toast.error("Target Price must be above zero");
toast.error("Target Price must be above zero", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
return;
}
@ -54,18 +57,13 @@
});
// Use toast.promise to handle pending, success, and error states.
toast.promise(
promise,
{
loading: "Creating price alert...",
success: "Successfully created price alert",
error: (err) => err.message || "Failed to create price alert",
},
{
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
},
);
toast.promise(promise, {
loading: "Creating price alert...",
success: "Successfully created price alert",
error: (err) => err.message || "Failed to create price alert",
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
// Await the promise and handle the result.
try {

View File

@ -13,8 +13,9 @@
.then(() => console.log("Content shared successfully."))
.catch((error) => console.log("Error sharing content:", error));
} else {
toast.error("Sharing is not supported by your device", {
style: "background: #2A2E39; color: #fff;",
toast?.error("Sharing is not supported by your device", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
}

View File

@ -93,7 +93,10 @@
// Handle the error appropriately (e.g., show an error message to the user)
}
} else {
toast.error("Only for Pro Members");
toast.error("Only for Pro Members", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
}

View File

@ -269,7 +269,8 @@
saveRules();
} else {
toast.error("Only for Pro Members", {
style: "border-radius: 200px; background: #2A2E39; color: #fff;",
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
}

View File

@ -1193,7 +1193,7 @@
-->
<slot />
<Toaster position="bottom-center" />
<Toaster position="top-center" />
{#if Cookie && $showCookieConsent === true}
<Cookie />
{/if}

View File

@ -163,7 +163,8 @@
function handleAddRule() {
if (ruleName === "") {
toast.error("Please select a rule", {
style: "border-radius: 200px; background: #2A2E39; color: #fff;",
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
return;
}
@ -220,11 +221,6 @@
}
} else {
ruleOfList = [...ruleOfList, newRule];
/*
toast.success('Rule added', {
style: 'border-radius: 200px; background: #2A2E39; color: #fff;'
});
*/
shouldLoadWorker.set(true);
}
@ -444,7 +440,8 @@
}
} else {
toast.error(`Market is closed`, {
style: "border-radius: 200px; background: #2A2E39; color: #fff;",
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
}

View File

@ -58,7 +58,8 @@
?.catch((error) => console.log("Error sharing content:", error));
} else {
toast.error("Sharing is not supported by your device", {
style: "background: #2A2E39; color: #fff;",
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
}

View File

@ -64,7 +64,10 @@
isLoaded = true;
} catch (error) {
console.error("Error loading heatmap:", error);
toast.error("Failed to load heatmap. Please try again.");
toast.error("Failed to load heatmap. Please try again.", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
} finally {
isLoading = false;
}

View File

@ -61,7 +61,8 @@
?.catch((error) => console.log("Error sharing content:", error));
} else {
toast.error("Sharing is not supported by your device", {
style: "background: #2A2E39; color: #fff;",
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
}

View File

@ -24,21 +24,33 @@
break;
} else form?.notVerified === false;
{
toast.success("Login successfully!");
toast.success("Login successfully!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
}
case "redirect":
isClicked = true;
toast.success("Login successfully!");
toast.success("Login successfully!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
case "failure":
toast.error("Invalid credentials");
toast.error("Invalid credentials", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
case "error":
toast.error(result.error.message);
toast.error(result.error.message, {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
break;
default:
await update();

View File

@ -229,7 +229,10 @@
function handleAddRule() {
if (ruleName === "") {
toast.error("Please select a rule");
toast.error("Please select a rule", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
return;
}
@ -508,7 +511,10 @@
shouldLoadWorker.set(true);
}
} else {
toast.error(`Market is closed`);
toast.error(`Market is closed`, {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
}
@ -773,7 +779,10 @@
}
}
} else {
toast.error("Only for Pro Members");
toast.error("Only for Pro Members", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
};

View File

@ -83,9 +83,15 @@
async function handleDeleteTickers() {
if (numberOfChecked === 0) {
toast.error(`You need to select symbols before you can delete them`);
toast.error(`You need to select symbols before you can delete them`, {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
} else {
toast.success(`Price alerts deleted successfully`);
toast.success(`Price alerts deleted successfully`, {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
const symbolsToDelete = priceAlertList
?.filter((item) => deletePriceAlertList.includes(item.id))

View File

@ -412,7 +412,7 @@
class="w-28 transform ease-in-out duration-300"
style="transform: rotate(23deg);"
loading="lazy"
alt="pro tier"
alt="Pro tier Logo"
/>
<h2 class="text-4xl font-bold text-white">Pro Tier</h2>
</div>
@ -680,6 +680,34 @@
>Realtime Dark Pool Data</span
>
</li>
<li class="flex items-center space-x-3">
<!-- Icon -->
<svg
class="shrink-0 w-5 h-5"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 48 48"
><mask id="ipSSuccess0"
><g
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="4"
><path
fill="#fff"
stroke="#fff"
d="m24 4l5.253 3.832l6.503-.012l1.997 6.188l5.268 3.812L41 24l2.021 6.18l-5.268 3.812l-1.997 6.188l-6.503-.012L24 44l-5.253-3.832l-6.503.012l-1.997-6.188l-5.268-3.812L7 24l-2.021-6.18l5.268-3.812l1.997-6.188l6.503.012L24 4Z"
/><path stroke="#09090B" d="m17 24l5 5l10-10" /></g
></mask
><path
fill="#00FC50"
d="M0 0h48v48H0z"
mask="url(#ipSSuccess0)"
/></svg
>
<span class="text-white text-[1rem] font-semibold"
>Priority Support</span
>
</li>
</ol>
<div class="divider"></div>
<div class="m-auto w-full text-white text-sm mb-6">
@ -748,7 +776,7 @@
</label>
{/if}
<div class="m-auto w-full text-white text-[¹rem] mt-4">
<div class="m-auto w-full text-white text-[1rem] mt-4">
30 Day Money Back Guarantee
</div>
</div>

View File

@ -38,19 +38,31 @@
return async ({ result, update }) => {
switch (result.type) {
case "success":
toast.success("Subscription Cancelled successfully!");
toast.success("Subscription Cancelled successfully!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
case "redirect":
toast.success("Subscription Cancelled successfully!");
toast.success("Subscription Cancelled successfully!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
case "failure":
toast.error("Something went wrong.");
toast.error("Something went wrong.", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
case "error":
toast.error(result.error.message);
toast.error(result.error.message, {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
break;
default:
await update();
@ -72,19 +84,31 @@
return async ({ result, update }) => {
switch (result.type) {
case "success":
toast.success("Subscription Reactivate successfully!");
toast.success("Subscription Reactivate successfully!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
case "redirect":
toast.success("Subscription Reactivate successfully!");
toast.success("Subscription Reactivate successfully!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
case "failure":
toast.error("Something went wrong.");
toast.error("Something went wrong.", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
case "error":
toast.error(result.error.message);
toast.error(result.error.message, {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
break;
default:
await update();
@ -106,19 +130,31 @@
return async ({ result, update }) => {
switch (result.type) {
case "success":
toast.success("Changing to Annual Plan successfully!");
toast.success("Changing to Annual Plan successfully!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
case "redirect":
toast.success("Changing to Annual Plan successfully!");
toast.success("Changing to Annual Plan successfully!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
case "failure":
toast.error("Something went wrong.");
toast.error("Something went wrong.", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
case "error":
toast.error(result.error.message);
toast.error(result.error.message, {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
break;
default:
await update();
@ -161,9 +197,15 @@
const output = await subscribeUser();
if (output?.success === true) {
isPushSubscribed = true;
toast.success("Push notification activated successfully!");
toast.success("Push notification activated successfully!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
} else {
toast.error("Your browser does not support push notifications...");
toast.error("Your browser does not support push notifications...", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
loading = false;
}

View File

@ -17,15 +17,24 @@
case "success":
case "redirect":
isClicked = true;
toast.success("Registration successfully!");
toast.success("Registration successfully!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
case "failure":
toast.error("Invalid credentials");
toast.error("Invalid credentials", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
await update();
break;
case "error":
toast.error(result.error.message);
toast.error(result.error.message, {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
break;
default:
await update();

View File

@ -12,16 +12,16 @@
event.preventDefault();
try {
await pb.collection("users").requestPasswordReset(email);
toast.success("Password resetted. Check your emails!");
toast.success("Password resetted. Check your emails!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
goto("/login");
} catch (err) {
toast.error(
{ err },
{
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
},
);
toast.error(err, {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
}
</script>

View File

@ -1493,7 +1493,10 @@
const output = await response.json();
if (output === "success") {
toast.success("Strategy deleted successfully!");
toast.success("Strategy deleted successfully!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
strategyList =
strategyList?.filter((item) => item?.id !== selectedStrategy) ?? [];
@ -1528,7 +1531,10 @@
?.map((rule) => [rule.name, new Set(rule.value)]), // Create Map from filtered rules
);
} else if (output === "failure") {
toast.error("Something went wrong. Please try again");
toast.error("Something went wrong. Please try again", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
}
@ -1542,12 +1548,18 @@
const title = formData.get("title");
if (!title || title.length === 0) {
toast.error("Title cannot be empty!");
toast.error("Title cannot be empty!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
return;
}
if (title?.length > 100) {
toast.error("Title is too long. Keep it simple and concise bruv!");
toast.error("Title is too long. Keep it simple and concise bruv!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
return;
}
@ -1568,7 +1580,10 @@
const output = await response?.json();
if (output?.id && output?.id?.length !== 0) {
toast.success("Strategy created successfully!");
toast.success("Strategy created successfully!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
const closePopup = document.getElementById("addStrategy");
closePopup?.dispatchEvent(new MouseEvent("click"));
@ -1579,7 +1594,10 @@
strategyList?.unshift(output);
selectedPopularStrategy = "";
} else {
toast.error("Something went wrong. Please try again later!");
toast.error("Something went wrong. Please try again later!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
return output;
@ -1692,7 +1710,10 @@
function handleAddRule() {
if (ruleName === "") {
toast.error("Please select a rule");
toast.error("Please select a rule", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
return;
}
@ -1904,7 +1925,10 @@ const handleKeyDown = (event) => {
});
if (printToast === true) {
toast.success("Strategy saved!");
toast.success("Strategy saved!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
//isSaved = true;

View File

@ -63,7 +63,8 @@
?.catch((error) => console.log("Error sharing content:", error));
} else {
toast.error("Sharing is not supported by your device", {
style: "background: #2A2E39; color: #fff;",
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
}

View File

@ -50,14 +50,16 @@
?.message ?? "";
toast.error("Invalid credentials", {
style: "border-radius: 200px; background: #2A2E39; color: #fff;",
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
} else {
// Handle other errors
console.error("Unexpected error during registration:", error);
toast.error("An unexpected error occurred", {
style: "border-radius: 200px; background: #2A2E39; color: #fff;",
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
}

View File

@ -88,9 +88,15 @@
async function handleDelete() {
if (numberOfChecked === 0) {
toast.error(`You need to select symbols before you can delete them`);
toast.error(`You need to select symbols before you can delete them`, {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
} else if (data?.getOptionsWatchlist?.id?.length === 0) {
toast.error(`You need to select symbols before you can delete them`);
toast.error(`You need to select symbols before you can delete them`, {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
} else {
optionsWatchlist = optionsWatchlist?.filter(
(item) => !deleteOptionsId?.includes(item?.id),

View File

@ -297,12 +297,18 @@
// Validate the title input
if (!title || title.toString().trim().length === 0) {
toast.error("Title cannot be empty!");
toast.error("Title cannot be empty!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
return;
}
if (title.toString().length > 100) {
toast.error("Title is too long. Keep it simple and concise bruv!");
toast.error("Title is too long. Keep it simple and concise bruv!", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
return;
}
@ -408,7 +414,10 @@
}
} catch (error) {
console.error("Error:", error);
toast.error("An error occurred. Please try again later.");
toast.error("An error occurred. Please try again later.", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
}
@ -437,7 +446,10 @@
async function handleDeleteTickers() {
if (numberOfChecked === 0) {
toast.error(`You need to select symbols before you can delete them`);
toast.error(`You need to select symbols before you can delete them`, {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
} else {
watchList = watchList?.filter(
(item) => !deleteTickerList?.includes(item?.symbol),
@ -501,7 +513,10 @@
async function handleAddTicker(event, ticker) {
// Check if the ticker is already in the watchlist.
if (watchList?.some((item) => item?.symbol === ticker)) {
toast.error("This symbol is already in your watchlist");
toast.error("This symbol is already in your watchlist", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
inputValue = "";
return;
}
@ -536,6 +551,8 @@
loading: "Updating watchlist...",
success: "Watchlist updated successfully!",
error: (err) => err.message || "Failed to update watchlist",
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
try {
@ -594,7 +611,10 @@
saveRules();
} else {
toast.error("Only for Pro Members");
toast.error("Only for Pro Members", {
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
}