Files
calendar/companion/utils/meetings-utils.ts
BetoandGitHub aa127b2c2b refactor: (companion) (iOS) create an ios screen for specific native logic (#26081)
* create an ios screen for specific native logic

* feat: update bookings layout to conditionally show header on iOS

* feat: add useActiveBookingFilter hook for managing booking filter state

- Introduced a new hook, useActiveBookingFilter, to manage the active booking filter state and provide related utilities.
- Added filter options for "upcoming", "unconfirmed", "past", and "cancelled" bookings.
- Updated index.ts to export the new hook and its types for UI state management.

* refactor: streamline booking filter management and remove unused code

- Integrated the useActiveBookingFilter hook to manage booking filter state, simplifying the filter logic.
- Removed redundant state variables and functions related to booking filters.
- Cleaned up the code by eliminating unused imports and commented-out code sections.
- Updated the booking fetching logic to utilize the new filter parameters directly.

* refactor: move meeting URL extraction and info retrieval to utility module

- Extracted meeting URL extraction and meeting info retrieval logic into a new utility module, meetings-utils.ts.
- Updated index.ios.tsx and index.tsx to utilize the new getMeetingInfo function from the utility module, simplifying the component code.
- Removed redundant helper functions from the component files to enhance maintainability.

* refactor: extract empty state content logic into utility module

- Moved the getEmptyStateContent function from the Bookings component files to a new utility module, bookings-utils.ts, to enhance code reusability and maintainability.
- Updated index.ios.tsx and index.tsx to utilize the new utility function, simplifying the component code and improving clarity.
- Removed redundant empty state logic from the component files.

* refactor: enhance booking filtering and utility functions

- Updated the Bookings component to utilize new utility functions for filtering bookings by event type and search queries, improving code clarity and maintainability.
- Moved formatting functions (formatTime, formatDate, formatMonthYear, getMonthYearKey) and grouping logic (groupBookingsByMonth) to the bookings-utils module, centralizing related functionality.
- Removed redundant code from the Bookings component files, streamlining the overall structure.

* refactor: implement booking actions hook for improved management

- Introduced a new `useBookingActions` hook to centralize booking-related actions such as rescheduling, confirming, and rejecting bookings, enhancing code organization and reusability.
- Updated the `Bookings` component to utilize the new hook, simplifying the component logic and reducing redundancy.
- Removed outdated state management and functions related to booking actions, streamlining the overall code structure.

* refactor: consolidate booking components and enhance structure

- Refactored the Bookings component to utilize a new BookingListScreen component, improving code organization and readability.
- Introduced BookingListItem for individual booking rendering, streamlining the rendering logic and enhancing maintainability.
- Removed redundant state management and functions from the Bookings component, simplifying the overall structure.
- Updated modal handling for booking actions, rescheduling, and rejection to improve user experience and code clarity.

* feat: add BookingListItem component for enhanced booking display

- Introduced a new BookingListItem component for rendering individual booking details, improving modularity and reusability.
- Implemented context menu actions for booking management, including rescheduling, editing location, and adding guests.
- Updated type definitions for BookingListItemProps to include additional action handlers for better functionality.
- Refactored existing BookingListItem component to utilize the new props structure, enhancing clarity and maintainability.

* refactor: simplify layout and styling in BookingListItem and BookingListScreen components

- Updated the BookingListItem component to streamline the layout by reducing padding and adjusting the gap between elements.
- Modified the BookingListScreen component to remove unnecessary horizontal padding in the content container style, enhancing the overall layout consistency.
2025-12-21 11:38:42 +00:00

94 lines
2.5 KiB
TypeScript

import { getAppIconUrl } from "./getAppIconUrl";
// Helper to extract clean meeting URL from potentially wrapped URLs
function extractMeetingUrl(location: string): string {
// Check if it's a goo.gl redirect URL with embedded meet.google.com link
if (location.includes("goo.gl") && location.includes("meet.google.com")) {
// Extract the actual meet.google.com URL from the redirect
const meetMatch = location.match(/meet\.google\.com\/[a-z]+-[a-z]+-[a-z]+/i);
if (meetMatch) {
return `https://${meetMatch[0]}`;
}
}
return location;
}
// Helper to detect meeting type from location URL and get icon/label
export const getMeetingInfo = (
location?: string
): { appId: string; label: string; iconUrl: string | null; cleanUrl: string } | null => {
if (!location) return null;
// Check if it's a URL
if (!location.match(/^https?:\/\//)) return null;
const lowerLocation = location.toLowerCase();
const cleanUrl = extractMeetingUrl(location);
// Cal Video
if (lowerLocation.includes("cal.com/video") || lowerLocation.includes("cal.video")) {
return {
appId: "cal-video",
label: "Join Cal Video",
iconUrl: getAppIconUrl("daily_video", "cal-video"),
cleanUrl,
};
}
// Google Meet (including goo.gl redirect URLs)
if (
lowerLocation.includes("meet.google.com") ||
(lowerLocation.includes("goo.gl") && lowerLocation.includes("meet"))
) {
return {
appId: "google-meet",
label: "Join Google Meet",
iconUrl: getAppIconUrl("google_video", "google-meet"),
cleanUrl,
};
}
// Zoom
if (lowerLocation.includes("zoom.us") || lowerLocation.includes("zoom.com")) {
return {
appId: "zoom",
label: "Join Zoom",
iconUrl: getAppIconUrl("zoom_video", "zoom"),
cleanUrl,
};
}
// Microsoft Teams
if (lowerLocation.includes("teams.microsoft.com") || lowerLocation.includes("teams.live.com")) {
return {
appId: "msteams",
label: "Join Microsoft Teams",
iconUrl: getAppIconUrl("office365_video", "msteams"),
cleanUrl,
};
}
// Webex
if (lowerLocation.includes("webex.com")) {
return {
appId: "webex",
label: "Join Webex",
iconUrl: getAppIconUrl("webex_video", "webex"),
cleanUrl,
};
}
// Jitsi
if (lowerLocation.includes("meet.jit.si") || lowerLocation.includes("jitsi")) {
return {
appId: "jitsi",
label: "Join Jitsi",
iconUrl: getAppIconUrl("jitsi_video", "jitsi"),
cleanUrl,
};
}
// Not a recognized conferencing app
return null;
};