Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/frontend/src/pages/CalendarPage/Components/EventModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
SlackMentionType
} from 'shared';
import { useToast } from '../../../hooks/toasts.hooks';
import { useAllMembers, useCurrentUser } from '../../../hooks/users.hooks';
import { useAllMembers, useCurrentUser, useUserScheduleSettings } from '../../../hooks/users.hooks';
import { useAllWorkPackagesPreview } from '../../../hooks/work-packages.hooks';
import { useAllTeamPreviews } from '../../../hooks/teams.hooks';
import { userToAutocompleteOption } from '../../../utils/teams.utils';
Expand Down Expand Up @@ -231,6 +231,7 @@ const EventModal: React.FC<BaseEventModalProps> = ({
const theme = useTheme();
const toast = useToast();
const user = useCurrentUser();
const { data: scheduleSettings } = useUserScheduleSettings(user.userId);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need isError, isLoading and error

const [datePickerOpen, setDatePickerOpen] = useState(false);
const [startTimePickerOpen, setStartTimePickerOpen] = useState(false);
const [endTimePickerOpen, setEndTimePickerOpen] = useState(false);
Expand Down Expand Up @@ -381,6 +382,16 @@ const EventModal: React.FC<BaseEventModalProps> = ({
}
}, [initialValues, users, teams]);

// When creating a new event, autofill personal zoom link from the user's schedule settings
// made it so it only fills when the field is empty, that way doesn't overwrite a link or anythingi me
useEffect(() => {
if (!open || isEditMode) return;
const personalZoomLink = scheduleSettings?.personalZoomLink;
if (personalZoomLink && !watch('zoomLink')) {
setValue('zoomLink', personalZoomLink);
}
}, [open, isEditMode, scheduleSettings, setValue, watch]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop setValue and watch from the dependency array
replace watch('zoomLink') with getValues('zoomLink')

useEffect(() => {
  if (!open || isEditMode) return;
  if (scheduleSettings?.personalZoomLink && !getValues('zoomLink')) {
    setValue('zoomLink', scheduleSettings.personalZoomLink);
  }
}, [open, isEditMode, scheduleSettings]);


const computedTitle = isEditMode ? 'Edit Event' : 'Add Event';

// Handle recurring dropdown toggle
Expand Down
Loading