fix: address PR review feedback
- Suppress note context menu when canEditDays is false instead of showing empty menu - Untie poll voting from collab_edit — voting is participation, not editing; any trip member can vote - Restore NoteFormModal props (note, tripId) to required; remove leftover canUploadFiles prop in favor of direct zustand hook
This commit is contained in:
@@ -222,13 +222,15 @@ interface NoteFormModalProps {
|
|||||||
existingCategories: string[]
|
existingCategories: string[]
|
||||||
categoryColors: Record<string, string>
|
categoryColors: Record<string, string>
|
||||||
getCategoryColor: (category: string) => string
|
getCategoryColor: (category: string) => string
|
||||||
note?: CollabNote | null
|
note: CollabNote | null
|
||||||
tripId?: number
|
tripId: number
|
||||||
t: (key: string) => string
|
t: (key: string) => string
|
||||||
canUploadFiles?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function NoteFormModal({ onClose, onSubmit, onDeleteFile, existingCategories, categoryColors, getCategoryColor, note, tripId, t, canUploadFiles = true }: NoteFormModalProps) {
|
function NoteFormModal({ onClose, onSubmit, onDeleteFile, existingCategories, categoryColors, getCategoryColor, note, tripId, t }: NoteFormModalProps) {
|
||||||
|
const can = useCanDo()
|
||||||
|
const tripObj = useTripStore((s) => s.trip)
|
||||||
|
const canUploadFiles = can('file_upload', tripObj)
|
||||||
const isEdit = !!note
|
const isEdit = !!note
|
||||||
const allCategories = [...new Set([...existingCategories, ...Object.keys(categoryColors || {})])].filter(Boolean)
|
const allCategories = [...new Set([...existingCategories, ...Object.keys(categoryColors || {})])].filter(Boolean)
|
||||||
|
|
||||||
@@ -887,7 +889,6 @@ export default function CollabNotes({ tripId, currentUser }: CollabNotesProps) {
|
|||||||
const can = useCanDo()
|
const can = useCanDo()
|
||||||
const trip = useTripStore((s) => s.trip)
|
const trip = useTripStore((s) => s.trip)
|
||||||
const canEdit = can('collab_edit', trip)
|
const canEdit = can('collab_edit', trip)
|
||||||
const canUploadFiles = can('file_upload', trip)
|
|
||||||
const [notes, setNotes] = useState([])
|
const [notes, setNotes] = useState([])
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const [showNewModal, setShowNewModal] = useState(false)
|
const [showNewModal, setShowNewModal] = useState(false)
|
||||||
@@ -1337,12 +1338,13 @@ export default function CollabNotes({ tripId, currentUser }: CollabNotesProps) {
|
|||||||
|
|
||||||
{showNewModal && (
|
{showNewModal && (
|
||||||
<NoteFormModal
|
<NoteFormModal
|
||||||
|
note={null}
|
||||||
|
tripId={tripId}
|
||||||
onClose={() => setShowNewModal(false)}
|
onClose={() => setShowNewModal(false)}
|
||||||
onSubmit={handleCreateNote}
|
onSubmit={handleCreateNote}
|
||||||
existingCategories={categories}
|
existingCategories={categories}
|
||||||
categoryColors={categoryColors}
|
categoryColors={categoryColors}
|
||||||
getCategoryColor={getCategoryColor}
|
getCategoryColor={getCategoryColor}
|
||||||
canUploadFiles={canUploadFiles}
|
|
||||||
t={t}
|
t={t}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -1358,7 +1360,6 @@ export default function CollabNotes({ tripId, currentUser }: CollabNotesProps) {
|
|||||||
existingCategories={categories}
|
existingCategories={categories}
|
||||||
categoryColors={categoryColors}
|
categoryColors={categoryColors}
|
||||||
getCategoryColor={getCategoryColor}
|
getCategoryColor={getCategoryColor}
|
||||||
canUploadFiles={canUploadFiles}
|
|
||||||
t={t}
|
t={t}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -270,15 +270,15 @@ function PollCard({ poll, currentUser, canEdit, onVote, onClose, onDelete, t }:
|
|||||||
const isWinner = isClosed && count === Math.max(...(poll.options || []).map(o => o.voters?.length || 0)) && count > 0
|
const isWinner = isClosed && count === Math.max(...(poll.options || []).map(o => o.voters?.length || 0)) && count > 0
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button key={idx} onClick={() => !isClosed && canEdit && onVote(poll.id, idx)}
|
<button key={idx} onClick={() => !isClosed && onVote(poll.id, idx)}
|
||||||
disabled={isClosed || !canEdit}
|
disabled={isClosed}
|
||||||
style={{
|
style={{
|
||||||
position: 'relative', display: 'flex', alignItems: 'center', gap: 8,
|
position: 'relative', display: 'flex', alignItems: 'center', gap: 8,
|
||||||
padding: '10px 12px', borderRadius: 10, border: 'none', cursor: (isClosed || !canEdit) ? 'default' : 'pointer',
|
padding: '10px 12px', borderRadius: 10, border: 'none', cursor: isClosed ? 'default' : 'pointer',
|
||||||
background: 'var(--bg-secondary)', fontFamily: FONT, textAlign: 'left', width: '100%',
|
background: 'var(--bg-secondary)', fontFamily: FONT, textAlign: 'left', width: '100%',
|
||||||
overflow: 'hidden', transition: 'transform 0.1s',
|
overflow: 'hidden', transition: 'transform 0.1s',
|
||||||
}}
|
}}
|
||||||
onMouseEnter={e => { if (!isClosed && canEdit) e.currentTarget.style.transform = 'scale(1.01)' }}
|
onMouseEnter={e => { if (!isClosed) e.currentTarget.style.transform = 'scale(1.01)' }}
|
||||||
onMouseLeave={e => e.currentTarget.style.transform = 'scale(1)'}
|
onMouseLeave={e => e.currentTarget.style.transform = 'scale(1)'}
|
||||||
>
|
>
|
||||||
{/* Progress bar background */}
|
{/* Progress bar background */}
|
||||||
|
|||||||
@@ -1302,11 +1302,11 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar({
|
|||||||
handleMergedDrop(day.id, 'place', Number(fromAssignmentId), 'note', note.id)
|
handleMergedDrop(day.id, 'place', Number(fromAssignmentId), 'note', note.id)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onContextMenu={e => ctxMenu.open(e, [
|
onContextMenu={canEditDays ? e => ctxMenu.open(e, [
|
||||||
canEditDays && { label: t('common.edit'), icon: Pencil, onClick: () => openEditNote(day.id, note) },
|
{ label: t('common.edit'), icon: Pencil, onClick: () => openEditNote(day.id, note) },
|
||||||
canEditDays && { divider: true },
|
{ divider: true },
|
||||||
canEditDays && { label: t('common.delete'), icon: Trash2, danger: true, onClick: () => deleteNote(day.id, note.id) },
|
{ label: t('common.delete'), icon: Trash2, danger: true, onClick: () => deleteNote(day.id, note.id) },
|
||||||
])}
|
]) : undefined}
|
||||||
onMouseEnter={() => setHoveredId(`note-${note.id}`)}
|
onMouseEnter={() => setHoveredId(`note-${note.id}`)}
|
||||||
onMouseLeave={() => setHoveredId(null)}
|
onMouseLeave={() => setHoveredId(null)}
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
Reference in New Issue
Block a user