diff --git a/pro/src/pages/CollectiveOffer/CollectiveOfferLayout/CollectiveOfferNavigation/CollectiveOfferNavigation.tsx b/pro/src/pages/CollectiveOffer/CollectiveOfferLayout/CollectiveOfferNavigation/CollectiveOfferNavigation.tsx
index 835ba573499..77c3dbf039c 100644
--- a/pro/src/pages/CollectiveOffer/CollectiveOfferLayout/CollectiveOfferNavigation/CollectiveOfferNavigation.tsx
+++ b/pro/src/pages/CollectiveOffer/CollectiveOfferLayout/CollectiveOfferNavigation/CollectiveOfferNavigation.tsx
@@ -268,7 +268,7 @@ export const CollectiveOfferNavigation = ({
offer,
CollectiveOfferTemplateAllowedAction.CAN_CREATE_BOOKABLE_OFFER
)
- : isTemplate
+ : isTemplate && offer.displayedStatus !== CollectiveOfferDisplayedStatus.PENDING
: false
return isEditingExistingOffer ? (
diff --git a/pro/src/pages/CollectiveOffer/CollectiveOfferLayout/CollectiveOfferNavigation/__specs__/CollectiveOfferNavigation.spec.tsx b/pro/src/pages/CollectiveOffer/CollectiveOfferLayout/CollectiveOfferNavigation/__specs__/CollectiveOfferNavigation.spec.tsx
index 12c6c1eca49..6f266433f33 100644
--- a/pro/src/pages/CollectiveOffer/CollectiveOfferLayout/CollectiveOfferNavigation/__specs__/CollectiveOfferNavigation.spec.tsx
+++ b/pro/src/pages/CollectiveOffer/CollectiveOfferLayout/CollectiveOfferNavigation/__specs__/CollectiveOfferNavigation.spec.tsx
@@ -363,11 +363,25 @@ describe('CollectiveOfferNavigation', () => {
isCreatingOffer: false,
})
- const duplicateOffer = screen.getByRole('button', {
+ const duplicateOfferButton = screen.getByRole('button', {
name: 'Créer une offre réservable',
})
- expect(duplicateOffer).toBeInTheDocument()
+ expect(duplicateOfferButton).toBeInTheDocument()
+ })
+
+ it('should not show create bookable offer button if template offer has pending status', () => {
+ renderCollectiveOfferNavigation({
+ ...props,
+ isTemplate: true,
+ offer: { ...offer, displayedStatus: CollectiveOfferDisplayedStatus.PENDING }
+ })
+
+ const duplicateOffer = screen.queryByRole('button', {
+ name: 'Créer une offre réservable',
+ })
+
+ expect(duplicateOffer).not.toBeInTheDocument()
})
it('should show create bookable offer if offer is template and ff is active', () => {
diff --git a/pro/src/pages/Offers/OffersTable/Cells/CollectiveActionsCells.tsx b/pro/src/pages/Offers/OffersTable/Cells/CollectiveActionsCells.tsx
index 102670ebb69..f8622e6070f 100644
--- a/pro/src/pages/Offers/OffersTable/Cells/CollectiveActionsCells.tsx
+++ b/pro/src/pages/Offers/OffersTable/Cells/CollectiveActionsCells.tsx
@@ -10,6 +10,7 @@ import { getErrorCode, isErrorAPIError } from 'apiClient/helpers'
import {
CollectiveBookingStatus,
CollectiveOfferAllowedAction,
+ CollectiveOfferDisplayedStatus,
CollectiveOfferResponseModel,
CollectiveOfferStatus,
CollectiveOfferTemplateAllowedAction,
@@ -256,11 +257,20 @@ export const CollectiveActionsCells = ({
const canDuplicateOffer = areCollectiveNewStatusesEnabled
? isActionAllowedOnCollectiveOffer(
offer,
- offer.isShowcase
- ? CollectiveOfferTemplateAllowedAction.CAN_CREATE_BOOKABLE_OFFER
- : CollectiveOfferAllowedAction.CAN_DUPLICATE
+ CollectiveOfferAllowedAction.CAN_DUPLICATE
+ )
+ : offer.displayedStatus !== CollectiveOfferDisplayedStatus.DRAFT
+
+ const canCreateBookableOffer = areCollectiveNewStatusesEnabled
+ ? isActionAllowedOnCollectiveOffer(
+ offer,
+ CollectiveOfferTemplateAllowedAction.CAN_CREATE_BOOKABLE_OFFER
)
- : offer.status !== CollectiveOfferStatus.DRAFT
+ : offer.isShowcase &&
+ ![
+ CollectiveOfferDisplayedStatus.DRAFT,
+ CollectiveOfferDisplayedStatus.PENDING,
+ ].includes(offer.displayedStatus)
const canArchiveOffer = areCollectiveNewStatusesEnabled
? isActionAllowedOnCollectiveOffer(
@@ -287,7 +297,11 @@ export const CollectiveActionsCells = ({
const noActionsAllowed = areCollectiveNewStatusesEnabled
? offer.allowedActions.length === 0
- : offer.isShowcase && offer.status === CollectiveOfferStatus.ARCHIVED
+ : offer.isShowcase &&
+ [
+ CollectiveOfferDisplayedStatus.ARCHIVED,
+ CollectiveOfferDisplayedStatus.PENDING,
+ ].includes(offer.displayedStatus)
const canEditOffer = areCollectiveNewStatusesEnabled
? hasOfferAnyEditionActionAllowed(offer)
@@ -295,15 +309,15 @@ export const CollectiveActionsCells = ({
!offer.isPublicApi &&
offer.status !== CollectiveOfferStatus.ARCHIVED
- const isBookingCancellable =
- areCollectiveNewStatusesEnabled ?
- isActionAllowedOnCollectiveOffer(offer,CollectiveOfferAllowedAction.CAN_CANCEL)
- : offer.status === CollectiveOfferStatus.SOLD_OUT &&
- offer.booking &&
- (offer.booking.booking_status ===
- CollectiveBookingStatus.PENDING ||
- offer.booking.booking_status ===
- CollectiveBookingStatus.CONFIRMED)
+ const isBookingCancellable = areCollectiveNewStatusesEnabled
+ ? isActionAllowedOnCollectiveOffer(
+ offer,
+ CollectiveOfferAllowedAction.CAN_CANCEL
+ )
+ : offer.status === CollectiveOfferStatus.SOLD_OUT &&
+ offer.booking &&
+ (offer.booking.booking_status === CollectiveBookingStatus.PENDING ||
+ offer.booking.booking_status === CollectiveBookingStatus.CONFIRMED)
const offerActivationWording =
'Votre offre est maintenant active et visible dans ADAGE'
@@ -403,13 +417,18 @@ export const CollectiveActionsCells = ({
className={styles['menu-item']}
onSelect={handleCreateOfferClick}
>
-
+
+ >
+ )}
{canArchiveOffer && (
<>
{
renderCollectiveActionsCell({
offer: collectiveOfferFactory({
isShowcase: true,
- status: CollectiveOfferStatus.DRAFT,
+ displayedStatus: CollectiveOfferDisplayedStatus.DRAFT,
+ }),
+ })
+
+ await userEvent.click(screen.getByTitle('Action'))
+
+ expect(
+ screen.queryByText('Créer une offre réservable')
+ ).not.toBeInTheDocument()
+ })
+
+ it('should not display duplicate button for pending template offer', async () => {
+ renderCollectiveActionsCell({
+ offer: collectiveOfferFactory({
+ isShowcase: true,
+ displayedStatus: CollectiveOfferDisplayedStatus.PENDING,
}),
})
@@ -185,7 +200,7 @@ describe('CollectiveActionsCells', () => {
it('should not display duplicate button for draft bookable offer', async () => {
renderCollectiveActionsCell({
offer: collectiveOfferFactory({
- status: CollectiveOfferStatus.DRAFT,
+ displayedStatus: CollectiveOfferDisplayedStatus.DRAFT,
}),
})