Skip to content

Commit

Permalink
feat(): add cancel/reschedule urls (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-grzelak authored Jun 2, 2023
1 parent ad518e0 commit ec7c6aa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
8 changes: 4 additions & 4 deletions extensions/calDotCom/__mocks__/calComApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const mock = jest.fn().mockImplementation((params) => {
return {
getBooking: jest.fn((params) => {
console.log('Mocking cal.com api', params)
return { booking: { id: 'test' } }
return { booking: { id: 'test', uid: 'test', eventTypeId: '123' } }
}),
};
});
}
})

export default mock;
export default mock
15 changes: 11 additions & 4 deletions extensions/calDotCom/actions/__tests__/getBooking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ jest.mock('../../calComApi')

describe('Simple getBooking action', () => {
const onComplete = jest.fn()
const settings = {
apiKey: 'apiKey',
}

beforeEach(() => {
onComplete.mockClear()
Expand All @@ -22,13 +25,17 @@ describe('Simple getBooking action', () => {
fields: {
bookingId: '123',
},
settings: {
apiKey: 'apiKey',
},
settings,
},
onComplete,
jest.fn()
)
expect(onComplete).toHaveBeenCalled()
expect(onComplete).toHaveBeenCalledWith({
data_points: {
cancelUrl: `https://app.cal.com/booking/test?cancel=true`,
rescheduleUrl: `https://app.cal.com/reschedule/test`,
eventTypeId: '123',
},
})
})
})
10 changes: 10 additions & 0 deletions extensions/calDotCom/actions/getBooking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ const dataPoints = {
key: 'status',
valueType: 'string',
},
cancelUrl: {
key: 'cancelUrl',
valueType: 'string',
},
rescheduleUrl: {
key: 'rescheduleUrl',
valueType: 'string',
},
} satisfies Record<string, DataPointDefinition>

export const getBooking: Action<typeof fields, typeof settings> = {
Expand Down Expand Up @@ -79,6 +87,8 @@ export const getBooking: Action<typeof fields, typeof settings> = {
startTime: booking.startTime,
endTime: booking.endTime,
status: booking.status,
cancelUrl: `https://app.cal.com/booking/${booking.uid}?cancel=true`,
rescheduleUrl: `https://app.cal.com/reschedule/${booking.uid}`,
},
})
} catch (error) {
Expand Down

0 comments on commit ec7c6aa

Please sign in to comment.