v0.12.31 multiple UI changes
This commit is contained in:
@@ -346,7 +346,7 @@ function RecurringChoiceModal({ title, onConfirm, onCancel }) {
|
||||
}
|
||||
|
||||
// ── Main Mobile Event Form ────────────────────────────────────────────────────
|
||||
export default function MobileEventForm({ event, eventTypes, userGroups, selectedDate, onSave, onCancel, onDelete, isToolManager }) {
|
||||
export default function MobileEventForm({ event, eventTypes, userGroups, selectedDate, onSave, onCancel, onDelete, isToolManager, userId }) {
|
||||
const toast = useToast();
|
||||
// Use local date for default, not UTC slice (avoids off-by-one for UTC- timezones)
|
||||
const defDate = selectedDate || new Date();
|
||||
@@ -373,7 +373,7 @@ export default function MobileEventForm({ event, eventTypes, userGroups, selecte
|
||||
const mountedRef = useRef(false);
|
||||
const [allDay, setAllDay] = useState(!!event?.all_day);
|
||||
const [track, setTrack] = useState(!!event?.track_availability);
|
||||
const [isPrivate, setIsPrivate] = useState(event ? !event.is_public : false);
|
||||
const [isPrivate, setIsPrivate] = useState(event ? !event.is_public : !isToolManager);
|
||||
const [groups, setGroups] = useState(new Set((event?.user_groups||[]).map(g=>g.id)));
|
||||
const [location, setLocation] = useState(event?.location||'');
|
||||
const [description, setDescription] = useState(event?.description||'');
|
||||
@@ -439,6 +439,7 @@ export default function MobileEventForm({ event, eventTypes, userGroups, selecte
|
||||
|
||||
const handle = () => {
|
||||
if(!title.trim()) return toast('Title required','error');
|
||||
if(!isToolManager && groups.size === 0) return toast('Select at least one group','error');
|
||||
const startMs = new Date(buildISO(sd, allDay?'00:00':st)).getTime();
|
||||
const endMs = new Date(buildISO(ed, allDay?'23:59':et)).getTime();
|
||||
if(ed < sd) return toast('End date cannot be before start date','error');
|
||||
@@ -452,7 +453,7 @@ export default function MobileEventForm({ event, eventTypes, userGroups, selecte
|
||||
setShowScopeModal(false);
|
||||
setSaving(true);
|
||||
try {
|
||||
const body = { title:title.trim(), eventTypeId:typeId||null, startAt:allDay?buildISO(sd,'00:00'):buildISO(sd,st), endAt:allDay?buildISO(ed,'23:59'):buildISO(ed,et), allDay, location, description, isPublic:!isPrivate, trackAvailability:track, userGroupIds:[...groups], recurrenceRule:recRule||null };
|
||||
const body = { title:title.trim(), eventTypeId:typeId||null, startAt:allDay?buildISO(sd,'00:00'):buildISO(sd,st), endAt:allDay?buildISO(ed,'23:59'):buildISO(ed,et), allDay, location, description, isPublic:isToolManager?!isPrivate:false, trackAvailability:track, userGroupIds:[...groups], recurrenceRule:recRule||null };
|
||||
const r = event ? await api.updateEvent(event.id, {...body, recurringScope:scope}) : await api.createEvent(body);
|
||||
onSave(r.event);
|
||||
} catch(e) { toast(e.message,'error'); }
|
||||
@@ -554,11 +555,14 @@ export default function MobileEventForm({ event, eventTypes, userGroups, selecte
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Private Event */}
|
||||
{/* Private Event — tool managers can toggle; regular users always private */}
|
||||
<div style={{ display:'flex',alignItems:'center',padding:'14px 20px',borderBottom:'1px solid var(--border)' }}>
|
||||
<span style={{ color:'var(--text-tertiary)',width:20,textAlign:'center',marginRight:16 }}><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"/><path d="M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"/><line x1="1" y1="1" x2="23" y2="23"/></svg></span>
|
||||
<span style={{ flex:1,fontSize:15 }}>Private Event</span>
|
||||
<Toggle checked={isPrivate} onChange={setIsPrivate}/>
|
||||
{isToolManager
|
||||
? <Toggle checked={isPrivate} onChange={setIsPrivate}/>
|
||||
: <span style={{ fontSize:13,color:'var(--text-tertiary)' }}>Always private</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
{/* Location */}
|
||||
@@ -572,7 +576,7 @@ export default function MobileEventForm({ event, eventTypes, userGroups, selecte
|
||||
</MobileRow>
|
||||
|
||||
{/* Delete */}
|
||||
{event && isToolManager && (
|
||||
{event && (isToolManager || (userId && event.created_by === userId)) && (
|
||||
<div style={{ padding:'16px 20px' }}>
|
||||
<button onClick={()=>onDelete(event)} style={{ width:'100%',padding:'14px',border:'1px solid var(--error)',borderRadius:'var(--radius)',background:'transparent',color:'var(--error)',fontSize:15,fontWeight:600,cursor:'pointer' }}>Delete Event</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user