Add new meetings feature

This commit is contained in:
blankhex committed 2026-10-24 18:31:01 +03:00
1 parent d09c63b88c
commit db6a333029
14 files changed
+1251 -8

No files matched your search

+104
View File
@@ -0,0 +1,104 @@
import React, { useState } from 'react'
import { api } from '../api.js'
// Formats a Date as the value a `datetime-local` input expects, in local time
// (YYYY-MM-DDTHH:mm).
function toLocalInputValue(date) {
const pad = (n) => String(n).padStart(2, '0')
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`
}
// Dedicated page for planning a meeting. Kept separate from the meetings list
// so creating a meeting is a deliberate, focused flow. On success the caller
// is expected to navigate back to the meetings list.
export default function PlanMeetingPage({ onCreated, onCancel }) {
const [title, setTitle] = useState('')
const [intent, setIntent] = useState('')
const [room, setRoom] = useState('')
// Prefill with the current date/time so the field is never empty by default.
const [scheduledAt, setScheduledAt] = useState(() => toLocalInputValue(new Date()))
const [saving, setSaving] = useState(false)
const [error, setError] = useState('')
const create = async (event) => {
event.preventDefault()
setError('')
if (!title.trim() || !scheduledAt) {
setError('A title and a date/time are required.')
return
}
setSaving(true)
try {
await api.createMeeting({
title,
intent,
room,
// datetime-local is local time; toISOString() produces the RFC3339 UTC
// instant the backend expects.
scheduledAt: new Date(scheduledAt).toISOString(),
})
onCreated?.()
} catch (err) {
setError(err.message)
setSaving(false)
}
}
return (
<section className="card plan-meeting">
<div className="card-head">
<h2>Plan a meeting</h2>
<button className="btn-ghost" type="button" onClick={() => onCancel?.()}>
Cancel
</button>
</div>
<form onSubmit={create}>
<label>
Title
<input
value={title}
onChange={(e) => setTitle(e.target.value)}
placeholder="Weekly sync"
/>
</label>
<label>
What is it about
<textarea
className="meeting-intent-field"
rows={6}
value={intent}
onChange={(e) => setIntent(e.target.value)}
placeholder="Discuss the roadmap"
/>
</label>
<label>
Room
<input
value={room}
onChange={(e) => setRoom(e.target.value)}
placeholder="weekly-sync"
/>
</label>
<label>
When
<input
type="datetime-local"
value={scheduledAt}
onChange={(e) => setScheduledAt(e.target.value)}
/>
</label>
<button className="btn-primary" type="submit" disabled={saving}>
{saving ? 'Creating…' : 'Create meeting'}
</button>
{error && <p className="error">{error}</p>}
<p className="hint">
The meeting is visible to every registered user, who can vote whether
they will join. Past meetings are removed 7 days after they occur.
</p>
</form>
</section>
)
}