Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | 3x 26x 26x 26x 26x 26x 26x 26x 26x 26x 18x 3x 3x 26x 26x 26x 1x 1x 1x 1x 1x 1x 26x 6x 20x 26x | import React, { useEffect, useState } from 'react';
import { Alert, Box, Button, CircularProgress, Stack, TextField, Typography } from '@mui/material';
import { useTranslation } from 'react-i18next';
import { usePatchSpeakerPool } from '@/hooks/useSpeakerPool';
import { usePublicUser } from '@/hooks/useUserPortrait';
import { OrganizerSelect } from '@/components/shared/OrganizerSelect';
import type { SpeakerPoolEntry } from '@/types/speakerPool.types';
interface DetailsTabPanelProps {
speaker: SpeakerPoolEntry;
eventCode: string;
/** When true, the panel renders editable form fields with Save/Cancel actions. */
isEditing: boolean;
/** Invoked when the user successfully saves edits, or cancels them. */
onExitEditMode: () => void;
}
interface EditFormState {
speakerName: string;
company: string;
expertise: string;
assignedOrganizerId: string;
notes: string;
}
export const DetailsTabPanel: React.FC<DetailsTabPanelProps> = ({
speaker,
eventCode,
isEditing,
onExitEditMode,
}) => {
const { t } = useTranslation('organizer');
const patchMutation = usePatchSpeakerPool();
// 2026-05-20 (Q#4) — once a real speaker is bound (CONTACTED→READY promote provisioned
// the User), the speaker_pool.speakerName field becomes a brainstorm-era audit string,
// not the editable display name. The canonical name is the linked User's first+last
// (same source the drawer header + kanban card already use). Edit-mode locks the
// speakerName field; read-only displays the User's name.
const { data: linkedUser } = usePublicUser(speaker.username ?? undefined);
const hasLinkedUser = !!(linkedUser?.firstName && linkedUser?.lastName);
const linkedUserDisplayName = hasLinkedUser
? `${linkedUser!.firstName} ${linkedUser!.lastName}`
: null;
// Phase D.5 (BATbern75 follow-up, 2026-05-21) — once a session is provisioned
// (status ≥ READY per Story 11.E.8), the drawer is a workflow surface only. The
// Details subtab locks all identity / brainstorm columns and exposes ONLY the
// assigned-organizer field for edit; the canonical identity flows from
// session_users + User (via the kanban card / drawer header / Phase A's overlay).
// Pre-session (IDENTIFIED/CONTACTED) brainstorm UX is preserved.
const isSessionAssigned = !!speaker.sessionId;
const [form, setForm] = useState<EditFormState>({
speakerName: speaker.speakerName ?? '',
company: speaker.company ?? '',
expertise: speaker.expertise ?? '',
assignedOrganizerId: speaker.assignedOrganizerId ?? '',
notes: speaker.notes ?? '',
});
const [submitError, setSubmitError] = useState<string | null>(null);
// Reset form whenever we enter edit mode or the underlying speaker changes (e.g.
// navigating between speakers while the drawer stays mounted).
useEffect(() => {
if (isEditing) {
setForm({
speakerName: speaker.speakerName ?? '',
company: speaker.company ?? '',
expertise: speaker.expertise ?? '',
assignedOrganizerId: speaker.assignedOrganizerId ?? '',
notes: speaker.notes ?? '',
});
setSubmitError(null);
}
}, [
isEditing,
speaker.id,
speaker.speakerName,
speaker.company,
speaker.expertise,
speaker.assignedOrganizerId,
speaker.notes,
]);
const trimmedName = form.speakerName.trim();
const nameError = trimmedName.length === 0;
const handleSave = async () => {
Iif (nameError) return;
setSubmitError(null);
try {
// Phase D.5: when a session is assigned, the only editable field is
// assignedOrganizerId; strip the locked fields from the payload to avoid
// sending no-op writes (and to make the "drawer is workflow-only post-session"
// contract explicit on the wire).
const payload = isSessionAssigned
? {
// Empty string means "unassigned" — pass it through so the backend can
// clear the column (PatchSpeakerPoolRequest treats empty as a sentinel).
assignedOrganizerId: form.assignedOrganizerId,
}
: {
speakerName: trimmedName,
company: form.company,
expertise: form.expertise,
assignedOrganizerId: form.assignedOrganizerId,
notes: form.notes,
};
await patchMutation.mutateAsync({
eventCode,
speakerId: speaker.id,
request: payload,
});
onExitEditMode();
} catch (err) {
setSubmitError(
err instanceof Error
? err.message
: t('speakerDrawer.editDetails.errors.saveFailed', 'Could not save changes.')
);
}
};
if (isEditing) {
return (
<Box sx={{ p: 2, overflow: 'auto' }} data-testid="details-tab-edit-mode">
<Stack spacing={2}>
{hasLinkedUser ? (
// 2026-05-20 (Q#4) — once the speaker is bound to a User, the name is owned
// by the User entity. Render as a read-only field with a hint telling the
// organizer to use the user-edit modal (accessible from the Content tab's
// "Edit speaker profile" button) to change it.
<TextField
label={t('speakers.speakerName', 'Speaker name')}
value={linkedUserDisplayName ?? ''}
fullWidth
size="small"
disabled
helperText={t(
'speakerDrawer.editDetails.speakerNameLockedHint',
'Name comes from the linked user profile. Use the Content tab’s "Edit speaker profile" to change it.'
)}
inputProps={{ 'data-testid': 'details-edit-speakerName-locked' }}
/>
) : (
<TextField
label={t('speakers.speakerName', 'Speaker name')}
value={form.speakerName}
onChange={(e) => setForm((s) => ({ ...s, speakerName: e.target.value }))}
required
fullWidth
size="small"
error={nameError}
helperText={
nameError
? t('speakerDrawer.editDetails.errors.nameRequired', 'Speaker name is required')
: undefined
}
inputProps={{
'data-testid': 'details-edit-speakerName',
maxLength: 255,
}}
/>
)}
<TextField
label={t('speakers.company', 'Company')}
value={form.company}
onChange={(e) => setForm((s) => ({ ...s, company: e.target.value }))}
fullWidth
size="small"
disabled={isSessionAssigned}
helperText={
isSessionAssigned
? t(
'speakerDrawer.editDetails.companyLockedHint',
'Company comes from the linked user profile once a session is assigned.'
)
: undefined
}
inputProps={{ 'data-testid': 'details-edit-company', maxLength: 255 }}
/>
<TextField
label={t('speakers.expertise', 'Expertise')}
value={form.expertise}
onChange={(e) => setForm((s) => ({ ...s, expertise: e.target.value }))}
fullWidth
size="small"
disabled={isSessionAssigned}
helperText={
isSessionAssigned
? t(
'speakerDrawer.editDetails.expertiseLockedHint',
'Expertise is a brainstorm-only field; sessions own the talk topic from READY onward.'
)
: undefined
}
inputProps={{ 'data-testid': 'details-edit-expertise', maxLength: 1000 }}
/>
{/* Epic 11 bug fix 2026-05-19 — assignedOrganizer is part of the edit-details
form (replaces the legacy standalone "Reassign organizer" secondary action). */}
<OrganizerSelect
value={form.assignedOrganizerId}
onChange={(id) => setForm((s) => ({ ...s, assignedOrganizerId: id }))}
includeUnassigned={true}
disabled={patchMutation.isPending}
size="small"
fullWidth
label={t('speakerBrainstorm.form.assignOrganizer', 'Assigned organizer')}
/>
<TextField
label={t('speakers.internalNotes', 'Internal notes')}
value={form.notes}
onChange={(e) => setForm((s) => ({ ...s, notes: e.target.value }))}
fullWidth
multiline
rows={3}
size="small"
disabled={isSessionAssigned}
helperText={
isSessionAssigned
? t(
'speakerDrawer.editDetails.notesLockedHint',
'Internal notes are a brainstorm-only field. Use the History timeline for post-session annotations.'
)
: undefined
}
inputProps={{ 'data-testid': 'details-edit-notes' }}
/>
{submitError && <Alert severity="error">{submitError}</Alert>}
<Stack direction="row" spacing={1} justifyContent="flex-end">
<Button
variant="outlined"
onClick={() => {
setSubmitError(null);
onExitEditMode();
}}
disabled={patchMutation.isPending}
data-testid="details-edit-cancel"
>
{t('common.cancel', 'Cancel')}
</Button>
<Button
variant="contained"
onClick={handleSave}
disabled={nameError || patchMutation.isPending}
startIcon={patchMutation.isPending ? <CircularProgress size={16} /> : null}
data-testid="details-edit-save"
>
{t('common.save', 'Save')}
</Button>
</Stack>
</Stack>
</Box>
);
}
// 2026-05-20 (Q#5) — Response Details / Decline Details / Submitted Content / Revision
// Feedback boxes were a chronological side-channel that duplicated UnifiedHistoryPanel.
// Dropped from the Details tab. The History tab is now the single timeline; the Details
// tab carries brainstorm/identity metadata only.
const displaySpeakerName = linkedUserDisplayName ?? speaker.speakerName ?? '—';
return (
<Box sx={{ p: 2, overflow: 'auto' }}>
{/* Brainstorm-level metadata — always shown so the read-only view matches the edit
form contents (otherwise hitting "Edit Details" produces a visually empty form). */}
<Box sx={{ mb: 2 }} data-testid="details-tab-readonly-metadata">
<Typography variant="body2" sx={{ color: 'text.secondary' }}>
{t('speakers.speakerName', 'Speaker name')}
</Typography>
<Typography variant="body1" sx={{ mb: 1 }}>
{displaySpeakerName}
</Typography>
{hasLinkedUser && speaker.speakerName && speaker.speakerName !== linkedUserDisplayName && (
<Typography
variant="caption"
color="text.secondary"
sx={{ display: 'block', mt: -1, mb: 1, fontStyle: 'italic' }}
data-testid="details-tab-brainstorm-name"
>
{t('speakerDrawer.brainstormNameLabel', 'brainstormed as')} {speaker.speakerName}
</Typography>
)}
{(speaker.company || speaker.expertise) && (
<>
{speaker.company && (
<>
<Typography variant="body2" sx={{ color: 'text.secondary' }}>
{t('speakers.company', 'Company')}
</Typography>
<Typography variant="body1" sx={{ mb: 1 }}>
{speaker.company}
</Typography>
</>
)}
{speaker.expertise && (
<>
<Typography variant="body2" sx={{ color: 'text.secondary' }}>
{t('speakers.expertise', 'Expertise')}
</Typography>
<Typography variant="body1" sx={{ mb: 1 }}>
{speaker.expertise}
</Typography>
</>
)}
</>
)}
{/* Epic 11 bug fix 2026-05-19 — assigned organizer shown in the Details read-only
view (was previously surfaced only via the now-removed "Reassign organizer"
secondary action). */}
<Typography variant="body2" sx={{ color: 'text.secondary' }}>
{t('speakerBrainstorm.form.assignOrganizer', 'Assigned organizer')}
</Typography>
<Typography variant="body1" sx={{ mb: 1 }}>
{speaker.assignedOrganizerId || t('common.unassigned', 'Unassigned')}
</Typography>
{speaker.notes && (
<>
<Typography variant="body2" sx={{ color: 'text.secondary' }}>
{t('speakers.internalNotes', 'Internal notes')}
</Typography>
<Typography variant="body1" sx={{ whiteSpace: 'pre-wrap' }}>
{speaker.notes}
</Typography>
</>
)}
</Box>
</Box>
);
};
|