Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

💬 Show a loading toast while scheduling a poll (#3401)

Luke Vella79524f2e2deb
diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.json
index d355132f4..4ee96c375 100644
--- a/apps/web/public/locales/en/app.json
+++ b/apps/web/public/locales/en/app.json
@@ -719,6 +719,7 @@
"pollRemovedWarningTitle": "Weren't expecting this link?",
"pollReopened": "Poll reopened",
"polls": "Polls",
+ "pollScheduled": "Poll scheduled",
"pollsListActions": "Actions",
"pollsListDates": "Dates",
"pollsListOrganizer": "Organizer",
@@ -819,6 +820,8 @@
"saving": "Saving...",
"schedulePoll": "Schedule",
"schedulePollDescription": "Select a final date for your event.",
+ "schedulePollError": "Failed to schedule poll",
+ "schedulingPoll": "Scheduling...",
"scrollLeft": "Scroll left",
"scrollRight": "Scroll right",
"searchEventsPlaceholder": "Search events by title...",
diff --git a/apps/web/src/features/poll/components/manage-poll/schedule-poll-dialog.tsx b/apps/web/src/features/poll/components/manage-poll/schedule-poll-dialog.tsx
index 8da68d91d..f30449be2 100644
--- a/apps/web/src/features/poll/components/manage-poll/schedule-poll-dialog.tsx
+++ b/apps/web/src/features/poll/components/manage-poll/schedule-poll-dialog.tsx
@@ -19,6 +19,7 @@ import {
FormLabel,
} from "@rallly/ui/form";
import { RadioGroup, RadioGroupItem } from "@rallly/ui/radio-group";
+import { toast } from "@rallly/ui/sonner";
import { useRouter } from "next/navigation";
import React from "react";
import { useForm } from "react-hook-form";
@@ -239,11 +240,27 @@ export function SchedulePollDialog(props: DialogProps) {
<SchedulePollForm
name="schedule-form"
onSubmit={(data) => {
- scheduleEvent.mutate({
- pollId: poll.id,
- optionId: data.selectedOptionId,
- notify: data.notify,
- });
+ toast.promise(
+ scheduleEvent.mutateAsync({
+ pollId: poll.id,
+ optionId: data.selectedOptionId,
+ notify: data.notify,
+ }),
+ {
+ loading: (
+ <Trans i18nKey="schedulingPoll" defaults="Scheduling..." />
+ ),
+ success: (
+ <Trans i18nKey="pollScheduled" defaults="Poll scheduled" />
+ ),
+ error: (
+ <Trans
+ i18nKey="schedulePollError"
+ defaults="Failed to schedule poll"
+ />
+ ),
+ },
+ );
props.onOpenChange?.(false);
}}
/>