Skip to content

Commit

Permalink
fix: several fixes in the offchain new flow
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmahidalgo committed Nov 5, 2024
1 parent 0b10a60 commit 2d26e62
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/components/CollectionDetailPage/CollectionDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,9 @@ export default function CollectionDetailPage({
{tab === ItemType.EMOTE || hasOnlyEmotes ? (
<Table.HeaderCell>{t('collection_detail_page.table.play_mode')}</Table.HeaderCell>
) : null}
<Table.HeaderCell>{t('collection_detail_page.table.price')}</Table.HeaderCell>
{isOffchainPublicItemOrdersEnabled && !collection.isPublished ? null : (
<Table.HeaderCell>{t('collection_detail_page.table.price')}</Table.HeaderCell>
)}
{collection.isPublished && collection.isApproved ? (
<Table.HeaderCell>{t('collection_detail_page.table.supply')}</Table.HeaderCell>
) : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@

.status {
padding: 4px 10px 4px 8px;
margin: 0 10px;
border-radius: 32px;
align-items: center;
width: fit-content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ export default function CollectionItem({
{data.category ? <div>{t(`emote.play_mode.${data.loop ? 'loop' : 'simple'}.text`)}</div> : null}
</Table.Cell>
) : null}
<Table.Cell className={styles.column}>{renderPrice()}</Table.Cell>
{isOffchainPublicItemOrdersEnabled && !collection.isPublished ? null : (
<Table.Cell className={styles.column}>{renderPrice()}</Table.Cell>
)}
{item.isPublished && item.isApproved ? (
<Table.Cell className={styles.column}>
<div>
Expand All @@ -233,7 +235,7 @@ export default function CollectionItem({
</Table.Cell>
) : null}
<Table.Cell>{renderItemStatus()}</Table.Cell>
{isOffchainPublicItemOrdersEnabled && !isOnSaleLegacy && !item.tradeId && (
{isOffchainPublicItemOrdersEnabled && !isOnSaleLegacy && !item.tradeId && item.isPublished && (
<Table.Cell>
<Button primary size="tiny" disabled={!isEnableForSaleOffchainMarketplace} onClick={handlePutForSale}>
{t('collection_item.put_for_sale')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ export const ConfirmCollectionItemsStep: React.FC<{
onPrevStep: () => void
isSigningCheque: boolean
isThirdParty: boolean
isOffchainPublicItemOrdersEnabled: boolean
collection: Collection
}> = props => {
const { items, collection, onNextStep, onPrevStep, isSigningCheque, isThirdParty } = props
const { items, collection, onNextStep, onPrevStep, isSigningCheque, isThirdParty, isOffchainPublicItemOrdersEnabled } = props
const isCollectionLinked = collection.linkedContractAddress && collection.linkedContractNetwork

const renderPrice = (item: Item) => {
Expand Down Expand Up @@ -106,7 +107,7 @@ export const ConfirmCollectionItemsStep: React.FC<{
<Table.HeaderCell width={7}>{t('collection_detail_page.table.item')}</Table.HeaderCell>
<Table.HeaderCell>{t('collection_detail_page.table.rarity')}</Table.HeaderCell>
<Table.HeaderCell>{t('collection_detail_page.table.category')}</Table.HeaderCell>
<Table.HeaderCell>{t('collection_detail_page.table.price')}</Table.HeaderCell>
{isOffchainPublicItemOrdersEnabled ? null : <Table.HeaderCell>{t('collection_detail_page.table.price')}</Table.HeaderCell>}
</Table.Row>
</Table.Header>
<Table.Body>
Expand Down Expand Up @@ -134,7 +135,7 @@ export const ConfirmCollectionItemsStep: React.FC<{
text={t(`${item.type}.category.${item.data.category!}`)}
></IconBadge>
</Table.Cell>
<Table.Cell className={styles.priceColumn}>{renderPrice(item)}</Table.Cell>
{isOffchainPublicItemOrdersEnabled ? null : <Table.Cell className={styles.priceColumn}>{renderPrice(item)}</Table.Cell>}
</Table.Row>
))}
</Table.Body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import { publishCollectionRequest } from 'modules/collection/actions'
import { CREATE_COLLECTION_FORUM_POST_REQUEST } from 'modules/forum/actions'
import { fetchRaritiesRequest, FETCH_RARITIES_REQUEST, FETCH_ITEMS_REQUEST } from 'modules/item/actions'
import { getIsPublishCollectionsWertEnabled } from 'modules/features/selectors'
import { getIsOffchainPublicItemOrdersEnabled, getIsPublishCollectionsWertEnabled } from 'modules/features/selectors'
import { OwnProps } from './PublishWizardCollectionModal.types'
import { AuthorizedPublishWizardThirdPartyCollectionModal, AuthorizedPublishWizardCollectionModal } from './PublishWizardCollectionModal'
import { useCallback, useMemo } from 'react'
Expand All @@ -46,6 +46,7 @@ export default (props: OwnProps) => {
const standardPublishingStatus = useSelector((state: RootState) => getPublishStatus(state), shallowEqual)
const thirdPartyPublishingStatus = useSelector((state: RootState) => getThirdPartyPublishStatus(state), shallowEqual)

const isOffchainPublicItemOrdersEnabled = useSelector((state: RootState) => getIsOffchainPublicItemOrdersEnabled(state))
const isPublishCollectionsWertEnabled = useSelector(getIsPublishCollectionsWertEnabled, shallowEqual)
const wallet = useSelector(getWallet, shallowEqual)!
const unsyncedCollectionError = useSelector(getUnsyncedCollectionError, shallowEqual)
Expand Down Expand Up @@ -147,6 +148,7 @@ export default (props: OwnProps) => {
itemError={itemError}
collectionError={collectionError || thirdPartyPublishingError}
isPublishCollectionsWertEnabled={isPublishCollectionsWertEnabled}
isOffchainPublicItemOrdersEnabled={isOffchainPublicItemOrdersEnabled}
onPublish={onPublish}
onFetchPrice={isThirdParty ? fetchThirdPartyPrice : onFetchRarities}
thirdParty={thirdParty}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,23 @@ export const PublishWizardCollectionModal: React.FC<Props & WithAuthorizedAction
isLoading,
price: itemPrice,
isPublishingFinished,
isOffchainPublicItemOrdersEnabled,
onClose,
onFetchPrice,
onPublish,
onAuthorizedAction,
onCloseAuthorization
} = props
const [currentStep, setCurrentStep] = useState<number>(PublishWizardCollectionSteps.CONFIRM_COLLECTION_NAME)
console.log('currentStep: ', currentStep)
const [emailAddress, setEmailAddress] = useState<string>('')
const [cheque, setCheque] = useState<Cheque | undefined>(undefined)
const [isSigningCheque, setIsSigningCheque] = useState<boolean>(false)
const [subscribeToNewsletter, setSubscribeToNewsletter] = useState<boolean>(false)
const isThirdParty = useMemo(() => isTPCollection(collection), [collection])
const allItems = useMemo(() => [...itemsToPublish, ...itemsWithChanges], [itemsToPublish, itemsWithChanges])

console.log('collection: ', collection)
useEffect(() => {
onFetchPrice()
}, [onFetchPrice])
Expand Down Expand Up @@ -155,6 +158,7 @@ export const PublishWizardCollectionModal: React.FC<Props & WithAuthorizedAction
collection={collection}
items={allItems}
isThirdParty={isThirdParty}
isOffchainPublicItemOrdersEnabled={isOffchainPublicItemOrdersEnabled}
onNextStep={handleOnConfirmItemsNextStep}
onPrevStep={handleOnPrevStep}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export type Props = Omit<ModalProps, 'metadata'> & {
isLoading: boolean
isPublishingFinished: boolean
isPublishCollectionsWertEnabled: boolean
isOffchainPublicItemOrdersEnabled: boolean
publishingStatus: AuthorizationStepStatus
onPublish: (
email: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const mapState = (state: RootState, ownProps: OwnProps): MapStateProps => {
}

const mapDispatch = (dispatch: MapDispatch): MapDispatchProps => ({
onSetMinters: (collection, minters) => dispatch(setCollectionMintersRequest(collection, minters))
onSetMinters: (collection, minters) => dispatch(setCollectionMintersRequest(collection, minters, false))
})

export default connect(mapState, mapDispatch)(SellCollectionModal)
4 changes: 2 additions & 2 deletions src/modules/collection/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ export const SET_COLLECTION_MINTERS_REQUEST = '[Request] Set collection minters'
export const SET_COLLECTION_MINTERS_SUCCESS = '[Success] Set collection minters'
export const SET_COLLECTION_MINTERS_FAILURE = '[Failure] Set collection minters'

export const setCollectionMintersRequest = (collection: Collection, accessList: Access[]) =>
action(SET_COLLECTION_MINTERS_REQUEST, { collection, accessList })
export const setCollectionMintersRequest = (collection: Collection, accessList: Access[], redirectToActivity?: boolean) =>
action(SET_COLLECTION_MINTERS_REQUEST, { collection, accessList, redirectToActivity })
export const setCollectionMintersSuccess = (collection: Collection, minters: string[], chainId: ChainId, txHash: string) =>
action(SET_COLLECTION_MINTERS_SUCCESS, {
collection,
Expand Down
6 changes: 4 additions & 2 deletions src/modules/collection/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ export function* collectionSaga(legacyBuilderClient: BuilderAPI, client: Builder
}

function* handleSetCollectionMintersRequest(action: SetCollectionMintersRequestAction) {
const { collection, accessList } = action.payload
const { collection, accessList, redirectToActivity = true } = action.payload
const history: History = yield getContext('history')

try {
Expand All @@ -642,7 +642,9 @@ export function* collectionSaga(legacyBuilderClient: BuilderAPI, client: Builder
const txHash: string = yield call(sendTransaction, contract, collection => collection.setMinters(addresses, values))

yield put(setCollectionMintersSuccess(collection, Array.from(newMinters), maticChainId, txHash))
history.replace(locations.activity())
if (redirectToActivity) {
history.replace(locations.activity())
}
} catch (error) {
yield put(setCollectionMintersFailure(collection, accessList, isErrorWithMessage(error) ? error.message : 'Unknown error'))
}
Expand Down

0 comments on commit 2d26e62

Please sign in to comment.