Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions platforms/eVoting/src/app/(app)/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,39 @@ export default function CreatePoll() {
const onSubmit = async (data: CreatePollForm) => {
setIsSubmitting(true);
try {
// Convert local deadline to UTC before sending to backend
let utcDeadline: string | undefined;
if (data.deadline) {
// Create a Date object from the local datetime-local input
const localDate = new Date(data.deadline);
// Convert to UTC ISO string
utcDeadline = localDate.toISOString();

// Show user the timezone conversion for transparency
const localTime = localDate.toLocaleString();
const utcTime = new Date(utcDeadline).toLocaleString('en-US', { timeZone: 'UTC' });

console.log('🕐 Deadline conversion:', {
local: data.deadline,
localTime,
utc: utcDeadline,
utcTime
});

toast({
title: "Timezone Converted",
description: `Local: ${localTime} → UTC: ${utcTime}`,
duration: 3000,
});
}

await pollApi.createPoll({
title: data.title,
mode: data.mode,
visibility: data.visibility,
groupId: data.groupId,
options: data.options.filter(option => option.trim() !== ""),
deadline: data.deadline || undefined
deadline: utcDeadline
});

toast({
Expand Down Expand Up @@ -225,7 +251,8 @@ export default function CreatePoll() {
required
/>
<p className="mt-1 text-sm text-gray-500">
Set a deadline for when voting will end.
Set a deadline for when voting will end.
<span className="text-blue-600 font-medium"> Note: Times are automatically converted to UTC for accurate backend processing.</span>
</p>
{errors.deadline && (
<p className="mt-1 text-sm text-red-600">
Expand Down
Loading