import React from 'react'; import { bool, oneOfType, object } from 'prop-types'; import { FormattedMessage } from '../../util/reactIntl'; import classNames from 'classnames'; import { LISTING_STATE_PENDING_APPROVAL, LISTING_STATE_CLOSED, LISTING_STATE_DRAFT, propTypes, } from '../../util/types'; import { NamedLink } from '../../components'; import EditIcon from './EditIcon'; import css from './ListingPage.css'; export const ActionBarMaybe = props => { const { isOwnListing, listing, editParams } = props; const state = listing.attributes.state; const isPendingApproval = state === LISTING_STATE_PENDING_APPROVAL; const isClosed = state === LISTING_STATE_CLOSED; const isDraft = state === LISTING_STATE_DRAFT; if (isOwnListing) { let ownListingTextTranslationId = 'ListingPage.ownListing'; if (isPendingApproval) { ownListingTextTranslationId = 'ListingPage.ownListingPendingApproval'; } else if (isClosed) { ownListingTextTranslationId = 'ListingPage.ownClosedListing'; } else if (isDraft) { ownListingTextTranslationId = 'ListingPage.ownListingDraft'; } const message = isDraft ? 'ListingPage.finishListing' : 'ListingPage.editListing'; const ownListingTextClasses = classNames(css.ownListingText, { [css.ownListingTextPendingApproval]: isPendingApproval, }); return (