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 | 5x 4x 4x 5x 8x 8x 5x 4x 4x 4x 4x 4x 5x 9x 9x 9x 9x 9x 1x 8x 1x 7x 4x | import React, { useState } from 'react';
import {
Alert,
Box,
Button,
Card,
CardContent,
Chip,
Collapse,
IconButton,
Stack,
Typography,
} from '@mui/material';
import {
Add as AddIcon,
EventNote as EventNoteIcon,
KeyboardArrowDown as ArrowDownIcon,
KeyboardArrowUp as ArrowUpIcon,
} from '@mui/icons-material';
import { useTranslation } from 'react-i18next';
import { BATbernLoader } from '@components/shared/BATbernLoader';
import { usePartnerMeetings } from '@/hooks/usePartnerMeetings';
import CreateMeetingDialog from '@/components/organizer/CreateMeetingDialog';
import type { PartnerMeetingDTO } from '@/services/api/partnerMeetingsApi';
type UserRole = 'ORGANIZER' | 'PARTNER' | 'SPEAKER' | 'ATTENDEE';
interface PartnerMeetingsTabProps {
companyName: string;
role?: UserRole; // Story 8.0: hide Add Meeting for PARTNER
}
const formatMeetingDate = (dateString: string): string => {
const date = new Date(dateString);
return date.toLocaleDateString('en-US', {
month: 'short',
day: 'numeric',
year: 'numeric',
});
};
const formatTime = (timeString: string | null | undefined): string | null => {
Iif (!timeString) return null;
return timeString.slice(0, 5);
};
interface MeetingCardProps {
meeting: PartnerMeetingDTO;
isOrganizer: boolean;
t: (key: string, opts?: Record<string, unknown>) => string;
}
const MeetingCard: React.FC<MeetingCardProps> = ({ meeting, isOrganizer, t }) => {
const [expanded, setExpanded] = useState(false);
const startTime = formatTime(meeting.startTime);
const endTime = formatTime(meeting.endTime);
const timeDisplay =
startTime && endTime ? `${startTime} – ${endTime}` : startTime ? startTime : null;
return (
<Card>
<CardContent>
<Stack spacing={1}>
{/* Meeting Header */}
<Stack direction="row" justifyContent="space-between" alignItems="flex-start">
<Box sx={{ flex: 1 }}>
<Typography variant="h6" gutterBottom>
{meeting.agenda ?? `${meeting.meetingType} Meeting`}
</Typography>
<Stack direction="row" spacing={1} alignItems="center">
<Chip
label={t(
meeting.meetingType === 'SPRING'
? 'meetings.fields.type.spring'
: 'meetings.fields.type.autumn'
)}
size="small"
variant="outlined"
/>
{meeting.inviteSentAt && (
<Chip label={t('meetings.inviteSent')} size="small" color="success" />
)}
</Stack>
</Box>
<IconButton
size="small"
onClick={() => setExpanded((prev) => !prev)}
aria-label={expanded ? 'Collapse' : 'Expand'}
>
{expanded ? <ArrowUpIcon /> : <ArrowDownIcon />}
</IconButton>
</Stack>
{/* Summary row: date, time, location */}
<Stack direction="row" spacing={2} flexWrap="wrap">
<Typography variant="body2" color="text.secondary">
<strong>{t('meetings.columns.date')}:</strong>{' '}
{formatMeetingDate(meeting.meetingDate)}
</Typography>
{timeDisplay && (
<Typography variant="body2" color="text.secondary">
<strong>{t('meetings.columns.time')}:</strong> {timeDisplay}
</Typography>
)}
<Typography variant="body2" color="text.secondary">
<strong>{t('meetings.columns.location')}:</strong> {meeting.location ?? 'TBD'}
</Typography>
</Stack>
{/* Collapsible agenda (read-only for partners, and organizers) */}
<Collapse in={expanded} timeout="auto" unmountOnExit>
<Box sx={{ pt: 1 }}>
<Typography variant="subtitle2" gutterBottom>
{t('meetings.fields.agenda')}
</Typography>
<Typography
variant="body2"
color={meeting.agenda ? 'text.primary' : 'text.secondary'}
sx={{ whiteSpace: 'pre-wrap' }}
>
{meeting.agenda ?? '—'}
</Typography>
{/* Notes section — organizers only */}
{isOrganizer && (
<Box sx={{ mt: 2 }}>
<Typography variant="subtitle2" gutterBottom>
{t('meetings.fields.notes')}
</Typography>
<Typography
variant="body2"
color={meeting.notes ? 'text.primary' : 'text.secondary'}
sx={{ whiteSpace: 'pre-wrap' }}
>
{meeting.notes ?? '—'}
</Typography>
</Box>
)}
</Box>
</Collapse>
</Stack>
</CardContent>
</Card>
);
};
export const PartnerMeetingsTab: React.FC<PartnerMeetingsTabProps> = ({ companyName, role }) => {
const { t } = useTranslation('partners');
const { data: meetings, isLoading, error } = usePartnerMeetings(companyName);
const isOrganizer = role === 'ORGANIZER';
const [createOpen, setCreateOpen] = useState(false);
if (isLoading) {
return (
<Box display="flex" justifyContent="center" alignItems="center" minHeight="200px">
<BATbernLoader size={96} />
</Box>
);
}
if (error) {
return <Alert severity="error">Failed to load meetings. Please try again later.</Alert>;
}
return (
<Box>
<Stack direction="row" justifyContent="space-between" alignItems="center" mb={3}>
<Typography variant="h6">{t('detail.meetingsTab.title')}</Typography>
{isOrganizer && (
<Button
variant="contained"
startIcon={<AddIcon />}
onClick={() => setCreateOpen(true)}
data-testid="add-meeting-button"
>
{t('detail.meetingsTab.addMeeting')}
</Button>
)}
</Stack>
<CreateMeetingDialog open={createOpen} onClose={() => setCreateOpen(false)} />
{/* Meetings List */}
{!meetings || meetings.length === 0 ? (
<Card>
<CardContent>
<Stack alignItems="center" spacing={2} py={4}>
<EventNoteIcon sx={{ fontSize: 64, color: 'text.secondary' }} />
<Typography variant="h6" color="text.secondary">
No meetings scheduled
</Typography>
<Typography variant="body2" color="text.secondary">
Schedule meetings to track partnership coordination
</Typography>
</Stack>
</CardContent>
</Card>
) : (
<Stack spacing={2}>
{meetings.map((meeting: PartnerMeetingDTO) => (
<MeetingCard key={meeting.id} meeting={meeting} isOrganizer={isOrganizer} t={t} />
))}
</Stack>
)}
</Box>
);
};
|