Compare commits
No commits in common. "576dea2f9871ab8ece9e32926a97c5c0b03012b3" and "f57a6d07f59826c22e93a893ce21769e2457695a" have entirely different histories.
576dea2f98
...
f57a6d07f5
@ -1,237 +0,0 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Modal, Tabs, Table, Button, Input, Tag, Form, Select, DatePicker, TimePicker, Space, Spin, Typography, message } from 'antd';
|
||||
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons';
|
||||
import { api } from '@/lib/api';
|
||||
import type { SchedulingPoll, PollsListResponse, SchedulingPollStatus } from '@/types/api';
|
||||
import { POLL_STATUS_COLORS, POLL_STATUS_LABELS } from '@/types/api';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const TIMEZONE_OPTIONS = [
|
||||
'America/Vancouver',
|
||||
'America/Edmonton',
|
||||
'America/Regina',
|
||||
'America/Winnipeg',
|
||||
'America/Toronto',
|
||||
'America/Halifax',
|
||||
'America/St_Johns',
|
||||
'America/New_York',
|
||||
'America/Chicago',
|
||||
'America/Denver',
|
||||
'America/Los_Angeles',
|
||||
];
|
||||
|
||||
interface PollInsertModalProps {
|
||||
open: boolean;
|
||||
onCancel: () => void;
|
||||
onInsert: (slug: string) => void;
|
||||
}
|
||||
|
||||
export function PollInsertModal({ open, onCancel, onInsert }: PollInsertModalProps) {
|
||||
const [polls, setPolls] = useState<SchedulingPoll[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [search, setSearch] = useState('');
|
||||
|
||||
// Create tab state
|
||||
const [form] = Form.useForm();
|
||||
const [creating, setCreating] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
setLoading(true);
|
||||
setSearch('');
|
||||
api.get<PollsListResponse>('/meeting-planner', { params: { limit: 100 } })
|
||||
.then(({ data }) => setPolls(data.polls || []))
|
||||
.catch(() => setPolls([]))
|
||||
.finally(() => setLoading(false));
|
||||
}, [open]);
|
||||
|
||||
const filtered = search
|
||||
? polls.filter((p) => {
|
||||
const q = search.toLowerCase();
|
||||
return p.title.toLowerCase().includes(q) || p.slug.toLowerCase().includes(q);
|
||||
})
|
||||
: polls;
|
||||
|
||||
const handleCreate = async (values: any) => {
|
||||
setCreating(true);
|
||||
try {
|
||||
const options = values.options.map((opt: any) => ({
|
||||
date: opt.date.format('YYYY-MM-DD'),
|
||||
startTime: opt.startTime.format('HH:mm'),
|
||||
endTime: opt.endTime.format('HH:mm'),
|
||||
}));
|
||||
const { data } = await api.post('/meeting-planner', {
|
||||
title: values.title,
|
||||
description: values.description,
|
||||
timezone: values.timezone,
|
||||
allowAnonymous: true,
|
||||
notifyOnVote: true,
|
||||
options,
|
||||
});
|
||||
message.success('Poll created');
|
||||
form.resetFields();
|
||||
onInsert(data.slug);
|
||||
} catch {
|
||||
message.error('Failed to create poll');
|
||||
} finally {
|
||||
setCreating(false);
|
||||
}
|
||||
};
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: 'Title',
|
||||
dataIndex: 'title',
|
||||
key: 'title',
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: 'Slug',
|
||||
dataIndex: 'slug',
|
||||
key: 'slug',
|
||||
width: 160,
|
||||
ellipsis: true,
|
||||
render: (slug: string) => <Text copyable code style={{ fontSize: 12 }}>{slug}</Text>,
|
||||
},
|
||||
{
|
||||
title: 'Status',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
width: 90,
|
||||
render: (status: SchedulingPollStatus) => (
|
||||
<Tag color={POLL_STATUS_COLORS[status]}>{POLL_STATUS_LABELS[status]}</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: 'Options',
|
||||
key: 'options',
|
||||
width: 70,
|
||||
align: 'center' as const,
|
||||
render: (_: unknown, r: SchedulingPoll) => r._count?.options ?? '–',
|
||||
},
|
||||
{
|
||||
title: 'Votes',
|
||||
key: 'votes',
|
||||
width: 60,
|
||||
align: 'center' as const,
|
||||
render: (_: unknown, r: SchedulingPoll) => r._count?.votes ?? '–',
|
||||
},
|
||||
{
|
||||
title: '',
|
||||
key: 'action',
|
||||
width: 80,
|
||||
render: (_: unknown, record: SchedulingPoll) => (
|
||||
<Button type="primary" size="small" onClick={() => onInsert(record.slug)}>
|
||||
Insert
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<Modal
|
||||
open={open}
|
||||
onCancel={onCancel}
|
||||
title="Insert Scheduling Poll"
|
||||
footer={null}
|
||||
width={700}
|
||||
destroyOnClose
|
||||
>
|
||||
<Tabs
|
||||
items={[
|
||||
{
|
||||
key: 'existing',
|
||||
label: 'Select Existing',
|
||||
children: (
|
||||
<>
|
||||
<Input.Search
|
||||
placeholder="Search by title or slug…"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
allowClear
|
||||
style={{ marginBottom: 12 }}
|
||||
/>
|
||||
{loading ? (
|
||||
<div style={{ textAlign: 'center', padding: 32 }}><Spin /></div>
|
||||
) : (
|
||||
<Table
|
||||
dataSource={filtered}
|
||||
columns={columns}
|
||||
rowKey="id"
|
||||
size="small"
|
||||
pagination={false}
|
||||
scroll={{ y: 300 }}
|
||||
locale={{ emptyText: search ? 'No polls match your search' : 'No polls found — create one in the "Create New" tab' }}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'create',
|
||||
label: 'Create New',
|
||||
children: (
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
onFinish={handleCreate}
|
||||
initialValues={{ timezone: 'America/Edmonton', options: [{}] }}
|
||||
size="small"
|
||||
>
|
||||
<Form.Item name="title" label="Title" rules={[{ required: true, message: 'Title is required' }]}>
|
||||
<Input placeholder="e.g. Team standup scheduling" />
|
||||
</Form.Item>
|
||||
<Form.Item name="description" label="Description">
|
||||
<Input.TextArea rows={2} placeholder="Optional description" />
|
||||
</Form.Item>
|
||||
<Form.Item name="timezone" label="Timezone" rules={[{ required: true }]}>
|
||||
<Select options={TIMEZONE_OPTIONS.map((tz) => ({ label: tz, value: tz }))} />
|
||||
</Form.Item>
|
||||
|
||||
<Text strong style={{ display: 'block', marginBottom: 8 }}>Date/Time Options</Text>
|
||||
<Form.List name="options" rules={[{
|
||||
validator: async (_, opts) => {
|
||||
if (!opts || opts.length < 1) throw new Error('At least one option');
|
||||
},
|
||||
}]}>
|
||||
{(fields, { add, remove }) => (
|
||||
<>
|
||||
{fields.map(({ key, name, ...rest }) => (
|
||||
<Space key={key} align="start" style={{ display: 'flex', marginBottom: 8 }}>
|
||||
<Form.Item {...rest} name={[name, 'date']} rules={[{ required: true, message: 'Date' }]} style={{ marginBottom: 0 }}>
|
||||
<DatePicker placeholder="Date" />
|
||||
</Form.Item>
|
||||
<Form.Item {...rest} name={[name, 'startTime']} rules={[{ required: true, message: 'Start' }]} style={{ marginBottom: 0 }}>
|
||||
<TimePicker format="HH:mm" placeholder="Start" minuteStep={15} />
|
||||
</Form.Item>
|
||||
<Form.Item {...rest} name={[name, 'endTime']} rules={[{ required: true, message: 'End' }]} style={{ marginBottom: 0 }}>
|
||||
<TimePicker format="HH:mm" placeholder="End" minuteStep={15} />
|
||||
</Form.Item>
|
||||
{fields.length > 1 && (
|
||||
<Button type="text" danger icon={<DeleteOutlined />} onClick={() => remove(name)} />
|
||||
)}
|
||||
</Space>
|
||||
))}
|
||||
<Form.Item style={{ marginBottom: 12 }}>
|
||||
<Button type="dashed" onClick={() => add()} block icon={<PlusOutlined />}>
|
||||
Add Option
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</>
|
||||
)}
|
||||
</Form.List>
|
||||
|
||||
<Form.Item style={{ marginBottom: 0, textAlign: 'right' }}>
|
||||
<Button type="primary" htmlType="submit" loading={creating}>
|
||||
Create & Insert
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@ -82,7 +82,6 @@ import { ProductInsertModal } from '@/components/payments/ProductInsertModal';
|
||||
import type { ProductInsertResult } from '@/components/payments/ProductInsertModal';
|
||||
import { AdPickerModal } from '@/components/media/AdPickerModal';
|
||||
import type { AdInsertResult } from '@/components/media/AdPickerModal';
|
||||
import { PollInsertModal } from '@/components/scheduling/PollInsertModal';
|
||||
|
||||
type LayoutMode = 'split' | 'editor' | 'preview';
|
||||
type PreviewMode = 'desktop' | 'mobile';
|
||||
@ -594,6 +593,7 @@ export default function DocsPage() {
|
||||
const [productInsertOpen, setProductInsertOpen] = useState(false);
|
||||
const [adPickerOpen, setAdPickerOpen] = useState(false);
|
||||
const [pollInsertOpen, setPollInsertOpen] = useState(false);
|
||||
const [pollSlugInput, setPollSlugInput] = useState('');
|
||||
const [dragOver, setDragOver] = useState(false);
|
||||
const dragCounter = useRef(0);
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
@ -820,8 +820,9 @@ export default function DocsPage() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Scheduling poll — opens picker modal
|
||||
// Scheduling poll — opens slug input modal
|
||||
if (snippetId === 'scheduling-poll') {
|
||||
setPollSlugInput('');
|
||||
setPollInsertOpen(true);
|
||||
return;
|
||||
}
|
||||
@ -1068,7 +1069,10 @@ export default function DocsPage() {
|
||||
setAdPickerOpen(false);
|
||||
}, []);
|
||||
|
||||
const handlePollInsert = useCallback((slug: string) => {
|
||||
const handlePollInsert = useCallback(() => {
|
||||
const slug = pollSlugInput.trim();
|
||||
if (!slug) return;
|
||||
|
||||
const html = `<div class="scheduling-poll-block" data-poll-slug="${slug}" data-show-comments="true" data-title="Vote on a Meeting Time">\n Loading poll...\n</div>`;
|
||||
|
||||
const ed = monacoEditorRef.current;
|
||||
@ -1079,7 +1083,8 @@ export default function DocsPage() {
|
||||
}
|
||||
}
|
||||
setPollInsertOpen(false);
|
||||
}, []);
|
||||
setPollSlugInput('');
|
||||
}, [pollSlugInput]);
|
||||
|
||||
const handleCtxMenuClick = useCallback((snippetId: string) => {
|
||||
setCtxMenu(null);
|
||||
@ -2214,11 +2219,25 @@ export default function DocsPage() {
|
||||
/>
|
||||
|
||||
{/* Scheduling Poll Insert Modal */}
|
||||
<PollInsertModal
|
||||
<Modal
|
||||
title="Insert Scheduling Poll"
|
||||
open={pollInsertOpen}
|
||||
onCancel={() => setPollInsertOpen(false)}
|
||||
onInsert={handlePollInsert}
|
||||
/>
|
||||
onOk={handlePollInsert}
|
||||
onCancel={() => { setPollInsertOpen(false); setPollSlugInput(''); }}
|
||||
okText="Insert"
|
||||
okButtonProps={{ disabled: !pollSlugInput.trim() }}
|
||||
>
|
||||
<Typography.Text type="secondary" style={{ display: 'block', marginBottom: 12 }}>
|
||||
Enter the slug of the scheduling poll to embed. You can find poll slugs in the Meeting Planner admin page.
|
||||
</Typography.Text>
|
||||
<Input
|
||||
placeholder="e.g. team-meeting-march"
|
||||
value={pollSlugInput}
|
||||
onChange={(e) => setPollSlugInput(e.target.value)}
|
||||
onPressEnter={handlePollInsert}
|
||||
autoFocus
|
||||
/>
|
||||
</Modal>
|
||||
|
||||
{/* Custom right-click context menu with submenus */}
|
||||
{ctxMenu && (
|
||||
|
||||
@ -233,17 +233,6 @@ export default function MeetingPlannerPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleRemoveVoter = async (voterKey: string) => {
|
||||
if (!selectedPoll) return;
|
||||
try {
|
||||
await api.delete(`/meeting-planner/${selectedPoll.id}/voters/${encodeURIComponent(voterKey)}`);
|
||||
message.success('Voter removed');
|
||||
fetchPollDetail(selectedPoll.id);
|
||||
} catch {
|
||||
message.error('Failed to remove voter');
|
||||
}
|
||||
};
|
||||
|
||||
const openEditDrawer = async (id: string) => {
|
||||
try {
|
||||
const { data } = await api.get<PollDetailResponse>(`/meeting-planner/${id}`);
|
||||
@ -294,23 +283,13 @@ export default function MeetingPlannerPage() {
|
||||
|
||||
const handleUpdateOption = async (optionId: string, field: string, value: string) => {
|
||||
if (!editPoll) return;
|
||||
// Optimistic update: immediately reflect the change in local state
|
||||
const optimisticDate = field === 'date' ? value + 'T00:00:00.000Z' : undefined;
|
||||
setEditPoll((prev) => prev ? {
|
||||
...prev,
|
||||
options: prev.options.map((opt: any) =>
|
||||
opt.id === optionId
|
||||
? { ...opt, [field]: optimisticDate ?? value }
|
||||
: opt
|
||||
),
|
||||
} : prev);
|
||||
try {
|
||||
await api.put(`/meeting-planner/${editPoll.id}/options/${optionId}`, { [field]: value });
|
||||
message.success('Option updated');
|
||||
} catch {
|
||||
// Revert on failure by refetching
|
||||
// Refresh edit poll data
|
||||
const { data } = await api.get<PollDetailResponse>(`/meeting-planner/${editPoll.id}`);
|
||||
setEditPoll(data);
|
||||
message.success('Option updated');
|
||||
} catch {
|
||||
message.error('Failed to update option');
|
||||
}
|
||||
};
|
||||
@ -420,7 +399,6 @@ export default function MeetingPlannerPage() {
|
||||
<th style={{ padding: '8px 12px', borderBottom: '2px solid #303030', textAlign: 'left', minWidth: 120 }}>
|
||||
Voter
|
||||
</th>
|
||||
<th style={{ padding: '8px 4px', borderBottom: '2px solid #303030', width: 36 }} />
|
||||
{poll.options.map((opt) => (
|
||||
<th
|
||||
key={opt.id}
|
||||
@ -447,14 +425,6 @@ export default function MeetingPlannerPage() {
|
||||
<td style={{ padding: '6px 12px', borderBottom: '1px solid #303030' }}>
|
||||
{voter.name}
|
||||
</td>
|
||||
<td style={{ padding: '6px 4px', borderBottom: '1px solid #303030', textAlign: 'center' }}>
|
||||
<Popconfirm
|
||||
title={`Remove ${voter.name}'s votes?`}
|
||||
onConfirm={() => handleRemoveVoter(voter.voterKey)}
|
||||
>
|
||||
<Button size="small" type="text" danger icon={<DeleteOutlined />} />
|
||||
</Popconfirm>
|
||||
</td>
|
||||
{poll.options.map((opt) => {
|
||||
const value = voter.votes[opt.id] as PollVoteValue | undefined;
|
||||
return (
|
||||
@ -485,7 +455,6 @@ export default function MeetingPlannerPage() {
|
||||
{/* Tally row */}
|
||||
<tr style={{ fontWeight: 600 }}>
|
||||
<td style={{ padding: '8px 12px', borderTop: '2px solid #303030' }}>Score</td>
|
||||
<td style={{ borderTop: '2px solid #303030' }} />
|
||||
{poll.options.map((opt) => (
|
||||
<td
|
||||
key={opt.id}
|
||||
|
||||
@ -15,7 +15,6 @@ import {
|
||||
Space,
|
||||
Divider,
|
||||
Alert,
|
||||
Collapse,
|
||||
} from 'antd';
|
||||
import {
|
||||
CalendarOutlined,
|
||||
@ -23,7 +22,6 @@ import {
|
||||
EnvironmentOutlined,
|
||||
CheckCircleOutlined,
|
||||
SendOutlined,
|
||||
EyeOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import axios from 'axios';
|
||||
import dayjs from 'dayjs';
|
||||
@ -60,7 +58,6 @@ export default function SchedulingPollPage() {
|
||||
const [votes, setVotes] = useState<Record<string, PollVoteValue>>({});
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const [hasVoted, setHasVoted] = useState(false);
|
||||
const [voteSuccess, setVoteSuccess] = useState(false);
|
||||
|
||||
// Comment form state
|
||||
const [commentName, setCommentName] = useState(user?.name || '');
|
||||
@ -101,7 +98,6 @@ export default function SchedulingPollPage() {
|
||||
useEffect(() => { fetchPoll(); }, [fetchPoll]);
|
||||
|
||||
const handleVoteChange = (optionId: string, value: PollVoteValue) => {
|
||||
setVoteSuccess(false);
|
||||
setVotes((prev) => ({ ...prev, [optionId]: value }));
|
||||
};
|
||||
|
||||
@ -137,7 +133,6 @@ export default function SchedulingPollPage() {
|
||||
|
||||
message.success(hasVoted ? 'Votes updated' : 'Votes submitted');
|
||||
setHasVoted(true);
|
||||
setVoteSuccess(true);
|
||||
fetchPoll();
|
||||
} catch (err: any) {
|
||||
message.error(err.response?.data?.error?.message || 'Failed to submit votes');
|
||||
@ -297,66 +292,6 @@ export default function SchedulingPollPage() {
|
||||
)}
|
||||
</Card>
|
||||
))}
|
||||
|
||||
{/* Mobile: collapsible voter responses */}
|
||||
{(poll.voters?.length ?? 0) > 0 && (
|
||||
<Collapse
|
||||
ghost
|
||||
style={{ marginBottom: 12 }}
|
||||
items={[{
|
||||
key: 'responses',
|
||||
label: (
|
||||
<Space>
|
||||
<EyeOutlined />
|
||||
<span>View Responses ({poll.voters?.length})</span>
|
||||
</Space>
|
||||
),
|
||||
children: (
|
||||
<div>
|
||||
{poll.voters?.map((voter, i) => (
|
||||
<div
|
||||
key={i}
|
||||
style={{
|
||||
padding: '10px 0',
|
||||
borderBottom: i < (poll.voters?.length ?? 0) - 1 ? '1px solid #252525' : undefined,
|
||||
}}
|
||||
>
|
||||
<Text strong style={{ display: 'block', marginBottom: 6 }}>{voter.name}</Text>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>
|
||||
{poll.options?.map((opt) => {
|
||||
const value = voter.votes[opt.id] as PollVoteValue | undefined;
|
||||
return value ? (
|
||||
<Tag
|
||||
key={opt.id}
|
||||
color={value === 'YES' ? 'green' : value === 'IF_NEED_BE' ? 'gold' : 'default'}
|
||||
style={{ fontSize: 11 }}
|
||||
>
|
||||
{dayjs(opt.date).format('M/D')} {VOTE_VALUE_LABELS[value]}
|
||||
</Tag>
|
||||
) : null;
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
{/* Score summary */}
|
||||
<Divider style={{ margin: '8px 0' }} />
|
||||
<Text strong style={{ display: 'block', marginBottom: 6 }}>Scores</Text>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 6 }}>
|
||||
{poll.options?.map((opt) => (
|
||||
<Tag
|
||||
key={opt.id}
|
||||
color={opt.score === bestScore && bestScore > 0 ? 'green' : 'default'}
|
||||
style={{ fontSize: 11 }}
|
||||
>
|
||||
{dayjs(opt.date).format('M/D')}: {opt.score ?? 0}
|
||||
</Tag>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
}]}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
/* Desktop: voting matrix */
|
||||
@ -507,18 +442,6 @@ export default function SchedulingPollPage() {
|
||||
>
|
||||
{hasVoted ? 'Update Votes' : 'Submit Votes'}
|
||||
</Button>
|
||||
|
||||
{voteSuccess && (
|
||||
<Alert
|
||||
type="success"
|
||||
message="Your votes have been recorded!"
|
||||
showIcon
|
||||
icon={<CheckCircleOutlined />}
|
||||
style={{ marginTop: 12 }}
|
||||
closable
|
||||
onClose={() => setVoteSuccess(false)}
|
||||
/>
|
||||
)}
|
||||
</Card>
|
||||
)}
|
||||
|
||||
|
||||
@ -2849,7 +2849,6 @@ export interface PollDetailResponse extends SchedulingPoll {
|
||||
comments: SchedulingPollComment[];
|
||||
voters: Array<{
|
||||
name: string;
|
||||
voterKey: string;
|
||||
votes: Record<string, PollVoteValue>;
|
||||
}>;
|
||||
}
|
||||
|
||||
@ -50,7 +50,6 @@ const ANT_ICON_TO_MATERIAL: Record<string, string> = {
|
||||
HomeOutlined: 'home',
|
||||
SendOutlined: 'send',
|
||||
EnvironmentOutlined: 'place',
|
||||
ScheduleOutlined: 'schedule',
|
||||
CalendarOutlined: 'event',
|
||||
PlayCircleOutlined: 'play_circle',
|
||||
HeartOutlined: 'favorite_border',
|
||||
@ -61,18 +60,6 @@ const ANT_ICON_TO_MATERIAL: Record<string, string> = {
|
||||
BookOutlined: 'menu_book',
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert an Ant Design icon name to a Material Icons ligature name.
|
||||
* Uses the explicit mapping first, then falls back to stripping the
|
||||
* Outlined/Filled/TwoTone suffix and converting PascalCase to snake_case.
|
||||
*/
|
||||
function toMaterialIcon(antIcon: string): string {
|
||||
if (ANT_ICON_TO_MATERIAL[antIcon]) return ANT_ICON_TO_MATERIAL[antIcon];
|
||||
// Fallback: strip suffix, convert PascalCase → snake_case
|
||||
const base = antIcon.replace(/(Outlined|Filled|TwoTone)$/, '');
|
||||
return base.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
|
||||
}
|
||||
|
||||
interface NavConfigItem {
|
||||
id: string;
|
||||
label: string;
|
||||
@ -428,7 +415,7 @@ class HeaderBuilderService {
|
||||
id: item.id,
|
||||
label: item.label,
|
||||
path: resolvedPath,
|
||||
icon: toMaterialIcon(item.icon),
|
||||
icon: ANT_ICON_TO_MATERIAL[item.icon] || item.icon,
|
||||
enabled: true,
|
||||
order: item.order,
|
||||
type: item.type,
|
||||
|
||||
@ -124,16 +124,6 @@ adminRouter.post('/:id/convert-to-event', async (req: Request, res: Response, ne
|
||||
} catch (err) { next(err); }
|
||||
});
|
||||
|
||||
// Remove voter
|
||||
adminRouter.delete('/:id/voters/:voterKey', async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const id = req.params.id as string;
|
||||
const voterKey = decodeURIComponent(req.params.voterKey as string);
|
||||
const poll = await meetingPlannerService.removeVoter(id, voterKey);
|
||||
res.json(poll);
|
||||
} catch (err) { next(err); }
|
||||
});
|
||||
|
||||
// Delete comment
|
||||
adminRouter.delete('/:id/comments/:commentId', async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
|
||||
@ -61,11 +61,11 @@ function groupVotesByVoter(votes: Array<{
|
||||
optionId: string;
|
||||
value: PollVoteValue;
|
||||
}>) {
|
||||
const voterMap = new Map<string, { name: string; voterKey: string; votes: Record<string, PollVoteValue> }>();
|
||||
const voterMap = new Map<string, { name: string; votes: Record<string, PollVoteValue> }>();
|
||||
for (const vote of votes) {
|
||||
const key = vote.userId || vote.voterToken || vote.voterName;
|
||||
if (!voterMap.has(key)) {
|
||||
voterMap.set(key, { name: vote.voterName, voterKey: key, votes: {} });
|
||||
voterMap.set(key, { name: vote.voterName, votes: {} });
|
||||
}
|
||||
voterMap.get(key)!.votes[vote.optionId] = vote.value;
|
||||
}
|
||||
@ -343,25 +343,6 @@ export const meetingPlannerService = {
|
||||
});
|
||||
},
|
||||
|
||||
async removeVoter(pollId: string, voterKey: string) {
|
||||
const poll = await prisma.schedulingPoll.findUnique({ where: { id: pollId } });
|
||||
if (!poll) throw new AppError(404, 'Poll not found');
|
||||
|
||||
const result = await prisma.schedulingPollVote.deleteMany({
|
||||
where: {
|
||||
pollId,
|
||||
OR: [
|
||||
{ userId: voterKey },
|
||||
{ voterToken: voterKey },
|
||||
{ voterName: voterKey, userId: null, voterToken: null },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
if (result.count === 0) throw new AppError(404, 'Voter not found');
|
||||
return this.findById(pollId);
|
||||
},
|
||||
|
||||
async deleteComment(pollId: string, commentId: string) {
|
||||
const comment = await prisma.schedulingPollComment.findFirst({
|
||||
where: { id: commentId, pollId },
|
||||
|
||||
@ -13,9 +13,11 @@
|
||||
<div class="cm-header-nav__links-inner">
|
||||
<a href="#" data-path="/" class="cm-header-nav__link" data-nav-id="home" target="_blank" rel="noopener noreferrer"><span class="material-icons-outlined">home</span><span class="cm-header-nav__label">Home</span></a>
|
||||
<a href="#" data-path="/campaigns" class="cm-header-nav__link" data-nav-id="campaigns"><span class="material-icons-outlined">send</span><span class="cm-header-nav__label">Campaigns</span></a>
|
||||
<a href="#" data-path="/shifts" class="cm-header-nav__link" data-nav-id="shifts"><span class="material-icons-outlined">schedule</span><span class="cm-header-nav__label">Shifts</span></a>
|
||||
<a href="#" data-path="/map" class="cm-header-nav__link" data-nav-id="map"><span class="material-icons-outlined">place</span><span class="cm-header-nav__label">Map</span></a>
|
||||
<a href="#" data-path="/shifts" class="cm-header-nav__link" data-nav-id="shifts"><span class="material-icons-outlined">event</span><span class="cm-header-nav__label">Shifts</span></a>
|
||||
<a href="#" data-path="/events" class="cm-header-nav__link" data-nav-id="events" target="_blank" rel="noopener noreferrer"><span class="material-icons-outlined">event</span><span class="cm-header-nav__label">Events</span></a>
|
||||
<a href="#" data-path="/gallery" class="cm-header-nav__link" data-nav-id="gallery"><span class="material-icons-outlined">play_circle</span><span class="cm-header-nav__label">Gallery</span></a>
|
||||
<a href="#" data-path="/pricing" class="cm-header-nav__link" data-nav-id="pricing"><span class="material-icons-outlined">attach_money</span><span class="cm-header-nav__label">Pricing</span></a>
|
||||
<a href="#" data-path="/shop" class="cm-header-nav__link" data-nav-id="shop"><span class="material-icons-outlined">shopping_bag</span><span class="cm-header-nav__label">Shop</span></a>
|
||||
<a href="#" data-path="/donate" class="cm-header-nav__link" data-nav-id="donate"><span class="material-icons-outlined">favorite_border</span><span class="cm-header-nav__label">Donate</span></a>
|
||||
<a href="/" class="cm-header-nav__link" data-nav-id="landing"><span class="material-icons-outlined">language</span><span class="cm-header-nav__label">Website</span></a>
|
||||
@ -40,9 +42,11 @@
|
||||
<div class="cm-header-nav__mobile-links">
|
||||
<a href="#" data-path="/" class="cm-header-nav__mobile-link" data-nav-id="home" target="_blank" rel="noopener noreferrer"><span class="material-icons-outlined">home</span><span>Home</span></a>
|
||||
<a href="#" data-path="/campaigns" class="cm-header-nav__mobile-link" data-nav-id="campaigns"><span class="material-icons-outlined">send</span><span>Campaigns</span></a>
|
||||
<a href="#" data-path="/shifts" class="cm-header-nav__mobile-link" data-nav-id="shifts"><span class="material-icons-outlined">schedule</span><span>Shifts</span></a>
|
||||
<a href="#" data-path="/map" class="cm-header-nav__mobile-link" data-nav-id="map"><span class="material-icons-outlined">place</span><span>Map</span></a>
|
||||
<a href="#" data-path="/shifts" class="cm-header-nav__mobile-link" data-nav-id="shifts"><span class="material-icons-outlined">event</span><span>Shifts</span></a>
|
||||
<a href="#" data-path="/events" class="cm-header-nav__mobile-link" data-nav-id="events" target="_blank" rel="noopener noreferrer"><span class="material-icons-outlined">event</span><span>Events</span></a>
|
||||
<a href="#" data-path="/gallery" class="cm-header-nav__mobile-link" data-nav-id="gallery"><span class="material-icons-outlined">play_circle</span><span>Gallery</span></a>
|
||||
<a href="#" data-path="/pricing" class="cm-header-nav__mobile-link" data-nav-id="pricing"><span class="material-icons-outlined">attach_money</span><span>Pricing</span></a>
|
||||
<a href="#" data-path="/shop" class="cm-header-nav__mobile-link" data-nav-id="shop"><span class="material-icons-outlined">shopping_bag</span><span>Shop</span></a>
|
||||
<a href="#" data-path="/donate" class="cm-header-nav__mobile-link" data-nav-id="donate"><span class="material-icons-outlined">favorite_border</span><span>Donate</span></a>
|
||||
<a href="/" class="cm-header-nav__mobile-link" data-nav-id="landing"><span class="material-icons-outlined">language</span><span>Website</span></a>
|
||||
|
||||
@ -13,9 +13,11 @@
|
||||
<div class="cm-header-nav__links-inner">
|
||||
<a href="#" data-path="/" class="cm-header-nav__link" data-nav-id="home" target="_blank" rel="noopener noreferrer"><span class="material-icons-outlined">home</span><span class="cm-header-nav__label">Home</span></a>
|
||||
<a href="#" data-path="/campaigns" class="cm-header-nav__link" data-nav-id="campaigns"><span class="material-icons-outlined">send</span><span class="cm-header-nav__label">Campaigns</span></a>
|
||||
<a href="#" data-path="/shifts" class="cm-header-nav__link" data-nav-id="shifts"><span class="material-icons-outlined">schedule</span><span class="cm-header-nav__label">Shifts</span></a>
|
||||
<a href="#" data-path="/map" class="cm-header-nav__link" data-nav-id="map"><span class="material-icons-outlined">place</span><span class="cm-header-nav__label">Map</span></a>
|
||||
<a href="#" data-path="/shifts" class="cm-header-nav__link" data-nav-id="shifts"><span class="material-icons-outlined">event</span><span class="cm-header-nav__label">Shifts</span></a>
|
||||
<a href="#" data-path="/events" class="cm-header-nav__link" data-nav-id="events" target="_blank" rel="noopener noreferrer"><span class="material-icons-outlined">event</span><span class="cm-header-nav__label">Events</span></a>
|
||||
<a href="#" data-path="/gallery" class="cm-header-nav__link" data-nav-id="gallery"><span class="material-icons-outlined">play_circle</span><span class="cm-header-nav__label">Gallery</span></a>
|
||||
<a href="#" data-path="/pricing" class="cm-header-nav__link" data-nav-id="pricing"><span class="material-icons-outlined">attach_money</span><span class="cm-header-nav__label">Pricing</span></a>
|
||||
<a href="#" data-path="/shop" class="cm-header-nav__link" data-nav-id="shop"><span class="material-icons-outlined">shopping_bag</span><span class="cm-header-nav__label">Shop</span></a>
|
||||
<a href="#" data-path="/donate" class="cm-header-nav__link" data-nav-id="donate"><span class="material-icons-outlined">favorite_border</span><span class="cm-header-nav__label">Donate</span></a>
|
||||
<a href="/" class="cm-header-nav__link" data-nav-id="landing"><span class="material-icons-outlined">language</span><span class="cm-header-nav__label">Website</span></a>
|
||||
@ -40,9 +42,11 @@
|
||||
<div class="cm-header-nav__mobile-links">
|
||||
<a href="#" data-path="/" class="cm-header-nav__mobile-link" data-nav-id="home" target="_blank" rel="noopener noreferrer"><span class="material-icons-outlined">home</span><span>Home</span></a>
|
||||
<a href="#" data-path="/campaigns" class="cm-header-nav__mobile-link" data-nav-id="campaigns"><span class="material-icons-outlined">send</span><span>Campaigns</span></a>
|
||||
<a href="#" data-path="/shifts" class="cm-header-nav__mobile-link" data-nav-id="shifts"><span class="material-icons-outlined">schedule</span><span>Shifts</span></a>
|
||||
<a href="#" data-path="/map" class="cm-header-nav__mobile-link" data-nav-id="map"><span class="material-icons-outlined">place</span><span>Map</span></a>
|
||||
<a href="#" data-path="/shifts" class="cm-header-nav__mobile-link" data-nav-id="shifts"><span class="material-icons-outlined">event</span><span>Shifts</span></a>
|
||||
<a href="#" data-path="/events" class="cm-header-nav__mobile-link" data-nav-id="events" target="_blank" rel="noopener noreferrer"><span class="material-icons-outlined">event</span><span>Events</span></a>
|
||||
<a href="#" data-path="/gallery" class="cm-header-nav__mobile-link" data-nav-id="gallery"><span class="material-icons-outlined">play_circle</span><span>Gallery</span></a>
|
||||
<a href="#" data-path="/pricing" class="cm-header-nav__mobile-link" data-nav-id="pricing"><span class="material-icons-outlined">attach_money</span><span>Pricing</span></a>
|
||||
<a href="#" data-path="/shop" class="cm-header-nav__mobile-link" data-nav-id="shop"><span class="material-icons-outlined">shopping_bag</span><span>Shop</span></a>
|
||||
<a href="#" data-path="/donate" class="cm-header-nav__mobile-link" data-nav-id="donate"><span class="material-icons-outlined">favorite_border</span><span>Donate</span></a>
|
||||
<a href="/" class="cm-header-nav__mobile-link" data-nav-id="landing"><span class="material-icons-outlined">language</span><span>Website</span></a>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user