Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a17ab5c
Show scheduled call
parasharrajat Apr 28, 2025
c2002f1
Merge branch 'parasharrajat/scheduling-call' into parasharrajat/sched…
parasharrajat May 2, 2025
add9cd9
fix issues with HeaderView
parasharrajat May 2, 2025
358c7c0
Add Reschedule and cancellation
parasharrajat May 2, 2025
559b4e4
Remove hard coded test data
parasharrajat May 2, 2025
a2c2d93
Merge branch 'main' of github.com:Expensify/App into parasharrajat/sc…
parasharrajat May 9, 2025
8b0eb63
Fix issues
parasharrajat May 9, 2025
4c69bd3
fix issue
parasharrajat May 9, 2025
14cc642
fix tests
parasharrajat May 9, 2025
614aba2
fix tests
parasharrajat May 12, 2025
a8907dc
Fix reschedule link
parasharrajat May 13, 2025
67388ae
Get the correct scheduled call
parasharrajat May 13, 2025
15897f2
Remove permission check
parasharrajat May 13, 2025
2b56338
Handle timezone properly
parasharrajat May 13, 2025
3da9685
Merge branch 'main' of github.com:Expensify/App into parasharrajat/sc…
parasharrajat May 13, 2025
33e0bb2
Handle timezones and show correct selected call
parasharrajat May 13, 2025
8490ce5
Change design
parasharrajat May 13, 2025
4b62c7a
Find the correct selected call
parasharrajat May 14, 2025
0796287
Fix icon colot
parasharrajat May 14, 2025
907b4f3
Formatting
parasharrajat May 14, 2025
e637c90
Remove test flag
parasharrajat May 14, 2025
9d2b132
Fix designs
parasharrajat May 15, 2025
205efb7
Reset flag
parasharrajat May 15, 2025
d9e8676
fixed lint
parasharrajat May 16, 2025
27ee5b3
Fix designs
parasharrajat May 16, 2025
1ac1ed2
Fix timezone crash
parasharrajat May 19, 2025
a8dc932
Merge branch 'main' of github.com:Expensify/App into parasharrajat/sc…
parasharrajat May 19, 2025
268379b
Merge branch 'main' of github.com:Expensify/App into parasharrajat/sc…
parasharrajat May 20, 2025
133903d
Merge branch 'main' of github.com:Expensify/App into parasharrajat/sc…
parasharrajat May 20, 2025
e236190
Merge branch 'main' of github.com:Expensify/App into parasharrajat/sc…
parasharrajat May 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3178,6 +3178,7 @@ const CONST = {
HEADER: 'header',
MENTION_ICON: 'mention-icon',
SMALL_NORMAL: 'small-normal',
LARGE_NORMAL: 'large-normal',
},
COMPANY_CARD: {
FEED_BANK_NAME: {
Expand Down Expand Up @@ -7086,6 +7087,12 @@ const CONST = {
EMBEDDED_DEMO_WHITELIST: ['http://', 'https://', 'about:'] as string[],
EMBEDDED_DEMO_IFRAME_TITLE: 'Test Drive',
},

SCHEDULE_CALL_STATUS: {
CREATED: 'created',
RESCHEDULED: 'rescheduled',
CANCELLED: 'cancelled',
},
} as const;

type Country = keyof typeof CONST.ALL_COUNTRIES;
Expand Down
3 changes: 3 additions & 0 deletions src/components/ButtonWithDropdownMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function ButtonWithDropdownMenu<IValueType>({
shouldShowSelectedItemCheck = false,
testID,
secondLineText = '',
icon,
}: ButtonWithDropdownMenuProps<IValueType>) {
const theme = useTheme();
const styles = useThemeStyles();
Expand Down Expand Up @@ -155,6 +156,7 @@ function ButtonWithDropdownMenu<IValueType>({
isSplitButton={isSplitButton}
testID={testID}
secondLineText={secondLineText}
icon={icon}
/>

{isSplitButton && (
Expand Down Expand Up @@ -205,6 +207,7 @@ function ButtonWithDropdownMenu<IValueType>({
innerStyles={[innerStyleDropButton]}
enterKeyEventListenerPriority={enterKeyEventListenerPriority}
secondLineText={secondLineText}
icon={icon}
/>
)}
{(shouldAlwaysShowDropdownMenu || options.length > 1) && !!popoverAnchorPosition && (
Expand Down
9 changes: 8 additions & 1 deletion src/components/ButtonWithDropdownMenu/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {RefObject} from 'react';
import type {GestureResponderEvent, StyleProp, View, ViewStyle} from 'react-native';
import type {GestureResponderEvent, StyleProp, TextStyle, View, ViewStyle} from 'react-native';
import type {ValueOf} from 'type-fest';
import type {PopoverMenuItem} from '@components/PopoverMenu';
import type CONST from '@src/CONST';
Expand Down Expand Up @@ -34,8 +34,12 @@ type DropdownOption<TValueType> = {
numberOfLinesTitle?: number;
titleStyle?: ViewStyle;
shouldCloseModalOnSelect?: boolean;
description?: string;
descriptionTextStyle?: StyleProp<TextStyle>;
wrapperStyle?: StyleProp<ViewStyle>;
displayInDefaultIconColor?: boolean;
subMenuItems?: PopoverMenuItem[];
avatarSize?: ValueOf<typeof CONST.AVATAR_SIZE>;
};

type ButtonWithDropdownMenuProps<TValueType> = {
Expand Down Expand Up @@ -125,6 +129,9 @@ type ButtonWithDropdownMenuProps<TValueType> = {

/** The second line text displays under the first line */
secondLineText?: string;

/** Icon for main button */
icon?: IconAsset;
};

export type {
Expand Down
2 changes: 2 additions & 0 deletions src/components/Icon/Illustrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ import FolderOpen from '@assets/images/simple-illustrations/simple-illustration_
import Gears from '@assets/images/simple-illustrations/simple-illustration__gears.svg';
import HandCard from '@assets/images/simple-illustrations/simple-illustration__handcard.svg';
import HandEarth from '@assets/images/simple-illustrations/simple-illustration__handearth.svg';
import HeadSet from '@assets/images/simple-illustrations/simple-illustration__headset.svg';
import HotDogStand from '@assets/images/simple-illustrations/simple-illustration__hotdogstand.svg';
import Hourglass from '@assets/images/simple-illustrations/simple-illustration__hourglass.svg';
import House from '@assets/images/simple-illustrations/simple-illustration__house.svg';
Expand Down Expand Up @@ -221,6 +222,7 @@ export {
ThumbsUpStars,
Hands,
HandEarth,
HeadSet,
SmartScan,
Hourglass,
CommentBubbles,
Expand Down
2 changes: 2 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ const translations = {
comments: 'Comments',
sharedIn: 'Shared in',
unreported: 'Unreported',
reschedule: 'Reschedule',
general: 'General',
workspacesTabTitle: 'Workspaces',
},
Expand Down Expand Up @@ -6355,6 +6356,7 @@ const translations = {
dateTime: 'Date & time',
minutes: '30 minutes',
},
callScheduled: 'Call scheduled',
},
testDrive: {
quickAction: {
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ const translations = {
comments: 'Comentarios',
sharedIn: 'Compartido en',
unreported: 'No reportado',
reschedule: 'Reprogramar',

This comment was marked as resolved.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes

general: 'General',
workspacesTabTitle: 'Espacios',
},
Expand Down Expand Up @@ -6880,6 +6881,7 @@ const translations = {
dateTime: 'Fecha y hora',
minutes: '30 minutos',
},
callScheduled: 'Llamada programada',
},
testDrive: {
quickAction: {
Expand Down
11 changes: 11 additions & 0 deletions src/libs/DateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,16 @@ const isCurrentTimeWithinRange = (startTime: string, endTime: string): boolean =
return isAfter(now, new Date(startTime)) && isBefore(now, new Date(endTime));
};

const formatInTimeZoneWithFallback: typeof formatInTimeZone = (date, timeZone, formatStr, options?) => {
try {
return formatInTimeZone(date, timeZone, formatStr, options);
// On macOs and iOS devices some platform use deprecated old timezone values which results in invalid time string error.
// Try with backward timezone values on error.
} catch {
return formatInTimeZone(date, timezoneBackwardMap[timeZone], formatStr, options);
}
};

const DateUtils = {
isDate,
formatToDayOfWeek,
Expand Down Expand Up @@ -1021,6 +1031,7 @@ const DateUtils = {
isFutureDay,
getFormattedDateRangeForPerDiem,
isCurrentTimeWithinRange,
formatInTimeZoneWithFallback,
};

export default DateUtils;
9 changes: 9 additions & 0 deletions src/libs/DebugUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,14 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa
data: 'object',
errors: 'object',
});
case 'calendlyCalls':
return validateArray<ArrayElement<ReportNameValuePairs, 'calendlyCalls'>>(value, {
status: 'string',
host: 'number',
eventTime: 'string',
eventURI: 'string',
inserted: 'string',
});
case 'pendingAction':
return validateConstantEnum(value, CONST.RED_BRICK_ROAD_PENDING_ACTION);
case 'pendingFields':
Expand Down Expand Up @@ -637,6 +645,7 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa
createReport: CONST.RED_BRICK_ROAD_PENDING_ACTION,
exportFailedTime: CONST.RED_BRICK_ROAD_PENDING_ACTION,
calendlySchedule: CONST.RED_BRICK_ROAD_PENDING_ACTION,
calendlyCalls: CONST.RED_BRICK_ROAD_PENDING_ACTION,
});
}
}
Expand Down
5 changes: 0 additions & 5 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ function canUseRetractNewDot(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.RETRACT_NEWDOT) || canUseAllBetas(betas);
}

function canUseCallScheduling() {
return false;
}

function canUseMultiFilesDragAndDrop(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.NEWDOT_MULTI_FILES_DRAG_AND_DROP) || canUseAllBetas(betas);
}
Expand All @@ -107,7 +103,6 @@ export default {
canUseGlobalReimbursementsOnND,
canUsePrivateDomainOnboarding,
canUseRetractNewDot,
canUseCallScheduling,
canUseMultiLevelTags,
canUseMultiFilesDragAndDrop,
canUsePlaidCompanyCards,
Expand Down
25 changes: 22 additions & 3 deletions src/libs/actions/ScheduleCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {WRITE_COMMANDS} from '@libs/API/types';
import Navigation from '@libs/Navigation/Navigation';
import ONYXKEYS from '@src/ONYXKEYS';
import type {PersonalDetails, ScheduleCallDraft} from '@src/types/onyx';
import type {SelectedTimezone} from '@src/types/onyx/PersonalDetails';
import type {CalendlyCall} from '@src/types/onyx/ReportNameValuePairs';
import {openExternalLink} from './Link';

function getGuideCallAvailabilitySchedule(reportID: string) {
Expand Down Expand Up @@ -66,13 +68,30 @@ function clearBookingDraft() {
Onyx.set(`${ONYXKEYS.SCHEDULE_CALL_DRAFT}`, null);
}

function confirmBooking(data: Required<ScheduleCallDraft>, currentUser: PersonalDetails) {
function confirmBooking(data: Required<ScheduleCallDraft>, currentUser: PersonalDetails, timezone?: SelectedTimezone) {
const scheduleURL = `${data.guide.scheduleURL}?name=${encodeURIComponent(currentUser.displayName ?? '')}&email=${encodeURIComponent(
currentUser?.login ?? '',
)}&utm_source=newDot&utm_medium=report&utm_content=${data.reportID}`;
)}&utm_source=newDot&utm_medium=report&utm_content=${data.reportID}&timezone=${timezone}`;

openExternalLink(scheduleURL);
clearBookingDraft();
Navigation.dismissModal();
}
export {getGuideCallAvailabilitySchedule, saveBookingDraft, clearBookingDraft, confirmBooking};

function getEventIDFromURI(eventURI: string) {
const parts = eventURI.split('/');
// Last path in the URI is ID
return parts.slice(-1).at(0);
}

function rescheduleBooking(call: CalendlyCall) {
const rescheduleURL = `https://calendly.com/reschedulings/${getEventIDFromURI(call.eventURI)}`;
openExternalLink(rescheduleURL);
}

function cancelBooking(call: CalendlyCall) {
const cancelURL = `https://calendly.com/cancellations/${getEventIDFromURI(call.eventURI)}`;
openExternalLink(cancelURL);
}

export {getGuideCallAvailabilitySchedule, saveBookingDraft, clearBookingDraft, confirmBooking, rescheduleBooking, cancelBooking};
17 changes: 11 additions & 6 deletions src/pages/ScheduleCall/ScheduleCallConfirmationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import type {Timezone} from '@src/types/onyx/PersonalDetails';

function ScheduleCallConfirmationPage() {
const styles = useThemeStyles();
const {translate} = useLocalize();
const [scheduleCallDraft] = useOnyx(`${ONYXKEYS.SCHEDULE_CALL_DRAFT}`, {canBeMissing: false});
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const timezone: Timezone = currentUserPersonalDetails?.timezone ?? CONST.DEFAULT_TIME_ZONE;
const userTimezone = currentUserPersonalDetails?.timezone?.selected ? currentUserPersonalDetails?.timezone.selected : CONST.DEFAULT_TIME_ZONE.selected;

const personalDetails = usePersonalDetails();
const route = useRoute<PlatformStackRouteProp<ScheduleCallParamList, typeof SCREENS.SCHEDULE_CALL.CONFIRMATION>>();

Expand All @@ -48,8 +48,9 @@ function ScheduleCallConfirmationPage() {
reportID: scheduleCallDraft.reportID,
},
currentUserPersonalDetails,
userTimezone,
);
}, [currentUserPersonalDetails, scheduleCallDraft]);
}, [currentUserPersonalDetails, scheduleCallDraft, userTimezone]);

const guideDetails = useMemo(
() => (scheduleCallDraft?.guide?.accountID ? personalDetails?.[scheduleCallDraft?.guide?.accountID] : null),
Expand All @@ -61,12 +62,16 @@ function ScheduleCallConfirmationPage() {
return '';
}
const dateString = format(scheduleCallDraft.date, CONST.DATE.MONTH_DAY_YEAR_FORMAT);
const timeString = `${DateUtils.formatToLocalTime(scheduleCallDraft?.timeSlot)} - ${DateUtils.formatToLocalTime(addMinutes(scheduleCallDraft?.timeSlot, 30))}`;
const timeString = `${DateUtils.formatInTimeZoneWithFallback(scheduleCallDraft?.timeSlot, userTimezone, CONST.DATE.LOCAL_TIME_FORMAT)} - ${DateUtils.formatInTimeZoneWithFallback(
addMinutes(scheduleCallDraft?.timeSlot, 30),
userTimezone,
CONST.DATE.LOCAL_TIME_FORMAT,
)}`;

const timeZoneStirng = timezone.selected ? DateUtils.getZoneAbbreviation(new Date(scheduleCallDraft?.timeSlot), timezone.selected) : '';
const timeZoneStirng = DateUtils.getZoneAbbreviation(new Date(scheduleCallDraft?.timeSlot), userTimezone);

return `${dateString} from ${timeString} ${timeZoneStirng}`;
}, [scheduleCallDraft?.date, scheduleCallDraft?.timeSlot, timezone.selected]);
}, [scheduleCallDraft?.date, scheduleCallDraft?.timeSlot, userTimezone]);

