From 68f44f85391fbbbd0266ebb47faecb225dcdf137 Mon Sep 17 00:00:00 2001 From: Melisa Anabella Rossi Date: Thu, 16 Nov 2023 10:16:48 -0300 Subject: [PATCH] feat: add multiple tag campaign (#2053) --- .../CampaignBrowserPage.container.ts | 3 +- .../CampaignBrowserPage.tsx | 4 +- webapp/src/components/Campaign/config.ts | 1 + webapp/src/modules/event/actions.spec.ts | 46 +++++++++++++------ webapp/src/modules/event/actions.ts | 8 ++-- webapp/src/modules/event/reducer.spec.ts | 2 +- webapp/src/modules/event/reducer.ts | 4 +- webapp/src/modules/event/sagas.ts | 6 +-- 8 files changed, 48 insertions(+), 26 deletions(-) diff --git a/webapp/src/components/Campaign/CampaignBrowserPage/CampaignBrowserPage.container.ts b/webapp/src/components/Campaign/CampaignBrowserPage/CampaignBrowserPage.container.ts index 53e9864a2c..c6b0169c89 100644 --- a/webapp/src/components/Campaign/CampaignBrowserPage/CampaignBrowserPage.container.ts +++ b/webapp/src/components/Campaign/CampaignBrowserPage/CampaignBrowserPage.container.ts @@ -22,7 +22,8 @@ const mapState = (state: RootState): MapStateProps => ({ }) const mapDispatch = (dispatch: MapDispatch) => ({ - onFetchEventContracts: (tag: string) => dispatch(fetchEventRequest(tag)) + onFetchEventContracts: (eventTag: string, additionalSearchTags: string[] = []) => + dispatch(fetchEventRequest(eventTag, additionalSearchTags)) }) export default connect(mapState, mapDispatch)(BrowsePage) diff --git a/webapp/src/components/Campaign/CampaignBrowserPage/CampaignBrowserPage.tsx b/webapp/src/components/Campaign/CampaignBrowserPage/CampaignBrowserPage.tsx index 680156ae9b..174f353118 100644 --- a/webapp/src/components/Campaign/CampaignBrowserPage/CampaignBrowserPage.tsx +++ b/webapp/src/components/Campaign/CampaignBrowserPage/CampaignBrowserPage.tsx @@ -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 { ADDITIONAL_CAMPAIGN_BROWSE_TAGS, CAMPAIGN_TAG } from '../config' import { Props } from './CampaignBrowserPage.types' import './CampaignBrowserPage.css' @@ -27,7 +27,7 @@ const CampaignBrowserPage = (props: Props) => { const vendor = isVendor(props.vendor) ? props.vendor : VendorName.DECENTRALAND useEffect(() => { - onFetchEventContracts(CAMPAIGN_TAG) + onFetchEventContracts(CAMPAIGN_TAG, ADDITIONAL_CAMPAIGN_BROWSE_TAGS) }, [onFetchEventContracts]) const activeTab = NavigationTab.CAMPAIGN_BROWSER diff --git a/webapp/src/components/Campaign/config.ts b/webapp/src/components/Campaign/config.ts index e226e5958e..9ccd36fb22 100644 --- a/webapp/src/components/Campaign/config.ts +++ b/webapp/src/components/Campaign/config.ts @@ -1,2 +1,3 @@ export const CAMPAIGN_TAG = 'DCLMF23' +export const ADDITIONAL_CAMPAIGN_BROWSE_TAGS = ['MVMF22'] export const CAMPAING_TAB_ANIMATION_ENABLED = true diff --git a/webapp/src/modules/event/actions.spec.ts b/webapp/src/modules/event/actions.spec.ts index 810d2a6bbd..530521ab98 100644 --- a/webapp/src/modules/event/actions.spec.ts +++ b/webapp/src/modules/event/actions.spec.ts @@ -8,36 +8,56 @@ import { } from './actions' const anErrorMessage = 'An error' +let eventTag: string +let additionalTags: string[] describe('when creating the action to signal the start of the events request', () => { - let tag: string beforeEach(() => { - tag = 'a tag' + eventTag = 'eventTag' }) - it('should return an object representing the action', () => { - expect(fetchEventRequest(tag)).toEqual({ - type: FETCH_EVENT_REQUEST, - meta: undefined, - payload: { - tag - } + + describe('and there are not additional searchTags', () => { + it('should return an object representing the action', () => { + expect(fetchEventRequest(eventTag)).toEqual({ + type: FETCH_EVENT_REQUEST, + meta: undefined, + payload: { + eventTag, + additionalSearchTags: [] + } + }) + }) + }) + + describe('and there are additional search tags', () => { + beforeEach(() => { + additionalTags = ['tag1', 'tag2'] + }) + it('should return an object representing the action', () => { + expect(fetchEventRequest(eventTag, additionalTags)).toEqual({ + type: FETCH_EVENT_REQUEST, + meta: undefined, + payload: { + eventTag, + additionalSearchTags: additionalTags + } + }) }) }) }) describe('when creating the action to signal a success in the events request', () => { - let tag: string let contracts: string[] beforeEach(() => { - tag = 'a tag' + eventTag = 'a tag' contracts = ['0x1', '0x2'] }) it('should return an object representing the action', () => { - expect(fetchEventSuccess(tag, contracts)).toEqual({ + expect(fetchEventSuccess(eventTag, contracts)).toEqual({ type: FETCH_EVENT_SUCCESS, meta: undefined, - payload: { tag, contracts } + payload: { eventTag, contracts } }) }) }) diff --git a/webapp/src/modules/event/actions.ts b/webapp/src/modules/event/actions.ts index ddd73423c6..381ca5841c 100644 --- a/webapp/src/modules/event/actions.ts +++ b/webapp/src/modules/event/actions.ts @@ -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 = (eventTag: string, additionalSearchTags: string[] = []) => + action(FETCH_EVENT_REQUEST, { eventTag, additionalSearchTags }) +export const fetchEventSuccess = (eventTag: string, contracts: string[]) => + action(FETCH_EVENT_SUCCESS, { eventTag, contracts }) export const fetchEventFailure = (error: string) => action(FETCH_EVENT_FAILURE, { error }) diff --git a/webapp/src/modules/event/reducer.spec.ts b/webapp/src/modules/event/reducer.spec.ts index 09eb28959e..cdf5e910a8 100644 --- a/webapp/src/modules/event/reducer.spec.ts +++ b/webapp/src/modules/event/reducer.spec.ts @@ -60,7 +60,7 @@ describe('when reducing the successful action of fetching an event addresses by const initialState = { ...INITIAL_STATE, - data: { evnet1: ['0x1', '0x2'] }, + data: { event1: ['0x1', '0x2'] }, loading: loadingReducer([], requestAction) } diff --git a/webapp/src/modules/event/reducer.ts b/webapp/src/modules/event/reducer.ts index 898f65d201..a29dba2709 100644 --- a/webapp/src/modules/event/reducer.ts +++ b/webapp/src/modules/event/reducer.ts @@ -39,14 +39,14 @@ export function eventReducer( loading: loadingReducer(state.loading, action) } case FETCH_EVENT_SUCCESS: - const { tag, contracts } = action.payload + const { eventTag, contracts } = action.payload return { ...state, loading: loadingReducer(state.loading, action), error: null, data: { ...state.data, - [tag]: contracts + [eventTag]: contracts } } case FETCH_EVENT_FAILURE: diff --git a/webapp/src/modules/event/sagas.ts b/webapp/src/modules/event/sagas.ts index 712755253a..43dcc839c2 100644 --- a/webapp/src/modules/event/sagas.ts +++ b/webapp/src/modules/event/sagas.ts @@ -14,15 +14,15 @@ export function* eventSaga() { } export function* handleFetchEventRequest(action: FetchEventRequestAction) { - const { tag } = action.payload + const { eventTag, additionalSearchTags } = action.payload try { const addresses: string[] = yield call( [builderAPI, builderAPI.fetchAddressesByTag], - [tag] + [eventTag, ...additionalSearchTags] ) - yield put(fetchEventSuccess(tag, addresses)) + yield put(fetchEventSuccess(eventTag, addresses)) } catch (error) { yield put( fetchEventFailure(