Skip to content

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

♻️ Drop the legacy poll context from the Poll Admin header (#3591)

Luke Vellab25be0ee3536
diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/polls/[pollId]/layout.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/polls/[pollId]/layout.tsx
index 3cae203fb..fb6b7e058 100644
--- a/apps/web/src/app/[locale]/(space)/(dashboard)/polls/[pollId]/layout.tsx
+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/polls/[pollId]/layout.tsx
@@ -15,7 +15,6 @@ import {
} from "@/components/list-view";
import { PollProvider } from "@/features/poll/client";
import { PollAdminMenu } from "@/features/poll/components/poll-admin-menu";
-import { LegacyPollContextProvider } from "@/features/poll/components/poll-context-provider";
import { PollPrimaryActions } from "@/features/poll/components/poll-primary-actions";
import { loadAdminPoll, loadPoll } from "@/features/poll/loaders";
import { Trans } from "@/i18n/client";
@@ -41,7 +40,7 @@ async function PollHeaderActions({
const { pollId } = await params;
await loadPoll(pollId);
// The finalize dialog and CSV export read the whole poll, votes included,
- // from the poll context the legacy admin page provides.
+ // from the poll provider.
const { poll, participants, comments } = await loadAdminPoll(pollId);
return (
<PollProvider
@@ -50,10 +49,8 @@ async function PollHeaderActions({
comments={comments}
viewerRole="admin"
>
- <LegacyPollContextProvider>
- <PollAdminMenu />
- <PollPrimaryActions />
- </LegacyPollContextProvider>
+ <PollAdminMenu />
+ <PollPrimaryActions />
</PollProvider>
);
}
diff --git a/apps/web/src/features/poll/components/manage-poll/use-csv-exporter.ts b/apps/web/src/features/poll/components/manage-poll/use-csv-exporter.ts
index bf6756e0f..687ce8b8d 100644
--- a/apps/web/src/features/poll/components/manage-poll/use-csv-exporter.ts
+++ b/apps/web/src/features/poll/components/manage-poll/use-csv-exporter.ts
@@ -1,16 +1,24 @@
-import { useParticipants } from "@/features/poll/client";
-import { useOptions, usePoll } from "@/features/poll/components/poll-context";
+import { useParticipants, usePoll } from "@/features/poll/client";
+import { createOptionsContextValue } from "@/features/poll/components/poll-context";
import { useTranslation } from "@/i18n/client";
+import { useDateTimeConfig } from "@/lib/datetime/client";
import { dayjs } from "@/lib/dayjs";
export const useCsvExporter = () => {
- const { poll } = usePoll();
- const { options } = useOptions();
+ const poll = usePoll();
const { t } = useTranslation();
const { participants } = useParticipants();
+ const { locale, timeZone: viewerTimeZone, timeFormat } = useDateTimeConfig();
return {
exportToCsv: () => {
+ const { options } = createOptionsContextValue({
+ pollOptions: poll.options,
+ pollTimeZone: poll.timeZone,
+ locale,
+ timeZone: viewerTimeZone,
+ timeFormat,
+ });
// Excel only recognises a naive "YYYY-MM-DD HH:mm:ss" value (no "T", no
// offset) as a date, so the timezone lives in the header, not the cell.
// Use the IANA zone name rather than a fixed offset so the label stays