Skip to content

Commit

Permalink
feat: add multiple tag campaign
Browse files Browse the repository at this point in the history
  • Loading branch information
Melisa Anabella Rossi committed Nov 13, 2023
1 parent 4c772cb commit 582d702
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const mapState = (state: RootState): MapStateProps => ({
})

const mapDispatch = (dispatch: MapDispatch) => ({
onFetchEventContracts: (tag: string) => dispatch(fetchEventRequest(tag))
onFetchEventContracts: (tags: string[]) => dispatch(fetchEventRequest(tags))
})

export default connect(mapState, mapDispatch)(BrowsePage)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Navigation } from '../../Navigation'
import { AssetBrowse } from '../../AssetBrowse'
import { CampaignBrowserBanner } from '../banners/CampaignBrowserBanner'
import { CampaignBanner } from '../CampaignBanner'
import { CAMPAIGN_TAG } from '../config'
import { CAMPAIGN_BROWSE_TAGS, CAMPAIGN_TAG } from '../config'
import { Props } from './CampaignBrowserPage.types'
import './CampaignBrowserPage.css'

Expand All @@ -27,7 +27,7 @@ const CampaignBrowserPage = (props: Props) => {
const vendor = isVendor(props.vendor) ? props.vendor : VendorName.DECENTRALAND

useEffect(() => {
onFetchEventContracts(CAMPAIGN_TAG)
onFetchEventContracts(CAMPAIGN_BROWSE_TAGS)
}, [onFetchEventContracts])

const activeTab = NavigationTab.CAMPAIGN_BROWSER
Expand Down
1 change: 1 addition & 0 deletions webapp/src/components/Campaign/config.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export const CAMPAIGN_TAG = 'DCLMF23'
export const CAMPAIGN_BROWSE_TAGS = [CAMPAIGN_TAG, 'MVMF22']
export const CAMPAING_TAB_ANIMATION_ENABLED = true
16 changes: 8 additions & 8 deletions webapp/src/modules/event/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@ import {
const anErrorMessage = 'An error'

describe('when creating the action to signal the start of the events request', () => {
let tag: string
let tags: string[]
beforeEach(() => {
tag = 'a tag'
tags = ['a tag']
})
it('should return an object representing the action', () => {
expect(fetchEventRequest(tag)).toEqual({
expect(fetchEventRequest(tags)).toEqual({
type: FETCH_EVENT_REQUEST,
meta: undefined,
payload: {
tag
tags
}
})
})
})

describe('when creating the action to signal a success in the events request', () => {
let tag: string
let tags: string[]
let contracts: string[]
beforeEach(() => {
tag = 'a tag'
tags = ['a tag']
contracts = ['0x1', '0x2']
})

it('should return an object representing the action', () => {
expect(fetchEventSuccess(tag, contracts)).toEqual({
expect(fetchEventSuccess(tags, contracts)).toEqual({
type: FETCH_EVENT_SUCCESS,
meta: undefined,
payload: { tag, contracts }
payload: { tags, contracts }
})
})
})
Expand Down
8 changes: 4 additions & 4 deletions webapp/src/modules/event/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ export const FETCH_EVENT_REQUEST = '[Request] Fetch event'
export const FETCH_EVENT_SUCCESS = '[Success] Fetch event'
export const FETCH_EVENT_FAILURE = '[Failure] Fetch event'

export const fetchEventRequest = (tag: string) =>
action(FETCH_EVENT_REQUEST, { tag })
export const fetchEventSuccess = (tag: string, contracts: string[]) =>
action(FETCH_EVENT_SUCCESS, { tag, contracts })
export const fetchEventRequest = (tags: string[]) =>
action(FETCH_EVENT_REQUEST, { tags })
export const fetchEventSuccess = (tags: string[], contracts: string[]) =>
action(FETCH_EVENT_SUCCESS, { tags, contracts })
export const fetchEventFailure = (error: string) =>
action(FETCH_EVENT_FAILURE, { error })

Expand Down
4 changes: 2 additions & 2 deletions webapp/src/modules/event/reducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ failureActions.forEach(action => {
})

describe('when reducing the successful action of fetching an event addresses by tag', () => {
const requestAction = fetchEventRequest(eventTag)
const successAction = fetchEventSuccess(eventTag, eventAddresses)
const requestAction = fetchEventRequest([eventTag])
const successAction = fetchEventSuccess([eventTag], eventAddresses)

const initialState = {
...INITIAL_STATE,
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/modules/event/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ export function eventReducer(
loading: loadingReducer(state.loading, action)
}
case FETCH_EVENT_SUCCESS:
const { tag, contracts } = action.payload
const { tags, contracts } = action.payload
return {
...state,
loading: loadingReducer(state.loading, action),
error: null,
data: {
...state.data,
[tag]: contracts
[tags[0]]: contracts
}
}
case FETCH_EVENT_FAILURE:
Expand Down
6 changes: 3 additions & 3 deletions webapp/src/modules/event/sagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('when handling the fetch events request action', () => {
]
])
.put(fetchEventFailure(anError.message))
.dispatch(fetchEventRequest(eventTag))
.dispatch(fetchEventRequest([eventTag]))
.run({ silenceTimeout: true })
})
})
Expand All @@ -38,8 +38,8 @@ describe('when handling the fetch events request action', () => {
eventContracts
]
])
.put(fetchEventSuccess(eventTag, eventContracts))
.dispatch(fetchEventRequest(eventTag))
.put(fetchEventSuccess([eventTag], eventContracts))
.dispatch(fetchEventRequest([eventTag]))
.run({ silenceTimeout: true })
})
})
Expand Down
6 changes: 3 additions & 3 deletions webapp/src/modules/event/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ export function* eventSaga() {
}

export function* handleFetchEventRequest(action: FetchEventRequestAction) {
const { tag } = action.payload
const { tags } = action.payload

try {
const addresses: string[] = yield call(
[builderAPI, builderAPI.fetchAddressesByTag],
[tag]
tags
)

yield put(fetchEventSuccess(tag, addresses))
yield put(fetchEventSuccess(tags, addresses))
} catch (error) {
yield put(
fetchEventFailure(
Expand Down

0 comments on commit 582d702

Please sign in to comment.