Skip to content

Scheduling infrastructure for absolutely everyone.

feat(companion): availability detail page for android and extension (#26560)

Dhairyashil Shinde84d1ce5bff01
diff --git a/companion/app/(tabs)/(availability)/_layout.tsx b/companion/app/(tabs)/(availability)/_layout.tsx
index d175a850d2c..c4c05b17823 100644
--- a/companion/app/(tabs)/(availability)/_layout.tsx
+++ b/companion/app/(tabs)/(availability)/_layout.tsx
@@ -5,7 +5,7 @@ export default function AvailabilityLayout() {
return (
<Stack>
<Stack.Screen name="index" options={{ headerShown: false }} />
- <Stack.Screen name="availability-detail" options={{ headerShown: Platform.OS === "ios" }} />
+ <Stack.Screen name="availability-detail" />
</Stack>
);
}
diff --git a/companion/app/(tabs)/(availability)/availability-detail.tsx b/companion/app/(tabs)/(availability)/availability-detail.tsx
index 6aa2766ca32..f31ab0aecb2 100644
--- a/companion/app/(tabs)/(availability)/availability-detail.tsx
+++ b/companion/app/(tabs)/(availability)/availability-detail.tsx
@@ -1,47 +1,127 @@
+import { Ionicons } from "@expo/vector-icons";
import { Stack, useLocalSearchParams, useRouter } from "expo-router";
-import { useRef } from "react";
-import { Platform } from "react-native";
+import { useCallback, useRef } from "react";
+import { Text, TouchableOpacity } from "react-native";
import {
AvailabilityDetailScreen,
type AvailabilityDetailScreenHandle,
} from "@/components/screens/AvailabilityDetailScreen";
+import { HeaderButtonWrapper } from "@/components/HeaderButtonWrapper";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu";
+
+// Type for action handlers exposed by AvailabilityDetailScreen
+type ActionHandlers = {
+ handleSetAsDefault: () => void;
+ handleDelete: () => void;
+};
export default function AvailabilityDetail() {
const { id } = useLocalSearchParams<{ id: string }>();
const router = useRouter();
+
+ // Ref to store action handlers from AvailabilityDetailScreen
+ const actionHandlersRef = useRef<ActionHandlers | null>(null);
const screenRef = useRef<AvailabilityDetailScreenHandle>(null);
+ // Callback to receive action handlers from AvailabilityDetailScreen
+ const handleActionsReady = useCallback((handlers: ActionHandlers) => {
+ actionHandlersRef.current = handlers;
+ }, []);
+
+ // Navigation handlers for edit modal screens
+ const handleEditNameAndTimezone = useCallback(() => {
+ router.push(`/edit-availability-name?id=${id}` as never);
+ }, [router, id]);
+
+ const handleEditWorkingHours = useCallback(() => {
+ router.push(`/edit-availability-hours?id=${id}` as never);
+ }, [router, id]);
+
+ const handleEditOverride = useCallback(() => {
+ router.push(`/edit-availability-override?id=${id}` as never);
+ }, [router, id]);
+
+ // Action handlers for inline actions
+ const handleSetAsDefault = useCallback(() => {
+ if (actionHandlersRef.current?.handleSetAsDefault) {
+ actionHandlersRef.current.handleSetAsDefault();
+ } else if (screenRef.current?.setAsDefault) {
+ screenRef.current.setAsDefault();
+ }
+ }, []);
+
+ const handleDelete = useCallback(() => {
+ if (actionHandlersRef.current?.handleDelete) {
+ actionHandlersRef.current.handleDelete();
+ } else if (screenRef.current?.delete) {
+ screenRef.current.delete();
+ }
+ }, []);
+
if (!id) {
return null;
}
- const handleSave = () => {
- screenRef.current?.save();
- };
-
return (
<>
- <Stack.Screen options={{ headerShown: false }} />
-
- {Platform.OS === "ios" && (
- <Stack.Header>
- <Stack.Header.Left>
- <Stack.Header.Button onPress={() => router.back()}>
- <Stack.Header.Icon sf="chevron.left" />
- </Stack.Header.Button>
- </Stack.Header.Left>
-
- <Stack.Header.Title>Edit Availability</Stack.Header.Title>
-
- <Stack.Header.Right>
- <Stack.Header.Button onPress={handleSave} variant="prominent" tintColor="#000">
- Save
- </Stack.Header.Button>
- </Stack.Header.Right>
- </Stack.Header>
- )}
-
- <AvailabilityDetailScreen ref={screenRef} id={id} useNativeHeader={Platform.OS === "ios"} />
+ <Stack.Screen
+ options={{
+ title: "Availability",
+ headerBackTitle: "Availability",
+ headerStyle: {
+ backgroundColor: "#f2f2f7",
+ },
+ headerShadowVisible: false,
+ headerRight: () => (
+ <HeaderButtonWrapper side="right">
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <TouchableOpacity
+ style={{
+ padding: 8,
+ marginRight: -8,
+ }}
+ >
+ <Ionicons name="ellipsis-horizontal-circle" size={24} color="#007AFF" />
+ </TouchableOpacity>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-56">
+ <DropdownMenuItem onPress={handleEditNameAndTimezone}>
+ <Ionicons name="pencil-outline" size={18} color="#000" />
+ <Text className="ml-2 text-[15px] text-black">Name and Timezone</Text>
+ </DropdownMenuItem>
+ <DropdownMenuItem onPress={handleEditWorkingHours}>
+ <Ionicons name="time-outline" size={18} color="#000" />
+ <Text className="ml-2 text-[15px] text-black">Working Hours</Text>
+ </DropdownMenuItem>
+ <DropdownMenuItem onPress={handleEditOverride}>
+ <Ionicons name="calendar-outline" size={18} color="#000" />
+ <Text className="ml-2 text-[15px] text-black">Date Override</Text>
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem onPress={handleSetAsDefault}>
+ <Ionicons name="star-outline" size={18} color="#000" />
+ <Text className="ml-2 text-[15px] text-black">Set as Default</Text>
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem onPress={handleDelete} variant="destructive">
+ <Ionicons name="trash-outline" size={18} color="#FF3B30" />
+ <Text className="ml-2 text-[15px] text-[#FF3B30]">Delete Schedule</Text>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </HeaderButtonWrapper>
+ ),
+ }}
+ />
+
+ <AvailabilityDetailScreen ref={screenRef} id={id} onActionsReady={handleActionsReady} />
</>
);
}
diff --git a/companion/app/(tabs)/(event-types)/event-type-detail.tsx b/companion/app/(tabs)/(event-types)/event-type-detail.tsx
index d37455c4681..dec8cde9365 100644
--- a/companion/app/(tabs)/(event-types)/event-type-detail.tsx
+++ b/companion/app/(tabs)/(event-types)/event-type-detail.tsx
@@ -1256,46 +1256,6 @@ export default function EventTypeDetail() {
contentContainerStyle={{ padding: 16, paddingBottom: 200 }}
contentInsetAdjustmentBehavior="automatic"
>
- {/* Horizontal tabs only shown on web; Android uses header dropdown menu */}
- <Activity mode={Platform.OS === "web" ? "visible" : "hidden"}>
- <View
- style={{
- paddingBottom: 12,
- }}
- >
- <ScrollView
- horizontal
- showsHorizontalScrollIndicator={false}
- contentContainerStyle={{ paddingHorizontal: 12, gap: 4 }}
- >
- {tabs.map((tab) => (
- <TouchableOpacity
- key={tab.id}
- className={`min-w-[90px] items-center rounded-[24px] px-3 py-3 md:px-5 ${
- activeTab === tab.id ? "bg-[#EEEFF2]" : ""
- }`}
- onPress={() => setActiveTab(tab.id)}
- >
- <View className="flex-row items-center gap-2">
- <Ionicons
- name={tab.icon}
- size={18}
- color={activeTab === tab.id ? "#007AFF" : "#666"}
- />
- <Text
- className={`text-base font-medium ${
- activeTab === tab.id ? "font-semibold text-[#007AFF]" : "text-[#666]"
- }`}
- >
- {tab.label}
- </Text>
- </View>
- </TouchableOpacity>
- ))}
- </ScrollView>
- </View>
- </Activity>
-
{activeTab === "basics" ? (
<BasicsTab
eventTitle={eventTitle}
diff --git a/companion/app/(tabs)/_layout.tsx b/companion/app/(tabs)/_layout.tsx
index f13bbf38f7e..eb746e72ee2 100644
--- a/companion/app/(tabs)/_layout.tsx
+++ b/companion/app/(tabs)/_layout.tsx
@@ -70,6 +70,12 @@ function WebTabs() {
},
}}
>
+ <Tabs.Screen
+ name="index"
+ options={{
+ href: null,
+ }}
+ />
<Tabs.Screen
name="(event-types)"
options={{
diff --git a/companion/app/edit-availability-hours.tsx b/companion/app/edit-availability-hours.tsx
index d5814bab602..be67be47da8 100644
--- a/companion/app/edit-availability-hours.tsx
+++ b/companion/app/edit-availability-hours.tsx
@@ -1,7 +1,9 @@
+import { Ionicons } from "@expo/vector-icons";
import { Stack, useLocalSearchParams, useRouter } from "expo-router";
import { useCallback, useEffect, useState } from "react";
-import { ActivityIndicator, Alert, View } from "react-native";
+import { ActivityIndicator, Alert, TouchableOpacity, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { HeaderButtonWrapper } from "@/components/HeaderButtonWrapper";
import EditAvailabilityHoursScreenComponent from "@/components/screens/EditAvailabilityHoursScreen";
import { CalComAPIService, type Schedule } from "@/services/calcom";
@@ -29,6 +31,10 @@ export default function EditAvailabilityHours() {
}
}, [id, router]);
+ const handleClose = useCallback(() => {
+ router.back();
+ }, [router]);
+
const handleDayPress = useCallback(
(dayIndex: number) => {
router.push(`/edit-availability-day?id=${id}&day=${dayIndex}` as never);
@@ -42,7 +48,12 @@ export default function EditAvailabilityHours() {
className="flex-1 items-center justify-center bg-white"
style={{ paddingBottom: insets.bottom }}
>
- <Stack.Screen options={{ title: "Working Hours" }} />
+ <Stack.Screen
+ options={{
+ title: "Working Hours",
+ presentation: "modal",
+ }}
+ />
<ActivityIndicator size="large" color="#007AFF" />
</View>
);
@@ -50,7 +61,25 @@ export default function EditAvailabilityHours() {
return (
<View className="flex-1 bg-white" style={{ paddingBottom: insets.bottom }}>
- <Stack.Screen options={{ title: "Working Hours" }} />
+ <Stack.Screen
+ options={{
+ title: "Working Hours",
+ presentation: "modal",
+ contentStyle: {
+ backgroundColor: "#FFFFFF",
+ },
+ headerStyle: {
+ backgroundColor: "#FFFFFF",
+ },
+ headerLeft: () => (
+ <HeaderButtonWrapper side="left">
+ <TouchableOpacity onPress={handleClose} style={{ padding: 8 }}>
+ <Ionicons name="close" size={24} color="#000" />
+ </TouchableOpacity>
+ </HeaderButtonWrapper>
+ ),
+ }}
+ />
<EditAvailabilityHoursScreenComponent schedule={schedule} onDayPress={handleDayPress} />
</View>
);
diff --git a/companion/app/edit-availability-name.tsx b/companion/app/edit-availability-name.tsx
index 5cd3a8cbb58..9ab548ff91d 100644
--- a/companion/app/edit-availability-name.tsx
+++ b/companion/app/edit-availability-name.tsx
@@ -1,6 +1,7 @@
+import { Ionicons } from "@expo/vector-icons";
import { Stack, useLocalSearchParams, useRouter } from "expo-router";
import { useCallback, useEffect, useRef, useState } from "react";
-import { ActivityIndicator, Alert, Text, View } from "react-native";
+import { ActivityIndicator, Alert, Text, TouchableOpacity, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { HeaderButtonWrapper } from "@/components/HeaderButtonWrapper";
import type { EditAvailabilityNameScreenHandle } from "@/components/screens/EditAvailabilityNameScreen";
@@ -34,6 +35,10 @@ export default function EditAvailabilityName() {
}
}, [id, router]);
+ const handleClose = useCallback(() => {
+ router.back();
+ }, [router]);
+
const handleSave = useCallback(() => {
if (isSaving) return;
screenRef.current?.submit();
@@ -49,7 +54,12 @@ export default function EditAvailabilityName() {
className="flex-1 items-center justify-center bg-white"
style={{ paddingBottom: insets.bottom }}
>
- <Stack.Screen options={{ title: "Edit Name & Timezone" }} />
+ <Stack.Screen
+ options={{
+ title: "Edit Name & Timezone",
+ presentation: "modal",
+ }}
+ />
<ActivityIndicator size="large" color="#007AFF" />
</View>
);
@@ -60,6 +70,20 @@ export default function EditAvailabilityName() {
<Stack.Screen
options={{
title: "Edit Name & Timezone",
+ presentation: "modal",
+ contentStyle: {
+ backgroundColor: "#FFFFFF",
+ },
+ headerStyle: {
+ backgroundColor: "#FFFFFF",
+ },
+ headerLeft: () => (
+ <HeaderButtonWrapper side="left">
+ <TouchableOpacity onPress={handleClose} style={{ padding: 8 }}>
+ <Ionicons name="close" size={24} color="#000" />
+ </TouchableOpacity>
+ </HeaderButtonWrapper>
+ ),
headerRight: () => (
<HeaderButtonWrapper side="right">
<Text
diff --git a/companion/app/edit-availability-override.tsx b/companion/app/edit-availability-override.tsx
index d4bec5f788c..95196eeb689 100644
--- a/companion/app/edit-availability-override.tsx
+++ b/companion/app/edit-availability-override.tsx
@@ -1,6 +1,7 @@
+import { Ionicons } from "@expo/vector-icons";
import { Stack, useLocalSearchParams, useRouter } from "expo-router";
import { useCallback, useEffect, useRef, useState } from "react";
-import { ActivityIndicator, Alert, Text, View } from "react-native";
+import { ActivityIndicator, Alert, Text, TouchableOpacity, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { HeaderButtonWrapper } from "@/components/HeaderButtonWrapper";
import type { EditAvailabilityOverrideScreenHandle } from "@/components/screens/EditAvailabilityOverrideScreen";
@@ -40,6 +41,10 @@ export default function EditAvailabilityOverride() {
}
}, [id, router]);
+ const handleClose = useCallback(() => {
+ router.back();
+ }, [router]);
+
const handleSave = useCallback(() => {
if (isSaving) return;
screenRef.current?.submit();
@@ -66,7 +71,12 @@ export default function EditAvailabilityOverride() {
className="flex-1 items-center justify-center bg-white"
style={{ paddingBottom: insets.bottom }}
>
- <Stack.Screen options={{ title }} />
+ <Stack.Screen
+ options={{
+ title,
+ presentation: "modal",
+ }}
+ />
<ActivityIndicator size="large" color="#007AFF" />
</View>
);
@@ -77,6 +87,20 @@ export default function EditAvailabilityOverride() {
<Stack.Screen
options={{
title,
+ presentation: "modal",
+ contentStyle: {
+ backgroundColor: "#FFFFFF",
+ },
+ headerStyle: {
+ backgroundColor: "#FFFFFF",
+ },
+ headerLeft: () => (
+ <HeaderButtonWrapper side="left">
+ <TouchableOpacity onPress={handleClose} style={{ padding: 8 }}>
+ <Ionicons name="close" size={24} color="#000" />
+ </TouchableOpacity>
+ </HeaderButtonWrapper>
+ ),
headerRight: () => (
<HeaderButtonWrapper side="right">
<Text
diff --git a/companion/components/event-type-list-item/EventTypeListItemParts.tsx b/companion/components/event-type-list-item/EventTypeListItemParts.tsx
index 1f0b82be2ed..60d6a9fd980 100644
--- a/companion/components/event-type-list-item/EventTypeListItemParts.tsx
+++ b/companion/components/event-type-list-item/EventTypeListItemParts.tsx
@@ -134,7 +134,15 @@ export function EventTypeBadges({
{/* Price Badge */}
{hasPrice && formattedPrice ? (
- <Text className="text-sm font-medium text-cal-accent-success">{formattedPrice}</Text>
+ <View
+ className="rounded-md border border-cal-border bg-cal-border"
+ style={{ height: 24, paddingHorizontal: 8, flexDirection: "row", alignItems: "center" }}
+ >
+ <Ionicons name="card-outline" size={14} color="#000000" />
+ <Text className="ml-1.5 text-xs font-semibold text-cal-brand-black">
+ {formattedPrice}
+ </Text>
+ </View>
) : null}
{/* Repeats Badge */}
diff --git a/companion/components/event-type-list-item/useEventTypeListItemData.ts b/companion/components/event-type-list-item/useEventTypeListItemData.ts
index c5dcccd5737..dd0a425ac3b 100644
--- a/companion/components/event-type-list-item/useEventTypeListItemData.ts
+++ b/companion/components/event-type-list-item/useEventTypeListItemData.ts
@@ -20,7 +20,21 @@ export function useEventTypeListItemData(item: EventType): EventTypeListItemData
const formattedDuration = formatDuration(duration);
const normalizedDescription = item.description ? normalizeMarkdown(item.description) : null;
const hasPrice = item.price != null && item.price > 0;
- const formattedPrice = hasPrice ? `${item.currency || "$"}${item.price}` : null;
+ let formattedPrice: string | null = null;
+
+ if (hasPrice && item.price) {
+ // Price is in cents, convert to main unit
+ const priceAmount = item.price / 100;
+ try {
+ formattedPrice = new Intl.NumberFormat("en-US", {
+ style: "currency",
+ currency: item.currency?.toUpperCase() || "USD",
+ }).format(priceAmount);
+ } catch {
+ // Fallback if formatting fails
+ formattedPrice = `${item.currency?.toUpperCase() || "$"}${priceAmount.toFixed(2)}`;
+ }
+ }
return {
duration,
diff --git a/companion/components/screens/AvailabilityDetailScreen.ios.tsx b/companion/components/screens/AvailabilityDetailScreen.ios.tsx
index 33bbcfc40ce..b90d5e19cb3 100644
--- a/companion/components/screens/AvailabilityDetailScreen.ios.tsx
+++ b/companion/components/screens/AvailabilityDetailScreen.ios.tsx
@@ -114,8 +114,6 @@ export const AvailabilityDetailScreen = forwardRef<
endTime: string;
}[]
>([]);
- const [daysExpanded, setDaysExpanded] = useState(true);
- const [overridesExpanded, setOverridesExpanded] = useState(true);
const processScheduleData = useCallback(
(scheduleData: NonNullable<Awaited<ReturnType<typeof CalComAPIService.getScheduleById>>>) => {
@@ -327,46 +325,20 @@ export const AvailabilityDetailScreen = forwardRef<
</View>
</View>
- {/* Working Hours Summary Card */}
+ {/* Weekly Schedule Card - Navigable */}
<View className="mb-4 overflow-hidden rounded-xl bg-white">
- <View className="px-4 py-3.5">
- <Text className="mb-2.5 text-[13px] font-medium uppercase tracking-wide text-[#8E8E93]">
- Working Hours
- </Text>
- {Object.keys(availability).length > 0 ? (
- <View>
- {formatAvailabilityDisplay(availability).map((line) => (
- <Text key={line} className="mb-1 text-[17px] text-black">
- {line}
- </Text>
- ))}
+ <AppPressable onPress={() => router.push(`/edit-availability-hours?id=${id}` as never)}>
+ <View className="flex-row items-center justify-between px-4 py-3.5">
+ <Text className="text-[17px] text-black">Weekly Schedule</Text>
+ <View className="flex-row items-center">
+ <Text className="mr-1 text-[17px] text-[#8E8E93]">
+ {enabledDaysCount} {enabledDaysCount === 1 ? "day" : "days"}
+ </Text>
+ <Ionicons name="chevron-forward" size={18} color="#C7C7CC" />
</View>
- ) : (
- <Text className="text-[17px] text-[#8E8E93]">No availability set</Text>
- )}
- </View>
- </View>
-
- {/* Weekly Schedule Card - Expandable */}
- <View className="mb-4 overflow-hidden rounded-xl bg-white">
- <AppPressable
- className="flex-row items-center justify-between px-4 py-3.5"
- onPress={() => setDaysExpanded(!daysExpanded)}
- >
- <Text className="text-[17px] text-black">Weekly Schedule</Text>
- <View className="flex-row items-center">
- <Text className="mr-1 text-[17px] text-[#8E8E93]">
- {enabledDaysCount} {enabledDaysCount === 1 ? "day" : "days"}
- </Text>
- <Ionicons
- name={daysExpanded ? "chevron-down" : "chevron-forward"}
- size={18}
- color="#C7C7CC"
- />
</View>
- </AppPressable>
- {daysExpanded && (
+ {/* Expanded Day List */}
<View className="border-t border-[#E5E5EA] px-4 py-2.5">
{DAYS.map((day, dayIndex) => {
const daySlots = availability[dayIndex] || [];
@@ -412,38 +384,39 @@ export const AvailabilityDetailScreen = forwardRef<
);
})}
</View>
- )}
+ </AppPressable>
</View>
- {/* Timezone Card */}
+ {/* Timezone Card - Navigable */}
<View className="mb-4 overflow-hidden rounded-xl bg-white">
- <View className="flex-row items-center justify-between px-4 py-3.5">
- <Text className="text-[17px] text-black">Timezone</Text>
- <Text className="text-[17px] text-[#8E8E93]">{timeZone}</Text>
- </View>
+ <AppPressable onPress={() => router.push(`/edit-availability-name?id=${id}` as never)}>
+ <View className="flex-row items-center justify-between px-4 py-3.5">
+ <Text className="text-[17px] text-black">Timezone</Text>
+ <View className="flex-row items-center">
+ <Text className="mr-1 text-[17px] text-[#8E8E93]">{timeZone}</Text>
+ <Ionicons name="chevron-forward" size={18} color="#C7C7CC" />
+ </View>
+ </View>
+ </AppPressable>
</View>
- {/* Date Overrides Card - Expandable */}
+ {/* Date Overrides Card - Navigable */}
{overrides.length > 0 && (
<View className="mb-4 overflow-hidden rounded-xl bg-white">
<AppPressable
- className="flex-row items-center justify-between px-4 py-3.5"
- onPress={() => setOverridesExpanded(!overridesExpanded)}
+ onPress={() => router.push(`/edit-availability-override?id=${id}` as never)}
>
- <Text className="text-[17px] text-black">Date Overrides</Text>
- <View className="flex-row items-center">
- <Text className="mr-1 text-[17px] text-[#8E8E93]">
- {overrides.length} {overrides.length === 1 ? "override" : "overrides"}
- </Text>
- <Ionicons
- name={overridesExpanded ? "chevron-down" : "chevron-forward"}
- size={18}
- color="#C7C7CC"
- />
+ <View className="flex-row items-center justify-between px-4 py-3.5">
+ <Text className="text-[17px] text-black">Date Overrides</Text>
+ <View className="flex-row items-center">
+ <Text className="mr-1 text-[17px] text-[#8E8E93]">
+ {overrides.length} {overrides.length === 1 ? "override" : "overrides"}
+ </Text>
+ <Ionicons name="chevron-forward" size={18} color="#C7C7CC" />
+ </View>
</View>
- </AppPressable>
- {overridesExpanded && (
+ {/* Expanded Overrides List */}
<View className="border-t border-[#E5E5EA] px-4 py-2.5">
{overrides.map((override, index) => (
<View
@@ -464,7 +437,7 @@ export const AvailabilityDetailScreen = forwardRef<
</View>
))}
</View>
- )}
+ </AppPressable>
</View>
)}
diff --git a/companion/components/screens/AvailabilityDetailScreen.tsx b/companion/components/screens/AvailabilityDetailScreen.tsx
index 745d564d1ed..85c0dde8072 100644
--- a/companion/components/screens/AvailabilityDetailScreen.tsx
+++ b/companion/components/screens/AvailabilityDetailScreen.tsx
@@ -1,20 +1,23 @@
+/**
+ * AvailabilityDetailScreen Component (Android/Extension)
+ *
+ * Read-only display of availability schedule.
+ * Editing is done via separate modal screens.
+ */
+
import { Ionicons } from "@expo/vector-icons";
-import { GlassView } from "expo-glass-effect";
import { useRouter } from "expo-router";
import { forwardRef, useCallback, useEffect, useImperativeHandle, useState } from "react";
-import { ActivityIndicator, Alert, ScrollView, Switch, Text, TextInput, View } from "react-native";
+import { ActivityIndicator, Alert, ScrollView, Text, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppPressable } from "@/components/AppPressable";
-import { FullScreenModal } from "@/components/FullScreenModal";
-import { TIMEZONES } from "@/constants/timezones";
import { CalComAPIService, type Schedule } from "@/services/calcom";
import type { ScheduleAvailability } from "@/services/types";
import { showErrorAlert } from "@/utils/alerts";
const DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
-const DAY_ABBREVIATIONS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
-// Map day names to numbers - module scope for React Compiler optimization
+// Map day names to numbers
const DAY_NAME_TO_NUMBER: Record<string, number> = {
Sunday: 0,
Monday: 1,
@@ -32,16 +35,14 @@ const formatTime12Hour = (time24: string): string => {
const min = minutes || "00";
const period = hour >= 12 ? "PM" : "AM";
const hour12 = hour === 0 ? 12 : hour > 12 ? hour - 12 : hour;
- // Pad single-digit hours with leading zero for consistent width
const hour12Padded = hour12.toString().padStart(2, "0");
return `${hour12Padded}:${min} ${period}`;
};
-// Format availability for display
+// Format availability for display - groups days with same time range
const formatAvailabilityDisplay = (
availability: Record<number, ScheduleAvailability[]>
): string[] => {
- // Group slots by time range
const timeRangeMap: Record<string, number[]> = {};
Object.keys(availability).forEach((dayIndexStr) => {
@@ -58,12 +59,11 @@ const formatAvailabilityDisplay = (
}
});
- // Format each time range group
const formatted: string[] = [];
Object.keys(timeRangeMap).forEach((timeKey) => {
const days = timeRangeMap[timeKey].sort((a, b) => a - b);
const [startTime, endTime] = timeKey.split("-");
- const dayNames = days.map((day) => DAY_ABBREVIATIONS[day]).join(", ");
+ const dayNames = days.map((day) => DAYS[day]).join(", ");
const timeRange = `${formatTime12Hour(startTime)} - ${formatTime12Hour(endTime)}`;
formatted.push(`${dayNames}, ${timeRange}`);
});
@@ -71,28 +71,24 @@ const formatAvailabilityDisplay = (
return formatted;
};
-// Generate time options (15-minute intervals)
-const generateTimeOptions = () => {
- const options: string[] = [];
- for (let hour = 0; hour < 24; hour++) {
- for (let minute = 0; minute < 60; minute += 15) {
- const h = hour.toString().padStart(2, "0");
- const m = minute.toString().padStart(2, "0");
- options.push(`${h}:${m}`);
- }
- }
- return options;
+// Format date for display
+const formatDateForDisplay = (dateStr: string): string => {
+ if (!dateStr) return "";
+ const date = new Date(`${dateStr}T00:00:00`);
+ return date.toLocaleDateString("en-US", {
+ weekday: "short",
+ month: "short",
+ day: "numeric",
+ year: "numeric",
+ });
};
-const TIME_OPTIONS = generateTimeOptions();
-
export interface AvailabilityDetailScreenProps {
id: string;
- useNativeHeader?: boolean;
+ onActionsReady?: (handlers: { handleSetAsDefault: () => void; handleDelete: () => void }) => void;
}
export interface AvailabilityDetailScreenHandle {
- save: () => void;
setAsDefault: () => void;
delete: () => void;
refresh: () => void;
@@ -101,42 +97,23 @@ export interface AvailabilityDetailScreenHandle {
export const AvailabilityDetailScreen = forwardRef<
AvailabilityDetailScreenHandle,
AvailabilityDetailScreenProps
->(function AvailabilityDetailScreen({ id, useNativeHeader = false }, ref) {
+>(function AvailabilityDetailScreen({ id, onActionsReady }, ref) {
const router = useRouter();
const insets = useSafeAreaInsets();
const [loading, setLoading] = useState(true);
- const [saving, setSaving] = useState(false);
const [_schedule, setSchedule] = useState<Schedule | null>(null);
const [scheduleName, setScheduleName] = useState("");
const [timeZone, setTimeZone] = useState("");
const [isDefault, setIsDefault] = useState(false);
const [availability, setAvailability] = useState<Record<number, ScheduleAvailability[]>>({});
- const [showTimezoneModal, setShowTimezoneModal] = useState(false);
- const [showTimePicker, setShowTimePicker] = useState<{
- dayIndex: number;
- slotIndex: number;
- type: "start" | "end";
- } | null>(null);
const [overrides, setOverrides] = useState<
{
- date: string; // Format: "2024-05-20"
- startTime: string; // Format: "12:00" or "00:00" for unavailable
- endTime: string; // Format: "14:00" or "00:00" for unavailable
+ date: string;
+ startTime: string;
+ endTime: string;
}[]
>([]);
- const [showOverrideModal, setShowOverrideModal] = useState(false);
- const [editingOverride, setEditingOverride] = useState<number | null>(null);
- const [overrideDate, setOverrideDate] = useState("");
- const [overrideStartTime, setOverrideStartTime] = useState("09:00");
- const [overrideEndTime, setOverrideEndTime] = useState("17:00");
- const [isUnavailable, setIsUnavailable] = useState(false);
- const [showOverrideTimePicker, setShowOverrideTimePicker] = useState<{
- type: "start" | "end";
- } | null>(null);
-
- // Use all supported timezones from the shared constants
- const timezones = TIMEZONES;
const processScheduleData = useCallback(
(scheduleData: NonNullable<Awaited<ReturnType<typeof CalComAPIService.getScheduleById>>>) => {
@@ -149,29 +126,24 @@ export const AvailabilityDetailScreen = forwardRef<
setTimeZone(tz);
setIsDefault(isDefaultSchedule);
- // Convert availability array to day-indexed object
const availabilityMap: Record<number, ScheduleAvailability[]> = {};
const availabilityArray = scheduleData.availability;
if (availabilityArray && Array.isArray(availabilityArray)) {
availabilityArray.forEach((slot) => {
- // Handle both string day names and number day formats
let days: number[] = [];
if (Array.isArray(slot.days)) {
days = slot.days
.map((day) => {
- // If it's a day name string (e.g., "Sunday", "Monday")
if (typeof day === "string" && DAY_NAME_TO_NUMBER[day] !== undefined) {
return DAY_NAME_TO_NUMBER[day];
}
- // If it's a number string (e.g., "0", "1")
if (typeof day === "string") {
const parsed = parseInt(day, 10);
if (!Number.isNaN(parsed) && parsed >= 0 && parsed <= 6) {
return parsed;
}
}
- // If it's already a number
if (typeof day === "number" && day >= 0 && day <= 6) {
return day;
}
@@ -197,7 +169,6 @@ export const AvailabilityDetailScreen = forwardRef<
setAvailability(availabilityMap);
- // Load overrides if they exist
const overridesArray = scheduleData.overrides;
if (overridesArray && Array.isArray(overridesArray)) {
const formattedOverrides = overridesArray.map((override) => {
@@ -220,7 +191,6 @@ export const AvailabilityDetailScreen = forwardRef<
try {
scheduleData = await CalComAPIService.getScheduleById(Number(id));
} catch (error) {
- // Avoid logging raw error objects from API calls (may contain sensitive response data).
console.error("Error fetching schedule");
if (__DEV__) {
const message = error instanceof Error ? error.message : String(error);
@@ -246,139 +216,12 @@ export const AvailabilityDetailScreen = forwardRef<
}
}, [id, fetchSchedule]);
- const toggleDay = (dayIndex: number) => {
- setAvailability((prev) => {
- const newAvailability = { ...prev };
- if (newAvailability[dayIndex] && newAvailability[dayIndex].length > 0) {
- // Disable day - remove availability
- delete newAvailability[dayIndex];
- } else {
- // Enable day - add default time slot (9 AM - 5 PM)
- newAvailability[dayIndex] = [
- {
- days: [dayIndex.toString()],
- startTime: "09:00:00",
- endTime: "17:00:00",
- },
- ];
- }
- return newAvailability;
- });
- };
-
- const addTimeSlot = (dayIndex: number) => {
- setAvailability((prev) => {
- const newAvailability = { ...prev };
- if (!newAvailability[dayIndex]) {
- newAvailability[dayIndex] = [];
- }
- newAvailability[dayIndex].push({
- days: [dayIndex.toString()],
- startTime: "09:00:00",
- endTime: "17:00:00",
- });
- return newAvailability;
- });
- };
-
- const removeTimeSlot = (dayIndex: number, slotIndex: number) => {
- setAvailability((prev) => {
- const newAvailability = { ...prev };
- if (newAvailability[dayIndex]) {
- newAvailability[dayIndex] = newAvailability[dayIndex].filter((_, i) => i !== slotIndex);
- if (newAvailability[dayIndex].length === 0) {
- delete newAvailability[dayIndex];
- }
- }
- return newAvailability;
- });
- };
-
- const updateTimeSlot = (
- dayIndex: number,
- slotIndex: number,
- type: "start" | "end",
- time: string
- ) => {
- setAvailability((prev) => {
- const newAvailability = { ...prev };
- if (newAvailability[dayIndex]?.[slotIndex]) {
- const slot = { ...newAvailability[dayIndex][slotIndex] };
- if (type === "start") {
- slot.startTime = `${time}:00`;
- } else {
- slot.endTime = `${time}:00`;
- }
- newAvailability[dayIndex][slotIndex] = slot;
- }
- return newAvailability;
- });
- };
-
- const handleSave = async () => {
- // Validate availability name
- if (!scheduleName.trim()) {
- Alert.alert("Error", "Please enter an availability name");
+ const handleSetAsDefault = useCallback(async () => {
+ if (isDefault) {
+ Alert.alert("Info", "This schedule is already set as default");
return;
}
- setSaving(true);
- try {
- // Convert availability object back to array format with day names
- const availabilityArray: {
- days: string[]; // Day names like "Monday", "Tuesday"
- startTime: string; // Format: "09:00"
- endTime: string; // Format: "10:00"
- }[] = [];
-
- Object.keys(availability).forEach((dayIndexStr) => {
- const dayIndex = Number(dayIndexStr);
- const slots = availability[dayIndex];
- if (slots && slots.length > 0) {
- slots.forEach((slot) => {
- // Convert day number to day name
- const dayName = DAYS[dayIndex];
-
- // Format time from "09:00:00" to "09:00" (remove seconds)
- const formatTimeForAPI = (time: string): string => {
- return time.substring(0, 5); // Take only HH:MM
- };
-
- availabilityArray.push({
- days: [dayName],
- startTime: formatTimeForAPI(slot.startTime),
- endTime: formatTimeForAPI(slot.endTime),
- });
- });
- }
- });
-
- // Format overrides for API (ensure times are in HH:MM format)
- const formattedOverrides = overrides.map((override) => ({
- date: override.date,
- startTime: override.startTime.substring(0, 5), // Ensure HH:MM format
- endTime: override.endTime.substring(0, 5), // Ensure HH:MM format
- }));
-
- await CalComAPIService.updateSchedule(Number(id), {
- name: scheduleName.trim(),
- timeZone,
- availability: availabilityArray,
- isDefault: isDefault,
- overrides: formattedOverrides,
- });
-
- Alert.alert("Success", "Availability updated successfully", [
- { text: "OK", onPress: () => router.back() },
- ]);
- setSaving(false);
- } catch {
- showErrorAlert("Error", "Failed to update availability. Please try again.");
- setSaving(false);
- }
- };
-
- const handleSetAsDefault = async () => {
try {
await CalComAPIService.updateSchedule(Number(id), {
isDefault: true,
@@ -388,9 +231,17 @@ export const AvailabilityDetailScreen = forwardRef<
} catch {
showErrorAlert("Error", "Failed to set availability as default. Please try again.");
}
- };
+ }, [isDefault, id]);
+
+ const handleDelete = useCallback(() => {
+ if (isDefault) {
+ Alert.alert(
+ "Cannot Delete",
+ "You cannot delete the default schedule. Please set another schedule as default first."
+ );
+ return;
+ }
- const handleDelete = () => {
Alert.alert("Delete Availability", `Are you sure you want to delete "${scheduleName}"?`, [
{ text: "Cancel", style: "cancel" },
{
@@ -408,669 +259,198 @@ export const AvailabilityDetailScreen = forwardRef<
},
},
]);
- };
-
- // Expose methods to parent via ref
- useImperativeHandle(ref, () => ({
- save: handleSave,
- setAsDefault: handleSetAsDefault,
- delete: handleDelete,
- refresh: fetchSchedule,
- }));
-
- const handleAddOverride = () => {
- setEditingOverride(null);
- setOverrideDate("");
- setOverrideStartTime("09:00");
- setOverrideEndTime("17:00");
- setIsUnavailable(false);
- setShowOverrideModal(true);
- };
-
- const handleEditOverride = (index: number) => {
- const override = overrides[index];
- setEditingOverride(index);
- setOverrideDate(override.date);
- setOverrideStartTime(override.startTime);
- setOverrideEndTime(override.endTime);
- setIsUnavailable(override.startTime === "00:00" && override.endTime === "00:00");
- setShowOverrideModal(true);
- };
-
- const handleDeleteOverride = (index: number) => {
- Alert.alert("Delete Override", "Are you sure you want to delete this date override?", [
- { text: "Cancel", style: "cancel" },
- {
- text: "Delete",
- style: "destructive",
- onPress: () => {
- setOverrides(overrides.filter((_, i) => i !== index));
- },
- },
- ]);
- };
-
- const handleSaveOverride = () => {
- if (!overrideDate) {
- Alert.alert("Error", "Please select a date");
- return;
- }
-
- const newOverride = {
- date: overrideDate,
- startTime: isUnavailable ? "00:00" : overrideStartTime,
- endTime: isUnavailable ? "00:00" : overrideEndTime,
- };
+ }, [isDefault, scheduleName, id, router]);
+
+ // Expose handlers via ref
+ useImperativeHandle(
+ ref,
+ () => ({
+ setAsDefault: handleSetAsDefault,
+ delete: handleDelete,
+ refresh: fetchSchedule,
+ }),
+ [handleSetAsDefault, handleDelete, fetchSchedule]
+ );
- if (editingOverride !== null) {
- // Update existing override
- const updated = [...overrides];
- updated[editingOverride] = newOverride;
- setOverrides(updated);
- } else {
- // Add new override
- setOverrides([...overrides, newOverride]);
+ // Expose handlers to parent for header menu
+ useEffect(() => {
+ if (onActionsReady) {
+ onActionsReady({
+ handleSetAsDefault,
+ handleDelete,
+ });
}
+ }, [onActionsReady, handleSetAsDefault, handleDelete]);
- setShowOverrideModal(false);
- };
-
- const formatDateForDisplay = (dateStr: string): string => {
- if (!dateStr) return "";
- const date = new Date(`${dateStr}T00:00:00`);
- return date.toLocaleDateString("en-US", {
- month: "short",
- day: "numeric",
- year: "numeric",
- });
- };
+ // Count enabled days
+ const enabledDaysCount = Object.keys(availability).length;
if (loading) {
return (
- <View className="flex-1 items-center justify-center bg-[#f8f9fa]">
+ <View className="flex-1 items-center justify-center bg-[#f2f2f7]">
<ActivityIndicator size="large" color="#000000" />
- <Text className="mt-4 text-base text-[#666]">Loading availability...</Text>
+ <Text className="mt-4 text-[15px] text-[#8E8E93]">Loading availability...</Text>
</View>
);
}
return (
- <View className="flex-1 bg-[#f8f9fa]">
- {/* Glass Header - only show when not using native header */}
- {!useNativeHeader && (
- <GlassView
- style={[
- {
- position: "absolute",
- top: 0,
- left: 0,
- right: 0,
- zIndex: 1000,
- paddingHorizontal: 16,
- paddingBottom: 12,
- paddingTop: insets.top + 8,
- },
- ]}
- glassEffectStyle="clear"
- >
- <View className="min-h-[44px] flex-row items-center justify-between">
- <AppPressable
- className="h-10 w-10 items-start justify-center"
- onPress={() => router.back()}
- >
- <Ionicons name="chevron-back" size={24} color="#000" />
- </AppPressable>
-
- <Text
- className="mx-2.5 flex-1 text-center text-lg font-semibold text-black"
- numberOfLines={1}
- >
- Edit Availability
- </Text>
-
- <AppPressable
- className={`min-w-[60px] items-center rounded-[10px] bg-black px-2 py-2 md:px-4 ${
- saving ? "opacity-60" : ""
- }`}
- onPress={handleSave}
- disabled={saving}
- >
- <Text className="text-base font-semibold text-white">Save</Text>
- </AppPressable>
- </View>
- </GlassView>
- )}
-
+ <View className="flex-1 bg-[#f2f2f7]">
<ScrollView
className="flex-1"
- style={{ paddingTop: useNativeHeader ? 0 : insets.top + 70 }}
- contentContainerStyle={{ padding: 16, paddingBottom: 200 }}
- >
- <View className="gap-4">
- {/* Availability Name */}
- <View className="rounded-2xl bg-white p-6">
- <Text className="mb-3 text-base font-semibold text-[#333]">Availability Name</Text>
- <TextInput
- value={scheduleName}
- onChangeText={setScheduleName}
- placeholder="Enter availability name"
- placeholderTextColor="#999"
- className="rounded-lg border border-[#E5E5EA] bg-[#F8F9FA] px-3 py-3 text-base text-[#333]"
- />
- </View>
-
- {/* Working Hours Display */}
- <View className="rounded-2xl bg-white p-6">
- <Text className="mb-3 text-xl font-bold text-[#333]">Working Hours</Text>
- {Object.keys(availability).length > 0 ? (
- <View>
- {formatAvailabilityDisplay(availability).map((line) => (
- <Text key={line} className="mb-1 text-base text-[#666]">
- {line}
- </Text>
- ))}
- </View>
- ) : (
- <Text className="text-base text-[#999]">No availability set</Text>
- )}
- </View>
-
- {/* Availability Schedule */}
- <View className="rounded-2xl bg-white p-6">
- <Text className="mb-4 text-xl font-bold text-[#333]">Availability</Text>
- {DAYS.map((day, dayIndex) => {
- const daySlots = availability[dayIndex] || [];
- const isEnabled = daySlots.length > 0;
- const firstSlot = daySlots[0];
-
- return (
- <View
- key={day}
- className={`mb-3 border-b border-[#E5E5EA] pb-3 ${
- dayIndex === DAYS.length - 1 ? "mb-0 border-b-0 pb-0" : ""
- }`}
- >
- <View className="flex-row items-center">
- <View className="flex-1 flex-row items-center">
- <Switch
- value={isEnabled}
- onValueChange={() => toggleDay(dayIndex)}
- trackColor={{ false: "#E5E5EA", true: "#34C759" }}
- thumbColor="#fff"
- style={{
- transform: [{ scaleX: 0.8 }, { scaleY: 0.8 }],
- }}
- />
- <Text
- className="ml-1 text-base font-medium text-[#333]"
- style={{ width: 40 }}
- >
- {DAY_ABBREVIATIONS[dayIndex]}
- </Text>
- {isEnabled && firstSlot ? (
- <View className="flex-row items-center gap-2">
- <AppPressable
- onPress={() =>
- setShowTimePicker({
- dayIndex,
- slotIndex: 0,
- type: "start",
- })
- }
- className="rounded-lg border border-[#E5E5EA] bg-white px-2 py-1"
- style={{ width: 85 }}
- >
- <Text className="text-center text-base text-[#333]">
- {formatTime12Hour(firstSlot.startTime)}
- </Text>
- </AppPressable>
- <Text className="text-base text-[#666]">-</Text>
- <AppPressable
- onPress={() =>
- setShowTimePicker({
- dayIndex,
- slotIndex: 0,
- type: "end",
- })
- }
- className="rounded-lg border border-[#E5E5EA] bg-white px-2 py-1"
- style={{ width: 85 }}
- >
- <Text className="text-center text-base text-[#333]">
- {formatTime12Hour(firstSlot.endTime)}
- </Text>
- </AppPressable>
- </View>
- ) : null}
- </View>
- {isEnabled ? (
- <AppPressable onPress={() => addTimeSlot(dayIndex)} className="p-1">
- <Ionicons name="add-circle-outline" size={20} color="#007AFF" />
- </AppPressable>
- ) : null}
- </View>
-
- {isEnabled && daySlots.length > 1 ? (
- <View className="mt-2" style={{ marginLeft: 108 }}>
- {daySlots.slice(1).map((slot, slotIndex) => (
- <View
- key={`${slotIndex}-${slot.startTime}-${slot.endTime}`}
- className="mb-2 flex-row items-center gap-2"
- >
- <AppPressable
- onPress={() =>
- setShowTimePicker({
- dayIndex,
- slotIndex: slotIndex + 1,
- type: "start",
- })
- }
- className="rounded-lg border border-[#E5E5EA] bg-white px-2 py-1"
- style={{ width: 85 }}
- >
- <Text className="text-center text-base text-[#333]">
- {formatTime12Hour(slot.startTime)}
- </Text>
- </AppPressable>
- <Text className="text-base text-[#666]">-</Text>
- <AppPressable
- onPress={() =>
- setShowTimePicker({
- dayIndex,
- slotIndex: slotIndex + 1,
- type: "end",
- })
- }
- className="rounded-lg border border-[#E5E5EA] bg-white px-2 py-1"
- style={{ width: 85 }}
- >
- <Text className="text-center text-base text-[#333]">
- {formatTime12Hour(slot.endTime)}
- </Text>
- </AppPressable>
- <AppPressable
- onPress={() => removeTimeSlot(dayIndex, slotIndex + 1)}
- className="p-1"
- >
- <Ionicons name="trash-outline" size={20} color="#800020" />
- </AppPressable>
- </View>
- ))}
- </View>
- ) : null}
- </View>
- );
- })}
- </View>
-
- {/* Timezone */}
- <View className="rounded-2xl bg-white p-6">
- <Text className="mb-3 text-xl font-bold text-[#333]">Timezone</Text>
- <AppPressable
- onPress={() => setShowTimezoneModal(true)}
- className="flex-row items-center justify-between rounded-lg border border-[#E5E5EA] bg-[#F8F9FA] px-3 py-3"
- >
- <Text className="text-base text-[#333]">{timeZone}</Text>
- <Ionicons name="chevron-down" size={20} color="#666" />
- </AppPressable>
- </View>
-
- {/* Date Overrides */}
- <View className="rounded-2xl bg-white p-6">
- <Text className="mb-2 text-xl font-bold text-[#333]">Date overrides</Text>
- <Text className="mb-4 text-base text-[#666]">
- Add dates when your availability changes from your daily hours.
- </Text>
-
- {overrides.length > 0 ? (
- <View className="mb-4">
- {overrides.map((override, index) => (
- <View
- key={override.date}
- className="mb-2 flex-row items-center justify-between rounded-lg border border-[#E5E5EA] bg-[#F8F9FA] p-3"
- >
- <View className="flex-1">
- <Text className="mb-1 text-base font-medium text-[#333]">
- {formatDateForDisplay(override.date)}
- </Text>
- {override.startTime === "00:00" && override.endTime === "00:00" ? (
- <Text className="text-sm text-[#666]">Unavailable (All day)</Text>
- ) : (
- <Text className="text-sm text-[#666]">
- {formatTime12Hour(`${override.startTime}:00`)} -{" "}
- {formatTime12Hour(`${override.endTime}:00`)}
- </Text>
- )}
- </View>
- <View className="flex-row items-center gap-2">
- <AppPressable onPress={() => handleEditOverride(index)} className="p-2">
- <Ionicons name="pencil-outline" size={20} color="#007AFF" />
- </AppPressable>
- <AppPressable onPress={() => handleDeleteOverride(index)} className="p-2">
- <Ionicons name="trash-outline" size={20} color="#800020" />
- </AppPressable>
- </View>
- </View>
- ))}
- </View>
- ) : null}
-
- <AppPressable
- onPress={handleAddOverride}
- className="flex-row items-center justify-center rounded-lg border border-dashed border-[#E5E5EA] py-3"
- >
- <Ionicons name="add-circle-outline" size={20} color="#007AFF" />
- <Text className="ml-2 text-base font-medium text-[#007AFF]">Add an override</Text>
- </AppPressable>
- </View>
- </View>
- </ScrollView>
-
- {/* Bottom Action Bar */}
- <GlassView
- style={{
- position: "absolute",
- bottom: 0,
- left: 0,
- right: 0,
+ contentContainerStyle={{
+ paddingHorizontal: 16,
paddingTop: 16,
- paddingHorizontal: 20,
- backgroundColor: "#f8f9fa",
- borderTopWidth: 0.5,
- borderTopColor: "#E5E5EA",
- paddingBottom: insets.bottom + 12,
+ paddingBottom: insets.bottom + 100,
}}
- glassEffectStyle="clear"
+ showsVerticalScrollIndicator={false}
>
- <View className="flex-row items-center justify-between">
- <View className="flex-row items-center gap-2">
- <Text className="text-base font-medium text-[#333]">Set as Default</Text>
- <Switch
- value={isDefault}
- onValueChange={handleSetAsDefault}
- disabled={isDefault}
- trackColor={{ false: "#E5E5EA", true: "#34C759" }}
- thumbColor="#FFFFFF"
- />
- </View>
-
- <View className="flex-row items-center gap-3">
- <GlassView
- className="overflow-hidden rounded-full bg-[rgba(255,255,255,0.1)]"
- glassEffectStyle="clear"
+ {/* Schedule Title Section */}
+ <View className="mb-4">
+ <View className="mb-2 flex-row flex-wrap items-center">
+ <Text
+ className="text-[26px] font-semibold leading-tight text-black"
+ style={{ letterSpacing: -0.3 }}
>
- <AppPressable
- className="h-11 w-11 items-center justify-center"
- onPress={handleDelete}
- >
- <Ionicons name="trash-outline" size={20} color="#800020" />
- </AppPressable>
- </GlassView>
+ {scheduleName || "Untitled Schedule"}
+ </Text>
+ {isDefault && (
+ <Ionicons
+ name="star-outline"
+ size={20}
+ color="#000000"
+ style={{ marginLeft: 6, marginTop: 2 }}
+ />
+ )}
</View>
</View>
- </GlassView>
- {/* Timezone Modal */}
- <FullScreenModal
- visible={showTimezoneModal}
- animationType="fade"
- onRequestClose={() => setShowTimezoneModal(false)}
- >
- <AppPressable
- className="flex-1 items-center justify-center bg-black/50 p-2 md:p-4"
- activeOpacity={1}
- onPress={() => setShowTimezoneModal(false)}
- >
- <AppPressable
- className="max-h-[80%] w-[90%] max-w-[500px] rounded-2xl bg-white p-4"
- activeOpacity={1}
- onPress={(e) => e.stopPropagation()}
- >
- <View className="mb-4 flex-row items-center justify-between">
- <Text className="text-xl font-bold text-[#333]">Select Timezone</Text>
- <AppPressable onPress={() => setShowTimezoneModal(false)}>
- <Ionicons name="close" size={24} color="#666" />
- </AppPressable>
+ {/* Weekly Schedule Card - Navigable */}
+ <View className="mb-4 overflow-hidden rounded-xl bg-white">
+ <AppPressable onPress={() => router.push(`/edit-availability-hours?id=${id}` as never)}>
+ <View className="flex-row items-center justify-between px-4 py-3.5">
+ <Text className="text-[17px] text-black">Weekly Schedule</Text>
+ <View className="flex-row items-center">
+ <Text className="mr-1 text-[17px] text-[#8E8E93]">
+ {enabledDaysCount} {enabledDaysCount === 1 ? "day" : "days"}
+ </Text>
+ <Ionicons name="chevron-forward" size={18} color="#C7C7CC" />
+ </View>
</View>
- <ScrollView>
- {timezones.map((tz) => (
- <AppPressable
- key={tz}
- onPress={() => {
- setTimeZone(tz);
- setShowTimezoneModal(false);
- }}
- className="border-b border-[#E5E5EA] py-3"
- >
- <Text className="text-base text-[#333]">{tz}</Text>
- </AppPressable>
- ))}
- </ScrollView>
- </AppPressable>
- </AppPressable>
- </FullScreenModal>
- {/* Time Picker Modal */}
- <FullScreenModal
- visible={!!showTimePicker}
- animationType="fade"
- onRequestClose={() => setShowTimePicker(null)}
- >
- <AppPressable
- className="flex-1 items-center justify-center bg-black/50 p-2 md:p-4"
- activeOpacity={1}
- onPress={() => setShowTimePicker(null)}
- >
- <AppPressable
- className="max-h-[80%] w-[90%] max-w-[500px] rounded-2xl bg-white p-4"
- activeOpacity={1}
- onPress={(e) => e.stopPropagation()}
- >
- <View className="mb-4 flex-row items-center justify-between">
- <Text className="text-xl font-bold text-[#333]">
- Select {showTimePicker?.type === "start" ? "Start" : "End"} Time
- </Text>
- <AppPressable onPress={() => setShowTimePicker(null)}>
- <Ionicons name="close" size={24} color="#666" />
- </AppPressable>
- </View>
- <ScrollView>
- {TIME_OPTIONS.map((time) => {
- const currentTime =
- showTimePicker?.type === "start"
- ? availability[showTimePicker.dayIndex]?.[
- showTimePicker.slotIndex
- ]?.startTime.substring(0, 5)
- : availability[showTimePicker?.dayIndex || 0]?.[
- showTimePicker?.slotIndex || 0
- ]?.endTime.substring(0, 5);
- const isSelected = currentTime === time;
+ {/* Expanded Day List */}
+ <View className="border-t border-[#E5E5EA] px-4 py-2.5">
+ {DAYS.map((day, dayIndex) => {
+ const daySlots = availability[dayIndex] || [];
+ const isEnabled = daySlots.length > 0;
return (
- <AppPressable
- key={time}
- onPress={() => {
- if (showTimePicker) {
- updateTimeSlot(
- showTimePicker.dayIndex,
- showTimePicker.slotIndex,
- showTimePicker.type,
- time
- );
- setShowTimePicker(null);
- }
- }}
- className={`border-b border-[#E5E5EA] py-3 ${isSelected ? "bg-[#E3F2FD]" : ""}`}
+ <View
+ key={day}
+ className={`flex-row items-center py-3 ${
+ dayIndex > 0 ? "border-t border-[#E5E5EA]" : ""
+ }`}
>
+ <View
+ className={`mr-3 h-2.5 w-2.5 rounded-full ${
+ isEnabled ? "bg-[#34C759]" : "bg-[#E5E5EA]"
+ }`}
+ />
<Text
- className={`text-base ${
- isSelected ? "font-semibold text-[#007AFF]" : "text-[#333]"
+ className={`w-24 text-[15px] font-medium ${
+ isEnabled ? "text-black" : "text-[#8E8E93]"
}`}
>
- {time}
+ {DAYS[dayIndex]}
</Text>
- </AppPressable>
+
+ {isEnabled ? (
+ <View className="flex-1 items-end">
+ {daySlots.map((slot, slotIndex) => (
+ <Text
+ key={`${slotIndex}-${slot.startTime}`}
+ className={`text-[15px] text-black ${slotIndex > 0 ? "mt-1" : ""}`}
+ >
+ {formatTime12Hour(slot.startTime)} - {formatTime12Hour(slot.endTime)}
+ </Text>
+ ))}
+ </View>
+ ) : (
+ <Text className="flex-1 text-right text-[15px] text-[#8E8E93]">
+ Unavailable
+ </Text>
+ )}
+ </View>
);
})}
- </ScrollView>
+ </View>
</AppPressable>
- </AppPressable>
- </FullScreenModal>
+ </View>
- {/* Override Modal */}
- <FullScreenModal
- visible={showOverrideModal}
- animationType="fade"
- onRequestClose={() => setShowOverrideModal(false)}
- >
- <AppPressable
- className="flex-1 items-center justify-center bg-black/50 p-2 md:p-4"
- activeOpacity={1}
- onPress={() => setShowOverrideModal(false)}
- >
- <AppPressable
- className="max-h-[90%] w-[90%] max-w-[500px] rounded-2xl bg-white p-6"
- activeOpacity={1}
- onPress={(e) => e.stopPropagation()}
- >
- <View className="mb-4 flex-row items-center justify-between">
- <Text className="text-xl font-bold text-[#333]">
- {editingOverride !== null ? "Edit Override" : "Add Override"}
- </Text>
- <AppPressable onPress={() => setShowOverrideModal(false)}>
- <Ionicons name="close" size={24} color="#666" />
- </AppPressable>
+ {/* Timezone Card - Navigable */}
+ <View className="mb-4 overflow-hidden rounded-xl bg-white">
+ <AppPressable onPress={() => router.push(`/edit-availability-name?id=${id}` as never)}>
+ <View className="flex-row items-center justify-between px-4 py-3.5">
+ <Text className="text-[17px] text-black">Timezone</Text>
+ <View className="flex-row items-center">
+ <Text className="mr-1 text-[17px] text-[#8E8E93]">{timeZone}</Text>
+ <Ionicons name="chevron-forward" size={18} color="#C7C7CC" />
+ </View>
</View>
+ </AppPressable>
+ </View>
- <ScrollView>
- <View className="gap-4">
- {/* Date Picker */}
- <View>
- <Text className="mb-2 text-base font-semibold text-[#333]">
- Select the dates to override
- </Text>
- <TextInput
- value={overrideDate}
- onChangeText={setOverrideDate}
- placeholder="YYYY-MM-DD (e.g., 2024-05-20)"
- placeholderTextColor="#999"
- className="rounded-lg border border-[#E5E5EA] bg-[#F8F9FA] px-3 py-3 text-base text-[#333]"
- />
- <Text className="mt-1 text-sm text-[#666]">Enter date in YYYY-MM-DD format</Text>
- </View>
-
- {/* Unavailable Toggle */}
- <View className="flex-row items-center justify-between">
- <Text className="text-base font-semibold text-[#333]">
- Mark unavailable (All day)
+ {/* Date Overrides Card - Navigable */}
+ {overrides.length > 0 && (
+ <View className="mb-4 overflow-hidden rounded-xl bg-white">
+ <AppPressable
+ onPress={() => router.push(`/edit-availability-override?id=${id}` as never)}
+ >
+ <View className="flex-row items-center justify-between px-4 py-3.5">
+ <Text className="text-[17px] text-black">Date Overrides</Text>
+ <View className="flex-row items-center">
+ <Text className="mr-1 text-[17px] text-[#8E8E93]">
+ {overrides.length} {overrides.length === 1 ? "override" : "overrides"}
</Text>
- <Switch
- value={isUnavailable}
- onValueChange={setIsUnavailable}
- trackColor={{ false: "#E5E5EA", true: "#34C759" }}
- thumbColor="#FFFFFF"
- />
+ <Ionicons name="chevron-forward" size={18} color="#C7C7CC" />
</View>
+ </View>
- {/* Time Picker (only if not unavailable) */}
- {!isUnavailable ? (
- <View>
- <Text className="mb-3 text-base font-semibold text-[#333]">
- Which hours are you free?
+ {/* Expanded Overrides List */}
+ <View className="border-t border-[#E5E5EA] px-4 py-2.5">
+ {overrides.map((override, index) => (
+ <View
+ key={override.date}
+ className={`py-2.5 ${index > 0 ? "border-t border-[#E5E5EA]" : ""}`}
+ >
+ <Text className="mb-0.5 text-[17px] text-black">
+ {formatDateForDisplay(override.date)}
</Text>
- <View className="flex-row items-center gap-2">
- <AppPressable
- onPress={() => setShowOverrideTimePicker({ type: "start" })}
- className="flex-1 rounded-lg border border-[#E5E5EA] bg-white px-3 py-3"
- >
- <Text className="text-center text-base text-[#333]">
- {formatTime12Hour(`${overrideStartTime}:00`)}
- </Text>
- </AppPressable>
- <Text className="text-base text-[#666]">-</Text>
- <AppPressable
- onPress={() => setShowOverrideTimePicker({ type: "end" })}
- className="flex-1 rounded-lg border border-[#E5E5EA] bg-white px-3 py-3"
- >
- <Text className="text-center text-base text-[#333]">
- {formatTime12Hour(`${overrideEndTime}:00`)}
- </Text>
- </AppPressable>
- </View>
+ {override.startTime === "00:00" && override.endTime === "00:00" ? (
+ <Text className="text-[15px] text-[#FF3B30]">Unavailable</Text>
+ ) : (
+ <Text className="text-[15px] text-[#8E8E93]">
+ {formatTime12Hour(`${override.startTime}:00`)} -{" "}
+ {formatTime12Hour(`${override.endTime}:00`)}
+ </Text>
+ )}
</View>
- ) : null}
-
- {/* Save Button */}
- <AppPressable
- onPress={handleSaveOverride}
- className="mt-4 rounded-lg bg-black py-3"
- >
- <Text className="text-center text-base font-semibold text-white">
- Save Override
- </Text>
- </AppPressable>
+ ))}
</View>
- </ScrollView>
- </AppPressable>
- </AppPressable>
- </FullScreenModal>
-
- {/* Override Time Picker Modal */}
- <FullScreenModal
- visible={!!showOverrideTimePicker}
- animationType="fade"
- onRequestClose={() => setShowOverrideTimePicker(null)}
- >
- <AppPressable
- className="flex-1 items-center justify-center bg-black/50 p-2 md:p-4"
- activeOpacity={1}
- onPress={() => setShowOverrideTimePicker(null)}
- >
- <AppPressable
- className="max-h-[60%] w-[90%] max-w-[500px] rounded-2xl bg-white p-6"
- activeOpacity={1}
- onPress={(e) => e.stopPropagation()}
- >
- <View className="mb-4 flex-row items-center justify-between">
- <Text className="text-xl font-bold text-[#333]">
- Select {showOverrideTimePicker?.type === "start" ? "Start" : "End"} Time
- </Text>
- <AppPressable onPress={() => setShowOverrideTimePicker(null)}>
- <Ionicons name="close" size={24} color="#666" />
- </AppPressable>
+ </AppPressable>
+ </View>
+ )}
+
+ {/* No Overrides Message */}
+ {overrides.length === 0 && (
+ <View className="mb-4 overflow-hidden rounded-xl bg-white">
+ <View className="px-4 py-3.5">
+ <Text className="text-[17px] text-black">Date Overrides</Text>
+ <Text className="mt-1 text-[15px] text-[#8E8E93]">No date overrides set</Text>
</View>
- <ScrollView>
- {TIME_OPTIONS.map((time) => {
- const currentTime =
- showOverrideTimePicker?.type === "start" ? overrideStartTime : overrideEndTime;
- const isSelected = currentTime === time;
- return (
- <AppPressable
- key={time}
- onPress={() => {
- if (showOverrideTimePicker?.type === "start") {
- setOverrideStartTime(time);
- } else {
- setOverrideEndTime(time);
- }
- setShowOverrideTimePicker(null);
- }}
- className={`border-b border-[#E5E5EA] py-3 ${isSelected ? "bg-[#F0F9FF]" : ""}`}
- >
- <Text
- className={`text-base ${
- isSelected ? "font-semibold text-[#007AFF]" : "text-[#333]"
- }`}
- >
- {formatTime12Hour(`${time}:00`)}
- </Text>
- </AppPressable>
- );
- })}
- </ScrollView>
- </AppPressable>
- </AppPressable>
- </FullScreenModal>
+ </View>
+ )}
+ </ScrollView>
</View>
);
});
diff --git a/companion/components/screens/AvailabilityListScreen.tsx b/companion/components/screens/AvailabilityListScreen.tsx
index f1a0a72c831..364ce0810fb 100644
--- a/companion/components/screens/AvailabilityListScreen.tsx
+++ b/companion/components/screens/AvailabilityListScreen.tsx
@@ -9,6 +9,7 @@ import {
ScrollView,
Text,
TextInput,
+ TouchableOpacity,
View,
} from "react-native";
import { AppPressable } from "@/components/AppPressable";
@@ -290,13 +291,13 @@ export function AvailabilityListScreen({
autoCorrect={false}
clearButtonMode="while-editing"
/>
- <AppPressable
+ <TouchableOpacity
className="min-w-[60px] flex-row items-center justify-center gap-1 rounded-lg bg-black px-2.5 py-2"
onPress={handleCreateNew}
>
<Ionicons name="add" size={18} color="#fff" />
<Text className="text-base font-semibold text-white">New</Text>
- </AppPressable>
+ </TouchableOpacity>
</View>
</Activity>
@@ -439,12 +440,12 @@ export function AvailabilityListScreen({
animationType="fade"
onRequestClose={() => onShowCreateModalChange(false)}
>
- <AppPressable
+ <TouchableOpacity
className="flex-1 items-center justify-center bg-black/50 p-2 md:p-4"
activeOpacity={1}
onPress={() => onShowCreateModalChange(false)}
>
- <AppPressable
+ <TouchableOpacity
className="w-[90%] max-w-[500px] rounded-2xl bg-white"
activeOpacity={1}
onPress={(e) => e.stopPropagation()}
@@ -452,7 +453,10 @@ export function AvailabilityListScreen({
>
{/* Header */}
<View className="px-8 pb-4 pt-6">
- <Text className="text-2xl font-semibold text-gray-900">Add a new schedule</Text>
+ <Text className="mb-2 text-2xl font-semibold text-gray-900">
+ Add a new schedule
+ </Text>
+ <Text className="text-sm text-gray-500">Create a new availability schedule.</Text>
</View>
{/* Content */}
@@ -497,8 +501,8 @@ export function AvailabilityListScreen({
</AppPressable>
</View>
</View>
- </AppPressable>
- </AppPressable>
+ </TouchableOpacity>
+ </TouchableOpacity>
</FullScreenModal>
)}
diff --git a/companion/components/screens/BookingDetailScreen.tsx b/companion/components/screens/BookingDetailScreen.tsx
index ae7cc027521..5c0e4a8a6f1 100644
--- a/companion/components/screens/BookingDetailScreen.tsx
+++ b/companion/components/screens/BookingDetailScreen.tsx
@@ -599,7 +599,7 @@ export function BookingDetailScreen({
}}
/>
)}
- <View className="flex-1 bg-[#]">
+ <View className="flex-1 bg-[#f8f9fa]">
<ScrollView
className="flex-1"
contentContainerStyle={{ padding: 16, paddingBottom: 100 }}
diff --git a/companion/components/screens/EditAvailabilityDayScreen.tsx b/companion/components/screens/EditAvailabilityDayScreen.tsx
index c5c15a881a9..5ad63017845 100644
--- a/companion/components/screens/EditAvailabilityDayScreen.tsx
+++ b/companion/components/screens/EditAvailabilityDayScreen.tsx
@@ -1,6 +1,6 @@
import { Ionicons } from "@expo/vector-icons";
import { forwardRef, useCallback, useEffect, useImperativeHandle, useState } from "react";
-import { Alert, ScrollView, Switch, Text, View } from "react-native";
+import { Alert, Platform, ScrollView, Switch, Text, TouchableOpacity, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppPressable } from "@/components/AppPressable";
import { FullScreenModal } from "@/components/FullScreenModal";
@@ -8,6 +8,7 @@ import type { Schedule } from "@/services/calcom";
import { CalComAPIService } from "@/services/calcom";
import type { ScheduleAvailability } from "@/services/types";
import { showErrorAlert } from "@/utils/alerts";
+import { shadows } from "@/utils/shadows";
const DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
@@ -179,6 +180,57 @@ export const EditAvailabilityDayScreen = forwardRef<
const dayName = DAYS[dayIndex] || "Day";
+ // Render modal content
+ const renderTimePickerContent = () => (
+ <>
+ <View className="flex-row items-center justify-between border-b border-gray-200 px-4 py-4">
+ <Text className="text-[17px] font-semibold">
+ Select {showTimePicker?.type === "start" ? "Start" : "End"} Time
+ </Text>
+ <AppPressable onPress={() => setShowTimePicker(null)}>
+ <Ionicons name="close" size={24} color="#8E8E93" />
+ </AppPressable>
+ </View>
+ <ScrollView className="px-4 py-3">
+ {TIME_OPTIONS.map((time) => {
+ const slotIndex = showTimePicker?.slotIndex ?? 0;
+ const currentTime =
+ showTimePicker?.type === "start"
+ ? slots[slotIndex]?.startTime
+ : slots[slotIndex]?.endTime;
+ const isSelected = currentTime === time;
+
+ return (
+ <AppPressable key={time} onPress={() => handleTimeSelect(time)}>
+ <View
+ className={`mb-2.5 rounded-xl border-2 px-4 py-4 ${
+ isSelected
+ ? "border-[#007AFF] bg-blue-50 shadow-md"
+ : "border-gray-200 bg-gray-50"
+ }`}
+ >
+ <View className="flex-row items-center justify-between">
+ <Text
+ className={`text-[17px] ${
+ isSelected ? "font-semibold text-[#007AFF]" : "font-medium text-gray-900"
+ }`}
+ >
+ {formatTime12Hour(time)}
+ </Text>
+ {isSelected && (
+ <View className="rounded-full bg-[#007AFF] p-1.5">
+ <Ionicons name="checkmark" size={14} color="#FFFFFF" />
+ </View>
+ )}
+ </View>
+ </View>
+ </AppPressable>
+ );
+ })}
+ </ScrollView>
+ </>
+ );
+
// Initialize from schedule
useEffect(() => {
if (schedule) {
@@ -308,7 +360,7 @@ export const EditAvailabilityDayScreen = forwardRef<
}}
>
{/* Enable/Disable Toggle */}
- <View className="mb-4 flex-row items-center justify-between rounded-lg border border-gray-200 px-4 py-3.5">
+ <View className="mb-4 flex-row items-center justify-between rounded-xl border-2 border-gray-200 bg-gray-50 px-4 py-3.5">
<Text className="text-[17px] font-medium text-black">Available on {dayName}</Text>
<Switch
value={isEnabled}
@@ -326,59 +378,117 @@ export const EditAvailabilityDayScreen = forwardRef<
{slots.map((slot, index) => (
<View
key={`slot-${slot.startTime}-${slot.endTime}-${index}`}
- className="mb-3 rounded-lg border border-gray-200 px-4 py-3"
+ className="mb-3 rounded-xl border-2 border-gray-200 bg-white px-4 py-4"
>
<View className="flex-row items-center justify-between">
<Text className="text-[15px] font-medium text-gray-500">Slot {index + 1}</Text>
{slots.length > 1 && (
- <AppPressable onPress={() => handleRemoveSlot(index)} className="p-1">
- <Ionicons name="trash-outline" size={20} color="#FF3B30" />
+ <AppPressable
+ onPress={() => handleRemoveSlot(index)}
+ className="rounded-full bg-red-50 p-2"
+ >
+ <Ionicons name="trash-outline" size={18} color="#FF3B30" />
</AppPressable>
)}
</View>
<View className="mt-3 flex-row items-center">
- <AppPressable
- className="flex-1 rounded-lg bg-gray-100 px-3 py-2"
- onPress={() => setShowTimePicker({ slotIndex: index, type: "start" })}
- >
- <Text className="text-[13px] text-gray-500">Start</Text>
- <Text className="text-[17px] text-black">{formatTime12Hour(slot.startTime)}</Text>
- </AppPressable>
+ {Platform.OS === "web" ? (
+ <View className="flex-1 rounded-lg bg-gray-50 px-3 py-2.5 border border-gray-100">
+ <Text className="text-[13px] text-gray-500">Start</Text>
+ <input
+ type="time"
+ value={slot.startTime}
+ onChange={(e) => {
+ const newSlots = [...slots];
+ newSlots[index] = { ...newSlots[index], startTime: e.target.value };
+ setSlots(newSlots);
+ }}
+ style={{
+ fontSize: 17,
+ fontWeight: 500,
+ color: "#000",
+ backgroundColor: "transparent",
+ border: "none",
+ outline: "none",
+ fontFamily: "inherit",
+ width: "100%",
+ }}
+ />
+ </View>
+ ) : (
+ <AppPressable
+ className="flex-1 rounded-lg bg-gray-50 px-3 py-2.5 border border-gray-100"
+ onPress={() => setShowTimePicker({ slotIndex: index, type: "start" })}
+ >
+ <Text className="text-[13px] text-gray-500">Start</Text>
+ <Text className="text-[17px] font-medium text-black">
+ {formatTime12Hour(slot.startTime)}
+ </Text>
+ </AppPressable>
+ )}
<Text className="mx-3 text-[17px] text-gray-400">–</Text>
- <AppPressable
- className="flex-1 rounded-lg bg-gray-100 px-3 py-2"
- onPress={() => setShowTimePicker({ slotIndex: index, type: "end" })}
- >
- <Text className="text-[13px] text-gray-500">End</Text>
- <Text className="text-[17px] text-black">{formatTime12Hour(slot.endTime)}</Text>
- </AppPressable>
+ {Platform.OS === "web" ? (
+ <View className="flex-1 rounded-lg bg-gray-50 px-3 py-2.5 border border-gray-100">
+ <Text className="text-[13px] text-gray-500">End</Text>
+ <input
+ type="time"
+ value={slot.endTime}
+ onChange={(e) => {
+ const newSlots = [...slots];
+ newSlots[index] = { ...newSlots[index], endTime: e.target.value };
+ setSlots(newSlots);
+ }}
+ style={{
+ fontSize: 17,
+ fontWeight: 500,
+ color: "#000",
+ backgroundColor: "transparent",
+ border: "none",
+ outline: "none",
+ fontFamily: "inherit",
+ width: "100%",
+ }}
+ />
+ </View>
+ ) : (
+ <AppPressable
+ className="flex-1 rounded-lg bg-gray-50 px-3 py-2.5 border border-gray-100"
+ onPress={() => setShowTimePicker({ slotIndex: index, type: "end" })}
+ >
+ <Text className="text-[13px] text-gray-500">End</Text>
+ <Text className="text-[17px] font-medium text-black">
+ {formatTime12Hour(slot.endTime)}
+ </Text>
+ </AppPressable>
+ )}
</View>
</View>
))}
{/* Add Slot Button */}
- <AppPressable
- onPress={handleAddSlot}
- className="flex-row items-center justify-center rounded-lg border border-dashed border-gray-300 py-3.5"
- >
- <Ionicons name="add-circle" size={20} color="#007AFF" />
- <Text className="ml-2 text-[15px] font-medium text-[#007AFF]">Add Time Slot</Text>
+ <AppPressable onPress={handleAddSlot}>
+ <View className="flex-row items-center justify-center rounded-xl border-2 border-dashed border-gray-300 bg-gray-50 py-4">
+ <Ionicons name="add-circle" size={22} color="#007AFF" />
+ <Text className="ml-2 text-[17px] font-medium text-[#007AFF]">Add Time Slot</Text>
+ </View>
</AppPressable>
</>
)}
{/* Unavailable Message */}
{!isEnabled && (
- <View className="items-center rounded-lg border border-gray-200 px-4 py-8">
- <Ionicons name="moon-outline" size={40} color="#8E8E93" />
- <Text className="mt-3 text-center text-[17px] text-gray-500">
- You are unavailable on {dayName}
+ <View className="items-center rounded-xl border-2 border-dashed border-gray-200 px-4 py-12">
+ <View className="items-center justify-center rounded-full bg-gray-50 p-4">
+ <Ionicons name="moon-outline" size={32} color="#9CA3AF" />
+ </View>
+ <Text className="mt-4 text-center text-[17px] font-medium text-gray-900">
+ Unavailable
</Text>
- <Text className="mt-1 text-center text-[15px] text-gray-400">
- Toggle on to set availability
+ <Text className="mt-1 text-center text-[15px] text-gray-500">
+ You are currently unavailable on {dayName}.{"\n"}Toggle the switch above to add hours.
</Text>
</View>
)}
@@ -386,50 +496,27 @@ export const EditAvailabilityDayScreen = forwardRef<
{/* Time Picker Modal */}
<FullScreenModal
visible={!!showTimePicker}
- animationType="slide"
+ animationType={Platform.OS === "web" ? "fade" : "slide"}
onRequestClose={() => setShowTimePicker(null)}
>
- <View className="flex-1 bg-white">
- <View className="flex-row items-center justify-between border-b border-gray-200 px-4 py-3">
- <Text className="text-[17px] font-semibold">
- Select {showTimePicker?.type === "start" ? "Start" : "End"} Time
- </Text>
- <AppPressable onPress={() => setShowTimePicker(null)}>
- <Ionicons name="close" size={24} color="#8E8E93" />
- </AppPressable>
- </View>
- <ScrollView>
- {TIME_OPTIONS.map((time) => {
- const slotIndex = showTimePicker?.slotIndex ?? 0;
- const currentTime =
- showTimePicker?.type === "start"
- ? slots[slotIndex]?.startTime
- : slots[slotIndex]?.endTime;
- const isSelected = currentTime === time;
-
- return (
- <AppPressable
- key={time}
- onPress={() => handleTimeSelect(time)}
- className={`border-b border-gray-100 px-4 py-3.5 ${
- isSelected ? "bg-blue-50" : ""
- }`}
- >
- <View className="flex-row items-center justify-between">
- <Text
- className={`text-[17px] ${
- isSelected ? "font-medium text-[#007AFF]" : "text-black"
- }`}
- >
- {formatTime12Hour(time)}
- </Text>
- {isSelected && <Ionicons name="checkmark" size={20} color="#007AFF" />}
- </View>
- </AppPressable>
- );
- })}
- </ScrollView>
- </View>
+ {Platform.OS === "web" ? (
+ <TouchableOpacity
+ className="flex-1 items-center justify-center bg-black/50 p-4"
+ activeOpacity={1}
+ onPress={() => setShowTimePicker(null)}
+ >
+ <TouchableOpacity
+ className="max-h-[80%] w-full max-w-[500px] overflow-hidden rounded-2xl bg-white p-2"
+ activeOpacity={1}
+ onPress={(e) => e.stopPropagation()}
+ style={shadows.xl()}
+ >
+ {renderTimePickerContent()}
+ </TouchableOpacity>
+ </TouchableOpacity>
+ ) : (
+ <View className="flex-1 bg-white p-2">{renderTimePickerContent()}</View>
+ )}
</FullScreenModal>
</ScrollView>
);
diff --git a/companion/components/screens/EditAvailabilityHoursScreen.tsx b/companion/components/screens/EditAvailabilityHoursScreen.tsx
index 3e3d3b8f727..c97f1ee6735 100644
--- a/companion/components/screens/EditAvailabilityHoursScreen.tsx
+++ b/companion/components/screens/EditAvailabilityHoursScreen.tsx
@@ -110,53 +110,53 @@ export const EditAvailabilityHoursScreen = forwardRef<unknown, EditAvailabilityH
Tap a day to edit its hours
</Text>
- <View className="overflow-hidden rounded-lg border border-gray-200">
+ <View>
{DAYS.map((day, dayIndex) => {
const daySlots = availability[dayIndex] || [];
const isEnabled = daySlots.length > 0;
return (
- <AppPressable
- key={day}
- className={`flex-row items-center px-4 py-3.5 ${
- dayIndex > 0 ? "border-t border-gray-200" : ""
- }`}
- onPress={() => onDayPress(dayIndex)}
- >
- {/* Day status indicator */}
+ <AppPressable key={day} onPress={() => onDayPress(dayIndex)}>
<View
- className={`mr-3 h-2.5 w-2.5 rounded-full ${
- isEnabled ? "bg-green-500" : "bg-gray-300"
- }`}
- />
-
- {/* Day name */}
- <Text
- className={`w-24 text-[17px] font-medium ${
- isEnabled ? "text-black" : "text-gray-400"
+ className={`mb-2.5 flex-row items-center rounded-xl border-2 px-4 py-4 ${
+ isEnabled ? "border-gray-200 bg-white" : "border-gray-100 bg-gray-50"
}`}
>
- {day}
- </Text>
-
- {/* Time slots or unavailable */}
- <View className="flex-1">
- {isEnabled ? (
- daySlots.map((slot, slotIndex) => (
- <Text
- key={`${slotIndex}-${slot.startTime}`}
- className={`text-[15px] text-gray-500 ${slotIndex > 0 ? "mt-0.5" : ""}`}
- >
- {formatTime12Hour(slot.startTime)} – {formatTime12Hour(slot.endTime)}
- </Text>
- ))
- ) : (
- <Text className="text-[15px] text-gray-400">Unavailable</Text>
- )}
+ {/* Day status indicator */}
+ <View
+ className={`mr-3 h-2.5 w-2.5 rounded-full ${
+ isEnabled ? "bg-green-500" : "bg-gray-300"
+ }`}
+ />
+
+ {/* Day name */}
+ <Text
+ className={`w-28 text-[17px] font-medium ${
+ isEnabled ? "text-black" : "text-gray-400"
+ }`}
+ >
+ {day}
+ </Text>
+
+ {/* Time slots or unavailable */}
+ <View className="flex-1">
+ {isEnabled ? (
+ daySlots.map((slot, slotIndex) => (
+ <Text
+ key={`${slotIndex}-${slot.startTime}`}
+ className={`text-[15px] text-gray-600 ${slotIndex > 0 ? "mt-0.5" : ""}`}
+ >
+ {formatTime12Hour(slot.startTime)} – {formatTime12Hour(slot.endTime)}
+ </Text>
+ ))
+ ) : (
+ <Text className="text-[15px] text-gray-400">Unavailable</Text>
+ )}
+ </View>
+
+ {/* Chevron */}
+ <Ionicons name="chevron-forward" size={20} color="#C7C7CC" />
</View>
-
- {/* Chevron */}
- <Ionicons name="chevron-forward" size={18} color="#C7C7CC" />
</AppPressable>
);
})}
diff --git a/companion/components/screens/EditAvailabilityNameScreen.tsx b/companion/components/screens/EditAvailabilityNameScreen.tsx
index 50f11e0a025..a8b96afca1f 100644
--- a/companion/components/screens/EditAvailabilityNameScreen.tsx
+++ b/companion/components/screens/EditAvailabilityNameScreen.tsx
@@ -1,6 +1,15 @@
import { Ionicons } from "@expo/vector-icons";
import { forwardRef, useCallback, useEffect, useImperativeHandle, useState } from "react";
-import { Alert, KeyboardAvoidingView, ScrollView, Text, TextInput, View } from "react-native";
+import {
+ Alert,
+ KeyboardAvoidingView,
+ Platform,
+ ScrollView,
+ Text,
+ TextInput,
+ TouchableOpacity,
+ View,
+} from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppPressable } from "@/components/AppPressable";
import { FullScreenModal } from "@/components/FullScreenModal";
@@ -8,6 +17,7 @@ import { TIMEZONES as ALL_TIMEZONES } from "@/constants/timezones";
import type { Schedule } from "@/services/calcom";
import { CalComAPIService } from "@/services/calcom";
import { showErrorAlert } from "@/utils/alerts";
+import { shadows } from "@/utils/shadows";
// Format timezones for display
const TIMEZONES = ALL_TIMEZONES.map((tz) => ({
@@ -84,6 +94,57 @@ export const EditAvailabilityNameScreen = forwardRef<
const selectedTimezoneLabel = TIMEZONES.find((tz) => tz.id === timezone)?.label || timezone;
+ // Render timezone list content
+ const renderTimezoneContent = () => (
+ <>
+ <View className="flex-row items-center justify-between border-b border-gray-200 px-4 py-4">
+ <Text className="text-[17px] font-semibold">Select Timezone</Text>
+ <AppPressable onPress={() => setShowTimezoneModal(false)}>
+ <Ionicons name="close" size={24} color="#8E8E93" />
+ </AppPressable>
+ </View>
+ <ScrollView className="px-4 py-3">
+ {TIMEZONES.map((tz) => (
+ <AppPressable
+ key={tz.id}
+ onPress={() => {
+ setTimezone(tz.id);
+ setShowTimezoneModal(false);
+ }}
+ >
+ <View
+ className={`mb-2.5 rounded-xl border-2 px-4 py-4 ${
+ tz.id === timezone
+ ? "border-[#007AFF] bg-blue-50 shadow-md"
+ : "border-gray-200 bg-gray-50"
+ }`}
+ >
+ <View className="flex-row items-center justify-between">
+ <View className="flex-1">
+ <Text
+ className={`text-[17px] ${
+ tz.id === timezone
+ ? "font-semibold text-[#007AFF]"
+ : "font-medium text-gray-900"
+ }`}
+ >
+ {tz.label}
+ </Text>
+ <Text className="mt-0.5 text-[13px] text-gray-500">{tz.id}</Text>
+ </View>
+ {tz.id === timezone && (
+ <View className="rounded-full bg-[#007AFF] p-1.5">
+ <Ionicons name="checkmark" size={14} color="#FFFFFF" />
+ </View>
+ )}
+ </View>
+ </View>
+ </AppPressable>
+ ))}
+ </ScrollView>
+ </>
+ );
+
if (!schedule) {
return (
<View className="flex-1 items-center justify-center bg-white">
@@ -120,63 +181,49 @@ export const EditAvailabilityNameScreen = forwardRef<
<Text className="mb-2 text-[13px] font-medium uppercase tracking-wide text-gray-500">
Timezone
</Text>
- <AppPressable
- className="flex-row items-center justify-between rounded-lg border border-gray-300 bg-gray-50 px-4 py-3"
- onPress={() => setShowTimezoneModal(true)}
- >
- <View className="flex-row items-center">
- <Ionicons name="globe-outline" size={20} color="#007AFF" style={{ marginRight: 12 }} />
- <View>
- <Text className="text-[17px] text-black">{selectedTimezoneLabel}</Text>
- <Text className="mt-0.5 text-[13px] text-gray-500">{timezone}</Text>
+ <AppPressable onPress={() => setShowTimezoneModal(true)}>
+ <View className="flex-row items-center justify-between rounded-xl border-2 border-gray-200 bg-gray-50 px-4 py-4">
+ <View className="flex-row items-center">
+ <Ionicons
+ name="globe-outline"
+ size={20}
+ color="#007AFF"
+ style={{ marginRight: 12 }}
+ />
+ <View>
+ <Text className="text-[17px] text-black">{selectedTimezoneLabel}</Text>
+ <Text className="mt-0.5 text-[13px] text-gray-500">{timezone}</Text>
+ </View>
</View>
+ <Ionicons name="chevron-down" size={20} color="#C7C7CC" />
</View>
- <Ionicons name="chevron-forward" size={18} color="#C7C7CC" />
</AppPressable>
</ScrollView>
{/* Timezone Modal */}
<FullScreenModal
visible={showTimezoneModal}
- animationType="slide"
+ animationType={Platform.OS === "web" ? "fade" : "slide"}
onRequestClose={() => setShowTimezoneModal(false)}
>
- <View className="flex-1 bg-white">
- <View className="flex-row items-center justify-between border-b border-gray-200 px-4 py-3">
- <Text className="text-[17px] font-semibold">Select Timezone</Text>
- <AppPressable onPress={() => setShowTimezoneModal(false)}>
- <Ionicons name="close" size={24} color="#8E8E93" />
- </AppPressable>
- </View>
- <ScrollView>
- {TIMEZONES.map((tz) => (
- <AppPressable
- key={tz.id}
- onPress={() => {
- setTimezone(tz.id);
- setShowTimezoneModal(false);
- }}
- className={`border-b border-gray-100 px-4 py-3.5 ${
- tz.id === timezone ? "bg-blue-50" : ""
- }`}
- >
- <View className="flex-row items-center justify-between">
- <View>
- <Text
- className={`text-[17px] ${
- tz.id === timezone ? "font-medium text-[#007AFF]" : "text-black"
- }`}
- >
- {tz.label}
- </Text>
- <Text className="text-[13px] text-gray-500">{tz.id}</Text>
- </View>
- {tz.id === timezone && <Ionicons name="checkmark" size={20} color="#007AFF" />}
- </View>
- </AppPressable>
- ))}
- </ScrollView>
- </View>
+ {Platform.OS === "web" ? (
+ <TouchableOpacity
+ className="flex-1 items-center justify-center bg-black/50 p-4"
+ activeOpacity={1}
+ onPress={() => setShowTimezoneModal(false)}
+ >
+ <TouchableOpacity
+ className="max-h-[80%] w-full max-w-[500px] overflow-hidden rounded-2xl bg-white p-2"
+ activeOpacity={1}
+ onPress={(e) => e.stopPropagation()}
+ style={shadows.xl()}
+ >
+ {renderTimezoneContent()}
+ </TouchableOpacity>
+ </TouchableOpacity>
+ ) : (
+ <View className="flex-1 bg-white p-2">{renderTimezoneContent()}</View>
+ )}
</FullScreenModal>
</KeyboardAvoidingView>
);
diff --git a/companion/components/screens/EditAvailabilityOverrideScreen.tsx b/companion/components/screens/EditAvailabilityOverrideScreen.tsx
index 33b167755b3..fadc61f7959 100644
--- a/companion/components/screens/EditAvailabilityOverrideScreen.tsx
+++ b/companion/components/screens/EditAvailabilityOverrideScreen.tsx
@@ -1,12 +1,22 @@
import { Ionicons } from "@expo/vector-icons";
import { forwardRef, useCallback, useEffect, useImperativeHandle, useState } from "react";
-import { Alert, ScrollView, Switch, Text, TextInput, View } from "react-native";
+import {
+ Alert,
+ Platform,
+ ScrollView,
+ Switch,
+ Text,
+ TextInput,
+ TouchableOpacity,
+ View,
+} from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppPressable } from "@/components/AppPressable";
import { FullScreenModal } from "@/components/FullScreenModal";
import type { Schedule } from "@/services/calcom";
import { CalComAPIService } from "@/services/calcom";
import { showErrorAlert } from "@/utils/alerts";
+import { shadows } from "@/utils/shadows";
// Generate time options (15-minute intervals)
const generateTimeOptions = () => {
@@ -78,6 +88,53 @@ export const EditAvailabilityOverrideScreen = forwardRef<
type: "start" | "end";
} | null>(null);
+ // Render modal content
+ const renderTimePickerContent = () => (
+ <>
+ <View className="flex-row items-center justify-between border-b border-gray-200 px-4 py-3">
+ <Text className="text-[17px] font-semibold">
+ Select {showTimePicker?.type === "start" ? "Start" : "End"} Time
+ </Text>
+ <AppPressable onPress={() => setShowTimePicker(null)}>
+ <Ionicons name="close" size={24} color="#8E8E93" />
+ </AppPressable>
+ </View>
+ <ScrollView className="px-4 py-3">
+ {TIME_OPTIONS.map((time) => {
+ const currentTime = showTimePicker?.type === "start" ? startTime : endTime;
+ const isSelected = currentTime === time;
+
+ return (
+ <AppPressable key={time} onPress={() => handleTimeSelect(time)}>
+ <View
+ className={`mb-2.5 rounded-xl border-2 px-4 py-4 ${
+ isSelected
+ ? "border-[#007AFF] bg-blue-50 shadow-md"
+ : "border-gray-200 bg-gray-50"
+ }`}
+ >
+ <View className="flex-row items-center justify-between">
+ <Text
+ className={`text-[17px] ${
+ isSelected ? "font-semibold text-[#007AFF]" : "font-medium text-gray-900"
+ }`}
+ >
+ {formatTime12Hour(time)}
+ </Text>
+ {isSelected && (
+ <View className="rounded-full bg-[#007AFF] p-1.5">
+ <Ionicons name="checkmark" size={14} color="#FFFFFF" />
+ </View>
+ )}
+ </View>
+ </View>
+ </AppPressable>
+ );
+ })}
+ </ScrollView>
+ </>
+ );
+
// Initialize from existing override if editing
useEffect(() => {
if (schedule && isEditing && schedule.overrides && overrideIndex !== undefined) {
@@ -272,26 +329,43 @@ export const EditAvailabilityOverrideScreen = forwardRef<
>
{/* Date Input */}
<Text className="mb-2 text-[13px] font-medium text-gray-500">Date (YYYY-MM-DD)</Text>
- <View className="mb-4 rounded-lg border border-gray-200 px-4 py-3">
+ <View className="mb-4 rounded-xl border-2 border-gray-200 bg-gray-50 px-4 py-3">
<View className="flex-row items-center">
- <Ionicons name="calendar" size={20} color="#007AFF" style={{ marginRight: 12 }} />
- <TextInput
- className="flex-1 text-[17px] text-black"
- placeholder="2024-12-25"
- placeholderTextColor="#9CA3AF"
- value={selectedDate}
- onChangeText={setSelectedDate}
- />
+ <Ionicons name="calendar-outline" size={20} color="#007AFF" style={{ marginRight: 12 }} />
+ {Platform.OS === "web" ? (
+ <input
+ type="date"
+ value={selectedDate}
+ onChange={(e) => setSelectedDate(e.target.value)}
+ style={{
+ flex: 1,
+ fontSize: 17,
+ color: "#000",
+ backgroundColor: "transparent",
+ border: "none",
+ outline: "none",
+ fontFamily: "inherit",
+ }}
+ />
+ ) : (
+ <TextInput
+ className="flex-1 text-[17px] text-black"
+ placeholder="2024-12-25"
+ placeholderTextColor="#9CA3AF"
+ value={selectedDate}
+ onChangeText={setSelectedDate}
+ />
+ )}
</View>
- {selectedDate && (
+ {selectedDate ? (
<Text className="mt-2 text-[15px] text-gray-500">
{formatDateForDisplay(selectedDate)}
</Text>
- )}
+ ) : null}
</View>
{/* Unavailable Toggle */}
- <View className="mb-4 flex-row items-center justify-between rounded-lg border border-gray-200 px-4 py-3.5">
+ <View className="mb-4 flex-row items-center justify-between rounded-xl border-2 border-gray-200 bg-gray-50 px-4 py-3.5">
<View className="flex-row items-center">
<Ionicons name="moon-outline" size={20} color="#FF3B30" style={{ marginRight: 12 }} />
<View>
@@ -311,25 +385,65 @@ export const EditAvailabilityOverrideScreen = forwardRef<
{!isUnavailable && (
<>
<Text className="mb-2 text-[13px] font-medium text-gray-500">Available Hours</Text>
- <View className="mb-4 rounded-lg border border-gray-200 px-4 py-3.5">
+ <View className="mb-4 rounded-xl border-2 border-gray-200 bg-gray-50 px-4 py-3.5">
<View className="flex-row items-center">
- <AppPressable
- className="flex-1 rounded-lg bg-gray-100 px-3 py-2"
- onPress={() => setShowTimePicker({ type: "start" })}
- >
- <Text className="text-[13px] text-gray-500">Start Time</Text>
- <Text className="text-[17px] text-black">{formatTime12Hour(startTime)}</Text>
- </AppPressable>
+ {Platform.OS === "web" ? (
+ <View className="flex-1 rounded-lg bg-gray-200/50 px-3 py-2">
+ <Text className="text-[13px] text-gray-500">Start Time</Text>
+ <input
+ type="time"
+ value={startTime}
+ onChange={(e) => setStartTime(e.target.value)}
+ style={{
+ fontSize: 17,
+ color: "#000",
+ backgroundColor: "transparent",
+ border: "none",
+ outline: "none",
+ fontFamily: "inherit",
+ width: "100%",
+ }}
+ />
+ </View>
+ ) : (
+ <AppPressable
+ className="flex-1 rounded-lg bg-gray-200/50 px-3 py-2"
+ onPress={() => setShowTimePicker({ type: "start" })}
+ >
+ <Text className="text-[13px] text-gray-500">Start Time</Text>
+ <Text className="text-[17px] text-black">{formatTime12Hour(startTime)}</Text>
+ </AppPressable>
+ )}
<Text className="mx-4 text-[17px] text-gray-400">–</Text>
- <AppPressable
- className="flex-1 rounded-lg bg-gray-100 px-3 py-2"
- onPress={() => setShowTimePicker({ type: "end" })}
- >
- <Text className="text-[13px] text-gray-500">End Time</Text>
- <Text className="text-[17px] text-black">{formatTime12Hour(endTime)}</Text>
- </AppPressable>
+ {Platform.OS === "web" ? (
+ <View className="flex-1 rounded-lg bg-gray-200/50 px-3 py-2">
+ <Text className="text-[13px] text-gray-500">End Time</Text>
+ <input
+ type="time"
+ value={endTime}
+ onChange={(e) => setEndTime(e.target.value)}
+ style={{
+ fontSize: 17,
+ color: "#000",
+ backgroundColor: "transparent",
+ border: "none",
+ outline: "none",
+ fontFamily: "inherit",
+ width: "100%",
+ }}
+ />
+ </View>
+ ) : (
+ <AppPressable
+ className="flex-1 rounded-lg bg-gray-200/50 px-3 py-2"
+ onPress={() => setShowTimePicker({ type: "end" })}
+ >
+ <Text className="text-[13px] text-gray-500">End Time</Text>
+ <Text className="text-[17px] text-black">{formatTime12Hour(endTime)}</Text>
+ </AppPressable>
+ )}
</View>
</View>
</>
@@ -341,41 +455,41 @@ export const EditAvailabilityOverrideScreen = forwardRef<
<Text className="mb-2 mt-4 text-[13px] font-medium text-gray-500">
Existing Overrides
</Text>
- <View className="overflow-hidden rounded-lg border border-gray-200">
+ <View>
{schedule.overrides.map((override, index) => (
<AppPressable
key={override.date}
- className={`flex-row items-center justify-between px-4 py-3 ${
- index > 0 ? "border-t border-gray-200" : ""
- }`}
+ className="mb-2.5"
onPress={() => onEditOverride?.(index)}
>
- <View className="flex-1">
- <Text className="text-[15px] text-black">
- {formatDateForDisplay(override.date ?? "")}
- </Text>
- {override.startTime === "00:00" && override.endTime === "00:00" ? (
- <Text className="text-[13px] text-red-500">Unavailable</Text>
- ) : (
- <Text className="text-[13px] text-gray-500">
- {formatTime12Hour(override.startTime ?? "00:00")} –{" "}
- {formatTime12Hour(override.endTime ?? "00:00")}
+ <View className="flex-row items-center justify-between rounded-xl border-2 border-gray-200 bg-white px-4 py-3.5">
+ <View className="flex-1">
+ <Text className="text-[15px] font-medium text-black">
+ {formatDateForDisplay(override.date ?? "")}
</Text>
- )}
- </View>
- <View className="flex-row items-center">
- <AppPressable
- className="rounded-full bg-red-100 p-2"
- onPress={() => handleDeleteOverride(index)}
- >
- <Ionicons name="trash-outline" size={18} color="#FF3B30" />
- </AppPressable>
- <AppPressable
- className="ml-3 rounded-full bg-gray-100 p-2"
- onPress={() => onEditOverride?.(index)}
- >
- <Ionicons name="chevron-forward" size={18} color="#8E8E93" />
- </AppPressable>
+ {override.startTime === "00:00" && override.endTime === "00:00" ? (
+ <Text className="mt-0.5 text-[13px] text-red-500">Unavailable</Text>
+ ) : (
+ <Text className="mt-0.5 text-[13px] text-gray-500">
+ {formatTime12Hour(override.startTime ?? "00:00")} –{" "}
+ {formatTime12Hour(override.endTime ?? "00:00")}
+ </Text>
+ )}
+ </View>
+ <View className="flex-row items-center">
+ <AppPressable
+ className="rounded-full bg-red-50 p-2"
+ onPress={() => handleDeleteOverride(index)}
+ >
+ <Ionicons name="trash-outline" size={18} color="#FF3B30" />
+ </AppPressable>
+ <Ionicons
+ style={{ marginLeft: 12 }}
+ name="chevron-forward"
+ size={18}
+ color="#C7C7CC"
+ />
+ </View>
</View>
</AppPressable>
))}
@@ -386,46 +500,27 @@ export const EditAvailabilityOverrideScreen = forwardRef<
{/* Time Picker Modal */}
<FullScreenModal
visible={!!showTimePicker}
- animationType="slide"
+ animationType={Platform.OS === "web" ? "fade" : "slide"}
onRequestClose={() => setShowTimePicker(null)}
>
- <View className="flex-1 bg-white">
- <View className="flex-row items-center justify-between border-b border-gray-200 px-4 py-3">
- <Text className="text-[17px] font-semibold">
- Select {showTimePicker?.type === "start" ? "Start" : "End"} Time
- </Text>
- <AppPressable onPress={() => setShowTimePicker(null)}>
- <Ionicons name="close" size={24} color="#8E8E93" />
- </AppPressable>
- </View>
- <ScrollView>
- {TIME_OPTIONS.map((time) => {
- const currentTime = showTimePicker?.type === "start" ? startTime : endTime;
- const isSelected = currentTime === time;
-
- return (
- <AppPressable
- key={time}
- onPress={() => handleTimeSelect(time)}
- className={`border-b border-gray-100 px-4 py-3.5 ${
- isSelected ? "bg-blue-50" : ""
- }`}
- >
- <View className="flex-row items-center justify-between">
- <Text
- className={`text-[17px] ${
- isSelected ? "font-medium text-[#007AFF]" : "text-black"
- }`}
- >
- {formatTime12Hour(time)}
- </Text>
- {isSelected && <Ionicons name="checkmark" size={20} color="#007AFF" />}
- </View>
- </AppPressable>
- );
- })}
- </ScrollView>
- </View>
+ {Platform.OS === "web" ? (
+ <TouchableOpacity
+ className="flex-1 items-center justify-center bg-black/50 p-4"
+ activeOpacity={1}
+ onPress={() => setShowTimePicker(null)}
+ >
+ <TouchableOpacity
+ className="max-h-[80%] w-full max-w-[500px] overflow-hidden rounded-2xl bg-white p-2"
+ activeOpacity={1}
+ onPress={(e) => e.stopPropagation()}
+ style={shadows.xl()}
+ >
+ {renderTimePickerContent()}
+ </TouchableOpacity>
+ </TouchableOpacity>
+ ) : (
+ <View className="flex-1 bg-white p-2">{renderTimePickerContent()}</View>
+ )}
</FullScreenModal>
</ScrollView>
);