return (
<ScreenWrapper
Expand Down
14 changes: 7 additions & 7 deletions src/pages/ScheduleCall/ScheduleCallPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import {getGuideCallAvailabilitySchedule, saveBookingDraft} from '@libs/actions/ScheduleCall';
import DateUtils from '@libs/DateUtils';
import {getLatestError} from '@libs/ErrorUtils';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types';
Expand All @@ -25,7 +26,6 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import type {Timezone} from '@src/types/onyx/PersonalDetails';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import AvailableBookingDay from './AvailableBookingDay';

Expand All @@ -42,7 +42,7 @@ function ScheduleCallPage() {
const route = useRoute<PlatformStackRouteProp<ScheduleCallParamList, typeof SCREENS.SCHEDULE_CALL.BOOK>>();

const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const timezone: Timezone = currentUserPersonalDetails?.timezone ?? CONST.DEFAULT_TIME_ZONE;
const userTimezone = currentUserPersonalDetails?.timezone?.selected ? currentUserPersonalDetails?.timezone.selected : CONST.DEFAULT_TIME_ZONE.selected;

const [scheduleCallDraft] = useOnyx(`${ONYXKEYS.SCHEDULE_CALL_DRAFT}`, {canBeMissing: true});
const reportID = route.params?.reportID;
Expand Down Expand Up @@ -93,14 +93,14 @@ function ScheduleCallPage() {

const timeSlotMap: Record<string, TimeSlot[]> = {};
allTimeSlots.forEach((timeSlot) => {
const timeSlotDate = format(new Date(timeSlot?.startTime), CONST.DATE.FNS_FORMAT_STRING);
const timeSlotDate = DateUtils.formatInTimeZoneWithFallback(new Date(timeSlot?.startTime), userTimezone, CONST.DATE.FNS_FORMAT_STRING);
if (!timeSlotMap[timeSlotDate]) {
timeSlotMap[timeSlotDate] = [];
}
timeSlotMap[timeSlotDate].push(timeSlot);
});
return timeSlotMap;
}, [calendlySchedule]);
}, [calendlySchedule, userTimezone]);

const selectableDates = Object.keys(timeSlotDateMap).sort(compareAsc);
const firstDate = selectableDates.at(0);
Expand Down Expand Up @@ -165,7 +165,7 @@ function ScheduleCallPage() {
</View>
<MenuItemWithTopDescription
interactive={false}
title={timezone.selected}
title={userTimezone}
description={translate('timezonePage.timezone')}
style={[styles.mt3, styles.mb3]}
/>
Expand All @@ -187,7 +187,7 @@ function ScheduleCallPage() {
<Button
key={`time-slot-${timeSlot.startTime}`}
large
success={scheduleCallDraft?.timeSlot === timeSlot?.startTime}
success={scheduleCallDraft?.timeSlot === timeSlot.startTime}
onPress={() => {
saveBookingDraft({
timeSlot: timeSlot.startTime,
Expand All @@ -202,7 +202,7 @@ function ScheduleCallPage() {
}}
shouldEnableHapticFeedback
style={styles.twoColumnLayoutCol}
text={format(timeSlot.startTime, 'p')}
text={DateUtils.formatInTimeZoneWithFallback(timeSlot.startTime, userTimezone, CONST.DATE.LOCAL_TIME_FORMAT)}
/>
))}
{timeFillerItem}
Expand Down
Loading