Skip to content

Commit

Permalink
(PC-31778) fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
yleclercq-pass committed Sep 20, 2024
1 parent e4d0cb4 commit a83096b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ const renderEndedBookings = (bookings: BookingsResponse) => {
.spyOn(bookingsAPI, 'useBookings')
.mockReturnValue({ data: bookings } as QueryObserverResult<BookingsResponse, unknown>)

return render(reactQueryProviderHOC(<EndedBookings enableBookingImprove={false} />))
return render(
reactQueryProviderHOC(<EndedBookings enableBookingImprove={false} bookings={bookingsSnap} />)
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback } from 'react'

import { PostReactionRequest, ReactionTypeEnum } from 'api/gen'
import { PostOneReactionRequest, PostReactionRequest, ReactionTypeEnum } from 'api/gen'
import { useBookings } from 'features/bookings/api'
import { TWENTY_FOUR_HOURS } from 'features/home/constants'
import { useReactionMutation } from 'features/reactions/api/useReactionMutation'
Expand Down Expand Up @@ -30,8 +30,11 @@ export const IncomingReactionModalContainer = () => {
const firstBooking = bookingsWithoutReaction[0]

const handleSaveReaction = useCallback(
({ offerId, reactionType }: PostReactionRequest) => {
addReaction({ offerId, reactionType })
({ offerId, reactionType }: PostOneReactionRequest) => {
const reactionRequest: PostReactionRequest = {
reactions: [{ offerId, reactionType }],
}
addReaction(reactionRequest)
return Promise.resolve(true)
},
[addReaction]
Expand All @@ -41,8 +44,12 @@ export const IncomingReactionModalContainer = () => {
if (!firstBooking) return

addReaction({
offerId: firstBooking.stock.offer.id,
reactionType: ReactionTypeEnum.NO_REACTION,
reactions: [
{
offerId: firstBooking.stock.offer.id,
reactionType: ReactionTypeEnum.NO_REACTION,
},
],
})

hideReactionModal()
Expand Down
4 changes: 2 additions & 2 deletions src/features/reactions/api/useReactionMutation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('useReactionMutation', () => {

const { result } = renderUseReactionMutation()

result.current.mutate({ offerId: 12, reactionType: ReactionTypeEnum.LIKE })
result.current.mutate({ reactions: [{ offerId: 12, reactionType: ReactionTypeEnum.LIKE }] })

await waitFor(() => expect(result.current.isSuccess).toBeTruthy())
})
Expand All @@ -31,7 +31,7 @@ describe('useReactionMutation', () => {

const { result } = renderUseReactionMutation()

result.current.mutate({ offerId: 12, reactionType: ReactionTypeEnum.LIKE })
result.current.mutate({ reactions: [{ offerId: 12, reactionType: ReactionTypeEnum.LIKE }] })

await waitFor(() => {
expect(result.current.isError).toBeTruthy()
Expand Down

0 comments on commit a83096b

Please sign in to comment.